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" |
11 #include "core/frame/FrameHost.h" | 11 #include "core/frame/FrameHost.h" |
12 #include "core/frame/FrameView.h" | 12 #include "core/frame/FrameView.h" |
13 #include "core/frame/Settings.h" | 13 #include "core/frame/Settings.h" |
14 #include "core/frame/VisualViewport.h" | 14 #include "core/frame/VisualViewport.h" |
15 #include "core/input/EventHandler.h" | 15 #include "core/input/EventHandler.h" |
16 #include "core/input/EventHandlingUtil.h" | 16 #include "core/input/EventHandlingUtil.h" |
| 17 #include "core/input/InputDeviceCapabilities.h" |
17 #include "core/page/ChromeClient.h" | 18 #include "core/page/ChromeClient.h" |
18 #include "core/page/Page.h" | 19 #include "core/page/Page.h" |
19 | 20 |
20 namespace blink { | 21 namespace blink { |
21 | 22 |
22 GestureManager::GestureManager(LocalFrame& frame, | 23 GestureManager::GestureManager(LocalFrame& frame, |
23 ScrollManager& scrollManager, | 24 ScrollManager& scrollManager, |
24 MouseEventManager& mouseEventManager, | 25 MouseEventManager& mouseEventManager, |
25 PointerEventManager& pointerEventManager, | 26 PointerEventManager& pointerEventManager, |
26 SelectionController& selectionController) | 27 SelectionController& selectionController) |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 WebInputEventResult mouseDownEventResult = | 207 WebInputEventResult mouseDownEventResult = |
207 WebInputEventResult::HandledSuppressed; | 208 WebInputEventResult::HandledSuppressed; |
208 if (!m_suppressMouseEventsFromGestures) { | 209 if (!m_suppressMouseEventsFromGestures) { |
209 m_mouseEventManager->setClickCount(gestureEvent.tapCount()); | 210 m_mouseEventManager->setClickCount(gestureEvent.tapCount()); |
210 | 211 |
211 mouseDownEventResult = | 212 mouseDownEventResult = |
212 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( | 213 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( |
213 currentHitTest.innerNode(), currentHitTest.canvasRegionId(), | 214 currentHitTest.innerNode(), currentHitTest.canvasRegionId(), |
214 EventTypeNames::mousedown, fakeMouseDown); | 215 EventTypeNames::mousedown, fakeMouseDown); |
215 m_selectionController->initializeSelectionState(); | 216 m_selectionController->initializeSelectionState(); |
216 if (mouseDownEventResult == WebInputEventResult::NotHandled) | 217 if (mouseDownEventResult == WebInputEventResult::NotHandled) { |
217 mouseDownEventResult = m_mouseEventManager->handleMouseFocus( | 218 mouseDownEventResult = m_mouseEventManager->handleMouseFocus( |
218 currentHitTest, | 219 currentHitTest, m_frame->document() |
219 InputDeviceCapabilities::firesTouchEventsSourceCapabilities()); | 220 ->domWindow() |
220 if (mouseDownEventResult == WebInputEventResult::NotHandled) | 221 ->getInputDeviceCapabilities() |
| 222 ->firesTouchEvents(true)); |
| 223 } |
| 224 if (mouseDownEventResult == WebInputEventResult::NotHandled) { |
221 mouseDownEventResult = m_mouseEventManager->handleMousePressEvent( | 225 mouseDownEventResult = m_mouseEventManager->handleMousePressEvent( |
222 MouseEventWithHitTestResults(fakeMouseDown, currentHitTest)); | 226 MouseEventWithHitTestResults(fakeMouseDown, currentHitTest)); |
| 227 } |
223 } | 228 } |
224 | 229 |
225 if (currentHitTest.innerNode()) { | 230 if (currentHitTest.innerNode()) { |
226 DCHECK(gestureEvent.type() == WebInputEvent::GestureTap); | 231 DCHECK(gestureEvent.type() == WebInputEvent::GestureTap); |
227 HitTestResult result = currentHitTest; | 232 HitTestResult result = currentHitTest; |
228 result.setToShadowHostIfInUserAgentShadowRoot(); | 233 result.setToShadowHostIfInUserAgentShadowRoot(); |
229 m_frame->chromeClient().onMouseDown(result.innerNode()); | 234 m_frame->chromeClient().onMouseDown(result.innerNode()); |
230 } | 235 } |
231 | 236 |
232 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. | 237 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 WebInputEvent::IsCompatibilityEventForTouch), | 391 WebInputEvent::IsCompatibilityEventForTouch), |
387 gestureEvent.timeStampSeconds()); | 392 gestureEvent.timeStampSeconds()); |
388 | 393 |
389 if (!m_suppressMouseEventsFromGestures && m_frame->view()) { | 394 if (!m_suppressMouseEventsFromGestures && m_frame->view()) { |
390 HitTestRequest request(HitTestRequest::Active); | 395 HitTestRequest request(HitTestRequest::Active); |
391 LayoutPoint documentPoint = m_frame->view()->rootFrameToContents( | 396 LayoutPoint documentPoint = m_frame->view()->rootFrameToContents( |
392 flooredIntPoint(targetedEvent.event().positionInRootFrame())); | 397 flooredIntPoint(targetedEvent.event().positionInRootFrame())); |
393 MouseEventWithHitTestResults mev = | 398 MouseEventWithHitTestResults mev = |
394 m_frame->document()->performMouseEventHitTest(request, documentPoint, | 399 m_frame->document()->performMouseEventHitTest(request, documentPoint, |
395 mouseEvent); | 400 mouseEvent); |
396 m_mouseEventManager->handleMouseFocus( | 401 m_mouseEventManager->handleMouseFocus(mev.hitTestResult(), |
397 mev.hitTestResult(), | 402 m_frame->document() |
398 InputDeviceCapabilities::firesTouchEventsSourceCapabilities()); | 403 ->domWindow() |
| 404 ->getInputDeviceCapabilities() |
| 405 ->firesTouchEvents(true)); |
399 } | 406 } |
400 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); | 407 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); |
401 } | 408 } |
402 | 409 |
403 WebInputEventResult GestureManager::handleGestureShowPress() { | 410 WebInputEventResult GestureManager::handleGestureShowPress() { |
404 m_lastShowPressTimestamp = TimeTicks::Now(); | 411 m_lastShowPressTimestamp = TimeTicks::Now(); |
405 | 412 |
406 FrameView* view = m_frame->view(); | 413 FrameView* view = m_frame->view(); |
407 if (!view) | 414 if (!view) |
408 return WebInputEventResult::NotHandled; | 415 return WebInputEventResult::NotHandled; |
(...skipping 16 matching lines...) Expand all Loading... |
425 | 432 |
426 return &m_frame->page()->frameHost(); | 433 return &m_frame->page()->frameHost(); |
427 } | 434 } |
428 | 435 |
429 WTF::Optional<WTF::TimeTicks> GestureManager::getLastShowPressTimestamp() | 436 WTF::Optional<WTF::TimeTicks> GestureManager::getLastShowPressTimestamp() |
430 const { | 437 const { |
431 return m_lastShowPressTimestamp; | 438 return m_lastShowPressTimestamp; |
432 } | 439 } |
433 | 440 |
434 } // namespace blink | 441 } // namespace blink |
OLD | NEW |