| 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/editing/SelectionController.h" | 8 #include "core/editing/SelectionController.h" |
| 9 #include "core/events/GestureEvent.h" | 9 #include "core/events/GestureEvent.h" |
| 10 #include "core/frame/FrameHost.h" | 10 #include "core/frame/FrameHost.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut
tonDown), | 180 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut
tonDown), |
| 181 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope
rties::PointerType::Mouse); | 181 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope
rties::PointerType::Mouse); |
| 182 | 182 |
| 183 // TODO(mustaq): We suppress MEs plus all it's side effects. What would that | 183 // TODO(mustaq): We suppress MEs plus all it's side effects. What would that |
| 184 // mean for for TEs? What's the right balance here? crbug.com/617255 | 184 // mean for for TEs? What's the right balance here? crbug.com/617255 |
| 185 WebInputEventResult mouseDownEventResult = WebInputEventResult::HandledSuppr
essed; | 185 WebInputEventResult mouseDownEventResult = WebInputEventResult::HandledSuppr
essed; |
| 186 if (!m_suppressMouseEventsFromGestures) { | 186 if (!m_suppressMouseEventsFromGestures) { |
| 187 mouseDownEventResult = m_frame->eventHandler().dispatchMouseEvent(EventT
ypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMo
useDown); | 187 mouseDownEventResult = m_frame->eventHandler().dispatchMouseEvent(EventT
ypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMo
useDown); |
| 188 m_selectionController->initializeSelectionState(); | 188 m_selectionController->initializeSelectionState(); |
| 189 if (mouseDownEventResult == WebInputEventResult::NotHandled) | 189 if (mouseDownEventResult == WebInputEventResult::NotHandled) |
| 190 mouseDownEventResult = m_frame->eventHandler().handleMouseFocus(Mous
eEventWithHitTestResults(fakeMouseDown, currentHitTest), InputDeviceCapabilities
::firesTouchEventsSourceCapabilities()); | 190 mouseDownEventResult = m_frame->eventHandler().handleMouseFocus(curr
entHitTest, InputDeviceCapabilities::firesTouchEventsSourceCapabilities()); |
| 191 if (mouseDownEventResult == WebInputEventResult::NotHandled) | 191 if (mouseDownEventResult == WebInputEventResult::NotHandled) |
| 192 mouseDownEventResult = m_frame->eventHandler().handleMousePressEvent
(MouseEventWithHitTestResults(fakeMouseDown, currentHitTest)); | 192 mouseDownEventResult = m_frame->eventHandler().handleMousePressEvent
(MouseEventWithHitTestResults(fakeMouseDown, currentHitTest)); |
| 193 } | 193 } |
| 194 | 194 |
| 195 if (currentHitTest.innerNode()) { | 195 if (currentHitTest.innerNode()) { |
| 196 DCHECK(gestureEvent.type() == PlatformEvent::GestureTap); | 196 DCHECK(gestureEvent.type() == PlatformEvent::GestureTap); |
| 197 HitTestResult result = currentHitTest; | 197 HitTestResult result = currentHitTest; |
| 198 result.setToShadowHostIfInUserAgentShadowRoot(); | 198 result.setToShadowHostIfInUserAgentShadowRoot(); |
| 199 m_frame->chromeClient().onMouseDown(result.innerNode()); | 199 m_frame->chromeClient().onMouseDown(result.innerNode()); |
| 200 } | 200 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 unsigned modifiers = gestureEvent.getModifiers(); | 291 unsigned modifiers = gestureEvent.getModifiers(); |
| 292 | 292 |
| 293 if (!m_suppressMouseEventsFromGestures) { | 293 if (!m_suppressMouseEventsFromGestures) { |
| 294 // Send MouseMoved event prior to handling (https://crbug.com/485290). | 294 // Send MouseMoved event prior to handling (https://crbug.com/485290). |
| 295 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.g
lobalPosition(), | 295 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.g
lobalPosition(), |
| 296 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, | 296 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, |
| 297 static_cast<PlatformEvent::Modifiers>(modifiers), | 297 static_cast<PlatformEvent::Modifiers>(modifiers), |
| 298 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerP
roperties::PointerType::Mouse); | 298 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerP
roperties::PointerType::Mouse); |
| 299 m_frame->eventHandler().dispatchMouseEvent( | 299 m_frame->eventHandler().dispatchMouseEvent( |
| 300 EventTypeNames::mousemove, targetedEvent.hitTestResult().innerNode()
, 0, fakeMouseMove); | 300 EventTypeNames::mousemove, targetedEvent.hitTestResult().innerNode()
, 0, fakeMouseMove); |
| 301 |
| 302 if (m_frame->view()) { |
| 303 HitTestRequest request(HitTestRequest::Active); |
| 304 LayoutPoint documentPoint = m_frame->view()->rootFrameToContents(tar
getedEvent.event().position()); |
| 305 HitTestResult hitTestResult(request, documentPoint); |
| 306 m_frame->eventHandler().handleMouseFocus(hitTestResult, InputDeviceC
apabilities::firesTouchEventsSourceCapabilities()); |
| 307 } |
| 301 } | 308 } |
| 302 | 309 |
| 303 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; | 310 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; |
| 304 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) | 311 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) |
| 305 eventType = PlatformEvent::MouseReleased; | 312 eventType = PlatformEvent::MouseReleased; |
| 306 | 313 |
| 307 // To simulate right-click behavior, we send a right mouse down and then con
text menu event. | 314 PlatformMouseEvent mouseEvent(targetedEvent.event().position(), targetedEven
t.event().globalPosition(), NoButton, |
| 308 // TODO(crbug.com/579564): Maybe we should not send mouse down at all | 315 eventType, /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(mod
ifiers), PlatformMouseEvent::FromTouch, |
| 309 PlatformMouseEvent mouseEvent(targetedEvent.event().position(), targetedEven
t.event().globalPosition(), RightButton, eventType, 1, | 316 WTF::monotonicallyIncreasingTime(), WebPointerProperties::PointerType::M
ouse); |
| 310 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::RightBu
ttonDown), | |
| 311 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), WebPo
interProperties::PointerType::Mouse); | |
| 312 if (!m_suppressMouseEventsFromGestures) { | |
| 313 // FIXME: Send HitTestResults to avoid redundant hit tests. | |
| 314 m_frame->eventHandler().handleMousePressEvent(mouseEvent); | |
| 315 } | |
| 316 | 317 |
| 317 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); | 318 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); |
| 318 // We do not need to send a corresponding mouse release because in case of | |
| 319 // right-click, the context menu takes capture and consumes all events. | |
| 320 } | 319 } |
| 321 | 320 |
| 322 WebInputEventResult GestureManager::handleGestureShowPress() | 321 WebInputEventResult GestureManager::handleGestureShowPress() |
| 323 { | 322 { |
| 324 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); | 323 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); |
| 325 | 324 |
| 326 FrameView* view = m_frame->view(); | 325 FrameView* view = m_frame->view(); |
| 327 if (!view) | 326 if (!view) |
| 328 return WebInputEventResult::NotHandled; | 327 return WebInputEventResult::NotHandled; |
| 329 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) | 328 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 346 | 345 |
| 347 return &m_frame->page()->frameHost(); | 346 return &m_frame->page()->frameHost(); |
| 348 } | 347 } |
| 349 | 348 |
| 350 double GestureManager::getLastShowPressTimestamp() const | 349 double GestureManager::getLastShowPressTimestamp() const |
| 351 { | 350 { |
| 352 return m_lastShowPressTimestamp; | 351 return m_lastShowPressTimestamp; |
| 353 } | 352 } |
| 354 | 353 |
| 355 } // namespace blink | 354 } // namespace blink |
| OLD | NEW |