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

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

Issue 2255323004: Create MouseEventManager and EventHandlingUtil (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 4 years, 3 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "core/frame/FrameHost.h" 56 #include "core/frame/FrameHost.h"
57 #include "core/frame/FrameView.h" 57 #include "core/frame/FrameView.h"
58 #include "core/frame/LocalFrame.h" 58 #include "core/frame/LocalFrame.h"
59 #include "core/frame/Settings.h" 59 #include "core/frame/Settings.h"
60 #include "core/frame/UseCounter.h" 60 #include "core/frame/UseCounter.h"
61 #include "core/frame/VisualViewport.h" 61 #include "core/frame/VisualViewport.h"
62 #include "core/html/HTMLDialogElement.h" 62 #include "core/html/HTMLDialogElement.h"
63 #include "core/html/HTMLFrameElementBase.h" 63 #include "core/html/HTMLFrameElementBase.h"
64 #include "core/html/HTMLFrameSetElement.h" 64 #include "core/html/HTMLFrameSetElement.h"
65 #include "core/html/HTMLInputElement.h" 65 #include "core/html/HTMLInputElement.h"
66 #include "core/input/EventHandlingUtil.h"
66 #include "core/input/InputDeviceCapabilities.h" 67 #include "core/input/InputDeviceCapabilities.h"
67 #include "core/input/TouchActionUtil.h" 68 #include "core/input/TouchActionUtil.h"
68 #include "core/layout/HitTestRequest.h" 69 #include "core/layout/HitTestRequest.h"
69 #include "core/layout/HitTestResult.h" 70 #include "core/layout/HitTestResult.h"
70 #include "core/layout/LayoutPart.h" 71 #include "core/layout/LayoutPart.h"
71 #include "core/layout/LayoutTextControlSingleLine.h" 72 #include "core/layout/LayoutTextControlSingleLine.h"
72 #include "core/layout/LayoutView.h" 73 #include "core/layout/LayoutView.h"
73 #include "core/layout/api/LayoutViewItem.h" 74 #include "core/layout/api/LayoutViewItem.h"
74 #include "core/loader/DocumentLoader.h" 75 #include "core/loader/DocumentLoader.h"
75 #include "core/loader/FrameLoader.h" 76 #include "core/loader/FrameLoader.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 , m_hoverTimer(this, &EventHandler::hoverTimerFired) 185 , m_hoverTimer(this, &EventHandler::hoverTimerFired)
185 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired) 186 , m_cursorUpdateTimer(this, &EventHandler::cursorUpdateTimerFired)
186 , m_mouseDownMayStartAutoscroll(false) 187 , m_mouseDownMayStartAutoscroll(false)
187 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d) 188 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire d)
188 , m_svgPan(false) 189 , m_svgPan(false)
189 , m_eventHandlerWillResetCapturingMouseEventsNode(0) 190 , m_eventHandlerWillResetCapturingMouseEventsNode(0)
190 , m_clickCount(0) 191 , m_clickCount(0)
191 , m_shouldOnlyFireDragOverEvent(false) 192 , m_shouldOnlyFireDragOverEvent(false)
192 , m_mousePositionIsUnknown(true) 193 , m_mousePositionIsUnknown(true)
193 , m_mouseDownTimestamp(0) 194 , m_mouseDownTimestamp(0)
194 , m_pointerEventManager(frame)
195 , m_scrollManager(frame) 195 , m_scrollManager(frame)
196 , m_mouseEventManager(frame)
196 , m_keyboardEventManager(frame, &m_scrollManager) 197 , m_keyboardEventManager(frame, &m_scrollManager)
198 , m_pointerEventManager(frame, &m_mouseEventManager)
197 , m_gestureManager(frame, &m_scrollManager, &m_pointerEventManager, m_select ionController) 199 , m_gestureManager(frame, &m_scrollManager, &m_pointerEventManager, m_select ionController)
198 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) 200 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired)
199 { 201 {
200 } 202 }
201 203
202 EventHandler::~EventHandler() 204 EventHandler::~EventHandler()
203 { 205 {
204 ASSERT(!m_fakeMouseMoveEventTimer.isActive()); 206 ASSERT(!m_fakeMouseMoveEventTimer.isActive());
205 } 207 }
206 208
207 DEFINE_TRACE(EventHandler) 209 DEFINE_TRACE(EventHandler)
208 { 210 {
209 visitor->trace(m_frame); 211 visitor->trace(m_frame);
210 visitor->trace(m_mousePressNode); 212 visitor->trace(m_mousePressNode);
211 visitor->trace(m_capturingMouseEventsNode); 213 visitor->trace(m_capturingMouseEventsNode);
212 visitor->trace(m_nodeUnderMouse); 214 visitor->trace(m_nodeUnderMouse);
213 visitor->trace(m_lastMouseMoveEventSubframe); 215 visitor->trace(m_lastMouseMoveEventSubframe);
214 visitor->trace(m_lastScrollbarUnderMouse); 216 visitor->trace(m_lastScrollbarUnderMouse);
215 visitor->trace(m_clickNode); 217 visitor->trace(m_clickNode);
216 visitor->trace(m_dragTarget); 218 visitor->trace(m_dragTarget);
217 visitor->trace(m_frameSetBeingResized); 219 visitor->trace(m_frameSetBeingResized);
218 visitor->trace(m_lastDeferredTapElement); 220 visitor->trace(m_lastDeferredTapElement);
219 visitor->trace(m_selectionController); 221 visitor->trace(m_selectionController);
220 visitor->trace(m_pointerEventManager); 222 visitor->trace(m_pointerEventManager);
221 visitor->trace(m_scrollManager); 223 visitor->trace(m_scrollManager);
222 visitor->trace(m_keyboardEventManager); 224 visitor->trace(m_keyboardEventManager);
223 visitor->trace(m_gestureManager); 225 visitor->trace(m_gestureManager);
226 visitor->trace(m_mouseEventManager);
dtapuska 2016/09/02 03:26:27 The trace should probably happen the order of the
Navid Zolghadr 2016/09/02 16:36:45 Done.
224 } 227 }
225 228
226 DragState& EventHandler::dragState() 229 DragState& EventHandler::dragState()
227 { 230 {
228 DEFINE_STATIC_LOCAL(DragState, state, (new DragState)); 231 DEFINE_STATIC_LOCAL(DragState, state, (new DragState));
229 return state; 232 return state;
230 } 233 }
231 234
232 void EventHandler::clear() 235 void EventHandler::clear()
233 { 236 {
(...skipping 13 matching lines...) Expand all
247 m_lastKnownMousePosition = IntPoint(); 250 m_lastKnownMousePosition = IntPoint();
248 m_lastKnownMouseGlobalPosition = IntPoint(); 251 m_lastKnownMouseGlobalPosition = IntPoint();
249 m_lastMouseDownUserGestureToken.clear(); 252 m_lastMouseDownUserGestureToken.clear();
250 m_mousePressNode = nullptr; 253 m_mousePressNode = nullptr;
251 m_mousePressed = false; 254 m_mousePressed = false;
252 m_capturesDragging = false; 255 m_capturesDragging = false;
253 m_capturingMouseEventsNode = nullptr; 256 m_capturingMouseEventsNode = nullptr;
254 m_pointerEventManager.clear(); 257 m_pointerEventManager.clear();
255 m_scrollManager.clear(); 258 m_scrollManager.clear();
256 m_gestureManager.clear(); 259 m_gestureManager.clear();
260 m_mouseEventManager.clear();
257 m_mouseDownMayStartDrag = false; 261 m_mouseDownMayStartDrag = false;
258 m_lastDeferredTapElement = nullptr; 262 m_lastDeferredTapElement = nullptr;
259 m_eventHandlerWillResetCapturingMouseEventsNode = false; 263 m_eventHandlerWillResetCapturingMouseEventsNode = false;
260 m_mouseDownMayStartAutoscroll = false; 264 m_mouseDownMayStartAutoscroll = false;
261 m_svgPan = false; 265 m_svgPan = false;
262 m_mouseDownPos = IntPoint(); 266 m_mouseDownPos = IntPoint();
263 m_mouseDownTimestamp = 0; 267 m_mouseDownTimestamp = 0;
264 m_dragStartPos = LayoutPoint(); 268 m_dragStartPos = LayoutPoint();
265 m_mouseDown = PlatformMouseEvent(); 269 m_mouseDown = PlatformMouseEvent();
266 } 270 }
267 271
268 WebInputEventResult EventHandler::mergeEventResult(
269 WebInputEventResult resultA, WebInputEventResult resultB)
270 {
271 // The ordering of the enumeration is specific. There are times that
272 // multiple events fire and we need to combine them into a single
273 // result code. The enumeration is based on the level of consumption that
274 // is most significant. The enumeration is ordered with smaller specified
275 // numbers first. Examples of merged results are:
276 // (HandledApplication, HandledSystem) -> HandledSystem
277 // (NotHandled, HandledApplication) -> HandledApplication
278 static_assert(static_cast<int>(WebInputEventResult::NotHandled) == 0, "WebIn putEventResult not ordered");
279 static_assert(static_cast<int>(WebInputEventResult::HandledSuppressed) < sta tic_cast<int>(WebInputEventResult::HandledApplication), "WebInputEventResult not ordered");
280 static_assert(static_cast<int>(WebInputEventResult::HandledApplication) < st atic_cast<int>(WebInputEventResult::HandledSystem), "WebInputEventResult not ord ered");
281 return static_cast<WebInputEventResult>(max(static_cast<int>(resultA), stati c_cast<int>(resultB)));
282 }
283
284 WebInputEventResult EventHandler::toWebInputEventResult(
285 DispatchEventResult result)
286 {
287 switch (result) {
288 case DispatchEventResult::NotCanceled:
289 return WebInputEventResult::NotHandled;
290 case DispatchEventResult::CanceledByEventHandler:
291 return WebInputEventResult::HandledApplication;
292 case DispatchEventResult::CanceledByDefaultEventHandler:
293 return WebInputEventResult::HandledSystem;
294 case DispatchEventResult::CanceledBeforeDispatch:
295 return WebInputEventResult::HandledSuppressed;
296 default:
297 ASSERT_NOT_REACHED();
298 return WebInputEventResult::HandledSystem;
299 }
300 }
301
302 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved) 272 void EventHandler::nodeWillBeRemoved(Node& nodeToBeRemoved)
303 { 273 {
304 if (nodeToBeRemoved.isShadowIncludingInclusiveAncestorOf(m_clickNode.get())) { 274 if (nodeToBeRemoved.isShadowIncludingInclusiveAncestorOf(m_clickNode.get())) {
305 // We don't dispatch click events if the mousedown node is removed 275 // We don't dispatch click events if the mousedown node is removed
306 // before a mouseup event. It is compatible with IE and Firefox. 276 // before a mouseup event. It is compatible with IE and Firefox.
307 m_clickNode = nullptr; 277 m_clickNode = nullptr;
308 } 278 }
309 } 279 }
310 280
311 WebInputEventResult EventHandler::handleMousePressEvent(const MouseEventWithHitT estResults& event) 281 WebInputEventResult EventHandler::handleMousePressEvent(const MouseEventWithHitT estResults& event)
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 return WebInputEventResult::HandledSystem; 831 return WebInputEventResult::HandledSystem;
862 } 832 }
863 } 833 }
864 834
865 // m_selectionInitiationState is initialized after dispatching mousedown 835 // m_selectionInitiationState is initialized after dispatching mousedown
866 // event in order not to keep the selection by DOM APIs because we can't 836 // event in order not to keep the selection by DOM APIs because we can't
867 // give the user the chance to handle the selection by user action like 837 // give the user the chance to handle the selection by user action like
868 // dragging if we keep the selection in case of mousedown. FireFox also has 838 // dragging if we keep the selection in case of mousedown. FireFox also has
869 // the same behavior and it's more compatible with other browsers. 839 // the same behavior and it's more compatible with other browsers.
870 selectionController().initializeSelectionState(); 840 selectionController().initializeSelectionState();
871 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly); 841 HitTestResult hitTestResult = EventHandlingUtil::hitTestResultInFrame(m_fram e, documentPoint, HitTestRequest::ReadOnly);
872 InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventTy pe() == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEvent sSourceCapabilities() : 842 InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventTy pe() == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEvent sSourceCapabilities() :
873 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); 843 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities();
874 if (eventResult == WebInputEventResult::NotHandled) 844 if (eventResult == WebInputEventResult::NotHandled)
875 eventResult = handleMouseFocus(hitTestResult, sourceCapabilities); 845 eventResult = handleMouseFocus(hitTestResult, sourceCapabilities);
876 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar(); 846 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar();
877 847
878 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults 848 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults
879 // in case the scrollbar widget was destroyed when the mouse event was handl ed. 849 // in case the scrollbar widget was destroyed when the mouse event was handl ed.
880 if (mev.scrollbar()) { 850 if (mev.scrollbar()) {
881 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); 851 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get();
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 ContainerNode* EventHandler::parentForClickEvent(const Node& node) 1056 ContainerNode* EventHandler::parentForClickEvent(const Node& node)
1087 { 1057 {
1088 // IE doesn't dispatch click events for mousedown/mouseup events across form 1058 // IE doesn't dispatch click events for mousedown/mouseup events across form
1089 // controls. 1059 // controls.
1090 if (node.isHTMLElement() && toHTMLElement(node).isInteractiveContent()) 1060 if (node.isHTMLElement() && toHTMLElement(node).isInteractiveContent())
1091 return nullptr; 1061 return nullptr;
1092 1062
1093 return FlatTreeTraversal::parent(node); 1063 return FlatTreeTraversal::parent(node);
1094 } 1064 }
1095 1065
1096 WebInputEventResult EventHandler::handleMouseReleaseEvent(const PlatformMouseEve nt& mouseEvent) 1066 WebInputEventResult EventHandler::handleMouseReleaseEvent(const PlatformMouseEve nt& mouseEvent)
mustaq 2016/08/30 21:49:23 This the only function that /needs/ the |m_clickCo
Navid Zolghadr 2016/08/31 14:23:47 I planned to do these in the next CL if you are ok
1097 { 1067 {
1098 TRACE_EVENT0("blink", "EventHandler::handleMouseReleaseEvent"); 1068 TRACE_EVENT0("blink", "EventHandler::handleMouseReleaseEvent");
1099 1069
1100 // For 4th/5th button in the mouse since Chrome does not yet send 1070 // For 4th/5th button in the mouse since Chrome does not yet send
1101 // button value to Blink but in some cases it does send the event. 1071 // button value to Blink but in some cases it does send the event.
1102 // This check is needed to suppress such an event (crbug.com/574959) 1072 // This check is needed to suppress such an event (crbug.com/574959)
1103 if (mouseEvent.pointerProperties().button == WebPointerProperties::Button::N oButton) 1073 if (mouseEvent.pointerProperties().button == WebPointerProperties::Button::N oButton)
1104 return WebInputEventResult::HandledSuppressed; 1074 return WebInputEventResult::HandledSuppressed;
1105 1075
1106 if (!mouseEvent.fromTouch()) 1076 if (!mouseEvent.fromTouch())
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 m_clickNode->updateDistribution(); 1149 m_clickNode->updateDistribution();
1180 mev.innerNode()->updateDistribution(); 1150 mev.innerNode()->updateDistribution();
1181 clickTargetNode = mev.innerNode()->commonAncestor( 1151 clickTargetNode = mev.innerNode()->commonAncestor(
1182 *m_clickNode, parentForClickEvent); 1152 *m_clickNode, parentForClickEvent);
1183 } 1153 }
1184 if (clickTargetNode) { 1154 if (clickTargetNode) {
1185 // Dispatch mouseup directly w/o calling updateMouseEventTargetNodeA ndSendEvents 1155 // Dispatch mouseup directly w/o calling updateMouseEventTargetNodeA ndSendEvents
1186 // because the mouseup dispatch above has already updated it 1156 // because the mouseup dispatch above has already updated it
1187 // correctly. Moreover, clickTargetNode is different from 1157 // correctly. Moreover, clickTargetNode is different from
1188 // mev.innerNode at drag-release. 1158 // mev.innerNode at drag-release.
1189 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMo useEvent(mev.event(), 1159 clickEventResult = EventHandlingUtil::toWebInputEventResult(
1160 clickTargetNode->dispatchMouseEvent(mev.event(),
1190 !RuntimeEnabledFeatures::auxclickEnabled() 1161 !RuntimeEnabledFeatures::auxclickEnabled()
1191 || (mev.event().pointerProperties().button == WebPointerProperti es::Button::Left) 1162 || (mev.event().pointerProperties().button == WebPointerProperti es::Button::Left)
1192 ? EventTypeNames::click 1163 ? EventTypeNames::click
1193 : EventTypeNames::auxclick, 1164 : EventTypeNames::auxclick,
1194 m_clickCount)); 1165 m_clickCount));
1195 } 1166 }
1196 } 1167 }
1197 1168
1198 m_scrollManager.clearResizeScrollableArea(false); 1169 m_scrollManager.clearResizeScrollableArea(false);
1199 1170
1200 if (eventResult == WebInputEventResult::NotHandled) 1171 if (eventResult == WebInputEventResult::NotHandled)
1201 eventResult = handleMouseReleaseEvent(mev); 1172 eventResult = handleMouseReleaseEvent(mev);
1202 clearDragHeuristicState(); 1173 clearDragHeuristicState();
1203 1174
1204 invalidateClick(); 1175 invalidateClick();
1205 1176
1206 return mergeEventResult(clickEventResult, eventResult); 1177 return EventHandlingUtil::mergeEventResult(clickEventResult, eventResult);
1207 } 1178 }
1208 1179
1209 WebInputEventResult EventHandler::dispatchDragEvent(const AtomicString& eventTyp e, Node* dragTarget, const PlatformMouseEvent& event, DataTransfer* dataTransfer ) 1180 WebInputEventResult EventHandler::dispatchDragEvent(const AtomicString& eventTyp e, Node* dragTarget, const PlatformMouseEvent& event, DataTransfer* dataTransfer )
1210 { 1181 {
1211 FrameView* view = m_frame->view(); 1182 FrameView* view = m_frame->view();
1212 1183
1213 // FIXME: We might want to dispatch a dragleave even if the view is gone. 1184 // FIXME: We might want to dispatch a dragleave even if the view is gone.
1214 if (!view) 1185 if (!view)
1215 return WebInputEventResult::NotHandled; 1186 return WebInputEventResult::NotHandled;
1216 1187
1217 DragEvent* me = DragEvent::create(eventType, 1188 DragEvent* me = DragEvent::create(eventType,
1218 true, true, m_frame->document()->domWindow(), 1189 true, true, m_frame->document()->domWindow(),
1219 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(), 1190 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(),
1220 event.movementDelta().x(), event.movementDelta().y(), 1191 event.movementDelta().x(), event.movementDelta().y(),
1221 event.getModifiers(), 1192 event.getModifiers(),
1222 0, MouseEvent::platformModifiersToButtons(event.getModifiers()), nullptr , event.timestamp(), dataTransfer, event.getSyntheticEventType()); 1193 0, MouseEvent::platformModifiersToButtons(event.getModifiers()), nullptr , event.timestamp(), dataTransfer, event.getSyntheticEventType());
1223 1194
1224 return toWebInputEventResult(dragTarget->dispatchEvent(me)); 1195 return EventHandlingUtil::toWebInputEventResult(dragTarget->dispatchEvent(me ));
1225 } 1196 }
1226 1197
1227 static bool targetIsFrame(Node* target, LocalFrame*& frame) 1198 static bool targetIsFrame(Node* target, LocalFrame*& frame)
1228 { 1199 {
1229 if (!isHTMLFrameElementBase(target)) 1200 if (!isHTMLFrameElementBase(target))
1230 return false; 1201 return false;
1231 1202
1232 // Cross-process drag and drop is not yet supported. 1203 // Cross-process drag and drop is not yet supported.
1233 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame()) 1204 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame())
1234 return false; 1205 return false;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 1437
1467 void EventHandler::updateMouseEventTargetNodeAndSendEvents(Node* targetNode, 1438 void EventHandler::updateMouseEventTargetNodeAndSendEvents(Node* targetNode,
1468 const PlatformMouseEvent& mouseEvent, bool isFrameBoundaryTransition) 1439 const PlatformMouseEvent& mouseEvent, bool isFrameBoundaryTransition)
1469 { 1440 {
1470 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent ); 1441 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent );
1471 m_pointerEventManager.sendMouseAndPossiblyPointerBoundaryEvents( 1442 m_pointerEventManager.sendMouseAndPossiblyPointerBoundaryEvents(
1472 lastNodeUnderMouse, m_nodeUnderMouse, mouseEvent, 1443 lastNodeUnderMouse, m_nodeUnderMouse, mouseEvent,
1473 isFrameBoundaryTransition); 1444 isFrameBoundaryTransition);
1474 } 1445 }
1475 1446
1476 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent) 1447 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent)
mustaq 2016/08/30 21:49:23 The only EventHandler state this function uses is
Navid Zolghadr 2016/08/31 14:23:48 I planned to do these in the next CL if you are ok
1477 { 1448 {
1478 updateMouseEventTargetNodeAndSendEvents(targetNode, mouseEvent); 1449 updateMouseEventTargetNodeAndSendEvents(targetNode, mouseEvent);
1479 if (!m_nodeUnderMouse)
1480 return WebInputEventResult::NotHandled;
1481 1450
1482 MouseEvent* event = MouseEvent::create(eventType, m_nodeUnderMouse->document ().domWindow(), mouseEvent, clickCount, nullptr); 1451 return m_mouseEventManager.dispatchMouseEvent(m_nodeUnderMouse, eventType,
1483 return toWebInputEventResult(m_nodeUnderMouse->dispatchEvent(event)); 1452 mouseEvent, nullptr, clickCount);
1484 } 1453 }
1485 1454
1486 bool EventHandler::isPointerEventActive(int pointerId) 1455 bool EventHandler::isPointerEventActive(int pointerId)
1487 { 1456 {
1488 return m_pointerEventManager.isActive(pointerId); 1457 return m_pointerEventManager.isActive(pointerId);
1489 } 1458 }
1490 1459
1491 void EventHandler::setPointerCapture(int pointerId, EventTarget* target) 1460 void EventHandler::setPointerCapture(int pointerId, EventTarget* target)
1492 { 1461 {
1493 // TODO(crbug.com/591387): This functionality should be per page not per fra me. 1462 // TODO(crbug.com/591387): This functionality should be per page not per fra me.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 lastNodeUnderMouse, &newNodeUnderMouse); 1498 lastNodeUnderMouse, &newNodeUnderMouse);
1530 m_nodeUnderMouse = newNodeUnderMouse; 1499 m_nodeUnderMouse = newNodeUnderMouse;
1531 return eventResult; 1500 return eventResult;
1532 } 1501 }
1533 1502
1534 void EventHandler::setClickNode(Node* node) 1503 void EventHandler::setClickNode(Node* node)
1535 { 1504 {
1536 m_clickNode = node; 1505 m_clickNode = node;
1537 } 1506 }
1538 1507
1539 WebInputEventResult EventHandler::handleMouseFocus(const HitTestResult& hitTestR esult, InputDeviceCapabilities* sourceCapabilities) 1508 WebInputEventResult EventHandler::handleMouseFocus(const HitTestResult& hitTestR esult, InputDeviceCapabilities* sourceCapabilities)
mustaq 2016/08/30 21:49:23 Can we move it to ME-Manager? This applies only if
Navid Zolghadr 2016/08/31 14:23:47 I planned to do these in the next CL if you are ok
1540 { 1509 {
1541 // If clicking on a frame scrollbar, do not mess up with content focus. 1510 // If clicking on a frame scrollbar, do not mess up with content focus.
1542 if (hitTestResult.scrollbar() && !m_frame->contentLayoutItem().isNull()) { 1511 if (hitTestResult.scrollbar() && !m_frame->contentLayoutItem().isNull()) {
1543 if (hitTestResult.scrollbar()->getScrollableArea() == m_frame->contentLa youtItem().getScrollableArea()) 1512 if (hitTestResult.scrollbar()->getScrollableArea() == m_frame->contentLa youtItem().getScrollableArea())
1544 return WebInputEventResult::NotHandled; 1513 return WebInputEventResult::NotHandled;
1545 } 1514 }
1546 1515
1547 // The layout needs to be up to date to determine if an element is focusable . 1516 // The layout needs to be up to date to determine if an element is focusable .
1548 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 1517 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets();
1549 1518
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 WebInputEventResult result = subframe->eventHandler().handleWheelEvent(e vent); 1629 WebInputEventResult result = subframe->eventHandler().handleWheelEvent(e vent);
1661 if (result != WebInputEventResult::NotHandled) 1630 if (result != WebInputEventResult::NotHandled)
1662 m_scrollManager.setFrameWasScrolledByUser(); 1631 m_scrollManager.setFrameWasScrolledByUser();
1663 return result; 1632 return result;
1664 } 1633 }
1665 1634
1666 if (node) { 1635 if (node) {
1667 WheelEvent* domEvent = WheelEvent::create(event, node->document().domWin dow()); 1636 WheelEvent* domEvent = WheelEvent::create(event, node->document().domWin dow());
1668 DispatchEventResult domEventResult = node->dispatchEvent(domEvent); 1637 DispatchEventResult domEventResult = node->dispatchEvent(domEvent);
1669 if (domEventResult != DispatchEventResult::NotCanceled) 1638 if (domEventResult != DispatchEventResult::NotCanceled)
1670 return toWebInputEventResult(domEventResult); 1639 return EventHandlingUtil::toWebInputEventResult(domEventResult);
1671 } 1640 }
1672 1641
1673 return WebInputEventResult::NotHandled; 1642 return WebInputEventResult::NotHandled;
1674 } 1643 }
1675 1644
1676 WebInputEventResult EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) 1645 WebInputEventResult EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
1677 { 1646 {
1678 // Propagation to inner frames is handled below this function. 1647 // Propagation to inner frames is handled below this function.
1679 ASSERT(m_frame == m_frame->localFrameRoot()); 1648 ASSERT(m_frame == m_frame->localFrameRoot());
1680 1649
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 applyTouchAdjustment(&adjustedEvent, &hitTestResult); 1950 applyTouchAdjustment(&adjustedEvent, &hitTestResult);
1982 1951
1983 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa ry because 1952 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa ry because
1984 // rect-based hit testing and touch adjustment sometimes return a different node than 1953 // rect-based hit testing and touch adjustment sometimes return a different node than
1985 // what a point-based hit test would return for the same point. 1954 // what a point-based hit test would return for the same point.
1986 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h ttp://crbug.com/398914 1955 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h ttp://crbug.com/398914
1987 if (shouldApplyTouchAdjustment(gestureEvent)) { 1956 if (shouldApplyTouchAdjustment(gestureEvent)) {
1988 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); 1957 LocalFrame* hitFrame = hitTestResult.innerNodeFrame();
1989 if (!hitFrame) 1958 if (!hitFrame)
1990 hitFrame = m_frame; 1959 hitFrame = m_frame;
1991 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->rootFra meToContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~ HitTestRequest::ListBased); 1960 hitTestResult = EventHandlingUtil::hitTestResultInFrame(hitFrame, hitFra me->view()->rootFrameToContents(adjustedEvent.position()), (hitType | HitTestReq uest::ReadOnly) & ~HitTestRequest::ListBased);
1992 } 1961 }
1993 1962
1994 // If we did a rect-based hit test it must be resolved to the best single no de by now to 1963 // If we did a rect-based hit test it must be resolved to the best single no de by now to
1995 // ensure consumers don't accidentally use one of the other candidates. 1964 // ensure consumers don't accidentally use one of the other candidates.
1996 ASSERT(!hitTestResult.isRectBasedTest()); 1965 ASSERT(!hitTestResult.isRectBasedTest());
1997 1966
1998 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); 1967 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult);
1999 } 1968 }
2000 1969
2001 void EventHandler::applyTouchAdjustment(PlatformGestureEvent* gestureEvent, HitT estResult* hitTestResult) 1970 void EventHandler::applyTouchAdjustment(PlatformGestureEvent* gestureEvent, HitT estResult* hitTestResult)
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 m_lastScrollbarUnderMouse->mouseExited(); 2498 m_lastScrollbarUnderMouse->mouseExited();
2530 2499
2531 // Send mouse entered if we're setting a new scrollbar. 2500 // Send mouse entered if we're setting a new scrollbar.
2532 if (scrollbar && setLast) 2501 if (scrollbar && setLast)
2533 scrollbar->mouseEntered(); 2502 scrollbar->mouseEntered();
2534 2503
2535 m_lastScrollbarUnderMouse = setLast ? scrollbar : nullptr; 2504 m_lastScrollbarUnderMouse = setLast ? scrollbar : nullptr;
2536 } 2505 }
2537 } 2506 }
2538 2507
2539 HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout Point& point, HitTestRequest::HitTestRequestType hitType)
2540 {
2541 HitTestResult result(HitTestRequest(hitType), point);
2542
2543 if (!frame || frame->contentLayoutItem().isNull())
2544 return result;
2545 if (frame->view()) {
2546 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars);
2547 if (!rect.contains(roundedIntPoint(point)))
2548 return result;
2549 }
2550 frame->contentLayoutItem().hitTest(result);
2551 return result;
2552 }
2553
2554 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) 2508 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt)
2555 { 2509 {
2556 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); 2510 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent");
2557 return m_pointerEventManager.handleTouchEvents(event); 2511 return m_pointerEventManager.handleTouchEvents(event);
2558 } 2512 }
2559 2513
2560 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) 2514 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event)
2561 { 2515 {
2562 m_mousePositionIsUnknown = false; 2516 m_mousePositionIsUnknown = false;
2563 m_lastKnownMousePosition = event.position(); 2517 m_lastKnownMousePosition = event.position();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2606 2560
2607 FrameHost* EventHandler::frameHost() const 2561 FrameHost* EventHandler::frameHost() const
2608 { 2562 {
2609 if (!m_frame->page()) 2563 if (!m_frame->page())
2610 return nullptr; 2564 return nullptr;
2611 2565
2612 return &m_frame->page()->frameHost(); 2566 return &m_frame->page()->frameHost();
2613 } 2567 }
2614 2568
2615 } // namespace blink 2569 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698