Bug 469613 - Page scrolling by clicking the scrollbar track can get stuck if the page is very long, r+sr=roc
☠☠ backed out by 48b1dea326bb ☠ ☠
authorMarkus Stange <mstange@themasta.com>
Fri, 09 Jan 2009 10:05:24 +0100
changeset 23503 fe759e3fd8950cc6c3525b435ef1a389fffc9047
parent 23502 82a898e520fec4f2973c2ff64f1ea3dd67480826
child 23504 7e5854c047bd7b1161cce2a3d9de8f82d22a85bc
child 23508 48b1dea326bb61ab862b363b4223404e242b2e88
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs469613
milestone1.9.2a1pre
Bug 469613 - Page scrolling by clicking the scrollbar track can get stuck if the page is very long, r+sr=roc
layout/generic/test/Makefile.in
layout/generic/test/test_bug469613.xul
view/src/nsScrollPortView.cpp
--- a/layout/generic/test/Makefile.in
+++ b/layout/generic/test/Makefile.in
@@ -60,15 +60,16 @@ include $(topsrcdir)/config/rules.mk
 		test_bug402380.html \
 		test_bug404872.html \
 		test_bug405178.html \
 		test_bug416168.html \
 		test_bug421436.html \
 		test_bug448860.html \
 		test_bug460532.html \
 		test_bug468167.html \
+		test_bug469613.xul \
 		test_character_movement.html \
 		test_word_movement.html \
 		test_backspace_delete.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/layout/generic/test/test_bug469613.xul
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=469613
+-->
+<window title="Mozilla Bug 469613"
+  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+  <title>Test for Bug 469613</title>
+  <script type="application/javascript" src="/MochiKit/packed.js" />
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"/>
+  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"/>
+<body  xmlns="http://www.w3.org/1999/xhtml">
+  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=469613">Mozilla Bug 469613</a>
+
+  <p id="display"></p>
+<div id="content" style="display: none">
+</div>
+</body>
+
+<vbox style="height: 100px; overflow: auto;" id="scrollbox">
+  <hbox style="height: 120px;"/>
+</vbox>
+
+<script class="testbody" type="application/javascript;version=1.7"><![CDATA[
+
+/** Test for Bug 469613 **/
+
+function doTest() {
+  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+  let scrollbox = document.getElementById("scrollbox");
+  scrollbox.scrollTop = 0;
+
+  // Make sure that the "scroll focus" is inside the scrollbox by moving the
+  // mouse in the scrollbox.
+  synthesizeMouse(scrollbox, 6, 6, { type: "mousemove" });
+  synthesizeMouse(scrollbox, 8, 8, { type: "mousemove" });
+
+  // Now scroll 10px down.
+  synthesizeMouseScroll(scrollbox, 10, 10, {axis:"vertical", delta:10, type:"MozMousePixelScroll"});
+
+  // Send a 0-delta scroll.
+  synthesizeMouseScroll(scrollbox, 10, 10, {axis:"vertical", delta:0, type:"MozMousePixelScroll"});
+
+  setTimeout(function() {
+    // Check if the 10px were scrolled.
+    is(scrollbox.scrollTop, 10, "Starting a 0-delta scroll shouldn't cancel a pending async scroll.")
+    SimpleTest.finish();
+  }, 0);
+}
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(doTest);
+
+]]></script>
+
+</window>
--- a/view/src/nsScrollPortView.cpp
+++ b/view/src/nsScrollPortView.cpp
@@ -238,19 +238,22 @@ static nsresult ClampScrollValues(nscoor
   
 /*
  * this method wraps calls to ScrollToImpl(), either in one shot or incrementally,
  *  based on the setting of the smooth scroll pref
  */
 NS_IMETHODIMP nsScrollPortView::ScrollTo(nscoord aDestinationX, nscoord aDestinationY,
                                          PRUint32 aUpdateFlags)
 {
-  // do nothing if the we aren't scrolling.
-  if (aDestinationX == mDestinationX && aDestinationY == mDestinationY) {
-    // kill any in-progress smooth scroll
+  // Do nothing if the target scroll position hasn't changed.
+  if (aDestinationX == mDestinationX && aDestinationY == mDestinationY)
+    return NS_OK;
+
+  if (aDestinationX == mOffsetX && aDestinationY == mOffsetY) {
+    // Kill any in-progress async scroll.
     delete mAsyncScroll;
     mAsyncScroll = nsnull;
     return NS_OK;
   }
 
   mDestinationX = aDestinationX;
   mDestinationY = aDestinationY;
   ClampScrollValues(mDestinationX, mDestinationY, this);