| 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/dom/DocumentUserGestureToken.h" |
| 9 #include "core/editing/SelectionController.h" | 9 #include "core/editing/SelectionController.h" |
| 10 #include "core/events/GestureEvent.h" | 10 #include "core/events/GestureEvent.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 IntPoint adjustedPoint = frameView->rootFrameToContents( | 148 IntPoint adjustedPoint = frameView->rootFrameToContents( |
| 149 flooredIntPoint(gestureEvent.positionInRootFrame())); | 149 flooredIntPoint(gestureEvent.positionInRootFrame())); |
| 150 | 150 |
| 151 const unsigned modifiers = gestureEvent.modifiers(); | 151 const unsigned modifiers = gestureEvent.modifiers(); |
| 152 | 152 |
| 153 if (!m_suppressMouseEventsFromGestures) { | 153 if (!m_suppressMouseEventsFromGestures) { |
| 154 WebMouseEvent fakeMouseMove( | 154 WebMouseEvent fakeMouseMove( |
| 155 WebInputEvent::MouseMove, gestureEvent, | 155 WebInputEvent::MouseMove, gestureEvent, |
| 156 WebPointerProperties::Button::NoButton, | 156 WebPointerProperties::Button::NoButton, |
| 157 /* clickCount */ 0, | 157 /* clickCount */ 0, |
| 158 static_cast<PlatformEvent::Modifiers>( | 158 static_cast<WebInputEvent::Modifiers>( |
| 159 modifiers | WebInputEvent::Modifiers::IsCompatibilityEventForTouch), | 159 modifiers | WebInputEvent::Modifiers::IsCompatibilityEventForTouch), |
| 160 gestureEvent.timeStampSeconds()); | 160 gestureEvent.timeStampSeconds()); |
| 161 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( | 161 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( |
| 162 currentHitTest.innerNode(), currentHitTest.canvasRegionId(), | 162 currentHitTest.innerNode(), currentHitTest.canvasRegionId(), |
| 163 EventTypeNames::mousemove, fakeMouseMove); | 163 EventTypeNames::mousemove, fakeMouseMove); |
| 164 } | 164 } |
| 165 | 165 |
| 166 // Do a new hit-test in case the mousemove event changed the DOM. | 166 // Do a new hit-test in case the mousemove event changed the DOM. |
| 167 // Note that if the original hit test wasn't over an element (eg. was over a | 167 // Note that if the original hit test wasn't over an element (eg. was over a |
| 168 // scrollbar) we don't want to re-hit-test because it may be in the wrong | 168 // scrollbar) we don't want to re-hit-test because it may be in the wrong |
| (...skipping 21 matching lines...) Expand all Loading... |
| 190 tappedNode ? &tappedNode->document() : nullptr)); | 190 tappedNode ? &tappedNode->document() : nullptr)); |
| 191 | 191 |
| 192 if (tappedNonTextNode && tappedNonTextNode->isTextNode()) | 192 if (tappedNonTextNode && tappedNonTextNode->isTextNode()) |
| 193 tappedNonTextNode = FlatTreeTraversal::parent(*tappedNonTextNode); | 193 tappedNonTextNode = FlatTreeTraversal::parent(*tappedNonTextNode); |
| 194 | 194 |
| 195 m_mouseEventManager->setClickNode(tappedNonTextNode); | 195 m_mouseEventManager->setClickNode(tappedNonTextNode); |
| 196 | 196 |
| 197 WebMouseEvent fakeMouseDown( | 197 WebMouseEvent fakeMouseDown( |
| 198 WebInputEvent::MouseDown, gestureEvent, | 198 WebInputEvent::MouseDown, gestureEvent, |
| 199 WebPointerProperties::Button::Left, gestureEvent.tapCount(), | 199 WebPointerProperties::Button::Left, gestureEvent.tapCount(), |
| 200 static_cast<PlatformEvent::Modifiers>( | 200 static_cast<WebInputEvent::Modifiers>( |
| 201 modifiers | WebInputEvent::Modifiers::LeftButtonDown | | 201 modifiers | WebInputEvent::Modifiers::LeftButtonDown | |
| 202 WebInputEvent::Modifiers::IsCompatibilityEventForTouch), | 202 WebInputEvent::Modifiers::IsCompatibilityEventForTouch), |
| 203 gestureEvent.timeStampSeconds()); | 203 gestureEvent.timeStampSeconds()); |
| 204 | 204 |
| 205 // TODO(mustaq): We suppress MEs plus all it's side effects. What would that | 205 // TODO(mustaq): We suppress MEs plus all it's side effects. What would that |
| 206 // mean for for TEs? What's the right balance here? crbug.com/617255 | 206 // mean for for TEs? What's the right balance here? crbug.com/617255 |
| 207 WebInputEventResult mouseDownEventResult = | 207 WebInputEventResult mouseDownEventResult = |
| 208 WebInputEventResult::HandledSuppressed; | 208 WebInputEventResult::HandledSuppressed; |
| 209 if (!m_suppressMouseEventsFromGestures) { | 209 if (!m_suppressMouseEventsFromGestures) { |
| 210 m_mouseEventManager->setClickCount(gestureEvent.tapCount()); | 210 m_mouseEventManager->setClickCount(gestureEvent.tapCount()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 241 if (mainFrame && mainFrame->view()) | 241 if (mainFrame && mainFrame->view()) |
| 242 mainFrame->view()->updateAllLifecyclePhases(); | 242 mainFrame->view()->updateAllLifecyclePhases(); |
| 243 adjustedPoint = frameView->rootFrameToContents(tappedPosition); | 243 adjustedPoint = frameView->rootFrameToContents(tappedPosition); |
| 244 currentHitTest = EventHandlingUtil::hitTestResultInFrame( | 244 currentHitTest = EventHandlingUtil::hitTestResultInFrame( |
| 245 m_frame, adjustedPoint, hitType); | 245 m_frame, adjustedPoint, hitType); |
| 246 } | 246 } |
| 247 | 247 |
| 248 WebMouseEvent fakeMouseUp( | 248 WebMouseEvent fakeMouseUp( |
| 249 WebInputEvent::MouseUp, gestureEvent, WebPointerProperties::Button::Left, | 249 WebInputEvent::MouseUp, gestureEvent, WebPointerProperties::Button::Left, |
| 250 gestureEvent.tapCount(), | 250 gestureEvent.tapCount(), |
| 251 static_cast<PlatformEvent::Modifiers>( | 251 static_cast<WebInputEvent::Modifiers>( |
| 252 modifiers | WebInputEvent::Modifiers::IsCompatibilityEventForTouch), | 252 modifiers | WebInputEvent::Modifiers::IsCompatibilityEventForTouch), |
| 253 gestureEvent.timeStampSeconds()); | 253 gestureEvent.timeStampSeconds()); |
| 254 WebInputEventResult mouseUpEventResult = | 254 WebInputEventResult mouseUpEventResult = |
| 255 m_suppressMouseEventsFromGestures | 255 m_suppressMouseEventsFromGestures |
| 256 ? WebInputEventResult::HandledSuppressed | 256 ? WebInputEventResult::HandledSuppressed |
| 257 : m_mouseEventManager->setMousePositionAndDispatchMouseEvent( | 257 : m_mouseEventManager->setMousePositionAndDispatchMouseEvent( |
| 258 currentHitTest.innerNode(), currentHitTest.canvasRegionId(), | 258 currentHitTest.innerNode(), currentHitTest.canvasRegionId(), |
| 259 EventTypeNames::mouseup, fakeMouseUp); | 259 EventTypeNames::mouseup, fakeMouseUp); |
| 260 | 260 |
| 261 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; | 261 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 const GestureEventWithHitTestResults& targetedEvent) { | 363 const GestureEventWithHitTestResults& targetedEvent) { |
| 364 const WebGestureEvent& gestureEvent = targetedEvent.event(); | 364 const WebGestureEvent& gestureEvent = targetedEvent.event(); |
| 365 unsigned modifiers = gestureEvent.modifiers(); | 365 unsigned modifiers = gestureEvent.modifiers(); |
| 366 | 366 |
| 367 if (!m_suppressMouseEventsFromGestures) { | 367 if (!m_suppressMouseEventsFromGestures) { |
| 368 // Send MouseMove event prior to handling (https://crbug.com/485290). | 368 // Send MouseMove event prior to handling (https://crbug.com/485290). |
| 369 WebMouseEvent fakeMouseMove( | 369 WebMouseEvent fakeMouseMove( |
| 370 WebInputEvent::MouseMove, gestureEvent, | 370 WebInputEvent::MouseMove, gestureEvent, |
| 371 WebPointerProperties::Button::NoButton, | 371 WebPointerProperties::Button::NoButton, |
| 372 /* clickCount */ 0, | 372 /* clickCount */ 0, |
| 373 static_cast<PlatformEvent::Modifiers>( | 373 static_cast<WebInputEvent::Modifiers>( |
| 374 modifiers | WebInputEvent::IsCompatibilityEventForTouch), | 374 modifiers | WebInputEvent::IsCompatibilityEventForTouch), |
| 375 gestureEvent.timeStampSeconds()); | 375 gestureEvent.timeStampSeconds()); |
| 376 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( | 376 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( |
| 377 targetedEvent.hitTestResult().innerNode(), | 377 targetedEvent.hitTestResult().innerNode(), |
| 378 targetedEvent.canvasRegionId(), EventTypeNames::mousemove, | 378 targetedEvent.canvasRegionId(), EventTypeNames::mousemove, |
| 379 fakeMouseMove); | 379 fakeMouseMove); |
| 380 } | 380 } |
| 381 | 381 |
| 382 WebInputEvent::Type eventType = WebInputEvent::MouseDown; | 382 WebInputEvent::Type eventType = WebInputEvent::MouseDown; |
| 383 if (m_frame->settings() && m_frame->settings()->getShowContextMenuOnMouseUp()) | 383 if (m_frame->settings() && m_frame->settings()->getShowContextMenuOnMouseUp()) |
| 384 eventType = WebInputEvent::MouseUp; | 384 eventType = WebInputEvent::MouseUp; |
| 385 | 385 |
| 386 WebMouseEvent mouseEvent( | 386 WebMouseEvent mouseEvent( |
| 387 eventType, gestureEvent, WebPointerProperties::Button::Right, | 387 eventType, gestureEvent, WebPointerProperties::Button::Right, |
| 388 /* clickCount */ 1, | 388 /* clickCount */ 1, |
| 389 static_cast<PlatformEvent::Modifiers>( | 389 static_cast<WebInputEvent::Modifiers>( |
| 390 modifiers | PlatformEvent::Modifiers::RightButtonDown | | 390 modifiers | WebInputEvent::Modifiers::RightButtonDown | |
| 391 WebInputEvent::IsCompatibilityEventForTouch), | 391 WebInputEvent::IsCompatibilityEventForTouch), |
| 392 gestureEvent.timeStampSeconds()); | 392 gestureEvent.timeStampSeconds()); |
| 393 | 393 |
| 394 if (!m_suppressMouseEventsFromGestures && m_frame->view()) { | 394 if (!m_suppressMouseEventsFromGestures && m_frame->view()) { |
| 395 HitTestRequest request(HitTestRequest::Active); | 395 HitTestRequest request(HitTestRequest::Active); |
| 396 LayoutPoint documentPoint = m_frame->view()->rootFrameToContents( | 396 LayoutPoint documentPoint = m_frame->view()->rootFrameToContents( |
| 397 flooredIntPoint(targetedEvent.event().positionInRootFrame())); | 397 flooredIntPoint(targetedEvent.event().positionInRootFrame())); |
| 398 MouseEventWithHitTestResults mev = | 398 MouseEventWithHitTestResults mev = |
| 399 m_frame->document()->performMouseEventHitTest(request, documentPoint, | 399 m_frame->document()->performMouseEventHitTest(request, documentPoint, |
| 400 mouseEvent); | 400 mouseEvent); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 432 |
| 433 return &m_frame->page()->frameHost(); | 433 return &m_frame->page()->frameHost(); |
| 434 } | 434 } |
| 435 | 435 |
| 436 WTF::Optional<WTF::TimeTicks> GestureManager::getLastShowPressTimestamp() | 436 WTF::Optional<WTF::TimeTicks> GestureManager::getLastShowPressTimestamp() |
| 437 const { | 437 const { |
| 438 return m_lastShowPressTimestamp; | 438 return m_lastShowPressTimestamp; |
| 439 } | 439 } |
| 440 | 440 |
| 441 } // namespace blink | 441 } // namespace blink |
| OLD | NEW |