Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 490783003: Reduce hit test on ShowPress by moving event targeting to WebViewImpl (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Switch back to using platform event position for content intents Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | Source/web/WebViewImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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"
74 #include "core/page/FocusController.h" 73 #include "core/page/FocusController.h"
75 #include "core/page/FrameTree.h" 74 #include "core/page/FrameTree.h"
76 #include "core/page/Page.h" 75 #include "core/page/Page.h"
77 #include "core/page/SpatialNavigation.h" 76 #include "core/page/SpatialNavigation.h"
78 #include "core/page/TouchAdjustment.h" 77 #include "core/page/TouchAdjustment.h"
79 #include "core/rendering/HitTestRequest.h" 78 #include "core/rendering/HitTestRequest.h"
80 #include "core/rendering/HitTestResult.h" 79 #include "core/rendering/HitTestResult.h"
81 #include "core/rendering/RenderFlowThread.h" 80 #include "core/rendering/RenderFlowThread.h"
82 #include "core/rendering/RenderLayer.h" 81 #include "core/rendering/RenderLayer.h"
83 #include "core/rendering/RenderTextControlSingleLine.h" 82 #include "core/rendering/RenderTextControlSingleLine.h"
(...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 ScrollableArea* sa = *it; 2054 ScrollableArea* sa = *it;
2056 ScrollAnimator* animator = sa->existingScrollAnimator(); 2055 ScrollAnimator* animator = sa->existingScrollAnimator();
2057 if (animator) 2056 if (animator)
2058 animator->cancelAnimations(); 2057 animator->cancelAnimations();
2059 } 2058 }
2060 return false; 2059 return false;
2061 } 2060 }
2062 2061
2063 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) 2062 bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
2064 { 2063 {
2064 // Propagation to inner frames is handled below this function.
2065 ASSERT(m_frame == m_frame->localFrameRoot());
2066
2067 // Scrolling-related gesture events invoke EventHandler recursively for each frame down
2068 // the chain, doing a single-frame hit-test per frame. This matches handleWh eelEvent.
2069 // FIXME: Add a test that traverses this path, e.g. for devtools overlay.
2070 if (gestureEvent.isScrollEvent())
2071 return handleGestureScrollEvent(gestureEvent);
2072
2073 // Hit test across all frames and do touch adjustment as necessary for the e vent type.
2074 GestureEventWithHitTestResults targetedEvent = targetGestureEvent(gestureEve nt);
2075
2076 return handleGestureEvent(targetedEvent);
2077 }
2078
2079 bool EventHandler::handleGestureEvent(const GestureEventWithHitTestResults& targ etedEvent)
2080 {
2065 TRACE_EVENT0("input", "EventHandler::handleGestureEvent"); 2081 TRACE_EVENT0("input", "EventHandler::handleGestureEvent");
2066 2082
2067 // Propagation to inner frames is handled below this function. 2083 // Propagation to inner frames is handled below this function.
2068 ASSERT(m_frame == m_frame->localFrameRoot()); 2084 ASSERT(m_frame == m_frame->localFrameRoot());
2069 2085
2070 // Scrolling-related gesture events invoke EventHandler recursively for each frame down 2086 // Non-scrolling related gesture events do a single cross-frame hit-test and jump
2071 // the chain, doing a single-frame hit-test per frame. This matches handleWh eelEvent. 2087 // directly to the inner most frame. This matches handleMousePressEvent etc.
2072 // Perhaps we could simplify things by rewriting scroll handling to work inn er frame 2088 ASSERT(!targetedEvent.event().isScrollEvent());
2073 // out, and then unify with other gesture events.
2074 if (gestureEvent.isScrollEvent())
2075 return handleGestureScrollEvent(gestureEvent);
2076
2077 // Non-scrolling related gesture events instead do a single cross-frame hit- test and
2078 // jump directly to the inner most frame. This matches handleMousePressEvent etc.
2079
2080 // Hit test across all frames and do touch adjustment as necessary for the e vent type.
2081 GestureEventWithHitTestResults targetedEvent = targetGestureEvent(gestureEve nt);
2082 2089
2083 // Route to the correct frame. 2090 // Route to the correct frame.
2084 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame()) 2091 if (LocalFrame* innerFrame = targetedEvent.hitTestResult().innerNodeFrame())
2085 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t); 2092 return innerFrame->eventHandler().handleGestureEventInFrame(targetedEven t);
2086 2093
2087 // No hit test result, handle in root instance. Perhaps we should just retur n false instead? 2094 // No hit test result, handle in root instance. Perhaps we should just retur n false instead?
2088 return handleGestureEventInFrame(targetedEvent); 2095 return handleGestureEventInFrame(targetedEvent);
2089 } 2096 }
2090 2097
2091 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent) 2098 bool EventHandler::handleGestureEventInFrame(const GestureEventWithHitTestResult s& targetedEvent)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 break; 2134 break;
2128 default: 2135 default:
2129 ASSERT_NOT_REACHED(); 2136 ASSERT_NOT_REACHED();
2130 } 2137 }
2131 2138
2132 return false; 2139 return false;
2133 } 2140 }
2134 2141
2135 bool EventHandler::handleGestureScrollEvent(const PlatformGestureEvent& gestureE vent) 2142 bool EventHandler::handleGestureScrollEvent(const PlatformGestureEvent& gestureE vent)
2136 { 2143 {
2144 TRACE_EVENT0("input", "EventHandler::handleGestureScrollEvent");
2145
2137 RefPtrWillBeRawPtr<Node> eventTarget = nullptr; 2146 RefPtrWillBeRawPtr<Node> eventTarget = nullptr;
2138 RefPtr<Scrollbar> scrollbar; 2147 RefPtr<Scrollbar> scrollbar;
2139 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) { 2148 if (gestureEvent.type() != PlatformEvent::GestureScrollBegin) {
2140 scrollbar = m_scrollbarHandlingScrollGesture.get(); 2149 scrollbar = m_scrollbarHandlingScrollGesture.get();
2141 eventTarget = m_scrollGestureHandlingNode.get(); 2150 eventTarget = m_scrollGestureHandlingNode.get();
2142 } 2151 }
2143 2152
2144 if (!eventTarget) { 2153 if (!eventTarget) {
2145 Document* document = m_frame->document(); 2154 Document* document = m_frame->document();
2146 if (!document->renderView()) 2155 if (!document->renderView())
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
2547 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius); 2556 IntRect touchRect(touchCenter - touchRadius, touchRadius + touchRadius);
2548 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes; 2557 WillBeHeapVector<RefPtrWillBeMember<Node>, 11> nodes;
2549 copyToVector(result.rectBasedTestResult(), nodes); 2558 copyToVector(result.rectBasedTestResult(), nodes);
2550 2559
2551 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful. 2560 // FIXME: the explicit Vector conversion copies into a temporary and is wast eful.
2552 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect, WillBeHeapVector<RefPtrWillBeMember<Node> >(nodes)); 2561 return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect, WillBeHeapVector<RefPtrWillBeMember<Node> >(nodes));
2553 } 2562 }
2554 2563
2555 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly) 2564 GestureEventWithHitTestResults EventHandler::targetGestureEvent(const PlatformGe stureEvent& gestureEvent, bool readOnly)
2556 { 2565 {
2566 TRACE_EVENT0("input", "EventHandler::targetGestureEvent");
2567
2557 ASSERT(m_frame == m_frame->localFrameRoot()); 2568 ASSERT(m_frame == m_frame->localFrameRoot());
2558 // Scrolling events get hit tested per frame (like wheel events do). 2569 // Scrolling events get hit tested per frame (like wheel events do).
2559 ASSERT(!gestureEvent.isScrollEvent()); 2570 ASSERT(!gestureEvent.isScrollEvent());
2560 2571
2561 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type()); 2572 HitTestRequest::HitTestRequestType hitType = getHitTypeForGestureType(gestur eEvent.type());
2562 double activeInterval = 0; 2573 double activeInterval = 0;
2563 bool shouldKeepActiveForMinInterval = false; 2574 bool shouldKeepActiveForMinInterval = false;
2564 if (readOnly) { 2575 if (readOnly) {
2565 hitType |= HitTestRequest::ReadOnly; 2576 hitType |= HitTestRequest::ReadOnly;
2566 } else if (gestureEvent.type() == PlatformEvent::GestureTap) { 2577 } else if (gestureEvent.type() == PlatformEvent::GestureTap) {
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
3869 unsigned EventHandler::accessKeyModifiers() 3880 unsigned EventHandler::accessKeyModifiers()
3870 { 3881 {
3871 #if OS(MACOSX) 3882 #if OS(MACOSX)
3872 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3883 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3873 #else 3884 #else
3874 return PlatformEvent::AltKey; 3885 return PlatformEvent::AltKey;
3875 #endif 3886 #endif
3876 } 3887 }
3877 3888
3878 } // namespace blink 3889 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | Source/web/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698