Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: third_party/WebKit/WebCore/platform/win/WheelEventWin.cpp

Issue 39293: WebKit merge 41447:41498 [third_party/WebKit] (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove CRLF Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 28 matching lines...) Expand all
39 ScreenToClient(hWnd, &point); 39 ScreenToClient(hWnd, &point);
40 return point; 40 return point;
41 } 41 }
42 42
43 static IntPoint globalPositionForEvent(HWND hWnd, LPARAM lParam) 43 static IntPoint globalPositionForEvent(HWND hWnd, LPARAM lParam)
44 { 44 {
45 POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; 45 POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
46 return point; 46 return point;
47 } 47 }
48 48
49 int PlatformWheelEvent::horizontalLineMultiplier() const 49 static int horizontalScrollChars()
50 { 50 {
51 static ULONG scrollChars; 51 static ULONG scrollChars;
52 if (!scrollChars && !SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrol lChars, 0)) 52 if (!scrollChars && !SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrol lChars, 0))
53 scrollChars = cLineMultiplier; 53 scrollChars = 1;
54 return scrollChars; 54 return scrollChars;
55 } 55 }
56 56
57 int PlatformWheelEvent::verticalLineMultiplier() const 57 static int verticalScrollLines()
58 { 58 {
59 static ULONG scrollLines; 59 static ULONG scrollLines;
60 if (!scrollLines && !SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrol lLines, 0)) 60 if (!scrollLines && !SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrol lLines, 0))
61 scrollLines = cLineMultiplier; 61 scrollLines = 3;
62 return scrollLines; 62 return scrollLines;
63 } 63 }
64 64
65 PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isHorizontal) 65 PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isHorizontal)
66 : m_position(positionForEvent(hWnd, lParam)) 66 : m_position(positionForEvent(hWnd, lParam))
67 , m_globalPosition(globalPositionForEvent(hWnd, lParam)) 67 , m_globalPosition(globalPositionForEvent(hWnd, lParam))
68 , m_isAccepted(false) 68 , m_isAccepted(false)
69 , m_shiftKey(wParam & MK_SHIFT) 69 , m_shiftKey(wParam & MK_SHIFT)
70 , m_ctrlKey(wParam & MK_CONTROL) 70 , m_ctrlKey(wParam & MK_CONTROL)
71 , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT) 71 , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT)
72 , m_metaKey(m_altKey) // FIXME: We'll have to test other browsers 72 , m_metaKey(m_altKey) // FIXME: We'll have to test other browsers
73 { 73 {
74 static ULONG scrollLines, scrollChars; 74 // How many pixels should we scroll per line? Gecko uses the height of the
75 // current line, which means scroll distance changes as you go through the
76 // page or go to different pages. IE 7 is ~50 px/line, although the value
77 // seems to vary slightly by page and zoom level. Since IE 7 has a
78 // smoothing algorithm on scrolling, it can get away with slightly larger
79 // scroll values without feeling jerky. Here we use 100 px per three lines
80 // (the default scroll amount on Windows is three lines per wheel tick).
81 static const float cScrollbarPixelsPerLine = 100.0f / 3.0f;
75 float delta = GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA; 82 float delta = GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
76 if (isHorizontal) { 83 if (isHorizontal) {
77 // Windows sends a positive delta for scrolling right, while AppKit 84 // Windows sends a positive delta for scrolling right, while AppKit
78 // sends a negative delta. EventHandler expects the AppKit values, 85 // sends a negative delta. EventHandler expects the AppKit values,
79 // so we have to negate our horizontal delta to match. 86 // so we have to negate our horizontal delta to match.
80 m_deltaX = -delta * horizontalLineMultiplier(); 87 m_deltaX = -delta * (float)horizontalScrollChars() * cScrollbarPixelsPer Line;
81 m_deltaY = 0; 88 m_deltaY = 0;
82 m_granularity = ScrollByLineWheelEvent; 89 m_granularity = ScrollByPixelWheelEvent;
83 } else { 90 } else {
84 m_deltaX = 0; 91 m_deltaX = 0;
85 m_deltaY = delta; 92 m_deltaY = delta;
86 int verticalMultiplier = verticalLineMultiplier(); 93 int verticalMultiplier = verticalScrollLines();
87 // A multiplier of -1 is used to mean that vertical wheel scrolling shou ld be done by page. 94 m_granularity = (verticalMultiplier == WHEEL_PAGESCROLL) ? ScrollByPageW heelEvent : ScrollByPixelWheelEvent;
88 m_granularity = (verticalMultiplier == -1) ? ScrollByPageWheelEvent : Sc rollByLineWheelEvent; 95 if (m_granularity == ScrollByPixelWheelEvent)
89 if (m_granularity == ScrollByLineWheelEvent) 96 m_deltaY *= (float)verticalMultiplier * cScrollbarPixelsPerLine;
90 m_deltaY *= verticalMultiplier;
91 } 97 }
92 } 98 }
93 99
94 } 100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698