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

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

Issue 2141993003: PointerEvents for long-press: fix double firing & canceling MEs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 } 767 }
768 768
769 static LayoutPoint contentPointFromRootFrame(LocalFrame* frame, const IntPoint& pointInRootFrame) 769 static LayoutPoint contentPointFromRootFrame(LocalFrame* frame, const IntPoint& pointInRootFrame)
770 { 770 {
771 FrameView* view = frame->view(); 771 FrameView* view = frame->view();
772 // FIXME: Is it really OK to use the wrong coordinates here when view is 0? 772 // FIXME: Is it really OK to use the wrong coordinates here when view is 0?
773 // Historically the code would just crash; this is clearly no worse than tha t. 773 // Historically the code would just crash; this is clearly no worse than tha t.
774 return view ? view->rootFrameToContents(pointInRootFrame) : pointInRootFrame ; 774 return view ? view->rootFrameToContents(pointInRootFrame) : pointInRootFrame ;
775 } 775 }
776 776
777 WebInputEventResult EventHandler::handleMousePressEvent(const PlatformMouseEvent & mouseEvent) 777 WebInputEventResult EventHandler::handleMousePressEvent(const PlatformMouseEvent & mouseEvent, const bool synthesizedFromTouch)
778 { 778 {
779 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); 779 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent");
780 780
781 // For 4th/5th button in the mouse since Chrome does not yet send 781 // For 4th/5th button in the mouse since Chrome does not yet send
782 // button value to Blink but in some cases it does send the event. 782 // button value to Blink but in some cases it does send the event.
783 // This check is needed to suppress such an event (crbug.com/574959) 783 // This check is needed to suppress such an event (crbug.com/574959)
784 if (mouseEvent.button() == NoButton) 784 if (mouseEvent.button() == NoButton)
785 return WebInputEventResult::HandledSuppressed; 785 return WebInputEventResult::HandledSuppressed;
786 786
787 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); 787 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 return WebInputEventResult::HandledSuppressed; 846 return WebInputEventResult::HandledSuppressed;
847 } 847 }
848 #endif 848 #endif
849 849
850 m_clickCount = mouseEvent.clickCount(); 850 m_clickCount = mouseEvent.clickCount();
851 m_clickNode = mev.innerNode()->isTextNode() ? FlatTreeTraversal::parent(*me v.innerNode()) : mev.innerNode(); 851 m_clickNode = mev.innerNode()->isTextNode() ? FlatTreeTraversal::parent(*me v.innerNode()) : mev.innerNode();
852 852
853 if (!mouseEvent.fromTouch()) 853 if (!mouseEvent.fromTouch())
854 m_frame->selection().setCaretBlinkingSuspended(true); 854 m_frame->selection().setCaretBlinkingSuspended(true);
855 855
856 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mousedown, mev.innerNode(), m_clickCount, mev.event()); 856 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(
857 EventTypeNames::mousedown, mev.innerNode(), m_clickCount, mev.event(), s ynthesizedFromTouch);
857 858
858 if (eventResult == WebInputEventResult::NotHandled && m_frame->view()) { 859 if (eventResult == WebInputEventResult::NotHandled && m_frame->view()) {
859 FrameView* view = m_frame->view(); 860 FrameView* view = m_frame->view();
860 PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->l ayoutObject()->enclosingLayer() : nullptr; 861 PaintLayer* layer = mev.innerNode()->layoutObject() ? mev.innerNode()->l ayoutObject()->enclosingLayer() : nullptr;
861 IntPoint p = view->rootFrameToContents(mouseEvent.position()); 862 IntPoint p = view->rootFrameToContents(mouseEvent.position());
862 if (layer && layer->getScrollableArea() && layer->getScrollableArea()->i sPointInResizeControl(p, ResizerForPointer)) { 863 if (layer && layer->getScrollableArea() && layer->getScrollableArea()->i sPointInResizeControl(p, ResizerForPointer)) {
863 m_scrollManager.setResizeScrollableArea(layer, p); 864 m_scrollManager.setResizeScrollableArea(layer, p);
864 return WebInputEventResult::HandledSystem; 865 return WebInputEventResult::HandledSystem;
865 } 866 }
866 } 867 }
867 868
868 // m_selectionInitiationState is initialized after dispatching mousedown 869 // m_selectionInitiationState is initialized after dispatching mousedown
869 // event in order not to keep the selection by DOM APIs Because we can't 870 // event in order not to keep the selection by DOM APIs Because we can't
870 // give the user the chance to handle the selection by user action like 871 // give the user the chance to handle the selection by user action like
871 // dragging if we keep the selection in case of mousedown. FireFox also has 872 // dragging if we keep the selection in case of mousedown. FireFox also has
872 // the same behavior and it's more compatible with other browsers. 873 // the same behavior and it's more compatible with other browsers.
873 selectionController().initializeSelectionState(); 874 selectionController().initializeSelectionState();
874 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly); 875 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly);
875 InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventTy pe() == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEvent sSourceCapabilities() : 876 InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventTy pe() == PlatformMouseEvent::FromTouch
876 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); 877 ? InputDeviceCapabilities::firesTouchEventsSourceCapabilities()
878 : InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities();
877 if (eventResult == WebInputEventResult::NotHandled) 879 if (eventResult == WebInputEventResult::NotHandled)
878 eventResult = handleMouseFocus(MouseEventWithHitTestResults(mev.event(), hitTestResult), sourceCapabilities); 880 eventResult = handleMouseFocus(MouseEventWithHitTestResults(mev.event(), hitTestResult), sourceCapabilities);
879 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar(); 881 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar();
880 882
881 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults 883 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults
882 // in case the scrollbar widget was destroyed when the mouse event was handl ed. 884 // in case the scrollbar widget was destroyed when the mouse event was handl ed.
883 if (mev.scrollbar()) { 885 if (mev.scrollbar()) {
884 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); 886 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get();
885 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); 887 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active );
886 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent); 888 mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mou seEvent);
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 { 1492 {
1491 m_pointerEventManager.releasePointerCapture(pointerId, target); 1493 m_pointerEventManager.releasePointerCapture(pointerId, target);
1492 } 1494 }
1493 1495
1494 void EventHandler::elementRemoved(EventTarget* target) 1496 void EventHandler::elementRemoved(EventTarget* target)
1495 { 1497 {
1496 m_pointerEventManager.elementRemoved(target); 1498 m_pointerEventManager.elementRemoved(target);
1497 } 1499 }
1498 1500
1499 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler. 1501 // TODO(mustaq): Make PE drive ME dispatch & bookkeeping in EventHandler.
1500 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse Event& mouseEvent) 1502 WebInputEventResult EventHandler::updatePointerTargetAndDispatchEvents(const Ato micString& mouseEventType, Node* targetNode, int clickCount, const PlatformMouse Event& mouseEvent, const bool synthesizedFromTouch)
1501 { 1503 {
1502 ASSERT(mouseEventType == EventTypeNames::mousedown 1504 ASSERT(mouseEventType == EventTypeNames::mousedown
1503 || mouseEventType == EventTypeNames::mousemove 1505 || mouseEventType == EventTypeNames::mousemove
1504 || mouseEventType == EventTypeNames::mouseup); 1506 || mouseEventType == EventTypeNames::mouseup);
1505 1507
1506 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent ); 1508 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent );
1507 1509
1510 if (synthesizedFromTouch)
1511 return dispatchMouseEvent(mouseEventType, m_nodeUnderMouse, clickCount, mouseEvent);
1512
1508 return m_pointerEventManager.sendMousePointerEvent( 1513 return m_pointerEventManager.sendMousePointerEvent(
1509 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr, 1514 m_nodeUnderMouse, mouseEventType, clickCount, mouseEvent, nullptr,
1510 lastNodeUnderMouse); 1515 lastNodeUnderMouse);
1511 } 1516 }
1512 1517
1513 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities) 1518 WebInputEventResult EventHandler::handleMouseFocus(const MouseEventWithHitTestRe sults& targetedEvent, InputDeviceCapabilities* sourceCapabilities)
1514 { 1519 {
1515 // If clicking on a frame scrollbar, do not mess up with content focus. 1520 // If clicking on a frame scrollbar, do not mess up with content focus.
1516 if (targetedEvent.hitTestResult().scrollbar() && !m_frame->contentLayoutItem ().isNull()) { 1521 if (targetedEvent.hitTestResult().scrollbar() && !m_frame->contentLayoutItem ().isNull()) {
1517 if (targetedEvent.hitTestResult().scrollbar()->getScrollableArea() == m_ frame->contentLayoutItem().getScrollableArea()) 1522 if (targetedEvent.hitTestResult().scrollbar()->getScrollableArea() == m_ frame->contentLayoutItem().getScrollableArea())
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 // Always set right button down as we are sending mousedown event regardless 2387 // Always set right button down as we are sending mousedown event regardless
2383 modifiers |= PlatformEvent::RightButtonDown; 2388 modifiers |= PlatformEvent::RightButtonDown;
2384 2389
2385 // TODO(crbug.com/579564): Maybe we should not send mouse down at all 2390 // TODO(crbug.com/579564): Maybe we should not send mouse down at all
2386 PlatformMouseEvent mouseEvent(targetedEvent.event().position(), targetedEven t.event().globalPosition(), RightButton, eventType, 1, 2391 PlatformMouseEvent mouseEvent(targetedEvent.event().position(), targetedEven t.event().globalPosition(), RightButton, eventType, 1,
2387 static_cast<PlatformEvent::Modifiers>(modifiers), 2392 static_cast<PlatformEvent::Modifiers>(modifiers),
2388 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), WebPo interProperties::PointerType::Mouse); 2393 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), WebPo interProperties::PointerType::Mouse);
2389 // To simulate right-click behavior, we send a right mouse down and then 2394 // To simulate right-click behavior, we send a right mouse down and then
2390 // context menu event. 2395 // context menu event.
2391 // FIXME: Send HitTestResults to avoid redundant hit tests. 2396 // FIXME: Send HitTestResults to avoid redundant hit tests.
2392 handleMousePressEvent(mouseEvent); 2397
2398 handleMousePressEvent(mouseEvent, true);
Rick Byers 2016/07/14 14:27:10 I think the real bug here related to the above FIX
mustaq 2016/07/14 15:05:14 I tried to address the TODO but Edge sends mousedo
2399
2393 return sendContextMenuEvent(mouseEvent); 2400 return sendContextMenuEvent(mouseEvent);
2394 // We do not need to send a corresponding mouse release because in case of 2401 // We do not need to send a corresponding mouse release because in case of
2395 // right-click, the context menu takes capture and consumes all events. 2402 // right-click, the context menu takes capture and consumes all events.
2396 } 2403 }
2397 2404
2398 void EventHandler::scheduleHoverStateUpdate() 2405 void EventHandler::scheduleHoverStateUpdate()
2399 { 2406 {
2400 if (!m_hoverTimer.isActive()) 2407 if (!m_hoverTimer.isActive())
2401 m_hoverTimer.startOneShot(0, BLINK_FROM_HERE); 2408 m_hoverTimer.startOneShot(0, BLINK_FROM_HERE);
2402 } 2409 }
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2852 2859
2853 FrameHost* EventHandler::frameHost() const 2860 FrameHost* EventHandler::frameHost() const
2854 { 2861 {
2855 if (!m_frame->page()) 2862 if (!m_frame->page())
2856 return nullptr; 2863 return nullptr;
2857 2864
2858 return &m_frame->page()->frameHost(); 2865 return &m_frame->page()->frameHost();
2859 } 2866 }
2860 2867
2861 } // namespace blink 2868 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698