| 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 17 matching lines...) Expand all Loading... |
| 28 m_scrollManager(scrollManager), | 28 m_scrollManager(scrollManager), |
| 29 m_mouseEventManager(mouseEventManager), | 29 m_mouseEventManager(mouseEventManager), |
| 30 m_pointerEventManager(pointerEventManager), | 30 m_pointerEventManager(pointerEventManager), |
| 31 m_selectionController(selectionController) { | 31 m_selectionController(selectionController) { |
| 32 clear(); | 32 clear(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void GestureManager::clear() { | 35 void GestureManager::clear() { |
| 36 m_suppressMouseEventsFromGestures = false; | 36 m_suppressMouseEventsFromGestures = false; |
| 37 m_longTapShouldInvokeContextMenu = false; | 37 m_longTapShouldInvokeContextMenu = false; |
| 38 m_lastShowPressTimestamp = 0; | 38 m_lastShowPressTimestamp = TimeTicks(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 DEFINE_TRACE(GestureManager) { | 41 DEFINE_TRACE(GestureManager) { |
| 42 visitor->trace(m_frame); | 42 visitor->trace(m_frame); |
| 43 visitor->trace(m_scrollManager); | 43 visitor->trace(m_scrollManager); |
| 44 visitor->trace(m_mouseEventManager); | 44 visitor->trace(m_mouseEventManager); |
| 45 visitor->trace(m_pointerEventManager); | 45 visitor->trace(m_pointerEventManager); |
| 46 visitor->trace(m_selectionController); | 46 visitor->trace(m_selectionController); |
| 47 } | 47 } |
| 48 | 48 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 365 |
| 366 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; | 366 PlatformEvent::EventType eventType = PlatformEvent::MousePressed; |
| 367 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) | 367 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) |
| 368 eventType = PlatformEvent::MouseReleased; | 368 eventType = PlatformEvent::MouseReleased; |
| 369 | 369 |
| 370 PlatformMouseEvent mouseEvent( | 370 PlatformMouseEvent mouseEvent( |
| 371 targetedEvent.event().position(), targetedEvent.event().globalPosition(), | 371 targetedEvent.event().position(), targetedEvent.event().globalPosition(), |
| 372 WebPointerProperties::Button::Right, eventType, /* clickCount */ 1, | 372 WebPointerProperties::Button::Right, eventType, /* clickCount */ 1, |
| 373 static_cast<PlatformEvent::Modifiers>( | 373 static_cast<PlatformEvent::Modifiers>( |
| 374 modifiers | PlatformEvent::Modifiers::RightButtonDown), | 374 modifiers | PlatformEvent::Modifiers::RightButtonDown), |
| 375 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), | 375 PlatformMouseEvent::FromTouch, TimeTicks::Now(), |
| 376 WebPointerProperties::PointerType::Mouse); | 376 WebPointerProperties::PointerType::Mouse); |
| 377 | 377 |
| 378 if (!m_suppressMouseEventsFromGestures && m_frame->view()) { | 378 if (!m_suppressMouseEventsFromGestures && m_frame->view()) { |
| 379 HitTestRequest request(HitTestRequest::Active); | 379 HitTestRequest request(HitTestRequest::Active); |
| 380 LayoutPoint documentPoint = | 380 LayoutPoint documentPoint = |
| 381 m_frame->view()->rootFrameToContents(targetedEvent.event().position()); | 381 m_frame->view()->rootFrameToContents(targetedEvent.event().position()); |
| 382 MouseEventWithHitTestResults mev = | 382 MouseEventWithHitTestResults mev = |
| 383 m_frame->document()->performMouseEventHitTest(request, documentPoint, | 383 m_frame->document()->performMouseEventHitTest(request, documentPoint, |
| 384 mouseEvent); | 384 mouseEvent); |
| 385 m_mouseEventManager->handleMouseFocus( | 385 m_mouseEventManager->handleMouseFocus( |
| 386 mev.hitTestResult(), | 386 mev.hitTestResult(), |
| 387 InputDeviceCapabilities::firesTouchEventsSourceCapabilities()); | 387 InputDeviceCapabilities::firesTouchEventsSourceCapabilities()); |
| 388 } | 388 } |
| 389 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); | 389 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); |
| 390 } | 390 } |
| 391 | 391 |
| 392 WebInputEventResult GestureManager::handleGestureShowPress() { | 392 WebInputEventResult GestureManager::handleGestureShowPress() { |
| 393 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); | 393 m_lastShowPressTimestamp = TimeTicks::Now(); |
| 394 | 394 |
| 395 FrameView* view = m_frame->view(); | 395 FrameView* view = m_frame->view(); |
| 396 if (!view) | 396 if (!view) |
| 397 return WebInputEventResult::NotHandled; | 397 return WebInputEventResult::NotHandled; |
| 398 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) | 398 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) |
| 399 scrollAnimator->cancelAnimation(); | 399 scrollAnimator->cancelAnimation(); |
| 400 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); | 400 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); |
| 401 if (!areas) | 401 if (!areas) |
| 402 return WebInputEventResult::NotHandled; | 402 return WebInputEventResult::NotHandled; |
| 403 for (const ScrollableArea* scrollableArea : *areas) { | 403 for (const ScrollableArea* scrollableArea : *areas) { |
| 404 ScrollAnimatorBase* animator = scrollableArea->existingScrollAnimator(); | 404 ScrollAnimatorBase* animator = scrollableArea->existingScrollAnimator(); |
| 405 if (animator) | 405 if (animator) |
| 406 animator->cancelAnimation(); | 406 animator->cancelAnimation(); |
| 407 } | 407 } |
| 408 return WebInputEventResult::NotHandled; | 408 return WebInputEventResult::NotHandled; |
| 409 } | 409 } |
| 410 | 410 |
| 411 FrameHost* GestureManager::frameHost() const { | 411 FrameHost* GestureManager::frameHost() const { |
| 412 if (!m_frame->page()) | 412 if (!m_frame->page()) |
| 413 return nullptr; | 413 return nullptr; |
| 414 | 414 |
| 415 return &m_frame->page()->frameHost(); | 415 return &m_frame->page()->frameHost(); |
| 416 } | 416 } |
| 417 | 417 |
| 418 double GestureManager::getLastShowPressTimestamp() const { | 418 TimeTicks GestureManager::getLastShowPressTimestamp() const { |
| 419 return m_lastShowPressTimestamp; | 419 return m_lastShowPressTimestamp; |
| 420 } | 420 } |
| 421 | 421 |
| 422 } // namespace blink | 422 } // namespace blink |
| OLD | NEW |