OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/input/GestureManager.h" | 5 #include "core/input/GestureManager.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/DocumentUserGestureToken.h" |
8 #include "core/editing/SelectionController.h" | 9 #include "core/editing/SelectionController.h" |
9 #include "core/events/GestureEvent.h" | 10 #include "core/events/GestureEvent.h" |
10 #include "core/frame/FrameHost.h" | 11 #include "core/frame/FrameHost.h" |
11 #include "core/frame/FrameView.h" | 12 #include "core/frame/FrameView.h" |
12 #include "core/frame/Settings.h" | 13 #include "core/frame/Settings.h" |
13 #include "core/frame/VisualViewport.h" | 14 #include "core/frame/VisualViewport.h" |
14 #include "core/input/EventHandler.h" | 15 #include "core/input/EventHandler.h" |
15 #include "core/input/EventHandlingUtil.h" | 16 #include "core/input/EventHandlingUtil.h" |
16 #include "core/page/ChromeClient.h" | 17 #include "core/page/ChromeClient.h" |
17 #include "core/page/Page.h" | 18 #include "core/page/Page.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 133 |
133 WebInputEventResult GestureManager::handleGestureTap( | 134 WebInputEventResult GestureManager::handleGestureTap( |
134 const GestureEventWithHitTestResults& targetedEvent) { | 135 const GestureEventWithHitTestResults& targetedEvent) { |
135 FrameView* frameView(m_frame->view()); | 136 FrameView* frameView(m_frame->view()); |
136 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); | 137 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); |
137 HitTestRequest::HitTestRequestType hitType = | 138 HitTestRequest::HitTestRequestType hitType = |
138 getHitTypeForGestureType(gestureEvent.type()); | 139 getHitTypeForGestureType(gestureEvent.type()); |
139 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); | 140 uint64_t preDispatchDomTreeVersion = m_frame->document()->domTreeVersion(); |
140 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); | 141 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); |
141 | 142 |
142 UserGestureIndicator gestureIndicator(UserGestureToken::create()); | |
143 | |
144 HitTestResult currentHitTest = targetedEvent.hitTestResult(); | 143 HitTestResult currentHitTest = targetedEvent.hitTestResult(); |
145 | 144 |
146 // We use the adjusted position so the application isn't surprised to see a | 145 // We use the adjusted position so the application isn't surprised to see a |
147 // event with co-ordinates outside the target's bounds. | 146 // event with co-ordinates outside the target's bounds. |
148 IntPoint adjustedPoint = | 147 IntPoint adjustedPoint = |
149 frameView->rootFrameToContents(gestureEvent.position()); | 148 frameView->rootFrameToContents(gestureEvent.position()); |
150 | 149 |
151 const unsigned modifiers = gestureEvent.getModifiers(); | 150 const unsigned modifiers = gestureEvent.getModifiers(); |
152 | 151 |
153 if (!m_suppressMouseEventsFromGestures) { | 152 if (!m_suppressMouseEventsFromGestures) { |
(...skipping 22 matching lines...) Expand all Loading... |
176 mainFrame->view()->updateLifecycleToCompositingCleanPlusScrolling(); | 175 mainFrame->view()->updateLifecycleToCompositingCleanPlusScrolling(); |
177 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); | 176 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); |
178 currentHitTest = EventHandlingUtil::hitTestResultInFrame( | 177 currentHitTest = EventHandlingUtil::hitTestResultInFrame( |
179 m_frame, adjustedPoint, hitType); | 178 m_frame, adjustedPoint, hitType); |
180 } | 179 } |
181 | 180 |
182 // Capture data for showUnhandledTapUIIfNeeded. | 181 // Capture data for showUnhandledTapUIIfNeeded. |
183 Node* tappedNode = currentHitTest.innerNode(); | 182 Node* tappedNode = currentHitTest.innerNode(); |
184 IntPoint tappedPosition = gestureEvent.position(); | 183 IntPoint tappedPosition = gestureEvent.position(); |
185 Node* tappedNonTextNode = tappedNode; | 184 Node* tappedNonTextNode = tappedNode; |
| 185 UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create( |
| 186 tappedNode ? &tappedNode->document() : nullptr)); |
186 | 187 |
187 if (tappedNonTextNode && tappedNonTextNode->isTextNode()) | 188 if (tappedNonTextNode && tappedNonTextNode->isTextNode()) |
188 tappedNonTextNode = FlatTreeTraversal::parent(*tappedNonTextNode); | 189 tappedNonTextNode = FlatTreeTraversal::parent(*tappedNonTextNode); |
189 | 190 |
190 m_mouseEventManager->setClickNode(tappedNonTextNode); | 191 m_mouseEventManager->setClickNode(tappedNonTextNode); |
191 | 192 |
192 PlatformMouseEvent fakeMouseDown( | 193 PlatformMouseEvent fakeMouseDown( |
193 gestureEvent.position(), gestureEvent.globalPosition(), | 194 gestureEvent.position(), gestureEvent.globalPosition(), |
194 WebPointerProperties::Button::Left, PlatformEvent::MousePressed, | 195 WebPointerProperties::Button::Left, PlatformEvent::MousePressed, |
195 gestureEvent.tapCount(), static_cast<PlatformEvent::Modifiers>( | 196 gestureEvent.tapCount(), static_cast<PlatformEvent::Modifiers>( |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 return nullptr; | 419 return nullptr; |
419 | 420 |
420 return &m_frame->page()->frameHost(); | 421 return &m_frame->page()->frameHost(); |
421 } | 422 } |
422 | 423 |
423 double GestureManager::getLastShowPressTimestamp() const { | 424 double GestureManager::getLastShowPressTimestamp() const { |
424 return m_lastShowPressTimestamp; | 425 return m_lastShowPressTimestamp; |
425 } | 426 } |
426 | 427 |
427 } // namespace blink | 428 } // namespace blink |
OLD | NEW |