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.
This commit is contained in:
2015-03-18 14:32:00 +01:00
Родитель 093246b8d4
Коммит 1079a8625f
1 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -1146,15 +1146,30 @@ ScrollFrameHelper::ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection
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);