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

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

Issue 1746283002: Rename enums/functions that collide in chromium style in platform/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get-names-13-platform: . Created 4 years, 9 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 namespace blink { 103 namespace blink {
104 104
105 namespace { 105 namespace {
106 106
107 bool hasTouchHandlers(const EventHandlerRegistry& registry) 107 bool hasTouchHandlers(const EventHandlerRegistry& registry)
108 { 108 {
109 return registry.hasEventHandlers(EventHandlerRegistry::TouchEventBlocking) 109 return registry.hasEventHandlers(EventHandlerRegistry::TouchEventBlocking)
110 || registry.hasEventHandlers(EventHandlerRegistry::TouchEventPassive); 110 || registry.hasEventHandlers(EventHandlerRegistry::TouchEventPassive);
111 } 111 }
112 112
113 const AtomicString& touchEventNameForTouchPointState(PlatformTouchPoint::State s tate) 113 const AtomicString& touchEventNameForTouchPointState(PlatformTouchPoint::TouchSt ate state)
114 { 114 {
115 switch (state) { 115 switch (state) {
116 case PlatformTouchPoint::TouchReleased: 116 case PlatformTouchPoint::TouchReleased:
117 return EventTypeNames::touchend; 117 return EventTypeNames::touchend;
118 case PlatformTouchPoint::TouchCancelled: 118 case PlatformTouchPoint::TouchCancelled:
119 return EventTypeNames::touchcancel; 119 return EventTypeNames::touchcancel;
120 case PlatformTouchPoint::TouchPressed: 120 case PlatformTouchPoint::TouchPressed:
121 return EventTypeNames::touchstart; 121 return EventTypeNames::touchstart;
122 case PlatformTouchPoint::TouchMoved: 122 case PlatformTouchPoint::TouchMoved:
123 return EventTypeNames::touchmove; 123 return EventTypeNames::touchmove;
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 } 1038 }
1039 } 1039 }
1040 1040
1041 // m_selectionInitiationState is initialized after dispatching mousedown 1041 // m_selectionInitiationState is initialized after dispatching mousedown
1042 // event in order not to keep the selection by DOM APIs Because we can't 1042 // event in order not to keep the selection by DOM APIs Because we can't
1043 // give the user the chance to handle the selection by user action like 1043 // give the user the chance to handle the selection by user action like
1044 // dragging if we keep the selection in case of mousedown. FireFox also has 1044 // dragging if we keep the selection in case of mousedown. FireFox also has
1045 // the same behavior and it's more compatible with other browsers. 1045 // the same behavior and it's more compatible with other browsers.
1046 selectionController().initializeSelectionState(); 1046 selectionController().initializeSelectionState();
1047 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly); 1047 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly);
1048 InputDeviceCapabilities* sourceCapabilities = mouseEvent.syntheticEventType( ) == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEventsSo urceCapabilities() : 1048 InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventTy pe() == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEvent sSourceCapabilities() :
1049 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); 1049 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities();
1050 if (eventResult == WebInputEventResult::NotHandled) 1050 if (eventResult == WebInputEventResult::NotHandled)
1051 eventResult = handleMouseFocus(MouseEventWithHitTestResults(mouseEvent, hitTestResult), sourceCapabilities); 1051 eventResult = handleMouseFocus(MouseEventWithHitTestResults(mouseEvent, hitTestResult), sourceCapabilities);
1052 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar(); 1052 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar();
1053 1053
1054 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults 1054 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults
1055 // in case the scrollbar widget was destroyed when the mouse event was handl ed. 1055 // in case the scrollbar widget was destroyed when the mouse event was handl ed.
1056 if (mev.scrollbar()) { 1056 if (mev.scrollbar()) {
1057 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); 1057 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get();
1058 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active ); 1058 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active );
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 } 1110 }
1111 1111
1112 return nullptr; 1112 return nullptr;
1113 } 1113 }
1114 1114
1115 WebInputEventResult EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& event) 1115 WebInputEventResult EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& event)
1116 { 1116 {
1117 TRACE_EVENT0("blink", "EventHandler::handleMouseMoveEvent"); 1117 TRACE_EVENT0("blink", "EventHandler::handleMouseMoveEvent");
1118 1118
1119 m_pointerEventManager.conditionallyEnableMouseEventForPointerTypeMouse( 1119 m_pointerEventManager.conditionallyEnableMouseEventForPointerTypeMouse(
1120 event.modifiers()); 1120 event.getModifiers());
1121 1121
1122 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); 1122 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view());
1123 1123
1124 HitTestResult hoveredNode = HitTestResult(); 1124 HitTestResult hoveredNode = HitTestResult();
1125 WebInputEventResult result = handleMouseMoveOrLeaveEvent(event, &hoveredNode ); 1125 WebInputEventResult result = handleMouseMoveOrLeaveEvent(event, &hoveredNode );
1126 1126
1127 Page* page = m_frame->page(); 1127 Page* page = m_frame->page();
1128 if (!page) 1128 if (!page)
1129 return result; 1129 return result;
1130 1130
1131 if (PaintLayer* layer = layerForNode(hoveredNode.innerNode())) { 1131 if (PaintLayer* layer = layerForNode(hoveredNode.innerNode())) {
1132 if (ScrollableArea* layerScrollableArea = associatedScrollableArea(layer )) 1132 if (ScrollableArea* layerScrollableArea = associatedScrollableArea(layer ))
1133 layerScrollableArea->mouseMovedInContentArea(); 1133 layerScrollableArea->mouseMovedInContentArea();
1134 } 1134 }
1135 1135
1136 if (FrameView* frameView = m_frame->view()) 1136 if (FrameView* frameView = m_frame->view())
1137 frameView->mouseMovedInContentArea(); 1137 frameView->mouseMovedInContentArea();
1138 1138
1139 hoveredNode.setToShadowHostIfInUserAgentShadowRoot(); 1139 hoveredNode.setToShadowHostIfInUserAgentShadowRoot();
1140 page->chromeClient().mouseDidMoveOverElement(hoveredNode); 1140 page->chromeClient().mouseDidMoveOverElement(hoveredNode);
1141 1141
1142 return result; 1142 return result;
1143 } 1143 }
1144 1144
1145 void EventHandler::handleMouseLeaveEvent(const PlatformMouseEvent& event) 1145 void EventHandler::handleMouseLeaveEvent(const PlatformMouseEvent& event)
1146 { 1146 {
1147 TRACE_EVENT0("blink", "EventHandler::handleMouseLeaveEvent"); 1147 TRACE_EVENT0("blink", "EventHandler::handleMouseLeaveEvent");
1148 1148
1149 m_pointerEventManager.conditionallyEnableMouseEventForPointerTypeMouse( 1149 m_pointerEventManager.conditionallyEnableMouseEventForPointerTypeMouse(
1150 event.modifiers()); 1150 event.getModifiers());
1151 1151
1152 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); 1152 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view());
1153 handleMouseMoveOrLeaveEvent(event, 0, false, true); 1153 handleMouseMoveOrLeaveEvent(event, 0, false, true);
1154 } 1154 }
1155 1155
1156 WebInputEventResult EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMous eEvent& mouseEvent, HitTestResult* hoveredNode, bool onlyUpdateScrollbars, bool forceLeave) 1156 WebInputEventResult EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMous eEvent& mouseEvent, HitTestResult* hoveredNode, bool onlyUpdateScrollbars, bool forceLeave)
1157 { 1157 {
1158 ASSERT(m_frame); 1158 ASSERT(m_frame);
1159 ASSERT(m_frame->view()); 1159 ASSERT(m_frame->view());
1160 1160
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); 1325 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev);
1326 if (m_eventHandlerWillResetCapturingMouseEventsNode) 1326 if (m_eventHandlerWillResetCapturingMouseEventsNode)
1327 m_capturingMouseEventsNode = nullptr; 1327 m_capturingMouseEventsNode = nullptr;
1328 if (subframe) 1328 if (subframe)
1329 return passMouseReleaseEventToSubframe(mev, subframe); 1329 return passMouseReleaseEventToSubframe(mev, subframe);
1330 1330
1331 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mouseup, mev.innerNode(), m_clickCount, mouseEvent); 1331 WebInputEventResult eventResult = updatePointerTargetAndDispatchEvents(Event TypeNames::mouseup, mev.innerNode(), m_clickCount, mouseEvent);
1332 1332
1333 // TODO(crbug/545647): This state should reset with pointercancel too. 1333 // TODO(crbug/545647): This state should reset with pointercancel too.
1334 m_pointerEventManager.conditionallyEnableMouseEventForPointerTypeMouse( 1334 m_pointerEventManager.conditionallyEnableMouseEventForPointerTypeMouse(
1335 mouseEvent.modifiers()); 1335 mouseEvent.getModifiers());
1336 1336
1337 bool contextMenuEvent = mouseEvent.button() == RightButton; 1337 bool contextMenuEvent = mouseEvent.button() == RightButton;
1338 #if OS(MACOSX) 1338 #if OS(MACOSX)
1339 // FIXME: The Mac port achieves the same behavior by checking whether the co ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl ementations. 1339 // FIXME: The Mac port achieves the same behavior by checking whether the co ntext menu is currently open in WebPage::mouseEvent(). Consider merging the impl ementations.
1340 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv ent::CtrlKey) 1340 if (mouseEvent.button() == LeftButton && mouseEvent.getModifiers() & Platfor mEvent::CtrlKey)
1341 contextMenuEvent = true; 1341 contextMenuEvent = true;
1342 #endif 1342 #endif
1343 1343
1344 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled; 1344 WebInputEventResult clickEventResult = WebInputEventResult::NotHandled;
1345 if (m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode && mev.innerNode()->canParticipateInFlatTree() && m_clickNode->canParticipateInF latTree()) { 1345 if (m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode && mev.innerNode()->canParticipateInFlatTree() && m_clickNode->canParticipateInF latTree()) {
1346 // Updates distribution because a 'mouseup' event listener can make the 1346 // Updates distribution because a 'mouseup' event listener can make the
1347 // tree dirty at dispatchMouseEvent() invocation above. 1347 // tree dirty at dispatchMouseEvent() invocation above.
1348 // Unless distribution is updated, commonAncestor would hit ASSERT. 1348 // Unless distribution is updated, commonAncestor would hit ASSERT.
1349 // Both m_clickNode and mev.innerNode() don't need to be updated 1349 // Both m_clickNode and mev.innerNode() don't need to be updated
1350 // because commonAncestor() will exit early if their documents are diffe rent. 1350 // because commonAncestor() will exit early if their documents are diffe rent.
(...skipping 28 matching lines...) Expand all
1379 FrameView* view = m_frame->view(); 1379 FrameView* view = m_frame->view();
1380 1380
1381 // FIXME: We might want to dispatch a dragleave even if the view is gone. 1381 // FIXME: We might want to dispatch a dragleave even if the view is gone.
1382 if (!view) 1382 if (!view)
1383 return WebInputEventResult::NotHandled; 1383 return WebInputEventResult::NotHandled;
1384 1384
1385 RefPtrWillBeRawPtr<DragEvent> me = DragEvent::create(eventType, 1385 RefPtrWillBeRawPtr<DragEvent> me = DragEvent::create(eventType,
1386 true, true, m_frame->document()->domWindow(), 1386 true, true, m_frame->document()->domWindow(),
1387 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(), 1387 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(),
1388 event.movementDelta().x(), event.movementDelta().y(), 1388 event.movementDelta().x(), event.movementDelta().y(),
1389 event.modifiers(), 1389 event.getModifiers(),
1390 0, MouseEvent::platformModifiersToButtons(event.modifiers()), nullptr, e vent.timestamp(), dataTransfer, event.syntheticEventType()); 1390 0, MouseEvent::platformModifiersToButtons(event.getModifiers()), nullptr , event.timestamp(), dataTransfer, event.getSyntheticEventType());
1391 1391
1392 return toWebInputEventResult(dragTarget->dispatchEvent(me.get())); 1392 return toWebInputEventResult(dragTarget->dispatchEvent(me.get()));
1393 } 1393 }
1394 1394
1395 static bool targetIsFrame(Node* target, LocalFrame*& frame) 1395 static bool targetIsFrame(Node* target, LocalFrame*& frame)
1396 { 1396 {
1397 if (!isHTMLFrameElementBase(target)) 1397 if (!isHTMLFrameElementBase(target))
1398 return false; 1398 return false;
1399 1399
1400 // Cross-process drag and drop is not yet supported. 1400 // Cross-process drag and drop is not yet supported.
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion(); 2057 uint64_t preDispatchStyleVersion = m_frame->document()->styleVersion();
2058 2058
2059 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture); 2059 UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
2060 2060
2061 HitTestResult currentHitTest = targetedEvent.hitTestResult(); 2061 HitTestResult currentHitTest = targetedEvent.hitTestResult();
2062 2062
2063 // We use the adjusted position so the application isn't surprised to see a event with 2063 // We use the adjusted position so the application isn't surprised to see a event with
2064 // co-ordinates outside the target's bounds. 2064 // co-ordinates outside the target's bounds.
2065 IntPoint adjustedPoint = frameView->rootFrameToContents(gestureEvent.positio n()); 2065 IntPoint adjustedPoint = frameView->rootFrameToContents(gestureEvent.positio n());
2066 2066
2067 unsigned modifiers = gestureEvent.modifiers(); 2067 unsigned modifiers = gestureEvent.getModifiers();
2068 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(), 2068 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(),
2069 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, 2069 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0,
2070 static_cast<PlatformEvent::Modifiers>(modifiers), 2070 static_cast<PlatformEvent::Modifiers>(modifiers),
2071 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope rties::PointerType::Mouse); 2071 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope rties::PointerType::Mouse);
2072 dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode(), 0, fakeMouseMove); 2072 dispatchMouseEvent(EventTypeNames::mousemove, currentHitTest.innerNode(), 0, fakeMouseMove);
2073 2073
2074 // Do a new hit-test in case the mousemove event changed the DOM. 2074 // Do a new hit-test in case the mousemove event changed the DOM.
2075 // Note that if the original hit test wasn't over an element (eg. was over a scrollbar) we 2075 // Note that if the original hit test wasn't over an element (eg. was over a scrollbar) we
2076 // don't want to re-hit-test because it may be in the wrong frame (and there 's no way the page 2076 // don't want to re-hit-test because it may be in the wrong frame (and there 's no way the page
2077 // could have seen the event anyway). 2077 // could have seen the event anyway).
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2153 m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPositionInViewp ort, tappedNode.get(), domTreeChanged || styleChanged); 2153 m_frame->chromeClient().showUnhandledTapUIIfNeeded(tappedPositionInViewp ort, tappedNode.get(), domTreeChanged || styleChanged);
2154 } 2154 }
2155 return eventResult; 2155 return eventResult;
2156 } 2156 }
2157 2157
2158 WebInputEventResult EventHandler::handleGestureLongPress(const GestureEventWithH itTestResults& targetedEvent) 2158 WebInputEventResult EventHandler::handleGestureLongPress(const GestureEventWithH itTestResults& targetedEvent)
2159 { 2159 {
2160 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 2160 const PlatformGestureEvent& gestureEvent = targetedEvent.event();
2161 IntPoint adjustedPoint = gestureEvent.position(); 2161 IntPoint adjustedPoint = gestureEvent.position();
2162 2162
2163 unsigned modifiers = gestureEvent.modifiers(); 2163 unsigned modifiers = gestureEvent.getModifiers();
2164 2164
2165 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests here (re-using the 2165 // FIXME: Ideally we should try to remove the extra mouse-specific hit-tests here (re-using the
2166 // supplied HitTestResult), but that will require some overhaul of the touch drag-and-drop code 2166 // supplied HitTestResult), but that will require some overhaul of the touch drag-and-drop code
2167 // and LongPress is such a special scenario that it's unlikely to matter muc h in practice. 2167 // and LongPress is such a special scenario that it's unlikely to matter muc h in practice.
2168 2168
2169 m_longTapShouldInvokeContextMenu = false; 2169 m_longTapShouldInvokeContextMenu = false;
2170 if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled() && m_ frame->view()) { 2170 if (m_frame->settings() && m_frame->settings()->touchDragDropEnabled() && m_ frame->view()) {
2171 PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosi tion(), LeftButton, PlatformEvent::MousePressed, 1, 2171 PlatformMouseEvent mouseDownEvent(adjustedPoint, gestureEvent.globalPosi tion(), LeftButton, PlatformEvent::MousePressed, 1,
2172 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef tButtonDown), 2172 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::Lef tButtonDown),
2173 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), W ebPointerProperties::PointerType::Mouse); 2173 PlatformMouseEvent::FromTouch, WTF::monotonicallyIncreasingTime(), W ebPointerProperties::PointerType::Mouse);
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2623 LocalFrame* lastEnteredFrameInDocument = indexEnteredFrameChain ? en teredFrameChain[indexEnteredFrameChain-1] : nullptr; 2623 LocalFrame* lastEnteredFrameInDocument = indexEnteredFrameChain ? en teredFrameChain[indexEnteredFrameChain-1] : nullptr;
2624 if (exitedFrameInDocument != lastEnteredFrameInDocument) 2624 if (exitedFrameInDocument != lastEnteredFrameInDocument)
2625 exitedFrameChain.append(exitedFrameInDocument); 2625 exitedFrameChain.append(exitedFrameInDocument);
2626 else if (nextExitedFrameInDocument && indexEnteredFrameChain) 2626 else if (nextExitedFrameInDocument && indexEnteredFrameChain)
2627 --indexEnteredFrameChain; 2627 --indexEnteredFrameChain;
2628 } 2628 }
2629 exitedFrameInDocument = nextExitedFrameInDocument; 2629 exitedFrameInDocument = nextExitedFrameInDocument;
2630 } 2630 }
2631 2631
2632 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 2632 const PlatformGestureEvent& gestureEvent = targetedEvent.event();
2633 unsigned modifiers = gestureEvent.modifiers(); 2633 unsigned modifiers = gestureEvent.getModifiers();
2634 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(), 2634 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(),
2635 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, 2635 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0,
2636 static_cast<PlatformEvent::Modifiers>(modifiers), 2636 static_cast<PlatformEvent::Modifiers>(modifiers),
2637 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope rties::PointerType::Mouse); 2637 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope rties::PointerType::Mouse);
2638 2638
2639 // Update the mouseout/mouseleave event 2639 // Update the mouseout/mouseleave event
2640 size_t indexExitedFrameChain = exitedFrameChain.size(); 2640 size_t indexExitedFrameChain = exitedFrameChain.size();
2641 while (indexExitedFrameChain) { 2641 while (indexExitedFrameChain) {
2642 LocalFrame* leaveFrame = exitedFrameChain[--indexExitedFrameChain]; 2642 LocalFrame* leaveFrame = exitedFrameChain[--indexExitedFrameChain];
2643 leaveFrame->eventHandler().updateMouseEventTargetNode(nullptr, fakeMouse Move); 2643 leaveFrame->eventHandler().updateMouseEventTargetNode(nullptr, fakeMouse Move);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2720 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->rootFra meToContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~ HitTestRequest::ListBased); 2720 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->rootFra meToContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~ HitTestRequest::ListBased);
2721 } 2721 }
2722 2722
2723 // If we did a rect-based hit test it must be resolved to the best single no de by now to 2723 // If we did a rect-based hit test it must be resolved to the best single no de by now to
2724 // ensure consumers don't accidentally use one of the other candidates. 2724 // ensure consumers don't accidentally use one of the other candidates.
2725 ASSERT(!hitTestResult.isRectBasedTest()); 2725 ASSERT(!hitTestResult.isRectBasedTest());
2726 2726
2727 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); 2727 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult);
2728 } 2728 }
2729 2729
2730 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo rmEvent::Type type) 2730 HitTestRequest::HitTestRequestType EventHandler::getHitTypeForGestureType(Platfo rmEvent::EventType type)
2731 { 2731 {
2732 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent; 2732 HitTestRequest::HitTestRequestType hitType = HitTestRequest::TouchEvent;
2733 switch (type) { 2733 switch (type) {
2734 case PlatformEvent::GestureShowPress: 2734 case PlatformEvent::GestureShowPress:
2735 case PlatformEvent::GestureTapUnconfirmed: 2735 case PlatformEvent::GestureTapUnconfirmed:
2736 return hitType | HitTestRequest::Active; 2736 return hitType | HitTestRequest::Active;
2737 case PlatformEvent::GestureTapDownCancel: 2737 case PlatformEvent::GestureTapDownCancel:
2738 // A TapDownCancel received when no element is active shouldn't really b e changing hover state. 2738 // A TapDownCancel received when no element is active shouldn't really b e changing hover state.
2739 if (!m_frame->document()->activeHoverElement()) 2739 if (!m_frame->document()->activeHoverElement())
2740 hitType |= HitTestRequest::ReadOnly; 2740 hitType |= HitTestRequest::ReadOnly;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2854 targetNode = doc; 2854 targetNode = doc;
2855 2855
2856 // Use the focused node as the target for hover and active. 2856 // Use the focused node as the target for hover and active.
2857 HitTestRequest request(HitTestRequest::Active); 2857 HitTestRequest request(HitTestRequest::Active);
2858 HitTestResult result(request, locationInRootFrame); 2858 HitTestResult result(request, locationInRootFrame);
2859 result.setInnerNode(targetNode); 2859 result.setInnerNode(targetNode);
2860 doc->updateHoverActiveState(request, result.innerElement()); 2860 doc->updateHoverActiveState(request, result.innerElement());
2861 2861
2862 // The contextmenu event is a mouse event even when invoked using the keyboa rd. 2862 // The contextmenu event is a mouse event even when invoked using the keyboa rd.
2863 // This is required for web compatibility. 2863 // This is required for web compatibility.
2864 PlatformEvent::Type eventType = PlatformEvent::MousePressed; 2864 PlatformEvent::EventType eventType = PlatformEvent::MousePressed;
2865 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) 2865 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp())
2866 eventType = PlatformEvent::MouseReleased; 2866 eventType = PlatformEvent::MouseReleased;
2867 2867
2868 PlatformMouseEvent mouseEvent(locationInRootFrame, globalPosition, 2868 PlatformMouseEvent mouseEvent(locationInRootFrame, globalPosition,
2869 RightButton, eventType, 1, 2869 RightButton, eventType, 1,
2870 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable, 2870 PlatformEvent::NoModifiers, PlatformMouseEvent::RealOrIndistinguishable,
2871 WTF::monotonicallyIncreasingTime(), WebPointerProperties::PointerType::M ouse); 2871 WTF::monotonicallyIncreasingTime(), WebPointerProperties::PointerType::M ouse);
2872 2872
2873 return sendContextMenuEvent(mouseEvent, overrideTargetElement); 2873 return sendContextMenuEvent(mouseEvent, overrideTargetElement);
2874 } 2874 }
2875 2875
2876 WebInputEventResult EventHandler::sendContextMenuEventForGesture(const GestureEv entWithHitTestResults& targetedEvent) 2876 WebInputEventResult EventHandler::sendContextMenuEventForGesture(const GestureEv entWithHitTestResults& targetedEvent)
2877 { 2877 {
2878 const PlatformGestureEvent& gestureEvent = targetedEvent.event(); 2878 const PlatformGestureEvent& gestureEvent = targetedEvent.event();
2879 unsigned modifiers = gestureEvent.modifiers(); 2879 unsigned modifiers = gestureEvent.getModifiers();
2880 2880
2881 // Send MouseMoved event prior to handling (https://crbug.com/485290). 2881 // Send MouseMoved event prior to handling (https://crbug.com/485290).
2882 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(), 2882 PlatformMouseEvent fakeMouseMove(gestureEvent.position(), gestureEvent.globa lPosition(),
2883 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0, 2883 NoButton, PlatformEvent::MouseMoved, /* clickCount */ 0,
2884 static_cast<PlatformEvent::Modifiers>(modifiers), 2884 static_cast<PlatformEvent::Modifiers>(modifiers),
2885 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope rties::PointerType::Mouse); 2885 PlatformMouseEvent::FromTouch, gestureEvent.timestamp(), WebPointerPrope rties::PointerType::Mouse);
2886 dispatchMouseEvent(EventTypeNames::mousemove, targetedEvent.hitTestResult(). innerNode(), 0, fakeMouseMove); 2886 dispatchMouseEvent(EventTypeNames::mousemove, targetedEvent.hitTestResult(). innerNode(), 0, fakeMouseMove);
2887 2887
2888 PlatformEvent::Type eventType = PlatformEvent::MousePressed; 2888 PlatformEvent::EventType eventType = PlatformEvent::MousePressed;
2889 2889
2890 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp()) 2890 if (m_frame->settings() && m_frame->settings()->showContextMenuOnMouseUp())
2891 eventType = PlatformEvent::MouseReleased; 2891 eventType = PlatformEvent::MouseReleased;
2892 2892
2893 // Always set right button down as we are sending mousedown event regardless 2893 // Always set right button down as we are sending mousedown event regardless
2894 modifiers |= PlatformEvent::RightButtonDown; 2894 modifiers |= PlatformEvent::RightButtonDown;
2895 2895
2896 // TODO(crbug.com/579564): Maybe we should not send mouse down at all 2896 // TODO(crbug.com/579564): Maybe we should not send mouse down at all
2897 PlatformMouseEvent mouseEvent(targetedEvent.event().position(), targetedEven t.event().globalPosition(), RightButton, eventType, 1, 2897 PlatformMouseEvent mouseEvent(targetedEvent.event().position(), targetedEven t.event().globalPosition(), RightButton, eventType, 1,
2898 static_cast<PlatformEvent::Modifiers>(modifiers), 2898 static_cast<PlatformEvent::Modifiers>(modifiers),
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
3046 m_lastDeferredTapElement = nullptr; 3046 m_lastDeferredTapElement = nullptr;
3047 } 3047 }
3048 3048
3049 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt) 3049 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt)
3050 { 3050 {
3051 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do. 3051 // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do.
3052 // IE matches lower and upper case access keys regardless of Shift key state - but if both upper and 3052 // IE matches lower and upper case access keys regardless of Shift key state - but if both upper and
3053 // lower case variants are present in a document, the correct element is mat ched based on Shift key state. 3053 // lower case variants are present in a document, the correct element is mat ched based on Shift key state.
3054 // Firefox only matches an access key if Shift is not pressed, and does that case-insensitively. 3054 // Firefox only matches an access key if Shift is not pressed, and does that case-insensitively.
3055 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey)); 3055 ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey));
3056 if ((evt.modifiers() & (PlatformEvent::KeyModifiers & ~PlatformEvent::ShiftK ey)) != accessKeyModifiers()) 3056 if ((evt.getModifiers() & (PlatformEvent::KeyModifiers & ~PlatformEvent::Shi ftKey)) != accessKeyModifiers())
3057 return false; 3057 return false;
3058 String key = evt.unmodifiedText(); 3058 String key = evt.unmodifiedText();
3059 Element* elem = m_frame->document()->getElementByAccessKey(key.lower()); 3059 Element* elem = m_frame->document()->getElementByAccessKey(key.lower());
3060 if (!elem) 3060 if (!elem)
3061 return false; 3061 return false;
3062 elem->accessKeyAction(false); 3062 elem->accessKeyAction(false);
3063 return true; 3063 return true;
3064 } 3064 }
3065 3065
3066 WebInputEventResult EventHandler::keyEvent(const PlatformKeyboardEvent& initialK eyEvent) 3066 WebInputEventResult EventHandler::keyEvent(const PlatformKeyboardEvent& initialK eyEvent)
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
3566 TouchInfo& touchInfo = touchInfos[i]; 3566 TouchInfo& touchInfo = touchInfos[i];
3567 const PlatformTouchPoint& touchPoint = touchInfo.point; 3567 const PlatformTouchPoint& touchPoint = touchInfo.point;
3568 3568
3569 3569
3570 if (touchPoint.state() == PlatformTouchPoint::TouchStationary 3570 if (touchPoint.state() == PlatformTouchPoint::TouchStationary
3571 || !touchInfo.knownTarget) 3571 || !touchInfo.knownTarget)
3572 continue; 3572 continue;
3573 3573
3574 WebInputEventResult result = 3574 WebInputEventResult result =
3575 m_pointerEventManager.sendTouchPointerEvent( 3575 m_pointerEventManager.sendTouchPointerEvent(
3576 touchInfo.touchTarget, touchPoint, event.modifiers(), 3576 touchInfo.touchTarget, touchPoint, event.getModifiers(),
3577 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(), 3577 touchInfo.adjustedRadius.width(), touchInfo.adjustedRadius.height(),
3578 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y()); 3578 touchInfo.adjustedPagePoint.x(), touchInfo.adjustedPagePoint.y());
3579 touchInfo.consumed = result != WebInputEventResult::NotHandled; 3579 touchInfo.consumed = result != WebInputEventResult::NotHandled;
3580 } 3580 }
3581 } 3581 }
3582 3582
3583 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos) 3583 void EventHandler::sendPointerCancels(WillBeHeapVector<TouchInfo>& touchInfos)
3584 { 3584 {
3585 if (!RuntimeEnabledFeatures::pointerEventEnabled()) 3585 if (!RuntimeEnabledFeatures::pointerEventEnabled())
3586 return; 3586 return;
3587 3587
3588 for (unsigned i = 0; i < touchInfos.size(); ++i) { 3588 for (unsigned i = 0; i < touchInfos.size(); ++i) {
3589 TouchInfo& touchInfo = touchInfos[i]; 3589 TouchInfo& touchInfo = touchInfos[i];
3590 const PlatformTouchPoint& point = touchInfo.point; 3590 const PlatformTouchPoint& point = touchInfo.point;
3591 const PlatformTouchPoint::State pointState = point.state(); 3591 const PlatformTouchPoint::TouchState pointState = point.state();
3592 3592
3593 if (pointState == PlatformTouchPoint::TouchReleased 3593 if (pointState == PlatformTouchPoint::TouchReleased
3594 || pointState == PlatformTouchPoint::TouchCancelled) 3594 || pointState == PlatformTouchPoint::TouchCancelled)
3595 continue; 3595 continue;
3596 3596
3597 m_pointerEventManager.sendTouchCancelPointerEvent( 3597 m_pointerEventManager.sendTouchCancelPointerEvent(
3598 touchInfo.touchTarget, 3598 touchInfo.touchTarget,
3599 point); 3599 point);
3600 } 3600 }
3601 } 3601 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3638 // event target. Used for the 'targetTouches' list in the JS event. 3638 // event target. Used for the 'targetTouches' list in the JS event.
3639 using TargetTouchesHeapMap = WillBeHeapHashMap<EventTarget*, RefPtrWillBeMem ber<TouchList>>; 3639 using TargetTouchesHeapMap = WillBeHeapHashMap<EventTarget*, RefPtrWillBeMem ber<TouchList>>;
3640 TargetTouchesHeapMap touchesByTarget; 3640 TargetTouchesHeapMap touchesByTarget;
3641 3641
3642 // Array of touches per state, used to assemble the 'changedTouches' list. 3642 // Array of touches per state, used to assemble the 'changedTouches' list.
3643 ChangedTouches changedTouches[PlatformTouchPoint::TouchStateEnd]; 3643 ChangedTouches changedTouches[PlatformTouchPoint::TouchStateEnd];
3644 3644
3645 for (unsigned i = 0; i < touchInfos.size(); ++i) { 3645 for (unsigned i = 0; i < touchInfos.size(); ++i) {
3646 const TouchInfo& touchInfo = touchInfos[i]; 3646 const TouchInfo& touchInfo = touchInfos[i];
3647 const PlatformTouchPoint& point = touchInfo.point; 3647 const PlatformTouchPoint& point = touchInfo.point;
3648 PlatformTouchPoint::State pointState = point.state(); 3648 PlatformTouchPoint::TouchState pointState = point.state();
3649 3649
3650 if (touchInfo.consumed) 3650 if (touchInfo.consumed)
3651 continue; 3651 continue;
3652 3652
3653 RefPtrWillBeRawPtr<Touch> touch = Touch::create( 3653 RefPtrWillBeRawPtr<Touch> touch = Touch::create(
3654 touchInfo.targetFrame.get(), 3654 touchInfo.targetFrame.get(),
3655 touchInfo.touchTarget.get(), 3655 touchInfo.touchTarget.get(),
3656 point.id(), 3656 point.id(),
3657 point.screenPos(), 3657 point.screenPos(),
3658 touchInfo.adjustedPagePoint, 3658 touchInfo.adjustedPagePoint,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3696 } 3696 }
3697 3697
3698 WebInputEventResult eventResult = WebInputEventResult::NotHandled; 3698 WebInputEventResult eventResult = WebInputEventResult::NotHandled;
3699 3699
3700 // Now iterate through the changedTouches list and m_targets within it, send ing 3700 // Now iterate through the changedTouches list and m_targets within it, send ing
3701 // TouchEvents to the targets as required. 3701 // TouchEvents to the targets as required.
3702 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) { 3702 for (unsigned state = 0; state != PlatformTouchPoint::TouchStateEnd; ++state ) {
3703 if (!changedTouches[state].m_touches) 3703 if (!changedTouches[state].m_touches)
3704 continue; 3704 continue;
3705 3705
3706 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::State>(state))); 3706 const AtomicString& eventName(touchEventNameForTouchPointState(static_ca st<PlatformTouchPoint::TouchState>(state)));
3707 for (const auto& eventTarget : changedTouches[state].m_targets) { 3707 for (const auto& eventTarget : changedTouches[state].m_targets) {
3708 EventTarget* touchEventTarget = eventTarget.get(); 3708 EventTarget* touchEventTarget = eventTarget.get();
3709 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create( 3709 RefPtrWillBeRawPtr<TouchEvent> touchEvent = TouchEvent::create(
3710 touches.get(), touchesByTarget.get(touchEventTarget), changedTou ches[state].m_touches.get(), 3710 touches.get(), touchesByTarget.get(touchEventTarget), changedTou ches[state].m_touches.get(),
3711 eventName, touchEventTarget->toNode()->document().domWindow(), 3711 eventName, touchEventTarget->toNode()->document().domWindow(),
3712 event.modifiers(), event.cancelable(), event.causesScrollingIfUn canceled(), event.timestamp()); 3712 event.getModifiers(), event.cancelable(), event.causesScrollingI fUncanceled(), event.timestamp());
3713 3713
3714 eventResult = mergeEventResult(eventResult, toWebInputEventResult(to uchEventTarget->dispatchEvent(touchEvent.get()))); 3714 eventResult = mergeEventResult(eventResult, toWebInputEventResult(to uchEventTarget->dispatchEvent(touchEvent.get())));
3715 } 3715 }
3716 } 3716 }
3717 3717
3718 return eventResult; 3718 return eventResult;
3719 } 3719 }
3720 3720
3721 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) 3721 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt)
3722 { 3722 {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3821 m_touchSequenceUserGestureToken.clear(); 3821 m_touchSequenceUserGestureToken.clear();
3822 } 3822 }
3823 return WebInputEventResult::NotHandled; 3823 return WebInputEventResult::NotHandled;
3824 } 3824 }
3825 3825
3826 // Compute and store the common info used by both PointerEvent and TouchEven t. 3826 // Compute and store the common info used by both PointerEvent and TouchEven t.
3827 WillBeHeapVector<TouchInfo> touchInfos(points.size()); 3827 WillBeHeapVector<TouchInfo> touchInfos(points.size());
3828 3828
3829 for (unsigned i = 0; i < points.size(); ++i) { 3829 for (unsigned i = 0; i < points.size(); ++i) {
3830 const PlatformTouchPoint& point = points[i]; 3830 const PlatformTouchPoint& point = points[i];
3831 PlatformTouchPoint::State pointState = point.state(); 3831 PlatformTouchPoint::TouchState pointState = point.state();
3832 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr; 3832 RefPtrWillBeRawPtr<EventTarget> touchTarget = nullptr;
3833 3833
3834 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla tformTouchPoint::TouchCancelled) { 3834 if (pointState == PlatformTouchPoint::TouchReleased || pointState == Pla tformTouchPoint::TouchCancelled) {
3835 // The target should be the original target for this touch, so get 3835 // The target should be the original target for this touch, so get
3836 // it from the hashmap. As it's a release or cancel we also remove 3836 // it from the hashmap. As it's a release or cancel we also remove
3837 // it from the map. 3837 // it from the map.
3838 touchTarget = m_targetForTouchID.take(point.id()); 3838 touchTarget = m_targetForTouchID.take(point.id());
3839 } else { 3839 } else {
3840 // No hittest is performed on move or stationary, since the target 3840 // No hittest is performed on move or stationary, since the target
3841 // is not allowed to change anyway. 3841 // is not allowed to change anyway.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
3966 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 3966 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
3967 { 3967 {
3968 #if OS(MACOSX) 3968 #if OS(MACOSX)
3969 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 3969 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
3970 #else 3970 #else
3971 return PlatformEvent::AltKey; 3971 return PlatformEvent::AltKey;
3972 #endif 3972 #endif
3973 } 3973 }
3974 3974
3975 } // namespace blink 3975 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.h ('k') | third_party/WebKit/Source/core/input/PointerEventManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698