- // Get the element window.\r
- var win = this.getWindow(),\r
- winHeight = win.getViewPaneSize().height;\r
-\r
- // Starts from the offset that will be scrolled with the negative value of\r
- // the visible window height.\r
- var offset = winHeight * -1;\r
-\r
- // Append the view pane's height if align to top.\r
- // Append element height if we are aligning to the bottom.\r
- if ( alignTop )\r
- offset += winHeight;\r
- else\r
+ var parent = this.getParent();\r
+ if ( !parent ) return;\r
+\r
+ // Scroll the element into parent container from the inner out.\r
+ do\r
+ {\r
+ // Check ancestors that overflows.\r
+ var overflowed =\r
+ parent.$.clientWidth && parent.$.clientWidth < parent.$.scrollWidth\r
+ || parent.$.clientHeight && parent.$.clientHeight < parent.$.scrollHeight;\r
+\r
+ if ( overflowed )\r
+ this.scrollIntoParent( parent, alignToTop, 1 );\r
+\r
+ // Walk across the frame.\r
+ if ( parent.is( 'html' ) )\r
+ {\r
+ var win = parent.getWindow();\r
+\r
+ // Avoid security error.\r
+ try\r
+ {\r
+ var iframe = win.$.frameElement;\r
+ iframe && ( parent = new CKEDITOR.dom.element( iframe ) );\r
+ }\r
+ catch(er){}\r
+ }\r
+ }\r
+ while ( ( parent = parent.getParent() ) );\r
+ },\r
+\r
+ /**\r
+ * Make any page element visible inside one of the ancestors by scrolling the parent.\r
+ * @param {CKEDITOR.dom.element|CKEDITOR.dom.window} parent The container to scroll into.\r
+ * @param {Boolean} [alignToTop] Align the element's top side with the container's\r
+ * when <code>true</code> is specified; align the bottom with viewport bottom when\r
+ * <code>false</code> is specified. Otherwise scroll on either side with the minimum\r
+ * amount to show the element.\r
+ * @param {Boolean} [hscroll] Whether horizontal overflow should be considered.\r
+ */\r
+ scrollIntoParent : function( parent, alignToTop, hscroll )\r
+ {\r
+ !parent && ( parent = this.getWindow() );\r
+\r
+ var doc = parent.getDocument();\r
+ var isQuirks = doc.$.compatMode == 'BackCompat';\r
+\r
+ // On window <html> is scrolled while quirks scrolls <body>.\r
+ if ( parent instanceof CKEDITOR.dom.window )\r
+ parent = isQuirks ? doc.getBody() : doc.getDocumentElement();\r
+\r
+ // Scroll the parent by the specified amount.\r
+ function scrollBy( x, y )\r
+ {\r
+ // Webkit doesn't support "scrollTop/scrollLeft"\r
+ // on documentElement/body element.\r
+ if ( /body|html/.test( parent.getName() ) )\r
+ parent.getWindow().$.scrollBy( x, y );\r
+ else\r
+ {\r
+ parent.$[ 'scrollLeft' ] += x;\r
+ parent.$[ 'scrollTop' ] += y;\r
+ }\r
+ }\r
+\r
+ // Figure out the element position relative to the specified window.\r
+ function screenPos( element, refWin )\r