| 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 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); | 378 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); |
| 379 } | 379 } |
| 380 | 380 |
| 381 WebInputEventResult GestureManager::handleGestureShowPress() { | 381 WebInputEventResult GestureManager::handleGestureShowPress() { |
| 382 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); | 382 m_lastShowPressTimestamp = TimeTicks::Now(); |
| 383 | 383 |
| 384 FrameView* view = m_frame->view(); | 384 FrameView* view = m_frame->view(); |
| 385 if (!view) | 385 if (!view) |
| 386 return WebInputEventResult::NotHandled; | 386 return WebInputEventResult::NotHandled; |
| 387 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) | 387 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) |
| 388 scrollAnimator->cancelAnimation(); | 388 scrollAnimator->cancelAnimation(); |
| 389 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); | 389 const FrameView::ScrollableAreaSet* areas = view->scrollableAreas(); |
| 390 if (!areas) | 390 if (!areas) |
| 391 return WebInputEventResult::NotHandled; | 391 return WebInputEventResult::NotHandled; |
| 392 for (const ScrollableArea* scrollableArea : *areas) { | 392 for (const ScrollableArea* scrollableArea : *areas) { |
| 393 ScrollAnimatorBase* animator = scrollableArea->existingScrollAnimator(); | 393 ScrollAnimatorBase* animator = scrollableArea->existingScrollAnimator(); |
| 394 if (animator) | 394 if (animator) |
| 395 animator->cancelAnimation(); | 395 animator->cancelAnimation(); |
| 396 } | 396 } |
| 397 return WebInputEventResult::NotHandled; | 397 return WebInputEventResult::NotHandled; |
| 398 } | 398 } |
| 399 | 399 |
| 400 FrameHost* GestureManager::frameHost() const { | 400 FrameHost* GestureManager::frameHost() const { |
| 401 if (!m_frame->page()) | 401 if (!m_frame->page()) |
| 402 return nullptr; | 402 return nullptr; |
| 403 | 403 |
| 404 return &m_frame->page()->frameHost(); | 404 return &m_frame->page()->frameHost(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 double GestureManager::getLastShowPressTimestamp() const { | 407 TimeTicks GestureManager::getLastShowPressTimestamp() const { |
| 408 return m_lastShowPressTimestamp; | 408 return m_lastShowPressTimestamp; |
| 409 } | 409 } |
| 410 | 410 |
| 411 } // namespace blink | 411 } // namespace blink |
| OLD | NEW |