| 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 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 if (scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->delta
X(), roundedIntPoint(wheelEvent->absoluteLocation()))) | 2218 if (scroll(ScrollRight, granularity, startNode, &stopNode, wheelEvent->delta
X(), roundedIntPoint(wheelEvent->absoluteLocation()))) |
| 2219 wheelEvent->setDefaultHandled(); | 2219 wheelEvent->setDefaultHandled(); |
| 2220 | 2220 |
| 2221 if (scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY
(), roundedIntPoint(wheelEvent->absoluteLocation()))) | 2221 if (scroll(ScrollDown, granularity, startNode, &stopNode, wheelEvent->deltaY
(), roundedIntPoint(wheelEvent->absoluteLocation()))) |
| 2222 wheelEvent->setDefaultHandled(); | 2222 wheelEvent->setDefaultHandled(); |
| 2223 | 2223 |
| 2224 if (!m_latchedWheelEventNode) | 2224 if (!m_latchedWheelEventNode) |
| 2225 m_previousWheelScrolledNode = stopNode; | 2225 m_previousWheelScrolledNode = stopNode; |
| 2226 } | 2226 } |
| 2227 | 2227 |
| 2228 bool EventHandler::hasScrollableAncestor(const Node* node) const |
| 2229 { |
| 2230 RenderObject* renderer = node->renderer(); |
| 2231 while (node && !renderer) { |
| 2232 node = node->parentElement(); |
| 2233 renderer = node ? node->renderer() : 0; |
| 2234 } |
| 2235 |
| 2236 if (renderer && renderer->isBox()) { |
| 2237 RenderBox* box = toRenderBox(renderer); |
| 2238 if (box->canBeScrolledAndHasScrollableArea()) |
| 2239 return true; |
| 2240 } |
| 2241 |
| 2242 if (renderer && renderer->enclosingScrollableBox()) |
| 2243 return true; |
| 2244 |
| 2245 LocalFrame* parent = m_frame->tree().parent(); |
| 2246 if (!parent) |
| 2247 return false; |
| 2248 |
| 2249 return parent->eventHandler().hasScrollableAncestor(m_frame->ownerElement())
; |
| 2250 } |
| 2251 |
| 2228 bool EventHandler::handleGestureShowPress() | 2252 bool EventHandler::handleGestureShowPress() |
| 2229 { | 2253 { |
| 2230 m_lastShowPressTimestamp = WTF::currentTime(); | 2254 m_lastShowPressTimestamp = WTF::currentTime(); |
| 2231 | 2255 |
| 2232 FrameView* view = m_frame->view(); | 2256 FrameView* view = m_frame->view(); |
| 2233 if (!view) | 2257 if (!view) |
| 2234 return false; | 2258 return false; |
| 2235 if (ScrollAnimator* scrollAnimator = view->existingScrollAnimator()) | 2259 if (ScrollAnimator* scrollAnimator = view->existingScrollAnimator()) |
| 2236 scrollAnimator->cancelAnimations(); | 2260 scrollAnimator->cancelAnimations(); |
| 2237 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); | 2261 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); |
| 2238 if (!areas) | 2262 if (!areas) |
| 2239 return false; | 2263 return false; |
| 2240 for (FrameView::ScrollableAreaSet::const_iterator it = areas->begin(); it !=
areas->end(); ++it) { | 2264 for (FrameView::ScrollableAreaSet::const_iterator it = areas->begin(); it !=
areas->end(); ++it) { |
| 2241 ScrollableArea* sa = *it; | 2265 ScrollableArea* sa = *it; |
| 2242 ScrollAnimator* animator = sa->scrollAnimator(); | 2266 ScrollAnimator* animator = sa->scrollAnimator(); |
| 2243 if (animator) | 2267 if (animator) |
| 2244 animator->cancelAnimations(); | 2268 animator->cancelAnimations(); |
| 2245 } | 2269 } |
| 2246 return false; | 2270 return false; |
| 2247 } | 2271 } |
| 2248 | 2272 |
| 2249 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) | 2273 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) |
| 2250 { | 2274 { |
| 2251 IntPoint adjustedPoint = gestureEvent.position(); | 2275 IntPoint adjustedPoint = gestureEvent.position(); |
| 2252 RefPtr<LocalFrame> subframe = nullptr; | 2276 RefPtr<LocalFrame> subframe = frameForGestureEvent(gestureEvent, adjustedPoi
nt); |
| 2253 switch (gestureEvent.type()) { | 2277 if (subframe != m_frame) |
| 2254 case PlatformEvent::GestureScrollBegin: | 2278 return subframe->eventHandler().handleGestureEvent(gestureEvent); |
| 2255 case PlatformEvent::GestureScrollUpdate: | |
| 2256 case PlatformEvent::GestureScrollUpdateWithoutPropagation: | |
| 2257 case PlatformEvent::GestureScrollEnd: | |
| 2258 case PlatformEvent::GestureFlingStart: | |
| 2259 // Handle directly in main frame | |
| 2260 break; | |
| 2261 | |
| 2262 case PlatformEvent::GestureTap: | |
| 2263 case PlatformEvent::GestureTapUnconfirmed: | |
| 2264 case PlatformEvent::GestureTapDown: | |
| 2265 case PlatformEvent::GestureShowPress: | |
| 2266 case PlatformEvent::GestureTapDownCancel: | |
| 2267 case PlatformEvent::GestureTwoFingerTap: | |
| 2268 case PlatformEvent::GestureLongPress: | |
| 2269 case PlatformEvent::GestureLongTap: | |
| 2270 case PlatformEvent::GesturePinchBegin: | |
| 2271 case PlatformEvent::GesturePinchEnd: | |
| 2272 case PlatformEvent::GesturePinchUpdate: | |
| 2273 adjustGesturePosition(gestureEvent, adjustedPoint); | |
| 2274 subframe = getSubFrameForGestureEvent(adjustedPoint, gestureEvent); | |
| 2275 if (subframe) | |
| 2276 return subframe->eventHandler().handleGestureEvent(gestureEvent); | |
| 2277 break; | |
| 2278 | |
| 2279 default: | |
| 2280 ASSERT_NOT_REACHED(); | |
| 2281 } | |
| 2282 | 2279 |
| 2283 Node* eventTarget = 0; | 2280 Node* eventTarget = 0; |
| 2284 Scrollbar* scrollbar = 0; | 2281 Scrollbar* scrollbar = 0; |
| 2285 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd | 2282 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd |
| 2286 || gestureEvent.type() == PlatformEvent::GestureScrollUpdate | 2283 || gestureEvent.type() == PlatformEvent::GestureScrollUpdate |
| 2287 || gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutPropa
gation | 2284 || gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutPropa
gation |
| 2288 || gestureEvent.type() == PlatformEvent::GestureFlingStart) { | 2285 || gestureEvent.type() == PlatformEvent::GestureFlingStart) { |
| 2289 scrollbar = m_scrollbarHandlingScrollGesture.get(); | 2286 scrollbar = m_scrollbarHandlingScrollGesture.get(); |
| 2290 eventTarget = m_scrollGestureHandlingNode.get(); | 2287 eventTarget = m_scrollGestureHandlingNode.get(); |
| 2291 } | 2288 } |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2648 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(),
gestureEvent.metaKey()); | 2645 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(),
gestureEvent.metaKey()); |
| 2649 syntheticWheelEvent.setHasPreciseScrollingDeltas(true); | 2646 syntheticWheelEvent.setHasPreciseScrollingDeltas(true); |
| 2650 | 2647 |
| 2651 bool scrolledFrame = view->wheelEvent(syntheticWheelEvent); | 2648 bool scrolledFrame = view->wheelEvent(syntheticWheelEvent); |
| 2652 if (scrolledFrame) | 2649 if (scrolledFrame) |
| 2653 setFrameWasScrolledByUser(); | 2650 setFrameWasScrolledByUser(); |
| 2654 | 2651 |
| 2655 return scrolledFrame; | 2652 return scrolledFrame; |
| 2656 } | 2653 } |
| 2657 | 2654 |
| 2658 LocalFrame* EventHandler::getSubFrameForGestureEvent(const IntPoint& touchAdjust
edPoint, const PlatformGestureEvent& gestureEvent) | 2655 LocalFrame* EventHandler::frameForGestureEvent(const PlatformGestureEvent& gestu
reEvent, IntPoint& adjustedPoint) |
| 2659 { | 2656 { |
| 2660 PlatformMouseEvent mouseDown(touchAdjustedPoint, gestureEvent.globalPosition
(), LeftButton, PlatformEvent::MousePressed, 1, | 2657 switch (gestureEvent.type()) { |
| 2661 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(),
gestureEvent.metaKey(), gestureEvent.timestamp()); | 2658 case PlatformEvent::GestureScrollBegin: |
| 2662 HitTestRequest request(HitTestRequest::ReadOnly); | 2659 case PlatformEvent::GestureScrollUpdate: |
| 2663 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDown); | 2660 case PlatformEvent::GestureScrollUpdateWithoutPropagation: |
| 2664 return subframeForHitTestResult(mev); | 2661 case PlatformEvent::GestureScrollEnd: |
| 2662 case PlatformEvent::GestureFlingStart: |
| 2663 // Handle in current frame |
| 2664 break; |
| 2665 |
| 2666 case PlatformEvent::GestureTap: |
| 2667 case PlatformEvent::GestureTapUnconfirmed: |
| 2668 case PlatformEvent::GestureTapDown: |
| 2669 case PlatformEvent::GestureShowPress: |
| 2670 case PlatformEvent::GestureTapDownCancel: |
| 2671 case PlatformEvent::GestureTwoFingerTap: |
| 2672 case PlatformEvent::GestureLongPress: |
| 2673 case PlatformEvent::GestureLongTap: |
| 2674 case PlatformEvent::GesturePinchBegin: |
| 2675 case PlatformEvent::GesturePinchEnd: |
| 2676 case PlatformEvent::GesturePinchUpdate: { |
| 2677 adjustGesturePosition(gestureEvent, adjustedPoint); |
| 2678 PlatformMouseEvent mouseDown(adjustedPoint, gestureEvent.globalPosition(
), LeftButton, PlatformEvent::MousePressed, 1, |
| 2679 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey
(), gestureEvent.metaKey(), gestureEvent.timestamp()); |
| 2680 HitTestRequest request(HitTestRequest::ReadOnly); |
| 2681 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDown)
; |
| 2682 RefPtr<LocalFrame> subframe = subframeForHitTestResult(mev); |
| 2683 if (subframe) |
| 2684 return subframe->eventHandler().frameForGestureEvent(gestureEvent, a
djustedPoint); |
| 2685 break; |
| 2686 } |
| 2687 |
| 2688 default: |
| 2689 ASSERT_NOT_REACHED(); |
| 2690 } |
| 2691 |
| 2692 return m_frame; |
| 2665 } | 2693 } |
| 2666 | 2694 |
| 2667 void EventHandler::clearGestureScrollNodes() | 2695 void EventHandler::clearGestureScrollNodes() |
| 2668 { | 2696 { |
| 2669 m_scrollGestureHandlingNode = nullptr; | 2697 m_scrollGestureHandlingNode = nullptr; |
| 2670 m_previousGestureScrolledNode = nullptr; | 2698 m_previousGestureScrolledNode = nullptr; |
| 2671 } | 2699 } |
| 2672 | 2700 |
| 2673 bool EventHandler::isScrollbarHandlingGestures() const | 2701 bool EventHandler::isScrollbarHandlingGestures() const |
| 2674 { | 2702 { |
| (...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4024 unsigned EventHandler::accessKeyModifiers() | 4052 unsigned EventHandler::accessKeyModifiers() |
| 4025 { | 4053 { |
| 4026 #if OS(MACOSX) | 4054 #if OS(MACOSX) |
| 4027 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4055 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
| 4028 #else | 4056 #else |
| 4029 return PlatformEvent::AltKey; | 4057 return PlatformEvent::AltKey; |
| 4030 #endif | 4058 #endif |
| 4031 } | 4059 } |
| 4032 | 4060 |
| 4033 } // namespace WebCore | 4061 } // namespace WebCore |
| OLD | NEW |