--- /dev/null
+/*\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+/**\r
+ * @fileOverview Defines the {@link CKEDITOR.dom.document} class, which\r
+ * represents a DOM document.\r
+ */\r
+\r
+/**\r
+ * Represents a DOM window.\r
+ * @constructor\r
+ * @augments CKEDITOR.dom.domObject\r
+ * @param {Object} domWindow A native DOM window.\r
+ * @example\r
+ * var document = new CKEDITOR.dom.window( window );\r
+ */\r
+CKEDITOR.dom.window = function( domWindow )\r
+{\r
+ CKEDITOR.dom.domObject.call( this, domWindow );\r
+};\r
+\r
+CKEDITOR.dom.window.prototype = new CKEDITOR.dom.domObject();\r
+\r
+CKEDITOR.tools.extend( CKEDITOR.dom.window.prototype,\r
+ /** @lends CKEDITOR.dom.window.prototype */\r
+ {\r
+ /**\r
+ * Moves the selection focus to this window.\r
+ * @function\r
+ * @example\r
+ * var win = new CKEDITOR.dom.window( window );\r
+ * <b>win.focus()</b>;\r
+ */\r
+ focus : function()\r
+ {\r
+ // Webkit is sometimes failed to focus iframe, blur it first(#3835).\r
+ if ( CKEDITOR.env.webkit && this.$.parent )\r
+ this.$.parent.focus();\r
+ this.$.focus();\r
+ },\r
+\r
+ /**\r
+ * Gets the width and height of this window's viewable area.\r
+ * @function\r
+ * @returns {Object} An object with the "width" and "height"\r
+ * properties containing the size.\r
+ * @example\r
+ * var win = new CKEDITOR.dom.window( window );\r
+ * var size = <b>win.getViewPaneSize()</b>;\r
+ * alert( size.width );\r
+ * alert( size.height );\r
+ */\r
+ getViewPaneSize : function()\r
+ {\r
+ var doc = this.$.document,\r
+ stdMode = doc.compatMode == 'CSS1Compat';\r
+ return {\r
+ width : ( stdMode ? doc.documentElement.clientWidth : doc.body.clientWidth ) || 0,\r
+ height : ( stdMode ? doc.documentElement.clientHeight : doc.body.clientHeight ) || 0\r
+ };\r
+ },\r
+\r
+ /**\r
+ * Gets the current position of the window's scroll.\r
+ * @function\r
+ * @returns {Object} An object with the "x" and "y" properties\r
+ * containing the scroll position.\r
+ * @example\r
+ * var win = new CKEDITOR.dom.window( window );\r
+ * var pos = <b>win.getScrollPosition()</b>;\r
+ * alert( pos.x );\r
+ * alert( pos.y );\r
+ */\r
+ getScrollPosition : function()\r
+ {\r
+ var $ = this.$;\r
+\r
+ if ( 'pageXOffset' in $ )\r
+ {\r
+ return {\r
+ x : $.pageXOffset || 0,\r
+ y : $.pageYOffset || 0\r
+ };\r
+ }\r
+ else\r
+ {\r
+ var doc = $.document;\r
+ return {\r
+ x : doc.documentElement.scrollLeft || doc.body.scrollLeft || 0,\r
+ y : doc.documentElement.scrollTop || doc.body.scrollTop || 0\r
+ };\r
+ }\r
+ }\r
+ });\r