Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: third_party/WebKit/Source/core/input/GestureManager.cpp

Issue 2446333002: Set right button for mousedown/contextmenu of long press gesture (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/events/touch/gesture/context-menu-on-two-finger-tap-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 gestureEvent.position(), gestureEvent.globalPosition(), 353 gestureEvent.position(), gestureEvent.globalPosition(),
354 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved, 354 WebPointerProperties::Button::NoButton, PlatformEvent::MouseMoved,
355 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers), 355 /* clickCount */ 0, static_cast<PlatformEvent::Modifiers>(modifiers),
356 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), 356 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(),
357 WebPointerProperties::PointerType::Mouse); 357 WebPointerProperties::PointerType::Mouse);
358 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( 358 m_mouseEventManager->setMousePositionAndDispatchMouseEvent(
359 targetedEvent.hitTestResult().innerNode(), EventTypeNames::mousemove, 359 targetedEvent.hitTestResult().innerNode(), EventTypeNames::mousemove,
360 fakeMouseMove); 360 fakeMouseMove);
361 } 361 }
362 362
363 PlatformEvent::EventType eventType = PlatformEvent::MousePressed;
364 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp())
365 eventType = PlatformEvent::MouseReleased;
366 PlatformMouseEvent mouseEvent( 363 PlatformMouseEvent mouseEvent(
367 targetedEvent.event().position(), targetedEvent.event().globalPosition(), 364 targetedEvent.event().position(), targetedEvent.event().globalPosition(),
368 WebPointerProperties::Button::NoButton, eventType, /* clickCount */ 0, 365 WebPointerProperties::Button::NoButton, PlatformEvent::MousePressed,
369 static_cast<PlatformEvent::Modifiers>(modifiers), 366 /* clickCount */ 1,
367 static_cast<PlatformEvent::Modifiers>(
368 modifiers | PlatformEvent::Modifiers::RightButtonDown),
370 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), 369 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(),
371 WebPointerProperties::PointerType::Mouse); 370 WebPointerProperties::PointerType::Mouse);
372 371
373 if (!m_suppressMouseEventsFromGestures && m_frame->view()) { 372 if (!m_suppressMouseEventsFromGestures && m_frame->view()) {
374 HitTestRequest request(HitTestRequest::Active); 373 HitTestRequest request(HitTestRequest::Active);
375 LayoutPoint documentPoint = 374 LayoutPoint documentPoint =
376 m_frame->view()->rootFrameToContents(targetedEvent.event().position()); 375 m_frame->view()->rootFrameToContents(targetedEvent.event().position());
377 MouseEventWithHitTestResults mev = 376 MouseEventWithHitTestResults mev =
378 m_frame->document()->performMouseEventHitTest(request, documentPoint, 377 m_frame->document()->performMouseEventHitTest(request, documentPoint,
379 mouseEvent); 378 mouseEvent);
380 379
381 WebInputEventResult eventResult = 380 WebInputEventResult eventResult =
382 m_mouseEventManager->setMousePositionAndDispatchMouseEvent( 381 m_mouseEventManager->setMousePositionAndDispatchMouseEvent(
383 mev.innerNode(), EventTypeNames::mousedown, mouseEvent); 382 mev.innerNode(), EventTypeNames::mousedown, mouseEvent);
384 383
385 if (eventResult == WebInputEventResult::NotHandled) 384 if (eventResult == WebInputEventResult::NotHandled)
386 eventResult = m_mouseEventManager->handleMouseFocus( 385 eventResult = m_mouseEventManager->handleMouseFocus(
387 mev.hitTestResult(), 386 mev.hitTestResult(),
388 InputDeviceCapabilities::firesTouchEventsSourceCapabilities()); 387 InputDeviceCapabilities::firesTouchEventsSourceCapabilities());
389 388
390 if (eventResult == WebInputEventResult::NotHandled) 389 if (eventResult == WebInputEventResult::NotHandled)
391 m_mouseEventManager->handleMousePressEvent(mev); 390 m_mouseEventManager->handleMousePressEvent(mev);
391
392 if (m_frame->settings() &&
393 m_frame->settings()->showContextMenuOnMouseUp()) {
394 m_mouseEventManager->setMousePositionAndDispatchMouseEvent(
395 mev.innerNode(), EventTypeNames::mouseup, mouseEvent);
396 m_mouseEventManager->setClickNode(mev.innerNode());
397 m_mouseEventManager->setClickCount(1);
398 m_mouseEventManager->dispatchMouseClickIfNeeded(mev);
399 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent);
400 }
401 WebInputEventResult result =
402 m_frame->eventHandler().sendContextMenuEvent(mouseEvent);
403 if (result != WebInputEventResult::NotHandled) {
404 m_mouseEventManager->setMousePositionAndDispatchMouseEvent(
405 mev.innerNode(), EventTypeNames::mouseup, mouseEvent);
406 m_mouseEventManager->setClickNode(mev.innerNode());
407 m_mouseEventManager->setClickCount(1);
408 m_mouseEventManager->dispatchMouseClickIfNeeded(mev);
Navid Zolghadr 2016/10/25 20:12:37 Do you think these few lines are worth adding a ne
409 }
410 return result;
392 } 411 }
393
394 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent); 412 return m_frame->eventHandler().sendContextMenuEvent(mouseEvent);
395 } 413 }
396 414
397 WebInputEventResult GestureManager::handleGestureShowPress() { 415 WebInputEventResult GestureManager::handleGestureShowPress() {
398 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime(); 416 m_lastShowPressTimestamp = WTF::monotonicallyIncreasingTime();
399 417
400 FrameView* view = m_frame->view(); 418 FrameView* view = m_frame->view();
401 if (!view) 419 if (!view)
402 return WebInputEventResult::NotHandled; 420 return WebInputEventResult::NotHandled;
403 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator()) 421 if (ScrollAnimatorBase* scrollAnimator = view->existingScrollAnimator())
(...skipping 14 matching lines...) Expand all
418 return nullptr; 436 return nullptr;
419 437
420 return &m_frame->page()->frameHost(); 438 return &m_frame->page()->frameHost();
421 } 439 }
422 440
423 double GestureManager::getLastShowPressTimestamp() const { 441 double GestureManager::getLastShowPressTimestamp() const {
424 return m_lastShowPressTimestamp; 442 return m_lastShowPressTimestamp;
425 } 443 }
426 444
427 } // namespace blink 445 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/events/touch/gesture/context-menu-on-two-finger-tap-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698