OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006-2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006-2009 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 396 |
397 // Convert wheel delta amount to a number of pixels to scroll. | 397 // Convert wheel delta amount to a number of pixels to scroll. |
398 // | 398 // |
399 // How many pixels should we scroll per line? Gecko uses the height of the | 399 // How many pixels should we scroll per line? Gecko uses the height of the |
400 // current line, which means scroll distance changes as you go through the | 400 // current line, which means scroll distance changes as you go through the |
401 // page or go to different pages. IE 8 is ~60 px/line, although the value | 401 // page or go to different pages. IE 8 is ~60 px/line, although the value |
402 // seems to vary slightly by page and zoom level. Also, IE defaults to | 402 // seems to vary slightly by page and zoom level. Also, IE defaults to |
403 // smooth scrolling while Firefox doesn't, so it can get away with somewhat | 403 // smooth scrolling while Firefox doesn't, so it can get away with somewhat |
404 // larger scroll values without feeling as jerky. Here we use 100 px per | 404 // larger scroll values without feeling as jerky. Here we use 100 px per |
405 // three lines (the default scroll amount is three lines per wheel tick). | 405 // three lines (the default scroll amount is three lines per wheel tick). |
| 406 // Even though we have smooth scrolling, we don't make this as large as IE |
| 407 // because subjectively IE feels like it scrolls farther than you want while |
| 408 // reading articles. |
406 static const float scrollbarPixelsPerLine = 100.0f / 3.0f; | 409 static const float scrollbarPixelsPerLine = 100.0f / 3.0f; |
407 wheelDelta /= WHEEL_DELTA; | 410 wheelDelta /= WHEEL_DELTA; |
408 float scrollDelta = wheelDelta; | 411 float scrollDelta = wheelDelta; |
409 if (horizontalScroll) { | 412 if (horizontalScroll) { |
410 unsigned long scrollChars = defaultScrollCharsPerWheelDelta; | 413 unsigned long scrollChars = defaultScrollCharsPerWheelDelta; |
411 SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0); | 414 SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0); |
412 // TODO(pkasting): Should probably have a different multiplier | 415 // TODO(pkasting): Should probably have a different multiplier |
413 // scrollbarPixelsPerChar here. | 416 // scrollbarPixelsPerChar here. |
414 scrollDelta *= static_cast<float>(scrollChars) * scrollbarPixelsPerLine; | 417 scrollDelta *= static_cast<float>(scrollChars) * scrollbarPixelsPerLine; |
415 } else { | 418 } else { |
(...skipping 12 matching lines...) Expand all Loading... |
428 result.wheelTicksX = wheelDelta; | 431 result.wheelTicksX = wheelDelta; |
429 } else { | 432 } else { |
430 result.deltaY = scrollDelta; | 433 result.deltaY = scrollDelta; |
431 result.wheelTicksY = wheelDelta; | 434 result.wheelTicksY = wheelDelta; |
432 } | 435 } |
433 | 436 |
434 return result; | 437 return result; |
435 } | 438 } |
436 | 439 |
437 } // namespace WebKit | 440 } // namespace WebKit |
OLD | NEW |