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

Side by Side Diff: content/browser/renderer_host/input/web_input_event_builders_win.cc

Issue 23532015: Fix scroll_delta computation on windows for vertical scroll by page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | « no previous file | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/renderer_host/input/web_input_event_builders_win.h" 5 #include "content/browser/renderer_host/input/web_input_event_builders_win.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/renderer_host/input/web_input_event_util.h" 8 #include "content/browser/renderer_host/input/web_input_event_util.h"
9 9
10 using WebKit::WebInputEvent; 10 using WebKit::WebInputEvent;
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // page or go to different pages. IE 8 is ~60 px/line, although the value 421 // page or go to different pages. IE 8 is ~60 px/line, although the value
422 // seems to vary slightly by page and zoom level. Also, IE defaults to 422 // seems to vary slightly by page and zoom level. Also, IE defaults to
423 // smooth scrolling while Firefox doesn't, so it can get away with somewhat 423 // smooth scrolling while Firefox doesn't, so it can get away with somewhat
424 // larger scroll values without feeling as jerky. Here we use 100 px per 424 // larger scroll values without feeling as jerky. Here we use 100 px per
425 // three lines (the default scroll amount is three lines per wheel tick). 425 // three lines (the default scroll amount is three lines per wheel tick).
426 // Even though we have smooth scrolling, we don't make this as large as IE 426 // Even though we have smooth scrolling, we don't make this as large as IE
427 // because subjectively IE feels like it scrolls farther than you want while 427 // because subjectively IE feels like it scrolls farther than you want while
428 // reading articles. 428 // reading articles.
429 static const float kScrollbarPixelsPerLine = 100.0f / 3.0f; 429 static const float kScrollbarPixelsPerLine = 100.0f / 3.0f;
430 wheel_delta /= WHEEL_DELTA; 430 wheel_delta /= WHEEL_DELTA;
431 float scroll_delta = wheel_delta * kScrollbarPixelsPerLine; 431 float scroll_delta = wheel_delta;
432 if (horizontal_scroll) { 432 if (horizontal_scroll) {
433 unsigned long scroll_chars = kDefaultScrollCharsPerWheelDelta; 433 unsigned long scroll_chars = kDefaultScrollCharsPerWheelDelta;
434 SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scroll_chars, 0); 434 SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scroll_chars, 0);
435 // TODO(pkasting): Should probably have a different multiplier 435 // TODO(pkasting): Should probably have a different multiplier
436 // scrollbarPixelsPerChar here. 436 // scrollbarPixelsPerChar here.
437 scroll_delta *= static_cast<float>(scroll_chars); 437 scroll_delta *= static_cast<float>(scroll_chars) * kScrollbarPixelsPerLine;
438 } else { 438 } else {
439 unsigned long scroll_lines = kDefaultScrollLinesPerWheelDelta; 439 unsigned long scroll_lines = kDefaultScrollLinesPerWheelDelta;
440 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scroll_lines, 0); 440 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scroll_lines, 0);
441 if (scroll_lines == WHEEL_PAGESCROLL) 441 if (scroll_lines == WHEEL_PAGESCROLL)
442 result.scrollByPage = true; 442 result.scrollByPage = true;
443 if (!result.scrollByPage) 443 if (!result.scrollByPage) {
444 scroll_delta *= static_cast<float>(scroll_lines); 444 scroll_delta *=
445 static_cast<float>(scroll_lines) * kScrollbarPixelsPerLine;
446 }
445 } 447 }
446 448
447 // Set scroll amount based on above calculations. WebKit expects positive 449 // Set scroll amount based on above calculations. WebKit expects positive
448 // deltaY to mean "scroll up" and positive deltaX to mean "scroll left". 450 // deltaY to mean "scroll up" and positive deltaX to mean "scroll left".
449 if (horizontal_scroll) { 451 if (horizontal_scroll) {
450 result.deltaX = scroll_delta; 452 result.deltaX = scroll_delta;
451 result.wheelTicksX = wheel_delta; 453 result.wheelTicksX = wheel_delta;
452 } else { 454 } else {
453 result.deltaY = scroll_delta; 455 result.deltaY = scroll_delta;
454 result.wheelTicksY = wheel_delta; 456 result.wheelTicksY = wheel_delta;
455 } 457 }
456 458
457 return result; 459 return result;
458 } 460 }
459 461
460 } // namespace content 462 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698