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 2202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2213 if (scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->delta X(), roundedIntPoint(wheelEvent->absoluteLocation()))) | 2213 if (scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->delta X(), roundedIntPoint(wheelEvent->absoluteLocation()))) |
2214 wheelEvent->setDefaultHandled(); | 2214 wheelEvent->setDefaultHandled(); |
2215 | 2215 |
2216 if (scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY (), roundedIntPoint(wheelEvent->absoluteLocation()))) | 2216 if (scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY (), roundedIntPoint(wheelEvent->absoluteLocation()))) |
2217 wheelEvent->setDefaultHandled(); | 2217 wheelEvent->setDefaultHandled(); |
2218 | 2218 |
2219 if (!m_latchedWheelEventNode) | 2219 if (!m_latchedWheelEventNode) |
2220 m_previousWheelScrolledNode = stopNode; | 2220 m_previousWheelScrolledNode = stopNode; |
2221 } | 2221 } |
2222 | 2222 |
2223 bool EventHandler::hasScrollableAncestor(const Node* node) const | |
2224 { | |
2225 RenderObject* renderer = node->renderer(); | |
2226 while (node && !renderer) { | |
2227 node = node->parentElement(); | |
2228 renderer = node ? node->renderer() : 0; | |
2229 } | |
2230 | |
2231 if (renderer && renderer->isBox()) { | |
2232 RenderBox* box = toRenderBox(renderer); | |
2233 if (box->canBeScrolledAndHasScrollableArea()) | |
2234 return true; | |
2235 } | |
2236 | |
2237 if (renderer && renderer->enclosingScrollableBox()) | |
2238 return true; | |
2239 | |
2240 LocalFrame* parent = m_frame->tree().parent(); | |
2241 if (!parent) | |
2242 return false; | |
2243 | |
2244 return parent->eventHandler().hasScrollableAncestor(m_frame->ownerElement()) ; | |
2245 } | |
2246 | |
2223 bool EventHandler::handleGestureShowPress() | 2247 bool EventHandler::handleGestureShowPress() |
2224 { | 2248 { |
2225 m_lastShowPressTimestamp = WTF::currentTime(); | 2249 m_lastShowPressTimestamp = WTF::currentTime(); |
2226 | 2250 |
2227 FrameView* view = m_frame->view(); | 2251 FrameView* view = m_frame->view(); |
2228 if (!view) | 2252 if (!view) |
2229 return false; | 2253 return false; |
2230 if (ScrollAnimator* scrollAnimator = view->existingScrollAnimator()) | 2254 if (ScrollAnimator* scrollAnimator = view->existingScrollAnimator()) |
2231 scrollAnimator->cancelAnimations(); | 2255 scrollAnimator->cancelAnimations(); |
2232 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); | 2256 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); |
2233 if (!areas) | 2257 if (!areas) |
2234 return false; | 2258 return false; |
2235 for (FrameView::ScrollableAreaSet::const_iterator it = areas->begin(); it != areas->end(); ++it) { | 2259 for (FrameView::ScrollableAreaSet::const_iterator it = areas->begin(); it != areas->end(); ++it) { |
2236 ScrollableArea* sa = *it; | 2260 ScrollableArea* sa = *it; |
2237 ScrollAnimator* animator = sa->scrollAnimator(); | 2261 ScrollAnimator* animator = sa->scrollAnimator(); |
2238 if (animator) | 2262 if (animator) |
2239 animator->cancelAnimations(); | 2263 animator->cancelAnimations(); |
2240 } | 2264 } |
2241 return false; | 2265 return false; |
2242 } | 2266 } |
2243 | 2267 |
2244 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) | 2268 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) |
2245 { | 2269 { |
2246 IntPoint adjustedPoint = gestureEvent.position(); | 2270 IntPoint adjustedPoint = gestureEvent.position(); |
2247 RefPtr<LocalFrame> subframe = nullptr; | 2271 RefPtr<LocalFrame> subframe = frameForGestureEvent(gestureEvent, adjustedPoi nt); |
2248 switch (gestureEvent.type()) { | 2272 if (subframe != m_frame) |
2249 case PlatformEvent::GestureScrollBegin: | 2273 return subframe->eventHandler().handleGestureEvent(gestureEvent); |
2250 case PlatformEvent::GestureScrollUpdate: | |
2251 case PlatformEvent::GestureScrollUpdateWithoutPropagation: | |
2252 case PlatformEvent::GestureScrollEnd: | |
2253 case PlatformEvent::GestureFlingStart: | |
2254 // Handle directly in main frame | |
2255 break; | |
2256 | |
2257 case PlatformEvent::GestureTap: | |
2258 case PlatformEvent::GestureTapUnconfirmed: | |
2259 case PlatformEvent::GestureTapDown: | |
2260 case PlatformEvent::GestureShowPress: | |
2261 case PlatformEvent::GestureTapDownCancel: | |
2262 case PlatformEvent::GestureTwoFingerTap: | |
2263 case PlatformEvent::GestureLongPress: | |
2264 case PlatformEvent::GestureLongTap: | |
2265 case PlatformEvent::GesturePinchBegin: | |
2266 case PlatformEvent::GesturePinchEnd: | |
2267 case PlatformEvent::GesturePinchUpdate: | |
2268 adjustGesturePosition(gestureEvent, adjustedPoint); | |
2269 subframe = getSubFrameForGestureEvent(adjustedPoint, gestureEvent); | |
2270 if (subframe) | |
2271 return subframe->eventHandler().handleGestureEvent(gestureEvent); | |
2272 break; | |
2273 | |
2274 default: | |
2275 ASSERT_NOT_REACHED(); | |
2276 } | |
2277 | 2274 |
2278 Node* eventTarget = 0; | 2275 Node* eventTarget = 0; |
2279 Scrollbar* scrollbar = 0; | 2276 Scrollbar* scrollbar = 0; |
2280 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd | 2277 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd |
2281 || gestureEvent.type() == PlatformEvent::GestureScrollUpdate | 2278 || gestureEvent.type() == PlatformEvent::GestureScrollUpdate |
2282 || gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutPropa gation | 2279 || gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutPropa gation |
2283 || gestureEvent.type() == PlatformEvent::GestureFlingStart) { | 2280 || gestureEvent.type() == PlatformEvent::GestureFlingStart) { |
2284 scrollbar = m_scrollbarHandlingScrollGesture.get(); | 2281 scrollbar = m_scrollbarHandlingScrollGesture.get(); |
2285 eventTarget = m_scrollGestureHandlingNode.get(); | 2282 eventTarget = m_scrollGestureHandlingNode.get(); |
2286 } | 2283 } |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2643 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey()); | 2640 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey()); |
2644 syntheticWheelEvent.setHasPreciseScrollingDeltas(true); | 2641 syntheticWheelEvent.setHasPreciseScrollingDeltas(true); |
2645 | 2642 |
2646 bool scrolledFrame = view->wheelEvent(syntheticWheelEvent); | 2643 bool scrolledFrame = view->wheelEvent(syntheticWheelEvent); |
2647 if (scrolledFrame) | 2644 if (scrolledFrame) |
2648 setFrameWasScrolledByUser(); | 2645 setFrameWasScrolledByUser(); |
2649 | 2646 |
2650 return scrolledFrame; | 2647 return scrolledFrame; |
2651 } | 2648 } |
2652 | 2649 |
2653 LocalFrame* EventHandler::getSubFrameForGestureEvent(const IntPoint& touchAdjust edPoint, const PlatformGestureEvent& gestureEvent) | 2650 LocalFrame* EventHandler::frameForGestureEvent(const PlatformGestureEvent& gestu reEvent, IntPoint& adjustedPoint) |
2654 { | 2651 { |
2655 PlatformMouseEvent mouseDown(touchAdjustedPoint, gestureEvent.globalPosition (), LeftButton, PlatformEvent::MousePressed, 1, | 2652 switch (gestureEvent.type()) { |
2656 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp()); | 2653 case PlatformEvent::GestureScrollBegin: |
2657 HitTestRequest request(HitTestRequest::ReadOnly); | 2654 case PlatformEvent::GestureScrollUpdate: |
2658 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDown); | 2655 case PlatformEvent::GestureScrollUpdateWithoutPropagation: |
2659 return subframeForHitTestResult(mev); | 2656 case PlatformEvent::GestureScrollEnd: |
2657 case PlatformEvent::GestureFlingStart: | |
2658 // Handle in current frame | |
2659 break; | |
2660 | |
2661 case PlatformEvent::GestureTap: | |
2662 case PlatformEvent::GestureTapUnconfirmed: | |
2663 case PlatformEvent::GestureTapDown: | |
2664 case PlatformEvent::GestureShowPress: | |
2665 case PlatformEvent::GestureTapDownCancel: | |
2666 case PlatformEvent::GestureTwoFingerTap: | |
2667 case PlatformEvent::GestureLongPress: | |
2668 case PlatformEvent::GestureLongTap: | |
2669 case PlatformEvent::GesturePinchBegin: | |
Rick Byers
2014/03/13 01:40:06
I know you're just moving code around here, but th
Zeeshan Qureshi
2014/03/24 21:37:43
I'm not quite sure why, I was hoping to dig into i
Rick Byers
2014/03/25 19:46:47
Ok, deferring this to a future CL is fine. Thanks
| |
2670 case PlatformEvent::GesturePinchEnd: | |
2671 case PlatformEvent::GesturePinchUpdate: { | |
2672 adjustGesturePosition(gestureEvent, adjustedPoint); | |
2673 PlatformMouseEvent mouseDown(adjustedPoint, gestureEvent.globalPosition( ), LeftButton, PlatformEvent::MousePressed, 1, | |
2674 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey (), gestureEvent.metaKey(), gestureEvent.timestamp()); | |
2675 HitTestRequest request(HitTestRequest::ReadOnly); | |
2676 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDown) ; | |
2677 RefPtr<LocalFrame> subframe = subframeForHitTestResult(mev); | |
2678 if (subframe) | |
2679 return subframe->eventHandler().frameForGestureEvent(gestureEvent, a djustedPoint); | |
2680 break; | |
2681 } | |
2682 | |
2683 default: | |
2684 ASSERT_NOT_REACHED(); | |
2685 } | |
2686 | |
2687 return m_frame; | |
2660 } | 2688 } |
2661 | 2689 |
2662 void EventHandler::clearGestureScrollNodes() | 2690 void EventHandler::clearGestureScrollNodes() |
2663 { | 2691 { |
2664 m_scrollGestureHandlingNode = nullptr; | 2692 m_scrollGestureHandlingNode = nullptr; |
2665 m_previousGestureScrolledNode = nullptr; | 2693 m_previousGestureScrolledNode = nullptr; |
2666 } | 2694 } |
2667 | 2695 |
2668 bool EventHandler::isScrollbarHandlingGestures() const | 2696 bool EventHandler::isScrollbarHandlingGestures() const |
2669 { | 2697 { |
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4015 unsigned EventHandler::accessKeyModifiers() | 4043 unsigned EventHandler::accessKeyModifiers() |
4016 { | 4044 { |
4017 #if OS(MACOSX) | 4045 #if OS(MACOSX) |
4018 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4046 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
4019 #else | 4047 #else |
4020 return PlatformEvent::AltKey; | 4048 return PlatformEvent::AltKey; |
4021 #endif | 4049 #endif |
4022 } | 4050 } |
4023 | 4051 |
4024 } // namespace WebCore | 4052 } // namespace WebCore |
OLD | NEW |