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

Side by Side Diff: Source/core/input/EventHandler.cpp

Issue 1195803003: Report accurate Overscroll on handleWheel. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 if (node && !node->dispatchWheelEvent(event)) 1775 if (node && !node->dispatchWheelEvent(event))
1776 RETURN_WHEEL_EVENT_HANDLED(); 1776 RETURN_WHEEL_EVENT_HANDLED();
1777 } 1777 }
1778 1778
1779 // We do another check on the frame view because the event handler can run 1779 // We do another check on the frame view because the event handler can run
1780 // JS which results in the frame getting destroyed. 1780 // JS which results in the frame getting destroyed.
1781 view = m_frame->view(); 1781 view = m_frame->view();
1782 if (!view) 1782 if (!view)
1783 return false; 1783 return false;
1784 1784
1785 if (view->scrollableArea()->handleWheel(event).didScroll()) 1785 ScrollResult scrollResult = view->scrollableArea()->handleWheel(event);
1786 if (m_frame->settings() && m_frame->settings()->elasticOverscrollEnabled())
1787 handleOverscroll(scrollResult);
1788 if (scrollResult.didScroll())
1786 RETURN_WHEEL_EVENT_HANDLED(); 1789 RETURN_WHEEL_EVENT_HANDLED();
1787 1790
1788 return false; 1791 return false;
1789 #undef RETURN_WHEEL_EVENT_HANDLED 1792 #undef RETURN_WHEEL_EVENT_HANDLED
1790 } 1793 }
1791 1794
1792 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent) 1795 void EventHandler::defaultWheelEventHandler(Node* startNode, WheelEvent* wheelEv ent)
1793 { 1796 {
1794 if (!startNode || !wheelEvent) 1797 if (!startNode || !wheelEvent)
1795 return; 1798 return;
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 } 2251 }
2249 2252
2250 void EventHandler::resetOverscroll(bool didScrollX, bool didScrollY) 2253 void EventHandler::resetOverscroll(bool didScrollX, bool didScrollY)
2251 { 2254 {
2252 if (didScrollX) 2255 if (didScrollX)
2253 m_accumulatedRootOverscroll.setWidth(0); 2256 m_accumulatedRootOverscroll.setWidth(0);
2254 if (didScrollY) 2257 if (didScrollY)
2255 m_accumulatedRootOverscroll.setHeight(0); 2258 m_accumulatedRootOverscroll.setHeight(0);
2256 } 2259 }
2257 2260
2258 void EventHandler::handleOverscroll(const ScrollResult& scrollResult, const Plat formGestureEvent& gestureEvent) 2261 void EventHandler::handleOverscroll(const ScrollResult& scrollResult, const Floa tPoint& position, const FloatSize& velocity)
2259 { 2262 {
2260 if (m_frame->isMainFrame() && m_frame->view() && m_frame->view()->scrollable Area()) { 2263 if (m_frame->isMainFrame() && m_frame->view() && m_frame->view()->scrollable Area()) {
2261 ScrollableArea* scrollablearea = m_frame->view()->scrollableArea(); 2264 ScrollableArea* scrollablearea = m_frame->view()->scrollableArea();
2262 // Set unusedDelta if axis is scrollable, else set 0 to ensure overflow is not reported on non-scrollable axes. 2265 FloatSize unusedDelta;
2263 FloatSize unusedDelta(scrollablearea->scrollSize(HorizontalScrollbar) ? scrollResult.unusedScrollDeltaX : 0, scrollablearea->scrollSize(VerticalScrollba r) ? scrollResult.unusedScrollDeltaY : 0); 2266 if (m_frame->settings() && m_frame->settings()->elasticOverscrollEnabled ()) {
2267 // ElasticOverscroll should be applied even on non-Scrollable axis.
bokan 2015/06/25 17:50:31 This distinction seems strange to me, we shouldn't
MuVen 2015/06/26 09:55:44 Done.
2268 unusedDelta.setWidth(scrollResult.unusedScrollDeltaX);
2269 unusedDelta.setHeight(scrollResult.unusedScrollDeltaY);
2270 } else {
2271 // In Case of android set unusedDelta if axis is scrollable, else se t 0 to ensure overflow is not reported on non-scrollable axes.
2272 unusedDelta.setWidth(scrollablearea->scrollSize(HorizontalScrollbar) ? scrollResult.unusedScrollDeltaX : 0);
2273 unusedDelta.setHeight(scrollablearea->scrollSize(VerticalScrollbar) ? scrollResult.unusedScrollDeltaY : 0);
2274 }
2264 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY); 2275 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY);
2265 if (unusedDelta != FloatSize()) { 2276 if (unusedDelta != FloatSize()) {
2266 m_accumulatedRootOverscroll += unusedDelta; 2277 m_accumulatedRootOverscroll += unusedDelta;
2267 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestur eEvent.position().y());
2268 FloatSize velocity = FloatSize(gestureEvent.velocityX(), gestureEven t.velocityY());
2269 m_frame->chromeClient().didOverscroll(unusedDelta, m_accumulatedRoot Overscroll, position, velocity); 2278 m_frame->chromeClient().didOverscroll(unusedDelta, m_accumulatedRoot Overscroll, position, velocity);
2270 } 2279 }
2271 } 2280 }
2272 } 2281 }
2273 2282
2274 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event) 2283 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture Event)
2275 { 2284 {
2276 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); 2285 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate);
2277 2286
2278 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); 2287 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 setFrameWasScrolledByUser(); 2356 setFrameWasScrolledByUser();
2348 return true; 2357 return true;
2349 } 2358 }
2350 } 2359 }
2351 2360
2352 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) 2361 if (RuntimeEnabledFeatures::scrollCustomizationEnabled())
2353 return false; 2362 return false;
2354 2363
2355 // Try to scroll the frame view. 2364 // Try to scroll the frame view.
2356 ScrollResult scrollResult = m_frame->applyScrollDelta(delta, false); 2365 ScrollResult scrollResult = m_frame->applyScrollDelta(delta, false);
2357 handleOverscroll(scrollResult, gestureEvent); 2366 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestureEvent.p osition().y());
2367 FloatSize velocity = FloatSize(gestureEvent.velocityX(), gestureEvent.veloci tyY());
2368 handleOverscroll(scrollResult, position, velocity);
2358 if (scrollResult.didScroll()) { 2369 if (scrollResult.didScroll()) {
2359 setFrameWasScrolledByUser(); 2370 setFrameWasScrolledByUser();
2360 return true; 2371 return true;
2361 } 2372 }
2362 2373
2363 return false; 2374 return false;
2364 } 2375 }
2365 2376
2366 void EventHandler::clearGestureScrollState() 2377 void EventHandler::clearGestureScrollState()
2367 { 2378 {
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after
3890 unsigned EventHandler::accessKeyModifiers() 3901 unsigned EventHandler::accessKeyModifiers()
3891 { 3902 {
3892 #if OS(MACOSX) 3903 #if OS(MACOSX)
3893 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3904 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3894 #else 3905 #else
3895 return PlatformEvent::AltKey; 3906 return PlatformEvent::AltKey;
3896 #endif 3907 #endif
3897 } 3908 }
3898 3909
3899 } // namespace blink 3910 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698