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 | |
Rick Byers
2014/02/21 03:35:52
some special cases that may require more general l
bokan
2014/02/24 14:55:35
I'll also add list box (<select> with size < 5) to
| |
2224 { | |
2225 RenderObject* renderer = node->renderer(); | |
2226 | |
2227 for (RenderLayer* parent = renderer ? renderer->enclosingLayer() : 0; parent ; parent = parent->parent()) { | |
Rick Byers
2014/02/21 03:35:52
Did bokan@ say that walking the layer tree was suf
bokan
2014/02/24 14:55:35
I think (though I could be wrong) it'll always cre
| |
2228 if (parent->scrollsOverflow()) | |
2229 return true; | |
2230 } | |
2231 | |
2232 Frame* parent = m_frame->tree().parent(); | |
2233 if (!parent) | |
2234 return false; | |
2235 | |
2236 return parent->eventHandler().hasScrollableAncestor(m_frame->ownerElement()) ; | |
2237 } | |
2238 | |
2223 bool EventHandler::handleGestureShowPress() | 2239 bool EventHandler::handleGestureShowPress() |
2224 { | 2240 { |
2225 m_lastShowPressTimestamp = WTF::currentTime(); | 2241 m_lastShowPressTimestamp = WTF::currentTime(); |
2226 | 2242 |
2227 FrameView* view = m_frame->view(); | 2243 FrameView* view = m_frame->view(); |
2228 if (!view) | 2244 if (!view) |
2229 return false; | 2245 return false; |
2230 if (ScrollAnimator* scrollAnimator = view->existingScrollAnimator()) | 2246 if (ScrollAnimator* scrollAnimator = view->existingScrollAnimator()) |
2231 scrollAnimator->cancelAnimations(); | 2247 scrollAnimator->cancelAnimations(); |
2232 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); | 2248 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); |
2233 if (!areas) | 2249 if (!areas) |
2234 return false; | 2250 return false; |
2235 for (FrameView::ScrollableAreaSet::const_iterator it = areas->begin(); it != areas->end(); ++it) { | 2251 for (FrameView::ScrollableAreaSet::const_iterator it = areas->begin(); it != areas->end(); ++it) { |
2236 ScrollableArea* sa = *it; | 2252 ScrollableArea* sa = *it; |
2237 ScrollAnimator* animator = sa->scrollAnimator(); | 2253 ScrollAnimator* animator = sa->scrollAnimator(); |
2238 if (animator) | 2254 if (animator) |
2239 animator->cancelAnimations(); | 2255 animator->cancelAnimations(); |
2240 } | 2256 } |
2241 return false; | 2257 return false; |
2242 } | 2258 } |
2243 | 2259 |
2244 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) | 2260 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) |
2245 { | 2261 { |
2246 IntPoint adjustedPoint = gestureEvent.position(); | 2262 IntPoint adjustedPoint = gestureEvent.position(); |
2247 RefPtr<Frame> subframe = 0; | 2263 RefPtr<Frame> subframe = frameForGestureEvent(gestureEvent, adjustedPoint); |
2248 switch (gestureEvent.type()) { | 2264 if (subframe != m_frame) |
2249 case PlatformEvent::GestureScrollBegin: | 2265 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 | 2266 |
2278 Node* eventTarget = 0; | 2267 Node* eventTarget = 0; |
2279 Scrollbar* scrollbar = 0; | 2268 Scrollbar* scrollbar = 0; |
2280 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd | 2269 if (gestureEvent.type() == PlatformEvent::GestureScrollEnd |
2281 || gestureEvent.type() == PlatformEvent::GestureScrollUpdate | 2270 || gestureEvent.type() == PlatformEvent::GestureScrollUpdate |
2282 || gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutPropa gation | 2271 || gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutPropa gation |
2283 || gestureEvent.type() == PlatformEvent::GestureFlingStart) { | 2272 || gestureEvent.type() == PlatformEvent::GestureFlingStart) { |
2284 scrollbar = m_scrollbarHandlingScrollGesture.get(); | 2273 scrollbar = m_scrollbarHandlingScrollGesture.get(); |
2285 eventTarget = m_scrollGestureHandlingNode.get(); | 2274 eventTarget = m_scrollGestureHandlingNode.get(); |
2286 } | 2275 } |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2643 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey()); | 2632 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey()); |
2644 syntheticWheelEvent.setHasPreciseScrollingDeltas(true); | 2633 syntheticWheelEvent.setHasPreciseScrollingDeltas(true); |
2645 | 2634 |
2646 bool scrolledFrame = view->wheelEvent(syntheticWheelEvent); | 2635 bool scrolledFrame = view->wheelEvent(syntheticWheelEvent); |
2647 if (scrolledFrame) | 2636 if (scrolledFrame) |
2648 setFrameWasScrolledByUser(); | 2637 setFrameWasScrolledByUser(); |
2649 | 2638 |
2650 return scrolledFrame; | 2639 return scrolledFrame; |
2651 } | 2640 } |
2652 | 2641 |
2653 Frame* EventHandler::getSubFrameForGestureEvent(const IntPoint& touchAdjustedPoi nt, const PlatformGestureEvent& gestureEvent) | 2642 Frame* EventHandler::frameForGestureEvent(const PlatformGestureEvent& gestureEve nt, IntPoint& adjustedPoint) |
2654 { | 2643 { |
2655 PlatformMouseEvent mouseDown(touchAdjustedPoint, gestureEvent.globalPosition (), LeftButton, PlatformEvent::MousePressed, 1, | 2644 switch (gestureEvent.type()) { |
2656 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey(), gestureEvent.timestamp()); | 2645 case PlatformEvent::GestureScrollBegin: |
2657 HitTestRequest request(HitTestRequest::ReadOnly); | 2646 case PlatformEvent::GestureScrollUpdate: |
2658 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDown); | 2647 case PlatformEvent::GestureScrollUpdateWithoutPropagation: |
2659 return subframeForHitTestResult(mev); | 2648 case PlatformEvent::GestureScrollEnd: |
2649 case PlatformEvent::GestureFlingStart: | |
2650 // Handle in current frame | |
2651 break; | |
2652 | |
2653 case PlatformEvent::GestureTap: | |
2654 case PlatformEvent::GestureTapUnconfirmed: | |
2655 case PlatformEvent::GestureTapDown: | |
2656 case PlatformEvent::GestureShowPress: | |
2657 case PlatformEvent::GestureTapDownCancel: | |
2658 case PlatformEvent::GestureTwoFingerTap: | |
2659 case PlatformEvent::GestureLongPress: | |
2660 case PlatformEvent::GestureLongTap: | |
2661 case PlatformEvent::GesturePinchBegin: | |
2662 case PlatformEvent::GesturePinchEnd: | |
2663 case PlatformEvent::GesturePinchUpdate: { | |
2664 adjustGesturePosition(gestureEvent, adjustedPoint); | |
2665 PlatformMouseEvent mouseDown(adjustedPoint, gestureEvent.globalPosition( ), LeftButton, PlatformEvent::MousePressed, 1, | |
2666 gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey (), gestureEvent.metaKey(), gestureEvent.timestamp()); | |
2667 HitTestRequest request(HitTestRequest::ReadOnly); | |
2668 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseDown) ; | |
2669 RefPtr<Frame> subframe = subframeForHitTestResult(mev); | |
2670 if (subframe) | |
2671 return subframe->eventHandler().frameForGestureEvent(gestureEvent, a djustedPoint); | |
2672 break; | |
2673 } | |
2674 | |
2675 default: | |
2676 ASSERT_NOT_REACHED(); | |
2677 } | |
2678 | |
2679 return m_frame; | |
2660 } | 2680 } |
2661 | 2681 |
2662 void EventHandler::clearGestureScrollNodes() | 2682 void EventHandler::clearGestureScrollNodes() |
2663 { | 2683 { |
2664 m_scrollGestureHandlingNode = 0; | 2684 m_scrollGestureHandlingNode = 0; |
2665 m_previousGestureScrolledNode = 0; | 2685 m_previousGestureScrolledNode = 0; |
2666 } | 2686 } |
2667 | 2687 |
2668 bool EventHandler::isScrollbarHandlingGestures() const | 2688 bool EventHandler::isScrollbarHandlingGestures() const |
2669 { | 2689 { |
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4016 unsigned EventHandler::accessKeyModifiers() | 4036 unsigned EventHandler::accessKeyModifiers() |
4017 { | 4037 { |
4018 #if OS(MACOSX) | 4038 #if OS(MACOSX) |
4019 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 4039 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
4020 #else | 4040 #else |
4021 return PlatformEvent::AltKey; | 4041 return PlatformEvent::AltKey; |
4022 #endif | 4042 #endif |
4023 } | 4043 } |
4024 | 4044 |
4025 } // namespace WebCore | 4045 } // namespace WebCore |
OLD | NEW |