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

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);
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 390
421 selectionController().handleMouseDraggedEvent(event, m_mouseDownPos, m_dragS tartPos, m_mousePressNode.get(), m_lastKnownMousePosition); 391 selectionController().handleMouseDraggedEvent(event, m_mouseDownPos, m_dragS tartPos, m_mousePressNode.get(), m_lastKnownMousePosition);
422 return WebInputEventResult::HandledSystem; 392 return WebInputEventResult::HandledSystem;
423 } 393 }
424 394
425 void EventHandler::updateSelectionForMouseDrag() 395 void EventHandler::updateSelectionForMouseDrag()
426 { 396 {
427 selectionController().updateSelectionForMouseDrag(m_mousePressNode.get(), m_ dragStartPos, m_lastKnownMousePosition); 397 selectionController().updateSelectionForMouseDrag(m_mousePressNode.get(), m_ dragStartPos, m_lastKnownMousePosition);
428 } 398 }
429 399
400 // TODO(nzolghadr): Refactor the mouse related functions to MouseEventManager.
430 WebInputEventResult EventHandler::handleMouseReleaseEvent(const MouseEventWithHi tTestResults& event) 401 WebInputEventResult EventHandler::handleMouseReleaseEvent(const MouseEventWithHi tTestResults& event)
431 { 402 {
432 AutoscrollController* controller = m_scrollManager.autoscrollController(); 403 AutoscrollController* controller = m_scrollManager.autoscrollController();
433 if (controller && controller->autoscrollInProgress()) 404 if (controller && controller->autoscrollInProgress())
434 m_scrollManager.stopAutoscroll(); 405 m_scrollManager.stopAutoscroll();
435 406
436 return selectionController().handleMouseReleaseEvent(event, m_dragStartPos) ? WebInputEventResult::HandledSystem : WebInputEventResult::NotHandled; 407 return selectionController().handleMouseReleaseEvent(event, m_dragStartPos) ? WebInputEventResult::HandledSystem : WebInputEventResult::NotHandled;
437 } 408 }
438 409
439 #if OS(WIN) 410 #if OS(WIN)
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 return WebInputEventResult::HandledSystem; 832 return WebInputEventResult::HandledSystem;
862 } 833 }
863 } 834 }
864 835
865 // m_selectionInitiationState is initialized after dispatching mousedown 836 // m_selectionInitiationState is initialized after dispatching mousedown
866 // event in order not to keep the selection by DOM APIs because we can't 837 // 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 838 // 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 839 // 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. 840 // the same behavior and it's more compatible with other browsers.
870 selectionController().initializeSelectionState(); 841 selectionController().initializeSelectionState();
871 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H itTestRequest::ReadOnly); 842 HitTestResult hitTestResult = EventHandlingUtil::hitTestResultInFrame(m_fram e, documentPoint, HitTestRequest::ReadOnly);
872 InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventTy pe() == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEvent sSourceCapabilities() : 843 InputDeviceCapabilities* sourceCapabilities = mouseEvent.getSyntheticEventTy pe() == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEvent sSourceCapabilities() :
873 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); 844 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities();
874 if (eventResult == WebInputEventResult::NotHandled) 845 if (eventResult == WebInputEventResult::NotHandled)
875 eventResult = handleMouseFocus(hitTestResult, sourceCapabilities); 846 eventResult = handleMouseFocus(hitTestResult, sourceCapabilities);
876 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar(); 847 m_capturesDragging = eventResult == WebInputEventResult::NotHandled || mev.s crollbar();
877 848
878 // If the hit testing originally determined the event was in a scrollbar, re fetch the MouseEventWithHitTestResults 849 // 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. 850 // in case the scrollbar widget was destroyed when the mouse event was handl ed.
880 if (mev.scrollbar()) { 851 if (mev.scrollbar()) {
881 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get(); 852 const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMou se.get();
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 m_clickNode->updateDistribution(); 1150 m_clickNode->updateDistribution();
1180 mev.innerNode()->updateDistribution(); 1151 mev.innerNode()->updateDistribution();
1181 clickTargetNode = mev.innerNode()->commonAncestor( 1152 clickTargetNode = mev.innerNode()->commonAncestor(
1182 *m_clickNode, parentForClickEvent); 1153 *m_clickNode, parentForClickEvent);
1183 } 1154 }
1184 if (clickTargetNode) { 1155 if (clickTargetNode) {
1185 // Dispatch mouseup directly w/o calling updateMouseEventTargetNodeA ndSendEvents 1156 // Dispatch mouseup directly w/o calling updateMouseEventTargetNodeA ndSendEvents
1186 // because the mouseup dispatch above has already updated it 1157 // because the mouseup dispatch above has already updated it
1187 // correctly. Moreover, clickTargetNode is different from 1158 // correctly. Moreover, clickTargetNode is different from
1188 // mev.innerNode at drag-release. 1159 // mev.innerNode at drag-release.
1189 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMo useEvent(mev.event(), 1160 clickEventResult = EventHandlingUtil::toWebInputEventResult(
1161 clickTargetNode->dispatchMouseEvent(mev.event(),
1190 !RuntimeEnabledFeatures::auxclickEnabled() 1162 !RuntimeEnabledFeatures::auxclickEnabled()
1191 || (mev.event().pointerProperties().button == WebPointerProperti es::Button::Left) 1163 || (mev.event().pointerProperties().button == WebPointerProperti es::Button::Left)
1192 ? EventTypeNames::click 1164 ? EventTypeNames::click
1193 : EventTypeNames::auxclick, 1165 : EventTypeNames::auxclick,
1194 m_clickCount)); 1166 m_clickCount));
1195 } 1167 }
1196 } 1168 }
1197 1169
1198 m_scrollManager.clearResizeScrollableArea(false); 1170 m_scrollManager.clearResizeScrollableArea(false);
1199 1171
1200 if (eventResult == WebInputEventResult::NotHandled) 1172 if (eventResult == WebInputEventResult::NotHandled)
1201 eventResult = handleMouseReleaseEvent(mev); 1173 eventResult = handleMouseReleaseEvent(mev);
1202 clearDragHeuristicState(); 1174 clearDragHeuristicState();
1203 1175
1204 invalidateClick(); 1176 invalidateClick();
1205 1177
1206 return mergeEventResult(clickEventResult, eventResult); 1178 return EventHandlingUtil::mergeEventResult(clickEventResult, eventResult);
1207 } 1179 }
1208 1180
1209 WebInputEventResult EventHandler::dispatchDragEvent(const AtomicString& eventTyp e, Node* dragTarget, const PlatformMouseEvent& event, DataTransfer* dataTransfer ) 1181 WebInputEventResult EventHandler::dispatchDragEvent(const AtomicString& eventTyp e, Node* dragTarget, const PlatformMouseEvent& event, DataTransfer* dataTransfer )
1210 { 1182 {
1211 FrameView* view = m_frame->view(); 1183 FrameView* view = m_frame->view();
1212 1184
1213 // FIXME: We might want to dispatch a dragleave even if the view is gone. 1185 // FIXME: We might want to dispatch a dragleave even if the view is gone.
1214 if (!view) 1186 if (!view)
1215 return WebInputEventResult::NotHandled; 1187 return WebInputEventResult::NotHandled;
1216 1188
1217 DragEvent* me = DragEvent::create(eventType, 1189 DragEvent* me = DragEvent::create(eventType,
1218 true, true, m_frame->document()->domWindow(), 1190 true, true, m_frame->document()->domWindow(),
1219 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(), 1191 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(),
1220 event.movementDelta().x(), event.movementDelta().y(), 1192 event.movementDelta().x(), event.movementDelta().y(),
1221 event.getModifiers(), 1193 event.getModifiers(),
1222 0, MouseEvent::platformModifiersToButtons(event.getModifiers()), nullptr , event.timestamp(), dataTransfer, event.getSyntheticEventType()); 1194 0, MouseEvent::platformModifiersToButtons(event.getModifiers()), nullptr , event.timestamp(), dataTransfer, event.getSyntheticEventType());
1223 1195
1224 return toWebInputEventResult(dragTarget->dispatchEvent(me)); 1196 return EventHandlingUtil::toWebInputEventResult(dragTarget->dispatchEvent(me ));
1225 } 1197 }
1226 1198
1227 static bool targetIsFrame(Node* target, LocalFrame*& frame) 1199 static bool targetIsFrame(Node* target, LocalFrame*& frame)
1228 { 1200 {
1229 if (!isHTMLFrameElementBase(target)) 1201 if (!isHTMLFrameElementBase(target))
1230 return false; 1202 return false;
1231 1203
1232 // Cross-process drag and drop is not yet supported. 1204 // Cross-process drag and drop is not yet supported.
1233 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame()) 1205 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame())
1234 return false; 1206 return false;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 { 1441 {
1470 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent ); 1442 Node* lastNodeUnderMouse = updateMouseEventTargetNode(targetNode, mouseEvent );
1471 m_pointerEventManager.sendMouseAndPossiblyPointerBoundaryEvents( 1443 m_pointerEventManager.sendMouseAndPossiblyPointerBoundaryEvents(
1472 lastNodeUnderMouse, m_nodeUnderMouse, mouseEvent, 1444 lastNodeUnderMouse, m_nodeUnderMouse, mouseEvent,
1473 isFrameBoundaryTransition); 1445 isFrameBoundaryTransition);
1474 } 1446 }
1475 1447
1476 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent) 1448 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent)
1477 { 1449 {
1478 updateMouseEventTargetNodeAndSendEvents(targetNode, mouseEvent); 1450 updateMouseEventTargetNodeAndSendEvents(targetNode, mouseEvent);
1479 if (!m_nodeUnderMouse)
1480 return WebInputEventResult::NotHandled;
1481 1451
1482 MouseEvent* event = MouseEvent::create(eventType, m_nodeUnderMouse->document ().domWindow(), mouseEvent, clickCount, nullptr); 1452 return m_mouseEventManager.dispatchMouseEvent(m_nodeUnderMouse, eventType,
1483 return toWebInputEventResult(m_nodeUnderMouse->dispatchEvent(event)); 1453 mouseEvent, nullptr, clickCount);
1484 } 1454 }
1485 1455
1486 bool EventHandler::isPointerEventActive(int pointerId) 1456 bool EventHandler::isPointerEventActive(int pointerId)
1487 { 1457 {
1488 return m_pointerEventManager.isActive(pointerId); 1458 return m_pointerEventManager.isActive(pointerId);
1489 } 1459 }
1490 1460
1491 void EventHandler::setPointerCapture(int pointerId, EventTarget* target) 1461 void EventHandler::setPointerCapture(int pointerId, EventTarget* target)
1492 { 1462 {
1493 // TODO(crbug.com/591387): This functionality should be per page not per fra me. 1463 // TODO(crbug.com/591387): This functionality should be per page not per fra me.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 WebInputEventResult result = subframe->eventHandler().handleWheelEvent(e vent); 1630 WebInputEventResult result = subframe->eventHandler().handleWheelEvent(e vent);
1661 if (result != WebInputEventResult::NotHandled) 1631 if (result != WebInputEventResult::NotHandled)
1662 m_scrollManager.setFrameWasScrolledByUser(); 1632 m_scrollManager.setFrameWasScrolledByUser();
1663 return result; 1633 return result;
1664 } 1634 }
1665 1635
1666 if (node) { 1636 if (node) {
1667 WheelEvent* domEvent = WheelEvent::create(event, node->document().domWin dow()); 1637 WheelEvent* domEvent = WheelEvent::create(event, node->document().domWin dow());
1668 DispatchEventResult domEventResult = node->dispatchEvent(domEvent); 1638 DispatchEventResult domEventResult = node->dispatchEvent(domEvent);
1669 if (domEventResult != DispatchEventResult::NotCanceled) 1639 if (domEventResult != DispatchEventResult::NotCanceled)
1670 return toWebInputEventResult(domEventResult); 1640 return EventHandlingUtil::toWebInputEventResult(domEventResult);
1671 } 1641 }
1672 1642
1673 return WebInputEventResult::NotHandled; 1643 return WebInputEventResult::NotHandled;
1674 } 1644 }
1675 1645
1676 WebInputEventResult EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) 1646 WebInputEventResult EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
1677 { 1647 {
1678 // Propagation to inner frames is handled below this function. 1648 // Propagation to inner frames is handled below this function.
1679 ASSERT(m_frame == m_frame->localFrameRoot()); 1649 ASSERT(m_frame == m_frame->localFrameRoot());
1680 1650
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 applyTouchAdjustment(&adjustedEvent, &hitTestResult); 1951 applyTouchAdjustment(&adjustedEvent, &hitTestResult);
1982 1952
1983 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa ry because 1953 // 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 1954 // 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. 1955 // 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 1956 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h ttp://crbug.com/398914
1987 if (shouldApplyTouchAdjustment(gestureEvent)) { 1957 if (shouldApplyTouchAdjustment(gestureEvent)) {
1988 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); 1958 LocalFrame* hitFrame = hitTestResult.innerNodeFrame();
1989 if (!hitFrame) 1959 if (!hitFrame)
1990 hitFrame = m_frame; 1960 hitFrame = m_frame;
1991 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->rootFra meToContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~ HitTestRequest::ListBased); 1961 hitTestResult = EventHandlingUtil::hitTestResultInFrame(hitFrame, hitFra me->view()->rootFrameToContents(adjustedEvent.position()), (hitType | HitTestReq uest::ReadOnly) & ~HitTestRequest::ListBased);
1992 } 1962 }
1993 1963
1994 // If we did a rect-based hit test it must be resolved to the best single no de by now to 1964 // 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. 1965 // ensure consumers don't accidentally use one of the other candidates.
1996 ASSERT(!hitTestResult.isRectBasedTest()); 1966 ASSERT(!hitTestResult.isRectBasedTest());
1997 1967
1998 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); 1968 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult);
1999 } 1969 }
2000 1970
2001 void EventHandler::applyTouchAdjustment(PlatformGestureEvent* gestureEvent, HitT estResult* hitTestResult) 1971 void EventHandler::applyTouchAdjustment(PlatformGestureEvent* gestureEvent, HitT estResult* hitTestResult)
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 m_lastScrollbarUnderMouse->mouseExited(); 2499 m_lastScrollbarUnderMouse->mouseExited();
2530 2500
2531 // Send mouse entered if we're setting a new scrollbar. 2501 // Send mouse entered if we're setting a new scrollbar.
2532 if (scrollbar && setLast) 2502 if (scrollbar && setLast)
2533 scrollbar->mouseEntered(); 2503 scrollbar->mouseEntered();
2534 2504
2535 m_lastScrollbarUnderMouse = setLast ? scrollbar : nullptr; 2505 m_lastScrollbarUnderMouse = setLast ? scrollbar : nullptr;
2536 } 2506 }
2537 } 2507 }
2538 2508
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) 2509 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt)
2555 { 2510 {
2556 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); 2511 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent");
2557 return m_pointerEventManager.handleTouchEvents(event); 2512 return m_pointerEventManager.handleTouchEvents(event);
2558 } 2513 }
2559 2514
2560 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) 2515 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event)
2561 { 2516 {
2562 m_mousePositionIsUnknown = false; 2517 m_mousePositionIsUnknown = false;
2563 m_lastKnownMousePosition = event.position(); 2518 m_lastKnownMousePosition = event.position();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2606 2561
2607 FrameHost* EventHandler::frameHost() const 2562 FrameHost* EventHandler::frameHost() const
2608 { 2563 {
2609 if (!m_frame->page()) 2564 if (!m_frame->page())
2610 return nullptr; 2565 return nullptr;
2611 2566
2612 return &m_frame->page()->frameHost(); 2567 return &m_frame->page()->frameHost();
2613 } 2568 }
2614 2569
2615 } // namespace blink 2570 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698