summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/win/WheelEventWin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/win/WheelEventWin.cpp')
-rw-r--r--WebCore/platform/win/WheelEventWin.cpp55
1 files changed, 36 insertions, 19 deletions
diff --git a/WebCore/platform/win/WheelEventWin.cpp b/WebCore/platform/win/WheelEventWin.cpp
index d272ba7..e6670a4 100644
--- a/WebCore/platform/win/WheelEventWin.cpp
+++ b/WebCore/platform/win/WheelEventWin.cpp
@@ -46,23 +46,23 @@ static IntPoint globalPositionForEvent(HWND hWnd, LPARAM lParam)
return point;
}
-int PlatformWheelEvent::horizontalLineMultiplier() const
+static int horizontalScrollChars()
{
static ULONG scrollChars;
if (!scrollChars && !SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0))
- scrollChars = cLineMultiplier;
+ scrollChars = 1;
return scrollChars;
}
-int PlatformWheelEvent::verticalLineMultiplier() const
+static int verticalScrollLines()
{
static ULONG scrollLines;
if (!scrollLines && !SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0))
- scrollLines = cLineMultiplier;
+ scrollLines = 3;
return scrollLines;
}
-
-PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isHorizontal)
+
+PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isMouseHWheel)
: m_position(positionForEvent(hWnd, lParam))
, m_globalPosition(globalPositionForEvent(hWnd, lParam))
, m_isAccepted(false)
@@ -71,23 +71,40 @@ PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam,
, m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT)
, m_metaKey(m_altKey) // FIXME: We'll have to test other browsers
{
- static ULONG scrollLines, scrollChars;
- float delta = GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
- if (isHorizontal) {
- // Windows sends a positive delta for scrolling right, while AppKit
- // sends a negative delta. EventHandler expects the AppKit values,
- // so we have to negate our horizontal delta to match.
- m_deltaX = -delta * horizontalLineMultiplier();
+ // 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 on Windows is three lines per wheel tick).
+ static const float cScrollbarPixelsPerLine = 100.0f / 3.0f;
+ float delta = GET_WHEEL_DELTA_WPARAM(wParam) / static_cast<float>(WHEEL_DELTA);
+ if (isMouseHWheel) {
+ // Windows is <-- -/+ -->, WebKit wants <-- +/- -->, so we negate
+ // |delta| after saving the original value on the wheel tick member.
+ m_wheelTicksX = delta;
+ m_wheelTicksY = 0;
+ delta = -delta;
+ } else {
+ // Even though we use shift + vertical wheel to scroll horizontally in
+ // WebKit, we still note it as a vertical scroll on the wheel tick
+ // member, so that the DOM event we later construct will match the real
+ // hardware event better.
+ m_wheelTicksX = 0;
+ m_wheelTicksY = delta;
+ }
+ if (isMouseHWheel || m_shiftKey) {
+ m_deltaX = delta * static_cast<float>(horizontalScrollChars()) * cScrollbarPixelsPerLine;
m_deltaY = 0;
- m_granularity = ScrollByLineWheelEvent;
+ m_granularity = ScrollByPixelWheelEvent;
} else {
m_deltaX = 0;
m_deltaY = delta;
- int verticalMultiplier = verticalLineMultiplier();
- // A multiplier of -1 is used to mean that vertical wheel scrolling should be done by page.
- m_granularity = (verticalMultiplier == -1) ? ScrollByPageWheelEvent : ScrollByLineWheelEvent;
- if (m_granularity == ScrollByLineWheelEvent)
- m_deltaY *= verticalMultiplier;
+ int verticalMultiplier = verticalScrollLines();
+ m_granularity = (verticalMultiplier == WHEEL_PAGESCROLL) ? ScrollByPageWheelEvent : ScrollByPixelWheelEvent;
+ if (m_granularity == ScrollByPixelWheelEvent)
+ m_deltaY *= static_cast<float>(verticalMultiplier) * cScrollbarPixelsPerLine;
}
}