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

Unified Diff: Source/core/input/EventHandler.cpp

Issue 1298973004: Remove special wheel handling path from ScrollableArea (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed TODO Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/RootFrameViewportTest.cpp ('k') | Source/platform/scroll/ScrollAnimator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/input/EventHandler.cpp
diff --git a/Source/core/input/EventHandler.cpp b/Source/core/input/EventHandler.cpp
index 006aa2c40a9b7a45bfea777b122a31c3acd2a0e9..2fb7d499c1fed0a20a0b7a358243d77ccd28fa68 100644
--- a/Source/core/input/EventHandler.cpp
+++ b/Source/core/input/EventHandler.cpp
@@ -1716,6 +1716,42 @@ bool EventHandler::slideFocusOnShadowHostIfNecessary(const Element& element)
return false;
}
+namespace {
+
+ScrollResult scrollAreaWithWheelEvent(const PlatformWheelEvent& event, ScrollableArea& scrollableArea)
+{
+ float deltaX = event.railsMode() != PlatformEvent::RailsModeVertical ? event.deltaX() : 0;
+ float deltaY = event.railsMode() != PlatformEvent::RailsModeHorizontal ? event.deltaY() : 0;
+
+ ScrollGranularity granularity =
+ event.granularity() == ScrollByPixelWheelEvent ? ScrollByPixel : ScrollByPage;
+
+ if (event.hasPreciseScrollingDeltas() && granularity == ScrollByPixel)
+ granularity = ScrollByPrecisePixel;
+
+ // If the event is a "PageWheelEvent" we should disregard the delta and
+ // scroll by *one* page length per event.
+ if (event.granularity() == ScrollByPageWheelEvent) {
+ if (deltaX)
+ deltaX = deltaX > 0 ? 1 : -1;
+ if (deltaY)
+ deltaY = deltaY > 0 ? 1 : -1;
+ }
+
+ // Positive delta is up and left.
+ ScrollResultOneDimensional resultY = scrollableArea.userScroll(ScrollUp, granularity, deltaY);
+ ScrollResultOneDimensional resultX = scrollableArea.userScroll(ScrollLeft, granularity, deltaX);
+
+ ScrollResult result;
+ result.didScrollY = resultY.didScroll;
+ result.didScrollX = resultX.didScroll;
+ result.unusedScrollDeltaY = resultY.unusedScrollDelta;
+ result.unusedScrollDeltaX = resultX.unusedScrollDelta;
+ return result;
+}
+
+} // namespace
+
bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event)
{
#define RETURN_WHEEL_EVENT_HANDLED() \
@@ -1773,7 +1809,11 @@ bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event)
if (!view)
return false;
- ScrollResult scrollResult = view->scrollableArea()->handleWheel(event);
+ // Wheel events which do not scroll are used to trigger zooming.
+ if (!event.canScroll())
+ return false;
+
+ ScrollResult scrollResult = scrollAreaWithWheelEvent(event, *view->scrollableArea());
if (m_frame->settings() && m_frame->settings()->reportWheelOverscroll())
handleOverscroll(scrollResult);
if (scrollResult.didScroll())
« no previous file with comments | « Source/core/frame/RootFrameViewportTest.cpp ('k') | Source/platform/scroll/ScrollAnimator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698