Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) | 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "core/input/EventHandler.h" | 29 #include "core/input/EventHandler.h" |
| 30 | 30 |
| 31 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 31 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 32 #include "core/HTMLNames.h" | 32 #include "core/HTMLNames.h" |
| 33 #include "core/InputTypeNames.h" | 33 #include "core/InputTypeNames.h" |
| 34 #include "core/clipboard/DataTransfer.h" | 34 #include "core/clipboard/DataTransfer.h" |
| 35 #include "core/dom/DOMNodeIds.h" | 35 #include "core/dom/DOMNodeIds.h" |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/dom/DocumentUserGestureToken.h" | |
| 37 #include "core/dom/TouchList.h" | 38 #include "core/dom/TouchList.h" |
| 38 #include "core/dom/shadow/FlatTreeTraversal.h" | 39 #include "core/dom/shadow/FlatTreeTraversal.h" |
| 39 #include "core/dom/shadow/ShadowRoot.h" | 40 #include "core/dom/shadow/ShadowRoot.h" |
| 40 #include "core/editing/EditingUtilities.h" | 41 #include "core/editing/EditingUtilities.h" |
| 41 #include "core/editing/Editor.h" | 42 #include "core/editing/Editor.h" |
| 42 #include "core/editing/FrameSelection.h" | 43 #include "core/editing/FrameSelection.h" |
| 43 #include "core/editing/SelectionController.h" | 44 #include "core/editing/SelectionController.h" |
| 44 #include "core/events/EventPath.h" | 45 #include "core/events/EventPath.h" |
| 45 #include "core/events/GestureEvent.h" | 46 #include "core/events/GestureEvent.h" |
| 46 #include "core/events/KeyboardEvent.h" | 47 #include "core/events/KeyboardEvent.h" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 const PlatformMouseEvent& mouseEvent) { | 566 const PlatformMouseEvent& mouseEvent) { |
| 566 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); | 567 TRACE_EVENT0("blink", "EventHandler::handleMousePressEvent"); |
| 567 | 568 |
| 568 // For 4th/5th button in the mouse since Chrome does not yet send | 569 // For 4th/5th button in the mouse since Chrome does not yet send |
| 569 // button value to Blink but in some cases it does send the event. | 570 // button value to Blink but in some cases it does send the event. |
| 570 // This check is needed to suppress such an event (crbug.com/574959) | 571 // This check is needed to suppress such an event (crbug.com/574959) |
| 571 if (mouseEvent.pointerProperties().button == | 572 if (mouseEvent.pointerProperties().button == |
| 572 WebPointerProperties::Button::NoButton) | 573 WebPointerProperties::Button::NoButton) |
| 573 return WebInputEventResult::HandledSuppressed; | 574 return WebInputEventResult::HandledSuppressed; |
| 574 | 575 |
| 575 UserGestureIndicator gestureIndicator(UserGestureToken::create()); | |
| 576 m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken = | |
| 577 UserGestureIndicator::currentToken(); | |
| 578 | |
| 579 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 576 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
| 580 m_capturingMouseEventsNode = nullptr; | 577 m_capturingMouseEventsNode = nullptr; |
| 581 m_mouseEventManager->handleMousePressEventUpdateStates(mouseEvent); | 578 m_mouseEventManager->handleMousePressEventUpdateStates(mouseEvent); |
| 582 selectionController().setMouseDownMayStartSelect(false); | 579 selectionController().setMouseDownMayStartSelect(false); |
| 583 if (!m_frame->view()) | 580 if (!m_frame->view()) |
| 584 return WebInputEventResult::NotHandled; | 581 return WebInputEventResult::NotHandled; |
| 585 | 582 |
| 586 HitTestRequest request(HitTestRequest::Active); | 583 HitTestRequest request(HitTestRequest::Active); |
| 587 // Save the document point we generate in case the window coordinate is | 584 // Save the document point we generate in case the window coordinate is |
| 588 // invalidated by what happens when we dispatch the event. | 585 // invalidated by what happens when we dispatch the event. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 612 subframe->eventHandler().m_mouseEventManager->capturesDragging()); | 609 subframe->eventHandler().m_mouseEventManager->capturesDragging()); |
| 613 if (m_mouseEventManager->mousePressed() && | 610 if (m_mouseEventManager->mousePressed() && |
| 614 m_mouseEventManager->capturesDragging()) { | 611 m_mouseEventManager->capturesDragging()) { |
| 615 m_capturingMouseEventsNode = mev.innerNode(); | 612 m_capturingMouseEventsNode = mev.innerNode(); |
| 616 m_eventHandlerWillResetCapturingMouseEventsNode = true; | 613 m_eventHandlerWillResetCapturingMouseEventsNode = true; |
| 617 } | 614 } |
| 618 m_mouseEventManager->invalidateClick(); | 615 m_mouseEventManager->invalidateClick(); |
| 619 return result; | 616 return result; |
| 620 } | 617 } |
| 621 | 618 |
| 619 UserGestureIndicator gestureIndicator( | |
| 620 DocumentUserGestureToken::create(m_frame->document())); | |
| 621 m_frame->localFrameRoot()->eventHandler().m_lastMouseDownUserGestureToken = | |
| 622 UserGestureIndicator::currentToken(); | |
| 623 | |
| 622 if (RuntimeEnabledFeatures::middleClickAutoscrollEnabled()) { | 624 if (RuntimeEnabledFeatures::middleClickAutoscrollEnabled()) { |
| 623 // We store whether middle click autoscroll is in progress before calling | 625 // We store whether middle click autoscroll is in progress before calling |
| 624 // stopAutoscroll() because it will set m_autoscrollType to NoAutoscroll on | 626 // stopAutoscroll() because it will set m_autoscrollType to NoAutoscroll on |
| 625 // return. | 627 // return. |
| 626 bool isMiddleClickAutoscrollInProgress = | 628 bool isMiddleClickAutoscrollInProgress = |
| 627 m_scrollManager->middleClickAutoscrollInProgress(); | 629 m_scrollManager->middleClickAutoscrollInProgress(); |
| 628 m_scrollManager->stopAutoscroll(); | 630 m_scrollManager->stopAutoscroll(); |
| 629 if (isMiddleClickAutoscrollInProgress) { | 631 if (isMiddleClickAutoscrollInProgress) { |
| 630 // We invalidate the click when exiting middle click auto scroll so that | 632 // We invalidate the click when exiting middle click auto scroll so that |
| 631 // we don't inadvertently navigate away from the current page (e.g. the | 633 // we don't inadvertently navigate away from the current page (e.g. the |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 // For 4th/5th button in the mouse since Chrome does not yet send | 892 // For 4th/5th button in the mouse since Chrome does not yet send |
| 891 // button value to Blink but in some cases it does send the event. | 893 // button value to Blink but in some cases it does send the event. |
| 892 // This check is needed to suppress such an event (crbug.com/574959) | 894 // This check is needed to suppress such an event (crbug.com/574959) |
| 893 if (mouseEvent.pointerProperties().button == | 895 if (mouseEvent.pointerProperties().button == |
| 894 WebPointerProperties::Button::NoButton) | 896 WebPointerProperties::Button::NoButton) |
| 895 return WebInputEventResult::HandledSuppressed; | 897 return WebInputEventResult::HandledSuppressed; |
| 896 | 898 |
| 897 if (!mouseEvent.fromTouch()) | 899 if (!mouseEvent.fromTouch()) |
| 898 m_frame->selection().setCaretBlinkingSuspended(false); | 900 m_frame->selection().setCaretBlinkingSuspended(false); |
| 899 | 901 |
| 900 std::unique_ptr<UserGestureIndicator> gestureIndicator; | |
| 901 | |
| 902 if (m_frame->localFrameRoot() | |
| 903 ->eventHandler() | |
| 904 .m_lastMouseDownUserGestureToken) { | |
| 905 gestureIndicator = wrapUnique(new UserGestureIndicator( | |
| 906 m_frame->localFrameRoot() | |
| 907 ->eventHandler() | |
| 908 .m_lastMouseDownUserGestureToken.release())); | |
| 909 } else { | |
| 910 gestureIndicator = | |
| 911 wrapUnique(new UserGestureIndicator(UserGestureToken::create())); | |
| 912 } | |
| 913 | |
| 914 if (RuntimeEnabledFeatures::middleClickAutoscrollEnabled()) { | 902 if (RuntimeEnabledFeatures::middleClickAutoscrollEnabled()) { |
| 915 if (Page* page = m_frame->page()) | 903 if (Page* page = m_frame->page()) |
| 916 page->autoscrollController().handleMouseReleaseForMiddleClickAutoscroll( | 904 page->autoscrollController().handleMouseReleaseForMiddleClickAutoscroll( |
| 917 m_frame, mouseEvent); | 905 m_frame, mouseEvent); |
| 918 } | 906 } |
| 919 | 907 |
| 920 m_mouseEventManager->setMousePressed(false); | 908 m_mouseEventManager->setMousePressed(false); |
| 921 m_mouseEventManager->setLastKnownMousePosition(mouseEvent); | 909 m_mouseEventManager->setLastKnownMousePosition(mouseEvent); |
| 922 m_mouseEventManager->handleSvgPanIfNeeded(true); | 910 m_mouseEventManager->handleSvgPanIfNeeded(true); |
| 923 | 911 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 944 EventHandlingUtil::performMouseEventHitTest(m_frame, request, mouseEvent); | 932 EventHandlingUtil::performMouseEventHitTest(m_frame, request, mouseEvent); |
| 945 LocalFrame* subframe = | 933 LocalFrame* subframe = |
| 946 m_capturingMouseEventsNode.get() | 934 m_capturingMouseEventsNode.get() |
| 947 ? subframeForTargetNode(m_capturingMouseEventsNode.get()) | 935 ? subframeForTargetNode(m_capturingMouseEventsNode.get()) |
| 948 : subframeForHitTestResult(mev); | 936 : subframeForHitTestResult(mev); |
| 949 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 937 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
| 950 m_capturingMouseEventsNode = nullptr; | 938 m_capturingMouseEventsNode = nullptr; |
| 951 if (subframe) | 939 if (subframe) |
| 952 return passMouseReleaseEventToSubframe(mev, subframe); | 940 return passMouseReleaseEventToSubframe(mev, subframe); |
| 953 | 941 |
| 942 std::unique_ptr<UserGestureIndicator> gestureIndicator; | |
|
Rick Byers
2016/10/17 17:02:46
So the effect of the mouse changes is that it's th
Nate Chapin
2016/10/18 23:26:33
Done, and explicitly noted that this behavior may
| |
| 943 if (m_frame->localFrameRoot() | |
| 944 ->eventHandler() | |
| 945 .m_lastMouseDownUserGestureToken) { | |
| 946 gestureIndicator = wrapUnique(new UserGestureIndicator( | |
| 947 m_frame->localFrameRoot() | |
| 948 ->eventHandler() | |
| 949 .m_lastMouseDownUserGestureToken.release())); | |
| 950 } else { | |
| 951 gestureIndicator = wrapUnique(new UserGestureIndicator( | |
| 952 DocumentUserGestureToken::create(m_frame->document()))); | |
| 953 } | |
| 954 | |
| 954 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents( | 955 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents( |
| 955 EventTypeNames::mouseup, mev.innerNode(), mev.event()); | 956 EventTypeNames::mouseup, mev.innerNode(), mev.event()); |
| 956 | 957 |
| 957 WebInputEventResult clickEventResult = | 958 WebInputEventResult clickEventResult = |
| 958 m_mouseEventManager->dispatchMouseClickIfNeeded(mev); | 959 m_mouseEventManager->dispatchMouseClickIfNeeded(mev); |
| 959 | 960 |
| 960 m_scrollManager->clearResizeScrollableArea(false); | 961 m_scrollManager->clearResizeScrollableArea(false); |
| 961 | 962 |
| 962 if (eventResult == WebInputEventResult::NotHandled) | 963 if (eventResult == WebInputEventResult::NotHandled) |
| 963 eventResult = m_mouseEventManager->handleMouseReleaseEvent(mev); | 964 eventResult = m_mouseEventManager->handleMouseReleaseEvent(mev); |
| (...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2050 } | 2051 } |
| 2051 | 2052 |
| 2052 FrameHost* EventHandler::frameHost() const { | 2053 FrameHost* EventHandler::frameHost() const { |
| 2053 if (!m_frame->page()) | 2054 if (!m_frame->page()) |
| 2054 return nullptr; | 2055 return nullptr; |
| 2055 | 2056 |
| 2056 return &m_frame->page()->frameHost(); | 2057 return &m_frame->page()->frameHost(); |
| 2057 } | 2058 } |
| 2058 | 2059 |
| 2059 } // namespace blink | 2060 } // namespace blink |
| OLD | NEW |