Bug 633762. Only bail early if we have an async scroll pending so the ScrollTo call can update mDestination. r=roc a=roc
authorTimothy Nikkel <tnikkel@gmail.com>
Sun, 20 Feb 2011 14:03:32 -0600
changeset 62884 ab9118f27d179ffc65b685f78da2eeb0394f434f
parent 62883 a18bb9d573f4eb29f3b98a826483d2f9f54d88a2
child 62885 1863cc5e27a69274499c17e2eac0c888d6afcdfa
push idunknown
push userunknown
push dateunknown
reviewersroc, roc
bugs633762
milestone2.0b12pre
Bug 633762. Only bail early if we have an async scroll pending so the ScrollTo call can update mDestination. r=roc a=roc
layout/generic/nsGfxScrollFrame.cpp
layout/generic/test/Makefile.in
layout/generic/test/bug633762_iframe.html
layout/generic/test/test_bug633762.html
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -2437,17 +2437,18 @@ void nsGfxScrollFrameInner::CurPosAttrib
   nsPoint dest;
   dest.x = GetCoordAttribute(mHScrollbarBox, nsGkAtoms::curpos,
                              -scrolledRect.x) +
            scrolledRect.x;
   dest.y = GetCoordAttribute(mVScrollbarBox, nsGkAtoms::curpos,
                              -scrolledRect.y) +
            scrolledRect.y;
 
-  if (dest == GetScrollPosition()) {
+  // If we have an async scroll pending don't stomp on that by calling ScrollTo.
+  if (mAsyncScroll && dest == GetScrollPosition()) {
     return;
   }
 
   PRBool isSmooth = aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::smooth);
   if (isSmooth) {
     // Make sure an attribute-setting callback occurs even if the view
     // didn't actually move yet.  We need to make sure other listeners
     // see that the scroll position is not (yet) what they thought it
--- a/layout/generic/test/Makefile.in
+++ b/layout/generic/test/Makefile.in
@@ -120,16 +120,18 @@ include $(topsrcdir)/config/rules.mk
 		file_bug514732_1.html \
 		file_bug514732_helper.html \
 		file_bug579767_1.html \
 		file_bug579767_2.html \
 		test_bug522632.html \
 		test_bug589621.html \
 		test_bug589623.html \
 		test_bug632379.xul \
+		test_bug633762.html \
+		bug633762_iframe.html \
 		$(srcdir)/../../reftests/backgrounds/blue-32x32.png \
 		$(srcdir)/../../reftests/backgrounds/fuchsia-32x32.png \
 		$(NULL)
 
 _CHROME_FILES = \
 		test_bug514732-2.xul \
 		file_bug514732_window.xul \
 		$(NULL)
new file mode 100644
--- /dev/null
+++ b/layout/generic/test/bug633762_iframe.html
@@ -0,0 +1,8 @@
+<html>
+<body>
+<div style="background: red; height: 4000px;">hi</div>
+<div id="b" style="background: blue; height: 10000px;"></div>
+<div id="a" style="background: yellow; height: 100px;"></div>
+<div style="background: green; height: 4000px;"></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/generic/test/test_bug633762.html
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=633762
+-->
+<head>
+  <title>Test for Bug 633762</title>
+  <script type="text/javascript" src="/MochiKit/packed.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+
+</head>
+<body>
+<p><a target="_blank" href="https://bugzilla.mozilla.org/show_bug?id=633762">Mozilla Bug 633762</a>
+
+<iframe id="i" src="bug633762_iframe.html#a"></iframe>
+
+<pre id="test">
+<script>
+
+var doc;
+
+function runTests() {
+  var i = document.getElementById("i");
+  doc = i.contentDocument;
+  var win = i.contentWindow;
+  // set display none on b
+  doc.getElementById("b").style.display = "none";
+  // flush layout
+  doc.documentElement.offsetLeft;
+  // click in middle of iframe document to give it focus
+  synthesizeMouseAtCenter(i, {}, win);
+  win.focus();
+  // record scrolltop
+  scrollTopBefore = doc.body.scrollTop;
+  // send up arrow key event
+  sendKey("UP", doc.body);
+
+  setTimeout("finish();", 0);
+}
+
+function finish() {
+  // assert that scroll top is now less than before
+  ok(scrollTopBefore > doc.body.scrollTop, "pressing up arrow should scroll up");
+  SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(runTests);
+</script>
+</pre>
+
+</body>
+</html>