Bug 539949. Keep trying to scroll content into view even if it is clipped out. r=roc a=blocking-final+
authorTimothy Nikkel <tnikkel@gmail.com>
Wed, 24 Nov 2010 19:35:01 -0600
changeset 58200 3c680a3b987f43f02d57d37909ac3f9b000f6337
parent 58199 563dd73da0561004d120c3dd13fabdf6d46f2446
child 58201 f86215099b30cd1e5a68d15a66f989aabc70dd12
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersroc, blocking-final
bugs539949
milestone2.0b8pre
Bug 539949. Keep trying to scroll content into view even if it is clipped out. r=roc a=blocking-final+
layout/base/nsPresShell.cpp
layout/reftests/bugs/539949-1-ref.html
layout/reftests/bugs/539949-1.html
layout/reftests/bugs/reftest.list
toolkit/content/tests/widgets/test_mousecapture.xul
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -4333,32 +4333,16 @@ PresShell::ScrollFrameRectIntoView(nsIFr
       if (oldPosition != newPosition) {
         didScroll = PR_TRUE;
       }
 
       // only scroll one container when this flag is set
       if (aFlags & nsIPresShell::SCROLL_FIRST_ANCESTOR_ONLY) {
         break;
       }
-
-      nsRect scrollPort = sf->GetScrollPortRect();
-      if (rect.XMost() < scrollPort.x ||
-          rect.x > scrollPort.XMost() ||
-          rect.YMost() < scrollPort.y ||
-          rect.y > scrollPort.YMost()) {
-        // We tried to show the rectangle, but none of it is visible,
-        // not even an edge.
-        // Stop trying to scroll ancestors into view.
-        break;
-      }
-
-      // Restrict rect to the area that is actually visible through
-      // the scrollport. We don't want to try to scroll some clipped-out
-      // part of 'rect' into view in some ancestor.
-      rect.IntersectRect(rect, sf->GetScrollPortRect());
     }
     rect += container->GetPosition();
     nsIFrame* parent = container->GetParent();
     if (!parent) {
       nsPoint extraOffset(0,0);
       parent = nsLayoutUtils::GetCrossDocParentFrame(container, &extraOffset);
       if (parent) {
         PRInt32 APD = container->PresContext()->AppUnitsPerDevPixel();        
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/539949-1-ref.html
@@ -0,0 +1,10 @@
+<html>
+<body>
+<div style="height: 10000px;"></div>
+<div style="position: relative;">
+   <div id="test2" style="position:absolute; top:-200px;"></div>
+   <div style="height: 100px; width: 100px; background: blue;"></div>
+</div>
+<div style="height: 10000px;"></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/539949-1.html
@@ -0,0 +1,10 @@
+<html>
+<body>
+<div style="height: 10000px;"></div>
+<div style="position: relative; overflow:hidden;">
+   <div id="test2" style="position:absolute; top:-200px;"></div>
+   <div style="height: 100px; width: 100px; background: blue;"></div>
+</div>
+<div style="height: 10000px;"></div>
+</body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1420,16 +1420,17 @@ asserts(5) == 528038-2.html 528038-2-ref
 == 538909-1.html 538909-1-ref.html
 == 538935-1.html 538935-1-ref.html
 == 539226-1.html about:blank
 == 539323-1.html 539323-1-ref.html
 == 539323-2.html 539323-2-ref.html
 == 539323-3.html 539323-3-ref.html
 == 539880-1.html 539880-1-ref.html
 == 539880-1-dynamic.html 539880-1-ref.html
+== 539949-1.html#test2 539949-1-ref.html#test2
 == 541382-1.html 541382-1-ref.html
 random-if(!haveTestPlugin) == 541406-1.html 541406-1-ref.html
 != 542116-1.html 542116-1-ref.html
 asserts(1) != 542116-2.html 542116-2-ref.html # bug 596901
 != 542116-3.html 542116-3-ref.html
 == 542317-1.html 542317-1-ref.html
 == 542605-hidden-unscrollable.xul 542605-hidden-unscrollable-ref.xul
 == 542620-1.html 542620-1-ref.html
--- a/toolkit/content/tests/widgets/test_mousecapture.xul
+++ b/toolkit/content/tests/widgets/test_mousecapture.xul
@@ -150,19 +150,26 @@ function runTests()
   // test that mousedown on an image with setCapture followed by a big enough
   // mouse move does not start a drag (bug 517737)
   var image = document.getElementById("image");
   synthesizeMouse(image, 2, 2, { type: "mousedown" });
   synthesizeMouseExpectEvent($("leftbox"), 2, 2, { type: "mousemove" },
                              image, "mousemove", "setCapture works on images");
   synthesizeMouse(image, 2, 2, { type: "mouseup" });
 
+  // save scroll
+  var scrollX = parent ? parent.scrollX : 0;
+  var scrollY = parent ? parent.scrollY : 0;
+
   var b = frames[0].document.getElementById("b");
   runCaptureTest(b, selectionCallback);
 
+  // restore scroll
+  if (parent) parent.scroll(scrollX, scrollY);
+
   frames[0].getSelection().collapseToStart();
 
   var body = frames[0].document.body;
   var fixed = frames[0].document.getElementById("fixed");
   function captureOnBody() { body.setCapture() }
   body.addEventListener("mousedown", captureOnBody, true);
   synthesizeMouse(body, 8, 8, { type: "mousedown" }, frames[0]);
   body.removeEventListener("mousedown", captureOnBody, true);