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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 #include "core/inspector/InspectorController.h" | 62 #include "core/inspector/InspectorController.h" |
63 #include "core/loader/FrameLoader.h" | 63 #include "core/loader/FrameLoader.h" |
64 #include "core/loader/FrameLoaderClient.h" | 64 #include "core/loader/FrameLoaderClient.h" |
65 #include "core/page/AutoscrollController.h" | 65 #include "core/page/AutoscrollController.h" |
66 #include "core/page/BackForwardClient.h" | 66 #include "core/page/BackForwardClient.h" |
67 #include "core/page/Chrome.h" | 67 #include "core/page/Chrome.h" |
68 #include "core/page/ChromeClient.h" | 68 #include "core/page/ChromeClient.h" |
69 #include "core/page/DragController.h" | 69 #include "core/page/DragController.h" |
70 #include "core/page/DragState.h" | 70 #include "core/page/DragState.h" |
71 #include "core/page/EditorClient.h" | 71 #include "core/page/EditorClient.h" |
72 #include "core/page/EventWithHitTestResults.h" | |
73 #include "core/page/FocusController.h" | 72 #include "core/page/FocusController.h" |
74 #include "core/page/FrameTree.h" | 73 #include "core/page/FrameTree.h" |
75 #include "core/page/Page.h" | 74 #include "core/page/Page.h" |
76 #include "core/page/SpatialNavigation.h" | 75 #include "core/page/SpatialNavigation.h" |
77 #include "core/page/TouchAdjustment.h" | 76 #include "core/page/TouchAdjustment.h" |
78 #include "core/rendering/HitTestRequest.h" | 77 #include "core/rendering/HitTestRequest.h" |
79 #include "core/rendering/HitTestResult.h" | 78 #include "core/rendering/HitTestResult.h" |
80 #include "core/rendering/RenderFlowThread.h" | 79 #include "core/rendering/RenderFlowThread.h" |
81 #include "core/rendering/RenderLayer.h" | 80 #include "core/rendering/RenderLayer.h" |
82 #include "core/rendering/RenderTextControlSingleLine.h" | 81 #include "core/rendering/RenderTextControlSingleLine.h" |
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2056 ScrollableArea* sa = *it; | 2055 ScrollableArea* sa = *it; |
2057 ScrollAnimator* animator = sa->existingScrollAnimator(); | 2056 ScrollAnimator* animator = sa->existingScrollAnimator(); |
2058 if (animator) | 2057 if (animator) |
2059 animator->cancelAnimations(); | 2058 animator->cancelAnimations(); |
2060 } | 2059 } |
2061 return false; | 2060 return false; |
2062 } | 2061 } |
2063 | 2062 |
2064 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) | 2063 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) |
2065 { | 2064 { |
2065 // Propagation to inner frames is handled below this function. | |
2066 ASSERT(m_frame == m_frame->localFrameRoot()); | |
2067 | |
2068 // Scrolling-related gesture events invoke EventHandler recursively for each frame down | |
2069 // the chain, doing a single-frame hit-test per frame. This matches handleWh eelEvent. | |
2070 // FIXME: Add a test that traverses this path, e.g. for devtools overlay. | |
Rick Byers
2014/08/26 21:16:41
Personally I wouldn't use a code comment for this
| |
2071 if (gestureEvent.isScrollEvent()) | |
2072 return handleGestureScrollEvent(gestureEvent); | |
2073 | |
2074 // Hit test across all frames and do touch adjustment as necessary for the e vent type. | |
2075 GestureEventWithHitTestResults targetedEvent = targetGestureEvent(gestureEve nt); | |
2076 | |
2077 return handleGestureEvent(targetedEvent); | |
2078 } | |
2079 | |
2080 bool EventHandler::handleGestureEvent(const GestureEventWithHitTestResults& targ etedEvent) | |
2081 { | |
2066 TRACE_EVENT0("input", "EventHandler::handleGestureEvent"); | 2082 TRACE_EVENT0("input", "EventHandler::handleGestureEvent"); |
2067 | 2083 |
2068 // Propagation to inner frames is handled below this function. | 2084 // Propagation to inner frames is handled below this function. |
2069 ASSERT(m_frame == m_frame->localFrameRoot()); | 2085 ASSERT(m_frame == m_frame->localFrameRoot()); |
2070 | 2086 |
2071 // Scrolling-related gesture events invoke EventHandler recursively for each frame down | 2087 // Non-scrolling related gesture events do a single cross-frame hit-test and jump |
2072 // the chain, doing a single-frame hit-test per frame. This matches handleWh eelEvent. | 2088 // directly to the inner most frame. This matches handleMousePressEvent etc. |
2073 // Perhaps we could simplify things by rewriting scroll handling to work inn er frame | 2089 ASSERT(!targetedEvent.event().isScrollEvent()); |
2074 // out, and then unify with other gesture events. | |
2075 if (gestureEvent.isScrollEvent()) | |
2076 return handleGestureScrollEvent(gestureEvent); | |
2077 | |
2078 // Non-scrolling related gesture events instead do a single cross-frame hit- test and | |
2079 // jump directly to the inner most frame. This matches handleMousePressEvent etc. | |
2080 | |
2081 // Hit test across all frames and do touch adjustment as necessary for the e vent type. | |
2082 GestureEventWithHitTestResults targetedEvent = targetGestureEvent(gestureEve nt); | |
2083 | 2090 |
2084 // Route to the correct frame. | 2091 // Route to the correct frame. |
2085 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) | 2092 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) |
2086 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t); | 2093 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t); |
2087 | 2094 |
2088 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? | 2095 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? |
2089 return handleGestureEventInFrame(targetedEvent); | 2096 return handleGestureEventInFrame(targetedEvent); |
2090 } | 2097 } |
2091 | 2098 |
2092 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent) | 2099 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2128 break; | 2135 break; |
2129 default: | 2136 default: |
2130 ASSERT_NOT_REACHED(); | 2137 ASSERT_NOT_REACHED(); |
2131 } | 2138 } |
2132 | 2139 |
2133 return false; | 2140 return false; |
2134 } | 2141 } |
2135 | 2142 |
2136 bool EventHandler::handleGestureScrollEvent(const PlatformGestureEvent& gestureE vent) | 2143 bool EventHandler::handleGestureScrollEvent(const PlatformGestureEvent& gestureE vent) |
2137 { | 2144 { |
2145 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent"); | |
2146 | |
2138 RefPtrWillBeRawPtr<Node> eventTarget = nullptr; | 2147 RefPtrWillBeRawPtr<Node> eventTarget = nullptr; |
2139 RefPtr<Scrollbar> scrollbar; | 2148 RefPtr<Scrollbar> scrollbar; |
2140 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) { | 2149 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) { |
2141 scrollbar = m_scrollbarHandlingScrollGesture.get(); | 2150 scrollbar = m_scrollbarHandlingScrollGesture.get(); |
2142 eventTarget = m_scrollGestureHandlingNode.get(); | 2151 eventTarget = m_scrollGestureHandlingNode.get(); |
2143 } | 2152 } |
2144 | 2153 |
2145 if (!eventTarget) { | 2154 if (!eventTarget) { |
2146 Document* document = m_frame->document(); | 2155 Document* document = m_frame->document(); |
2147 if (!document->renderView()) | 2156 if (!document->renderView()) |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2549 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); | 2558 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); |
2550 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; | 2559 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; |
2551 copyToVector(result.rectBasedTestResult(), nodes); | 2560 copyToVector(result.rectBasedTestResult(), nodes); |
2552 | 2561 |
2553 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. | 2562 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. |
2554 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect, WillBeHeapVector<RefPtrWillBeMember<Node> >(nodes)); | 2563 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect, WillBeHeapVector<RefPtrWillBeMember<Node> >(nodes)); |
2555 } | 2564 } |
2556 | 2565 |
2557 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) | 2566 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) |
2558 { | 2567 { |
2568 TRACE_EVENT0("input", "EventHandler::targetGestureEvent"); | |
2569 | |
2559 ASSERT(m_frame == m_frame->localFrameRoot()); | 2570 ASSERT(m_frame == m_frame->localFrameRoot()); |
2560 // Scrolling events get hit tested per frame (like wheel events do). | 2571 // Scrolling events get hit tested per frame (like wheel events do). |
2561 ASSERT(!gestureEvent.isScrollEvent()); | 2572 ASSERT(!gestureEvent.isScrollEvent()); |
2562 | 2573 |
2563 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); | 2574 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); |
2564 double activeInterval = 0; | 2575 double activeInterval = 0; |
2565 bool shouldKeepActiveForMinInterval = false; | 2576 bool shouldKeepActiveForMinInterval = false; |
2566 if (readOnly) { | 2577 if (readOnly) { |
2567 hitType |= HitTestRequest::ReadOnly; | 2578 hitType |= HitTestRequest::ReadOnly; |
2568 } else if (gestureEvent.type() == PlatformEvent::GestureTap) { | 2579 } else if (gestureEvent.type() == PlatformEvent::GestureTap) { |
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3881 unsigned EventHandler::accessKeyModifiers() | 3892 unsigned EventHandler::accessKeyModifiers() |
3882 { | 3893 { |
3883 #if OS(MACOSX) | 3894 #if OS(MACOSX) |
3884 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; | 3895 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; |
3885 #else | 3896 #else |
3886 return PlatformEvent::AltKey; | 3897 return PlatformEvent::AltKey; |
3887 #endif | 3898 #endif |
3888 } | 3899 } |
3889 | 3900 |
3890 } // namespace blink | 3901 } // namespace blink |
OLD | NEW |