Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 7398)
+++ /CKEditor/trunk/CHANGES.html	(revision 7399)
@@ -68,4 +68,5 @@
 		<li><a href="http://dev.ckeditor.com/ticket/8632">#8632</a> : Fix cursor panic when backspace is used in list item.</li>
 		<li><a href="http://dev.ckeditor.com/ticket/8324">#8324</a> : [IE8] Fix undo generate error when control type element is selected.</li>
+		<li><a href="http://dev.ckeditor.com/ticket/7946">#7946</a> : Fix find dialog result doesn't scroll into view when editor is off the view port.</li>
 	</ul>
 	<h3>
Index: /CKEditor/trunk/_source/core/dom/element.js
===================================================================
--- /CKEditor/trunk/_source/core/dom/element.js	(revision 7398)
+++ /CKEditor/trunk/_source/core/dom/element.js	(revision 7399)
@@ -1398,38 +1398,140 @@
 		},
 
-		scrollIntoView : function( alignTop )
-		{
-			// Get the element window.
-			var win = this.getWindow(),
-				winHeight = win.getViewPaneSize().height;
-
-			// Starts from the offset that will be scrolled with the negative value of
-			// the visible window height.
-			var offset = winHeight * -1;
-
-			// Append the view pane's height if align to top.
-			// Append element height if we are aligning to the bottom.
-			if ( alignTop )
-				offset += winHeight;
-			else
-			{
-				offset += this.$.offsetHeight || 0;
-
-				// Consider the margin in the scroll, which is ok for our current needs, but
-				// needs investigation if we will be using this function in other places.
-				offset += parseInt( this.getComputedStyle( 'marginBottom' ) || 0, 10 ) || 0;
-			}
-
-			// Append the offsets for the entire element hierarchy.
-			var elementPosition = this.getDocumentPosition();
-			offset += elementPosition.y;
-
-			// offset value might be out of range(nagative), fix it(#3692).
-			offset = offset < 0 ? 0 : offset;
-
-			// Scroll the window to the desired position, if not already visible(#3795).
-			var currentScroll = win.getScrollPosition().y;
-			if ( offset > currentScroll || offset < currentScroll - winHeight )
-				win.$.scrollTo( 0, offset );
+		/**
+		 * Make any page element visible inside of the browser viewport.
+		 * @param {Boolean} [alignToTop]
+		 */
+		scrollIntoView : function( alignToTop )
+		{
+			var parent = this.getParent();
+			if ( !parent ) return;
+
+			// Scroll the element into parent container from the inner out.
+			do
+			{
+				// Check ancestors that overflows.
+				var overflowed =
+					parent.$.clientWidth && parent.$.clientWidth < parent.$.scrollWidth
+					|| parent.$.clientHeight && parent.$.clientHeight < parent.$.scrollHeight;
+
+				if ( overflowed )
+					this.scrollIntoParent( parent, alignToTop, 1 );
+
+				// Walk across the frame.
+				if ( parent.is( 'html' ) )
+				{
+					var win = parent.getWindow();
+
+					// Avoid security error.
+					try
+					{
+						var iframe = win.$.frameElement;
+						iframe && ( parent = new CKEDITOR.dom.element( iframe ) );
+					}
+					catch(er){}
+				}
+			}
+			while ( parent = parent.getParent() );
+		},
+
+		/**
+		 * Make any page element visible inside one of the ancestor by scrolling the parent.
+		 * @param {CKEDITOR.dom.element|CKEDITOR.dom.window} parent The container to scroll into.
+		 * @param {Boolean} [alignToTop] Align the element's top side with the container's
+		 * when "true" is specified, align the bottom with viewport bottom when "false" is specified,
+		 * other wise scroll on either side with the minimum amount to show the element.
+		 * @param {Boolean} [hscroll] Whether horizontal overflow should be considered.
+		 */
+		scrollIntoParent : function( parent, alignToTop, hscroll )
+		{
+			!parent && ( parent = this.getWindow() );
+
+			var doc = parent.getDocument();
+			var isQuirks = doc.$.compatMode == 'BackCompat';
+
+			// On window <html> is scrolled while quirks scrolls <body>.
+			if ( parent instanceof CKEDITOR.dom.window )
+				parent = isQuirks ? doc.getBody() : doc.getDocumentElement();
+
+			// Scroll the parent by the specified amount.
+			function scrollBy( x, y )
+			{
+				// Webkit doesn't support "scrollTop/scrollLeft"
+				// on documentElement/body element.
+				if ( /body|html/.test( parent.getName() ) )
+					parent.getWindow().$.scrollBy( x, y );
+				else
+				{
+					parent.$[ 'scrollLeft' ] += x;
+					parent.$[ 'scrollTop' ] += y;
+				}
+			}
+
+			// Figure out the element position relative to the specified window.
+			function screenPos( element, refWin )
+			{
+				var pos = { x: 0, y: 0 };
+
+				if ( !( element.is( isQuirks ? 'body' : 'html' ) ) )
+				{
+					var box = element.$.getBoundingClientRect();
+					pos.x = box.left, pos.y = box.top;
+				}
+
+				var win = element.getWindow();
+				if ( !win.equals( refWin ) )
+				{
+					var outerPos = screenPos( CKEDITOR.dom.element.get( win.$.frameElement ), refWin );
+					pos.x += outerPos.x, pos.y += outerPos.y;
+				}
+
+				return pos;
+			}
+
+			// calculated margin size.
+			function margin( element, side )
+			{
+				return parseInt( element.getComputedStyle( 'margin-' + side ) || 0, 10 ) || 0;
+			}
+
+			var win = parent.getWindow();
+
+			var thisPos = screenPos( this, win ),
+				parentPos = screenPos( parent, win ),
+				eh = this.$.offsetHeight,
+				ew = this.$.offsetWidth,
+				ch = parent.$.clientHeight,
+				cw = parent.$.clientWidth,
+				lt,
+				br;
+
+			// Left-top margins.
+			lt =
+			{
+				x : thisPos.x - margin( this, 'left' ) - parentPos.x || 0,
+				y : thisPos.y - margin( this, 'top' ) - parentPos.y|| 0
+			};
+
+			// Bottom-right margins.
+			br =
+			{
+				x : thisPos.x + ew + margin( this, 'right' ) - ( ( parentPos.x ) + cw ) || 0,
+				y : thisPos.y + eh + margin( this, 'bottom' ) - ( ( parentPos.y ) + ch ) || 0
+			};
+
+			// 1. Do the specified alignment as much as possible;
+			// 2. Otherwise be smart to scroll only the minimum amount;
+			// 3. Never cut at the top;
+			// 4. DO NOT scroll when already visible.
+			if ( lt.y < 0 || br.y > 0 )
+			{
+				scrollBy( 0,
+						  alignToTop === true ? lt.y :
+						  alignToTop === false ? br.y :
+						  lt.y < 0 ? lt.y : br.y );
+			}
+
+			if ( hscroll && ( lt.x < 0 || br.x > 0 ) )
+				scrollBy( lt.x < 0 ? lt.x : br.x, 0 );
 		},
 
