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

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

Issue 1425053002: Fire pointermoves for mousemove events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweaked the tests. Created 5 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
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 namespace blink { 102 namespace blink {
103 103
104 namespace { 104 namespace {
105 105
106 bool isNodeInDocument(Node* n) 106 bool isNodeInDocument(Node* n)
107 { 107 {
108 return n && n->inDocument(); 108 return n && n->inDocument();
109 } 109 }
110 110
111 const AtomicString& touchEventNameForTouchPointState(PlatformTouchPoint::State s tate)
112 {
113 switch (state) {
114 case PlatformTouchPoint::TouchReleased:
115 return EventTypeNames::touchend;
116 case PlatformTouchPoint::TouchCancelled:
117 return EventTypeNames::touchcancel;
118 case PlatformTouchPoint::TouchPressed:
119 return EventTypeNames::touchstart;
120 case PlatformTouchPoint::TouchMoved:
121 return EventTypeNames::touchmove;
122 case PlatformTouchPoint::TouchStationary:
123 // Fall through to default
124 default:
125 ASSERT_NOT_REACHED();
126 return emptyAtom;
127 }
111 } 128 }
112 129
130 const AtomicString& pointerEventNameForTouchPointState(PlatformTouchPoint::State state)
131 {
132 switch (state) {
133 case PlatformTouchPoint::TouchReleased:
134 return EventTypeNames::pointerup;
135 case PlatformTouchPoint::TouchCancelled:
136 return EventTypeNames::pointercancel;
137 case PlatformTouchPoint::TouchPressed:
138 return EventTypeNames::pointerdown;
139 case PlatformTouchPoint::TouchMoved:
140 return EventTypeNames::pointermove;
141 case PlatformTouchPoint::TouchStationary:
142 // Fall through to default
143 default:
144 ASSERT_NOT_REACHED();
145 return emptyAtom;
146 }
147 }
148
149 const AtomicString& pointerEventNameForMouseEventName(const AtomicString& mouseE ventName)
150 {
151 #define RETURN_CORRESPONDING_PE_NAME(eventSuffix) \
152 if (mouseEventName == EventTypeNames::mouse##eventSuffix) {\
153 return EventTypeNames::pointer##eventSuffix;\
154 }
155
156 RETURN_CORRESPONDING_PE_NAME(down);
157 RETURN_CORRESPONDING_PE_NAME(enter);
158 RETURN_CORRESPONDING_PE_NAME(leave);
159 RETURN_CORRESPONDING_PE_NAME(move);
160 RETURN_CORRESPONDING_PE_NAME(out);
161 RETURN_CORRESPONDING_PE_NAME(over);
162 RETURN_CORRESPONDING_PE_NAME(up);
163
164 #undef RETURN_CORRESPONDING_PE_NAME
165
166 ASSERT_NOT_REACHED();
167 return emptyAtom;
168 }
169
170 } // namespace
171
113 using namespace HTMLNames; 172 using namespace HTMLNames;
114 173
115 // The link drag hysteresis is much larger than the others because there 174 // The link drag hysteresis is much larger than the others because there
116 // needs to be enough space to cancel the link press without starting a link dra g, 175 // needs to be enough space to cancel the link press without starting a link dra g,
117 // and because dragging links is rare. 176 // and because dragging links is rare.
118 static const int LinkDragHysteresis = 40; 177 static const int LinkDragHysteresis = 40;
119 static const int ImageDragHysteresis = 5; 178 static const int ImageDragHysteresis = 5;
120 static const int TextDragHysteresis = 3; 179 static const int TextDragHysteresis = 3;
121 static const int GeneralDragHysteresis = 3; 180 static const int GeneralDragHysteresis = 3;
122 181
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 m_resizeScrollableArea = layer->scrollableArea(); 1023 m_resizeScrollableArea = layer->scrollableArea();
965 m_resizeScrollableArea->setInResizeMode(true); 1024 m_resizeScrollableArea->setInResizeMode(true);
966 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p)); 1025 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset FromResizeCorner(p));
967 invalidateClick(); 1026 invalidateClick();
968 return true; 1027 return true;
969 } 1028 }
970 } 1029 }
971 1030
972 m_frame->selection().setCaretBlinkingSuspended(true); 1031 m_frame->selection().setCaretBlinkingSuspended(true);
973 1032
974 bool swallowEvent = dispatchPointerEventForMouseEvent(mev.innerNode(), Event TypeNames::pointerdown, mouseEvent); 1033 bool swallowEvent = dispatchPointerAndMouseEvent(EventTypeNames::mousedown, mev.innerNode(), m_clickCount, mouseEvent);
975
976 if (swallowEvent) {
977 m_preventMouseEventForPointerTypeMouse = true;
978 }
979 if (!m_preventMouseEventForPointerTypeMouse)
980 swallowEvent = swallowEvent || !dispatchMouseEvent(EventTypeNames::mouse down, mev.innerNode(), m_clickCount, mouseEvent);
981 1034
982 // m_selectionInitiationState is initialized after dispatching mousedown 1035 // m_selectionInitiationState is initialized after dispatching mousedown
983 // event in order not to keep the selection by DOM APIs Because we can't 1036 // event in order not to keep the selection by DOM APIs Because we can't
984 // give the user the chance to handle the selection by user action like 1037 // give the user the chance to handle the selection by user action like
985 // dragging if we keep the selection in case of mousedown. FireFox also has 1038 // dragging if we keep the selection in case of mousedown. FireFox also has
986 // the same behavior and it's more compatible with other browsers. 1039 // the same behavior and it's more compatible with other browsers.
987 selectionController().initializeSelectionState(); 1040 selectionController().initializeSelectionState();
988 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly); 1041 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly);
989 InputDeviceCapabilities* sourceCapabilities = mouseEvent.syntheticEventType( ) == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEventsSo urceCapabilities() : 1042 InputDeviceCapabilities* sourceCapabilities = mouseEvent.syntheticEventType( ) == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEventsSo urceCapabilities() :
990 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); 1043 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 m_cursorUpdateTimer.stop(); 1157 m_cursorUpdateTimer.stop();
1105 1158
1106 cancelFakeMouseMoveEvent(); 1159 cancelFakeMouseMoveEvent();
1107 1160
1108 if (m_svgPan) { 1161 if (m_svgPan) {
1109 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro otFrameToContents(m_lastKnownMousePosition)); 1162 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro otFrameToContents(m_lastKnownMousePosition));
1110 return true; 1163 return true;
1111 } 1164 }
1112 1165
1113 if (m_frameSetBeingResized) 1166 if (m_frameSetBeingResized)
1114 return !dispatchMouseEvent(EventTypeNames::mousemove, m_frameSetBeingRes ized.get(), 0, mouseEvent); 1167 return dispatchPointerAndMouseEvent(EventTypeNames::mousemove, m_frameSe tBeingResized.get(), 0, mouseEvent);
1115 1168
1116 // Send events right to a scrollbar if the mouse is pressed. 1169 // Send events right to a scrollbar if the mouse is pressed.
1117 if (m_lastScrollbarUnderMouse && m_mousePressed) { 1170 if (m_lastScrollbarUnderMouse && m_mousePressed) {
1118 m_lastScrollbarUnderMouse->mouseMoved(mouseEvent); 1171 m_lastScrollbarUnderMouse->mouseMoved(mouseEvent);
1119 return true; 1172 return true;
1120 } 1173 }
1121 1174
1122 // Mouse events simulated from touch should not hit-test again. 1175 // Mouse events simulated from touch should not hit-test again.
1123 ASSERT(!mouseEvent.fromTouch()); 1176 ASSERT(!mouseEvent.fromTouch());
1124 1177
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 view->setCursor(optionalCursor.cursor()); 1239 view->setCursor(optionalCursor.cursor());
1187 } 1240 }
1188 } 1241 }
1189 } 1242 }
1190 1243
1191 m_lastMouseMoveEventSubframe = newSubframe; 1244 m_lastMouseMoveEventSubframe = newSubframe;
1192 1245
1193 if (swallowEvent) 1246 if (swallowEvent)
1194 return true; 1247 return true;
1195 1248
1196 swallowEvent = !dispatchMouseEvent(EventTypeNames::mousemove, mev.innerNode( ), 0, mouseEvent); 1249 swallowEvent = dispatchPointerAndMouseEvent(EventTypeNames::mousemove, mev.i nnerNode(), 0, mouseEvent);
1250
1197 if (!swallowEvent) 1251 if (!swallowEvent)
1198 swallowEvent = handleMouseDraggedEvent(mev); 1252 swallowEvent = handleMouseDraggedEvent(mev);
1199 1253
1200 return swallowEvent; 1254 return swallowEvent;
1201 } 1255 }
1202 1256
1203 void EventHandler::invalidateClick() 1257 void EventHandler::invalidateClick()
1204 { 1258 {
1205 m_clickCount = 0; 1259 m_clickCount = 0;
1206 m_clickNode = nullptr; 1260 m_clickNode = nullptr;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 m_mousePressed = false; 1293 m_mousePressed = false;
1240 setLastKnownMousePosition(mouseEvent); 1294 setLastKnownMousePosition(mouseEvent);
1241 1295
1242 if (m_svgPan) { 1296 if (m_svgPan) {
1243 m_svgPan = false; 1297 m_svgPan = false;
1244 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro otFrameToContents(m_lastKnownMousePosition)); 1298 m_frame->document()->accessSVGExtensions().updatePan(m_frame->view()->ro otFrameToContents(m_lastKnownMousePosition));
1245 return true; 1299 return true;
1246 } 1300 }
1247 1301
1248 if (m_frameSetBeingResized) 1302 if (m_frameSetBeingResized)
1249 return !dispatchMouseEvent(EventTypeNames::mouseup, m_frameSetBeingResiz ed.get(), m_clickCount, mouseEvent); 1303 return dispatchMouseEvent(EventTypeNames::mouseup, m_frameSetBeingResize d.get(), m_clickCount, mouseEvent);
1250 1304
1251 if (m_lastScrollbarUnderMouse) { 1305 if (m_lastScrollbarUnderMouse) {
1252 invalidateClick(); 1306 invalidateClick();
1253 m_lastScrollbarUnderMouse->mouseUp(mouseEvent); 1307 m_lastScrollbarUnderMouse->mouseUp(mouseEvent);
1254 return !dispatchMouseEvent(EventTypeNames::mouseup, m_nodeUnderMouse.get (), m_clickCount, mouseEvent); 1308 return dispatchMouseEvent(EventTypeNames::mouseup, m_nodeUnderMouse.get( ), m_clickCount, mouseEvent);
1255 } 1309 }
1256 1310
1257 // Mouse events simulated from touch should not hit-test again. 1311 // Mouse events simulated from touch should not hit-test again.
1258 ASSERT(!mouseEvent.fromTouch()); 1312 ASSERT(!mouseEvent.fromTouch());
1259 1313
1260 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release; 1314 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release;
1261 HitTestRequest request(hitType); 1315 HitTestRequest request(hitType);
1262 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); 1316 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent);
1263 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); 1317 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev);
1264 if (m_eventHandlerWillResetCapturingMouseEventsNode) 1318 if (m_eventHandlerWillResetCapturingMouseEventsNode)
1265 m_capturingMouseEventsNode = nullptr; 1319 m_capturingMouseEventsNode = nullptr;
1266 if (subframe && passMouseReleaseEventToSubframe(mev, subframe)) 1320 if (subframe && passMouseReleaseEventToSubframe(mev, subframe))
1267 return true; 1321 return true;
1268 1322
1269 bool swallowPointerUpEvent = dispatchPointerEventForMouseEvent(mev.innerNode (), EventTypeNames::pointerup, mouseEvent); 1323 bool swallowUpEvent = dispatchPointerAndMouseEvent(EventTypeNames::mouseup, mev.innerNode(), m_clickCount, mouseEvent);
1270 bool swallowMouseUpEvent = false; 1324
1271 if (!m_preventMouseEventForPointerTypeMouse) { 1325 // TODO(crbug/545647): This state should reset with pointercancel too.
1272 swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, mev.i nnerNode(), m_clickCount, mouseEvent); 1326 m_preventMouseEventForPointerTypeMouse = false;
1273 } else {
1274 // TODO(crbug/545647): This state should reset with pointercancel too.
1275 m_preventMouseEventForPointerTypeMouse = false;
1276 }
1277 1327
1278 bool contextMenuEvent = mouseEvent.button() == RightButton; 1328 bool contextMenuEvent = mouseEvent.button() == RightButton;
1279 #if OS(MACOSX) 1329 #if OS(MACOSX)
1280 // 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. 1330 // 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.
1281 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv ent::CtrlKey) 1331 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv ent::CtrlKey)
1282 contextMenuEvent = true; 1332 contextMenuEvent = true;
1283 #endif 1333 #endif
1284 1334
1285 bool swallowClickEvent = false; 1335 bool swallowClickEvent = false;
1286 if (m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode && mev.innerNode()->canParticipateInComposedTree() && m_clickNode->canParticipat eInComposedTree()) { 1336 if (m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode && mev.innerNode()->canParticipateInComposedTree() && m_clickNode->canParticipat eInComposedTree()) {
(...skipping 14 matching lines...) Expand all
1301 EventTypeNames::click, m_clickCount); 1351 EventTypeNames::click, m_clickCount);
1302 } 1352 }
1303 } 1353 }
1304 1354
1305 if (m_resizeScrollableArea) { 1355 if (m_resizeScrollableArea) {
1306 m_resizeScrollableArea->setInResizeMode(false); 1356 m_resizeScrollableArea->setInResizeMode(false);
1307 m_resizeScrollableArea = nullptr; 1357 m_resizeScrollableArea = nullptr;
1308 } 1358 }
1309 1359
1310 bool swallowMouseReleaseEvent = false; 1360 bool swallowMouseReleaseEvent = false;
1311 if (!swallowPointerUpEvent && !swallowMouseUpEvent) 1361 if (!swallowUpEvent)
1312 swallowMouseReleaseEvent = handleMouseReleaseEvent(mev); 1362 swallowMouseReleaseEvent = handleMouseReleaseEvent(mev);
1313 1363
1314 invalidateClick(); 1364 invalidateClick();
1315 1365
1316 return swallowPointerUpEvent || swallowMouseUpEvent || swallowClickEvent || swallowMouseReleaseEvent; 1366 return swallowUpEvent || swallowClickEvent || swallowMouseReleaseEvent;
1317 } 1367 }
1318 1368
1319 bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTa rget, const PlatformMouseEvent& event, DataTransfer* dataTransfer) 1369 bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTa rget, const PlatformMouseEvent& event, DataTransfer* dataTransfer)
1320 { 1370 {
1321 FrameView* view = m_frame->view(); 1371 FrameView* view = m_frame->view();
1322 1372
1323 // FIXME: We might want to dispatch a dragleave even if the view is gone. 1373 // FIXME: We might want to dispatch a dragleave even if the view is gone.
1324 if (!view) 1374 if (!view)
1325 return false; 1375 return false;
1326 1376
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 for (size_t i = enteredAncestorIndex; i > 0; i--) { 1720 for (size_t i = enteredAncestorIndex; i > 0; i--) {
1671 if (enteredNodeHasCapturingAncestor || enteredAncestors[i-1]->hasEventLi steners(EventTypeNames::pointerenter)) { 1721 if (enteredNodeHasCapturingAncestor || enteredAncestors[i-1]->hasEventLi steners(EventTypeNames::pointerenter)) {
1672 dispatchPointerEventForMouseEvent(enteredAncestors[i-1].get(), Event TypeNames::pointerenter, mouseEvent, 1722 dispatchPointerEventForMouseEvent(enteredAncestors[i-1].get(), Event TypeNames::pointerenter, mouseEvent,
1673 exitedNode); 1723 exitedNode);
1674 } 1724 }
1675 if (enteredNodeHasCapturingAncestor || enteredAncestors[i-1]->hasEventLi steners(EventTypeNames::mouseenter)) 1725 if (enteredNodeHasCapturingAncestor || enteredAncestors[i-1]->hasEventLi steners(EventTypeNames::mouseenter))
1676 enteredAncestors[i-1]->dispatchMouseEvent(mouseEvent, EventTypeNames ::mouseenter, 0, exitedNode); 1726 enteredAncestors[i-1]->dispatchMouseEvent(mouseEvent, EventTypeNames ::mouseenter, 0, exitedNode);
1677 } 1727 }
1678 } 1728 }
1679 1729
1680 // The return value means 'continue default handling.'
1681 bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe tNode, int clickCount, const PlatformMouseEvent& mouseEvent) 1730 bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe tNode, int clickCount, const PlatformMouseEvent& mouseEvent)
Rick Byers 2015/10/30 17:21:29 So the pattern you're going for is that all EventH
mustaq 2015/11/03 20:44:30 Done. You are right: dispatchDragSrcEvent is the o
1682 { 1731 {
1683 updateMouseEventTargetNode(targetNode, mouseEvent); 1732 updateMouseEventTargetNode(targetNode, mouseEvent);
1684 return !m_nodeUnderMouse || m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, eventType, clickCount); 1733 return m_nodeUnderMouse && !m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, eventType, clickCount);
1685 } 1734 }
1686 1735
1687 // The return value means 'swallow event' (was handled), as for other handle* fu nctions. 1736 bool EventHandler::dispatchPointerAndMouseEvent(const AtomicString& mouseEventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent)
Rick Byers 2015/10/30 17:21:29 In the spirit of working towards pulling all mouse
mustaq 2015/11/03 20:44:30 I think the confusion is caused by the similar loo
Rick Byers 2015/11/03 20:59:56 I'd still like to untangle the mouse event support
mustaq 2015/11/03 21:37:34 Yes, your PE-driving-ME-dispatch suggestion made p
1737 {
1738 ASSERT(mouseEventType == EventTypeNames::mousedown
1739 || mouseEventType == EventTypeNames::mousemove
1740 || mouseEventType == EventTypeNames::mouseup);
1741
1742 updateMouseEventTargetNode(targetNode, mouseEvent);
1743 if (!m_nodeUnderMouse)
1744 return false;
1745
1746 bool swallowEvent = dispatchPointerEventForMouseEvent(m_nodeUnderMouse.get() ,
1747 pointerEventNameForMouseEventName(mouseEventType),
1748 mouseEvent);
1749
1750 if (swallowEvent && mouseEventType == EventTypeNames::mousedown) {
1751 m_preventMouseEventForPointerTypeMouse = true;
1752 }
1753
1754 if (!m_preventMouseEventForPointerTypeMouse) {
1755 swallowEvent |= !m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, mouseE ventType, clickCount);
1756 }
1757
1758 return swallowEvent;
1759 }
1760
1688 bool EventHandler::handleMouseFocus(const MouseEventWithHitTestResults& targeted Event, InputDeviceCapabilities* sourceCapabilities) 1761 bool EventHandler::handleMouseFocus(const MouseEventWithHitTestResults& targeted Event, InputDeviceCapabilities* sourceCapabilities)
1689 { 1762 {
1690 // If clicking on a frame scrollbar, do not mess up with content focus. 1763 // If clicking on a frame scrollbar, do not mess up with content focus.
1691 if (targetedEvent.hitTestResult().scrollbar() && m_frame->contentLayoutObjec t()) { 1764 if (targetedEvent.hitTestResult().scrollbar() && m_frame->contentLayoutObjec t()) {
1692 if (targetedEvent.hitTestResult().scrollbar()->scrollableArea() == m_fra me->contentLayoutObject()->scrollableArea()) 1765 if (targetedEvent.hitTestResult().scrollbar()->scrollableArea() == m_fra me->contentLayoutObject()->scrollableArea())
1693 return false; 1766 return false;
1694 } 1767 }
1695 1768
1696 // The layout needs to be up to date to determine if an element is focusable . 1769 // The layout needs to be up to date to determine if an element is focusable .
1697 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 1770 m_frame->document()->updateLayoutIgnorePendingStylesheets();
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 RefPtrWillBeRawPtr<Node> tappedNode = m_clickNode; 2192 RefPtrWillBeRawPtr<Node> tappedNode = m_clickNode;
2120 IntPoint tappedPosition = gestureEvent.position(); 2193 IntPoint tappedPosition = gestureEvent.position();
2121 2194
2122 if (m_clickNode && m_clickNode->isTextNode()) 2195 if (m_clickNode && m_clickNode->isTextNode())
2123 m_clickNode = ComposedTreeTraversal::parent(*m_clickNode); 2196 m_clickNode = ComposedTreeTraversal::parent(*m_clickNode);
2124 2197
2125 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa lPosition(), 2198 PlatformMouseEvent fakeMouseDown(gestureEvent.position(), gestureEvent.globa lPosition(),
2126 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(), 2199 LeftButton, PlatformEvent::MousePressed, gestureEvent.tapCount(),
2127 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown), 2200 static_cast<PlatformEvent::Modifiers>(modifiers | PlatformEvent::LeftBut tonDown),
2128 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); 2201 PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
2129 bool swallowMouseDownEvent = !dispatchMouseEvent(EventTypeNames::mousedown, currentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown); 2202 bool swallowMouseDownEvent = dispatchMouseEvent(EventTypeNames::mousedown, c urrentHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseDown);
2130 selectionController().initializeSelectionState(); 2203 selectionController().initializeSelectionState();
2131 if (!swallowMouseDownEvent) 2204 if (!swallowMouseDownEvent)
2132 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa keMouseDown, currentHitTest), InputDeviceCapabilities::firesTouchEventsSourceCap abilities()); 2205 swallowMouseDownEvent = handleMouseFocus(MouseEventWithHitTestResults(fa keMouseDown, currentHitTest), InputDeviceCapabilities::firesTouchEventsSourceCap abilities());
2133 if (!swallowMouseDownEvent) 2206 if (!swallowMouseDownEvent)
2134 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul ts(fakeMouseDown, currentHitTest)); 2207 swallowMouseDownEvent = handleMousePressEvent(MouseEventWithHitTestResul ts(fakeMouseDown, currentHitTest));
2135 2208
2136 if (currentHitTest.innerNode()) { 2209 if (currentHitTest.innerNode()) {
2137 ASSERT(gestureEvent.type() == PlatformEvent::GestureTap); 2210 ASSERT(gestureEvent.type() == PlatformEvent::GestureTap);
2138 HitTestResult result = currentHitTest; 2211 HitTestResult result = currentHitTest;
2139 result.setToShadowHostIfInUserAgentShadowRoot(); 2212 result.setToShadowHostIfInUserAgentShadowRoot();
2140 m_frame->chromeClient().onMouseDown(result.innerNode()); 2213 m_frame->chromeClient().onMouseDown(result.innerNode());
2141 } 2214 }
2142 2215
2143 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920 2216 // FIXME: Use a hit-test cache to avoid unnecessary hit tests. http://crbug. com/398920
2144 if (currentHitTest.innerNode()) { 2217 if (currentHitTest.innerNode()) {
2145 LocalFrame* mainFrame = m_frame->localFrameRoot(); 2218 LocalFrame* mainFrame = m_frame->localFrameRoot();
2146 if (mainFrame && mainFrame->view()) 2219 if (mainFrame && mainFrame->view())
2147 mainFrame->view()->updateAllLifecyclePhases(); 2220 mainFrame->view()->updateAllLifecyclePhases();
2148 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position()); 2221 adjustedPoint = frameView->rootFrameToContents(gestureEvent.position());
2149 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType); 2222 currentHitTest = hitTestResultInFrame(m_frame, adjustedPoint, hitType);
2150 } 2223 }
2151 PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalP osition(), 2224 PlatformMouseEvent fakeMouseUp(gestureEvent.position(), gestureEvent.globalP osition(),
2152 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(), 2225 LeftButton, PlatformEvent::MouseReleased, gestureEvent.tapCount(),
2153 static_cast<PlatformEvent::Modifiers>(modifiers), 2226 static_cast<PlatformEvent::Modifiers>(modifiers),
2154 PlatformMouseEvent::FromTouch, gestureEvent.timestamp()); 2227 PlatformMouseEvent::FromTouch, gestureEvent.timestamp());
2155 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, curr entHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp); 2228 bool swallowMouseUpEvent = dispatchMouseEvent(EventTypeNames::mouseup, curre ntHitTest.innerNode(), gestureEvent.tapCount(), fakeMouseUp);
2156 2229
2157 bool swallowClickEvent = false; 2230 bool swallowClickEvent = false;
2158 if (m_clickNode) { 2231 if (m_clickNode) {
2159 if (currentHitTest.innerNode()) { 2232 if (currentHitTest.innerNode()) {
2160 // Updates distribution because a mouseup (or mousedown) event liste ner can make the 2233 // Updates distribution because a mouseup (or mousedown) event liste ner can make the
2161 // tree dirty at dispatchMouseEvent() invocation above. 2234 // tree dirty at dispatchMouseEvent() invocation above.
2162 // Unless distribution is updated, commonAncestor would hit ASSERT. 2235 // Unless distribution is updated, commonAncestor would hit ASSERT.
2163 // Both m_clickNode and currentHitTest.innerNode()) don't need to be updated 2236 // Both m_clickNode and currentHitTest.innerNode()) don't need to be updated
2164 // because commonAncestor() will exit early if their documents are d ifferent. 2237 // because commonAncestor() will exit early if their documents are d ifferent.
2165 m_clickNode->updateDistribution(); 2238 m_clickNode->updateDistribution();
2166 Node* clickTargetNode = currentHitTest.innerNode()->commonAncestor(* m_clickNode, parentForClickEvent); 2239 Node* clickTargetNode = currentHitTest.innerNode()->commonAncestor(* m_clickNode, parentForClickEvent);
2167 swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, click TargetNode, gestureEvent.tapCount(), fakeMouseUp); 2240 swallowClickEvent = dispatchMouseEvent(EventTypeNames::click, clickT argetNode, gestureEvent.tapCount(), fakeMouseUp);
2168 } 2241 }
2169 m_clickNode = nullptr; 2242 m_clickNode = nullptr;
2170 } 2243 }
2171 2244
2172 if (!swallowMouseUpEvent) 2245 if (!swallowMouseUpEvent)
2173 swallowMouseUpEvent = handleMouseReleaseEvent(MouseEventWithHitTestResul ts(fakeMouseUp, currentHitTest)); 2246 swallowMouseUpEvent = handleMouseReleaseEvent(MouseEventWithHitTestResul ts(fakeMouseUp, currentHitTest));
2174 2247
2175 bool swallowed = swallowMouseDownEvent | swallowMouseUpEvent | swallowClickE vent; 2248 bool swallowed = swallowMouseDownEvent | swallowMouseUpEvent | swallowClickE vent;
2176 if (!swallowed && tappedNode && m_frame->page()) { 2249 if (!swallowed && tappedNode && m_frame->page()) {
2177 bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()-> domTreeVersion(); 2250 bool domTreeChanged = preDispatchDomTreeVersion != m_frame->document()-> domTreeVersion();
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2804 2877
2805 // Clear mouse press state to avoid initiating a drag while context menu is up. 2878 // Clear mouse press state to avoid initiating a drag while context menu is up.
2806 m_mousePressed = false; 2879 m_mousePressed = false;
2807 LayoutPoint positionInContents = v->rootFrameToContents(event.position()); 2880 LayoutPoint positionInContents = v->rootFrameToContents(event.position());
2808 HitTestRequest request(HitTestRequest::Active); 2881 HitTestRequest request(HitTestRequest::Active);
2809 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re quest, positionInContents, event); 2882 MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(re quest, positionInContents, event);
2810 2883
2811 selectionController().sendContextMenuEvent(mev, positionInContents); 2884 selectionController().sendContextMenuEvent(mev, positionInContents);
2812 2885
2813 Node* targetNode = overrideTargetNode ? overrideTargetNode : mev.innerNode() ; 2886 Node* targetNode = overrideTargetNode ? overrideTargetNode : mev.innerNode() ;
2814 return !dispatchMouseEvent(EventTypeNames::contextmenu, targetNode, 0, event ); 2887 return dispatchMouseEvent(EventTypeNames::contextmenu, targetNode, 0, event) ;
2815 } 2888 }
2816 2889
2817 bool EventHandler::sendContextMenuEventForKey(Element* overrideTargetElement) 2890 bool EventHandler::sendContextMenuEventForKey(Element* overrideTargetElement)
2818 { 2891 {
2819 FrameView* view = m_frame->view(); 2892 FrameView* view = m_frame->view();
2820 if (!view) 2893 if (!view)
2821 return false; 2894 return false;
2822 2895
2823 Document* doc = m_frame->document(); 2896 Document* doc = m_frame->document();
2824 if (!doc) 2897 if (!doc)
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
3547 m_lastScrollbarUnderMouse->mouseExited(); 3620 m_lastScrollbarUnderMouse->mouseExited();
3548 3621
3549 // Send mouse entered if we're setting a new scrollbar. 3622 // Send mouse entered if we're setting a new scrollbar.
3550 if (scrollbar && setLast) 3623 if (scrollbar && setLast)
3551 scrollbar->mouseEntered(); 3624 scrollbar->mouseEntered();
3552 3625
3553 m_lastScrollbarUnderMouse = setLast ? scrollbar : nullptr; 3626 m_lastScrollbarUnderMouse = setLast ? scrollbar : nullptr;
3554 } 3627 }
3555 } 3628 }
3556 3629
3557 static const AtomicString& touchEventNameForTouchPointState(PlatformTouchPoint:: State state)
3558 {
3559 switch (state) {
3560 case PlatformTouchPoint::TouchReleased:
3561 return EventTypeNames::touchend;
3562 case PlatformTouchPoint::TouchCancelled:
3563 return EventTypeNames::touchcancel;
3564 case PlatformTouchPoint::TouchPressed:
3565 return EventTypeNames::touchstart;
3566 case PlatformTouchPoint::TouchMoved:
3567 return EventTypeNames::touchmove;
3568 case PlatformTouchPoint::TouchStationary:
3569 // Fall through to default
3570 default:
3571 ASSERT_NOT_REACHED();
3572 return emptyAtom;
3573 }
3574 }
3575
3576 static const AtomicString& pointerEventNameForTouchPointState(PlatformTouchPoint ::State state)
3577 {
3578 switch (state) {
3579 case PlatformTouchPoint::TouchReleased:
3580 return EventTypeNames::pointerup;
3581 case PlatformTouchPoint::TouchCancelled:
3582 return EventTypeNames::pointercancel;
3583 case PlatformTouchPoint::TouchPressed:
3584 return EventTypeNames::pointerdown;
3585 case PlatformTouchPoint::TouchMoved:
3586 return EventTypeNames::pointermove;
3587 case PlatformTouchPoint::TouchStationary:
3588 // Fall through to default
3589 default:
3590 ASSERT_NOT_REACHED();
3591 return emptyAtom;
3592 }
3593 }
3594
3595 HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout Point& point, HitTestRequest::HitTestRequestType hitType) 3630 HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout Point& point, HitTestRequest::HitTestRequestType hitType)
3596 { 3631 {
3597 HitTestResult result(HitTestRequest(hitType), point); 3632 HitTestResult result(HitTestRequest(hitType), point);
3598 3633
3599 if (!frame || !frame->contentLayoutObject()) 3634 if (!frame || !frame->contentLayoutObject())
3600 return result; 3635 return result;
3601 if (frame->view()) { 3636 if (frame->view()) {
3602 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars); 3637 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars);
3603 if (!rect.contains(roundedIntPoint(point))) 3638 if (!rect.contains(roundedIntPoint(point)))
3604 return result; 3639 return result;
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
4034 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() 4069 PlatformEvent::Modifiers EventHandler::accessKeyModifiers()
4035 { 4070 {
4036 #if OS(MACOSX) 4071 #if OS(MACOSX)
4037 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey); 4072 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo rmEvent::AltKey);
4038 #else 4073 #else
4039 return PlatformEvent::AltKey; 4074 return PlatformEvent::AltKey;
4040 #endif 4075 #endif
4041 } 4076 }
4042 4077
4043 } // namespace blink 4078 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698