Bug 1120705 - Part 1: Limit scrollbar button scrolls to one page per click. r=roc
author<kgilbert>
Wed, 18 Mar 2015 14:32:00 +0100
changeset 234429 97aff00e4250d795c74c61026339383ada6f9fe8
parent 234392 0a11b73c77b78b08ea55b05e368a6522a34fa251
child 234430 e48cd77481ac00f381850b4d6b9b90d8ef76f469
push id28446
push userkwierso@gmail.com
push dateFri, 20 Mar 2015 02:15:45 +0000
treeherdermozilla-central@3257d9c4b257 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1120705
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1120705 - Part 1: Limit scrollbar button scrolls to one page per click. r=roc - When using the scrollbar buttons to scroll a very small scroll frame, it is possible to scroll more than one page. When this occurs, we now scroll by a page instead to maintain context between scrolls. - When scrolling with scrollbar buttons, the "toolkit.scrollbox.verticalScrollDistance" and "toolkit.scrollbox.horizontalScrollDistance" were swapped, resulting in too much scrolling when scrolling vertically and too little scrolling when scrolling horizontally. This has been fixed in ScrollFrameHelper::ScrollByLine.
layout/generic/nsGfxScrollFrame.cpp
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -1141,25 +1141,40 @@ ScrollFrameHelper::ScrollByWhole(nsScrol
 
 void
 ScrollFrameHelper::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection)
 {
   bool isHorizontal = aScrollbar->IsHorizontal();
   nsIntPoint delta;
   if (isHorizontal) {
     const double kScrollMultiplier =
-      Preferences::GetInt("toolkit.scrollbox.verticalScrollDistance",
+      Preferences::GetInt("toolkit.scrollbox.horizontalScrollDistance",
                           NS_DEFAULT_HORIZONTAL_SCROLL_DISTANCE);
     delta.x = aDirection * kScrollMultiplier;
+    if (GetLineScrollAmount().width * delta.x > GetPageScrollAmount().width) {
+      // The scroll frame is so small that the delta would be more
+      // than an entire page.  Scroll by one page instead to maintain
+      // context.
+      ScrollByPage(aScrollbar, aDirection);
+      return;
+    }
   } else {
     const double kScrollMultiplier =
-      Preferences::GetInt("toolkit.scrollbox.horizontalScrollDistance",
+      Preferences::GetInt("toolkit.scrollbox.verticalScrollDistance",
                           NS_DEFAULT_VERTICAL_SCROLL_DISTANCE);
     delta.y = aDirection * kScrollMultiplier;
-  }
+    if (GetLineScrollAmount().height * delta.y > GetPageScrollAmount().height) {
+      // The scroll frame is so small that the delta would be more
+      // than an entire page.  Scroll by one page instead to maintain
+      // context.
+      ScrollByPage(aScrollbar, aDirection);
+      return;
+    }
+  }
+  
   nsIntPoint overflow;
   ScrollBy(delta, nsIScrollableFrame::LINES, nsIScrollableFrame::SMOOTH,
            &overflow, nsGkAtoms::other);
 }
 
 void
 ScrollFrameHelper::RepeatButtonScroll(nsScrollbarFrame* aScrollbar)
 {