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