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 // Mouse events will be associated with the Document where mousedown |
| 943 // occurred. If, e.g., there is a mousedown, then a drag to a different |
| 944 // Document and mouseup there, the mouseup's gesture will be associated with |
| 945 // the mousedown's Document. It's not absolutely certain that this is the |
| 946 // correct behavior. |
| 947 std::unique_ptr<UserGestureIndicator> gestureIndicator; |
| 948 if (m_frame->localFrameRoot() |
| 949 ->eventHandler() |
| 950 .m_lastMouseDownUserGestureToken) { |
| 951 gestureIndicator = wrapUnique(new UserGestureIndicator( |
| 952 m_frame->localFrameRoot() |
| 953 ->eventHandler() |
| 954 .m_lastMouseDownUserGestureToken.release())); |
| 955 } else { |
| 956 gestureIndicator = wrapUnique(new UserGestureIndicator( |
| 957 DocumentUserGestureToken::create(m_frame->document()))); |
| 958 } |
| 959 |
954 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents( | 960 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents( |
955 EventTypeNames::mouseup, mev.innerNode(), mev.event()); | 961 EventTypeNames::mouseup, mev.innerNode(), mev.event()); |
956 | 962 |
957 WebInputEventResult clickEventResult = | 963 WebInputEventResult clickEventResult = |
958 m_mouseEventManager->dispatchMouseClickIfNeeded(mev); | 964 m_mouseEventManager->dispatchMouseClickIfNeeded(mev); |
959 | 965 |
960 m_scrollManager->clearResizeScrollableArea(false); | 966 m_scrollManager->clearResizeScrollableArea(false); |
961 | 967 |
962 if (eventResult == WebInputEventResult::NotHandled) | 968 if (eventResult == WebInputEventResult::NotHandled) |
963 eventResult = m_mouseEventManager->handleMouseReleaseEvent(mev); | 969 eventResult = m_mouseEventManager->handleMouseReleaseEvent(mev); |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 } | 2086 } |
2081 | 2087 |
2082 FrameHost* EventHandler::frameHost() const { | 2088 FrameHost* EventHandler::frameHost() const { |
2083 if (!m_frame->page()) | 2089 if (!m_frame->page()) |
2084 return nullptr; | 2090 return nullptr; |
2085 | 2091 |
2086 return &m_frame->page()->frameHost(); | 2092 return &m_frame->page()->frameHost(); |
2087 } | 2093 } |
2088 | 2094 |
2089 } // namespace blink | 2095 } // namespace blink |
OLD | NEW |