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

Side by Side Diff: webkit/glue/webinputevent_win.cc

Issue 40241: Convert from line scrolling to pixel scrolling. Increase pixel scroll amount... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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
« no previous file with comments | « webkit/glue/webinputevent_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "webkit/glue/webinputevent.h" 7 #include "webkit/glue/webinputevent.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 modifiers |= CTRL_KEY; 188 modifiers |= CTRL_KEY;
189 if (get_key_state(VK_MENU) & 0x8000) 189 if (get_key_state(VK_MENU) & 0x8000)
190 modifiers |= (ALT_KEY | META_KEY); 190 modifiers |= (ALT_KEY | META_KEY);
191 191
192 // Set coordinates by translating event coordinates from screen to client. 192 // Set coordinates by translating event coordinates from screen to client.
193 POINT client_point = { global_x, global_y }; 193 POINT client_point = { global_x, global_y };
194 MapWindowPoints(NULL, hwnd, &client_point, 1); 194 MapWindowPoints(NULL, hwnd, &client_point, 1);
195 x = client_point.x; 195 x = client_point.x;
196 y = client_point.y; 196 y = client_point.y;
197 197
198 // Convert wheel delta amount to a number of lines/chars to scroll. 198 // Convert wheel delta amount to a number of pixels to scroll.
199 //
200 // How many pixels should we scroll per line? Gecko uses the height of the
201 // current line, which means scroll distance changes as you go through the
202 // page or go to different pages. IE 7 is ~50 px/line, although the value
203 // seems to vary slightly by page and zoom level. Since IE 7 has a smoothing
204 // algorithm on scrolling, it can get away with slightly larger scroll values
205 // without feeling jerky. Here we use 100 px per three lines (the default
206 // scroll amount is three lines per wheel tick).
207 static const float kScrollbarPixelsPerLine = 100.0f / 3.0f;
199 float scroll_delta = wheel_delta / WHEEL_DELTA; 208 float scroll_delta = wheel_delta / WHEEL_DELTA;
200 if (horizontal_scroll) { 209 if (horizontal_scroll) {
201 unsigned long scroll_chars = kDefaultScrollCharsPerWheelDelta; 210 unsigned long scroll_chars = kDefaultScrollCharsPerWheelDelta;
202 SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scroll_chars, 0); 211 SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scroll_chars, 0);
203 scroll_delta *= static_cast<float>(scroll_chars); 212 // TODO(pkasting): Should probably have a different multiplier
213 // kScrollbarPixelsPerChar here.
214 scroll_delta *= static_cast<float>(scroll_chars) * kScrollbarPixelsPerLine;
204 } else { 215 } else {
205 unsigned long scroll_lines = kDefaultScrollLinesPerWheelDelta; 216 unsigned long scroll_lines = kDefaultScrollLinesPerWheelDelta;
206 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scroll_lines, 0); 217 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scroll_lines, 0);
207 if (scroll_lines == WHEEL_PAGESCROLL) 218 if (scroll_lines == WHEEL_PAGESCROLL)
208 scroll_by_page = true; 219 scroll_by_page = true;
209 if (!scroll_by_page) 220 if (!scroll_by_page) {
210 scroll_delta *= static_cast<float>(scroll_lines); 221 scroll_delta *=
222 static_cast<float>(scroll_lines) * kScrollbarPixelsPerLine;
223 }
211 } 224 }
212 225
213 // Set scroll amount based on above calculations. 226 // Set scroll amount based on above calculations.
214 if (horizontal_scroll) { 227 if (horizontal_scroll) {
215 // Scrolling up should move left, scrolling down should move right. This is
216 // opposite Safari, but seems more consistent with vertical scrolling.
217 delta_x = scroll_delta; 228 delta_x = scroll_delta;
218 delta_y = 0; 229 delta_y = 0;
219 } else { 230 } else {
220 delta_x = 0; 231 delta_x = 0;
221 delta_y = scroll_delta; 232 delta_y = scroll_delta;
222 } 233 }
223 } 234 }
224 235
225 // WebKeyboardEvent ----------------------------------------------------------- 236 // WebKeyboardEvent -----------------------------------------------------------
226 237
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 modifiers |= CTRL_KEY; 335 modifiers |= CTRL_KEY;
325 if (GetKeyState(VK_MENU) & 0x8000) 336 if (GetKeyState(VK_MENU) & 0x8000)
326 modifiers |= (ALT_KEY | META_KEY); 337 modifiers |= (ALT_KEY | META_KEY);
327 338
328 if (LOWORD(lparam) > 1) 339 if (LOWORD(lparam) > 1)
329 modifiers |= IS_AUTO_REPEAT; 340 modifiers |= IS_AUTO_REPEAT;
330 if (IsKeyPad(wparam, lparam)) 341 if (IsKeyPad(wparam, lparam))
331 modifiers |= IS_KEYPAD; 342 modifiers |= IS_KEYPAD;
332 } 343 }
333 344
OLDNEW
« no previous file with comments | « webkit/glue/webinputevent_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698