diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-06 20:43:24 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-06 20:43:24 +0000 |
commit | 1040cb10711a7a19051576eb96f33fc3632088f3 (patch) | |
tree | 5be594c815a19e21dbb004dcca8469e725e1cc36 | |
parent | 53939ea429d84e0a380b37ad15c9e4c0030caae3 (diff) | |
download | chromium_src-1040cb10711a7a19051576eb96f33fc3632088f3.zip chromium_src-1040cb10711a7a19051576eb96f33fc3632088f3.tar.gz chromium_src-1040cb10711a7a19051576eb96f33fc3632088f3.tar.bz2 |
Convert from line scrolling to pixel scrolling. Increase pixel scroll amount on Windows.
See also https://bugs.webkit.org/show_bug.cgi?id=24407 .
BUG=6172
Review URL: http://codereview.chromium.org/40241
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11151 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/glue/event_conversion.cc | 2 | ||||
-rw-r--r-- | webkit/glue/webinputevent_linux.cc | 10 | ||||
-rw-r--r-- | webkit/glue/webinputevent_mac.mm | 9 | ||||
-rw-r--r-- | webkit/glue/webinputevent_win.cc | 23 |
4 files changed, 26 insertions, 18 deletions
diff --git a/webkit/glue/event_conversion.cc b/webkit/glue/event_conversion.cc index 21259ff..a54f908 100644 --- a/webkit/glue/event_conversion.cc +++ b/webkit/glue/event_conversion.cc @@ -127,7 +127,7 @@ MakePlatformWheelEvent::MakePlatformWheelEvent(Widget* widget, m_deltaY = e.delta_y; m_isAccepted = false; m_granularity = e.scroll_by_page ? - ScrollByPageWheelEvent : ScrollByLineWheelEvent; + ScrollByPageWheelEvent : ScrollByPixelWheelEvent; m_shiftKey = (e.modifiers & WebInputEvent::SHIFT_KEY) != 0; m_ctrlKey = (e.modifiers & WebInputEvent::CTRL_KEY) != 0; m_altKey = (e.modifiers & WebInputEvent::ALT_KEY) != 0; diff --git a/webkit/glue/webinputevent_linux.cc b/webkit/glue/webinputevent_linux.cc index 12fb179..799bbb2 100644 --- a/webkit/glue/webinputevent_linux.cc +++ b/webkit/glue/webinputevent_linux.cc @@ -123,22 +123,22 @@ WebMouseWheelEvent::WebMouseWheelEvent(const GdkEventScroll* event) { // - Gtk makes the scroll amount a function of the size of the scroll bar, // which is not available to us here. // Instead, we pick a number that empirically matches Firefox's behavior. - static const float kWheelDelta = 4; + static const float kScrollbarPixelsPerTick = 160.0f / 3.0f; delta_x = 0; delta_y = 0; switch (event->direction) { case GDK_SCROLL_UP: - delta_y = kWheelDelta; + delta_y = kScrollbarPixelsPerTick; break; case GDK_SCROLL_DOWN: - delta_y = -kWheelDelta; + delta_y = -kScrollbarPixelsPerTick; break; case GDK_SCROLL_LEFT: - delta_x = kWheelDelta; + delta_x = kScrollbarPixelsPerTick; break; case GDK_SCROLL_RIGHT: - delta_x = -kWheelDelta; + delta_x = -kScrollbarPixelsPerTick; break; default: break; diff --git a/webkit/glue/webinputevent_mac.mm b/webkit/glue/webinputevent_mac.mm index f713683..bcf9c5f 100644 --- a/webkit/glue/webinputevent_mac.mm +++ b/webkit/glue/webinputevent_mac.mm @@ -35,8 +35,6 @@ #undef LOG #include "base/logging.h" -static const unsigned long kDefaultScrollLinesPerWheelDelta = 3; - // WebMouseEvent -------------------------------------------------------------- WebMouseEvent::WebMouseEvent(NSEvent *event, NSView* view) { @@ -136,14 +134,13 @@ WebMouseWheelEvent::WebMouseWheelEvent(NSEvent *event, NSView* view) { x = location.x; y = [view frame].size.height - location.y; // flip y - // Convert wheel delta amount to a number of lines to scroll. + // Convert wheel delta amount to a number of pixels to scroll. + static const float kScrollbarPixelsPerTick = 40.0f; float wheel_delta = [event deltaY]; - const float delta_lines = wheel_delta * kDefaultScrollLinesPerWheelDelta; + const float delta_lines = wheel_delta * kScrollbarPixelsPerTick; // Set scroll amount based on above calculations. if ([event modifierFlags] & NSShiftKeyMask) { - // Scrolling up should move left, scrolling down should move right. This is - // opposite Safari, but seems more consistent with vertical scrolling. delta_x = delta_lines; delta_y = 0; } else { diff --git a/webkit/glue/webinputevent_win.cc b/webkit/glue/webinputevent_win.cc index 455ecfc..8c82901 100644 --- a/webkit/glue/webinputevent_win.cc +++ b/webkit/glue/webinputevent_win.cc @@ -195,25 +195,36 @@ WebMouseWheelEvent::WebMouseWheelEvent(HWND hwnd, x = client_point.x; y = client_point.y; - // Convert wheel delta amount to a number of lines/chars to scroll. + // Convert wheel delta amount to a number of pixels to scroll. + // + // How many pixels should we scroll per line? Gecko uses the height of the + // current line, which means scroll distance changes as you go through the + // page or go to different pages. IE 7 is ~50 px/line, although the value + // seems to vary slightly by page and zoom level. Since IE 7 has a smoothing + // algorithm on scrolling, it can get away with slightly larger scroll values + // without feeling jerky. Here we use 100 px per three lines (the default + // scroll amount is three lines per wheel tick). + static const float kScrollbarPixelsPerLine = 100.0f / 3.0f; float scroll_delta = wheel_delta / WHEEL_DELTA; if (horizontal_scroll) { unsigned long scroll_chars = kDefaultScrollCharsPerWheelDelta; SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scroll_chars, 0); - scroll_delta *= static_cast<float>(scroll_chars); + // TODO(pkasting): Should probably have a different multiplier + // kScrollbarPixelsPerChar here. + scroll_delta *= static_cast<float>(scroll_chars) * kScrollbarPixelsPerLine; } else { unsigned long scroll_lines = kDefaultScrollLinesPerWheelDelta; SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scroll_lines, 0); if (scroll_lines == WHEEL_PAGESCROLL) scroll_by_page = true; - if (!scroll_by_page) - scroll_delta *= static_cast<float>(scroll_lines); + if (!scroll_by_page) { + scroll_delta *= + static_cast<float>(scroll_lines) * kScrollbarPixelsPerLine; + } } // Set scroll amount based on above calculations. if (horizontal_scroll) { - // Scrolling up should move left, scrolling down should move right. This is - // opposite Safari, but seems more consistent with vertical scrolling. delta_x = scroll_delta; delta_y = 0; } else { |