OLD | NEW |
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 Loading... |
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()->reportWheelOverscroll()) |
| 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 Loading... |
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 FloatSize unusedDelta(scrollResult.unusedScrollDeltaX, scrollResult.unusedSc
rollDeltaY); |
2261 ScrollableArea* scrollablearea = m_frame->view()->scrollableArea(); | 2264 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY); |
2262 // Set unusedDelta if axis is scrollable, else set 0 to ensure overflow
is not reported on non-scrollable axes. | 2265 if (unusedDelta != FloatSize()) { |
2263 FloatSize unusedDelta(scrollablearea->scrollSize(HorizontalScrollbar) ?
scrollResult.unusedScrollDeltaX : 0, scrollablearea->scrollSize(VerticalScrollba
r) ? scrollResult.unusedScrollDeltaY : 0); | 2266 m_accumulatedRootOverscroll += unusedDelta; |
2264 resetOverscroll(scrollResult.didScrollX, scrollResult.didScrollY); | 2267 m_frame->chromeClient().didOverscroll(unusedDelta, m_accumulatedRootOver
scroll, position, velocity); |
2265 if (unusedDelta != FloatSize()) { | |
2266 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); | |
2270 } | |
2271 } | 2268 } |
2272 } | 2269 } |
2273 | 2270 |
2274 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture
Event) | 2271 bool EventHandler::handleGestureScrollUpdate(const PlatformGestureEvent& gesture
Event) |
2275 { | 2272 { |
2276 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); | 2273 ASSERT(gestureEvent.type() == PlatformEvent::GestureScrollUpdate); |
2277 | 2274 |
2278 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); | 2275 FloatSize delta(gestureEvent.deltaX(), gestureEvent.deltaY()); |
2279 if (delta.isZero()) | 2276 if (delta.isZero()) |
2280 return false; | 2277 return false; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2347 setFrameWasScrolledByUser(); | 2344 setFrameWasScrolledByUser(); |
2348 return true; | 2345 return true; |
2349 } | 2346 } |
2350 } | 2347 } |
2351 | 2348 |
2352 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) | 2349 if (RuntimeEnabledFeatures::scrollCustomizationEnabled()) |
2353 return false; | 2350 return false; |
2354 | 2351 |
2355 // Try to scroll the frame view. | 2352 // Try to scroll the frame view. |
2356 ScrollResult scrollResult = m_frame->applyScrollDelta(delta, false); | 2353 ScrollResult scrollResult = m_frame->applyScrollDelta(delta, false); |
2357 handleOverscroll(scrollResult, gestureEvent); | 2354 FloatPoint position = FloatPoint(gestureEvent.position().x(), gestureEvent.p
osition().y()); |
| 2355 FloatSize velocity = FloatSize(gestureEvent.velocityX(), gestureEvent.veloci
tyY()); |
| 2356 if (m_frame->isMainFrame() && m_frame->view() && m_frame->view()->scrollable
Area()) { |
| 2357 ScrollableArea* scrollablearea = m_frame->view()->scrollableArea(); |
| 2358 // TODO(sataya.m) : In Case of android set unusedDelta to 0 to ensure ov
erflow is not reported |
| 2359 // on non-scrollable axis. Move this check to CC to block OverscrollGlow
Animation on non-scrollable axes. |
| 2360 scrollResult.unusedScrollDeltaX = scrollablearea->scrollSize(HorizontalS
crollbar) ? scrollResult.unusedScrollDeltaX : 0; |
| 2361 scrollResult.unusedScrollDeltaY = scrollablearea->scrollSize(VerticalScr
ollbar) ? scrollResult.unusedScrollDeltaY : 0; |
| 2362 } |
| 2363 handleOverscroll(scrollResult, position, velocity); |
2358 if (scrollResult.didScroll()) { | 2364 if (scrollResult.didScroll()) { |
2359 setFrameWasScrolledByUser(); | 2365 setFrameWasScrolledByUser(); |
2360 return true; | 2366 return true; |
2361 } | 2367 } |
2362 | 2368 |
2363 return false; | 2369 return false; |
2364 } | 2370 } |
2365 | 2371 |
2366 void EventHandler::clearGestureScrollState() | 2372 void EventHandler::clearGestureScrollState() |
2367 { | 2373 { |
(...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3889 unsigned EventHandler::accessKeyModifiers() | 3895 unsigned EventHandler::accessKeyModifiers() |
3890 { | 3896 { |
3891 #if OS(MACOSX) | 3897 #if OS(MACOSX) |
3892 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3898 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3893 #else | 3899 #else |
3894 return PlatformEvent::AltKey; | 3900 return PlatformEvent::AltKey; |
3895 #endif | 3901 #endif |
3896 } | 3902 } |
3897 | 3903 |
3898 } // namespace blink | 3904 } // namespace blink |
OLD | NEW |