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

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: Created 4 years, 4 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_gestureManager(frame, &m_scrollManager, &m_pointerEventManager, m_select ionController)
196 , m_mouseEventManager(frame)
197 , m_pointerEventManager(frame, &m_mouseEventManager)
195 , m_scrollManager(frame) 198 , m_scrollManager(frame)
196 , m_keyboardEventManager(frame, &m_scrollManager) 199 , m_keyboardEventManager(frame, &m_scrollManager)
197 , 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 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(MouseEventWithHitTestResults(mev.event(), hitTestResult), sourceCapabilities); 845 eventResult = handleMouseFocus(MouseEventWithHitTestResults(mev.event(), 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 m_clickNode->updateDistribution(); 1147 m_clickNode->updateDistribution();
1178 mev.innerNode()->updateDistribution(); 1148 mev.innerNode()->updateDistribution();
1179 clickTargetNode = mev.innerNode()->commonAncestor( 1149 clickTargetNode = mev.innerNode()->commonAncestor(
1180 *m_clickNode, parentForClickEvent); 1150 *m_clickNode, parentForClickEvent);
1181 } 1151 }
1182 if (clickTargetNode) { 1152 if (clickTargetNode) {
1183 // Dispatch mouseup directly w/o calling updateMouseEventTargetNodeA ndSendEvents 1153 // Dispatch mouseup directly w/o calling updateMouseEventTargetNodeA ndSendEvents
1184 // because the mouseup dispatch above has already updated it 1154 // because the mouseup dispatch above has already updated it
1185 // correctly. Moreover, clickTargetNode is different from 1155 // correctly. Moreover, clickTargetNode is different from
1186 // mev.innerNode at drag-release. 1156 // mev.innerNode at drag-release.
1187 clickEventResult = toWebInputEventResult(clickTargetNode->dispatchMo useEvent(mev.event(), 1157 clickEventResult = EventHandlingUtil::toWebInputEventResult(clickTar getNode->dispatchMouseEvent(mev.event(),
1188 !RuntimeEnabledFeatures::auxclickEnabled() || (mev.event().butto n() == MouseButton::LeftButton) 1158 !RuntimeEnabledFeatures::auxclickEnabled() || (mev.event().butto n() == MouseButton::LeftButton)
1189 ? EventTypeNames::click 1159 ? EventTypeNames::click
1190 : EventTypeNames::auxclick, 1160 : EventTypeNames::auxclick,
1191 m_clickCount)); 1161 m_clickCount));
1192 } 1162 }
1193 } 1163 }
1194 1164
1195 m_scrollManager.clearResizeScrollableArea(false); 1165 m_scrollManager.clearResizeScrollableArea(false);
1196 1166
1197 if (eventResult == WebInputEventResult::NotHandled) 1167 if (eventResult == WebInputEventResult::NotHandled)
1198 eventResult = handleMouseReleaseEvent(mev); 1168 eventResult = handleMouseReleaseEvent(mev);
1199 clearDragHeuristicState(); 1169 clearDragHeuristicState();
1200 1170
1201 invalidateClick(); 1171 invalidateClick();
1202 1172
1203 return mergeEventResult(clickEventResult, eventResult); 1173 return EventHandlingUtil::mergeEventResult(clickEventResult, eventResult);
1204 } 1174 }
1205 1175
1206 WebInputEventResult EventHandler::dispatchDragEvent(const AtomicString& eventTyp e, Node* dragTarget, const PlatformMouseEvent& event, DataTransfer* dataTransfer ) 1176 WebInputEventResult EventHandler::dispatchDragEvent(const AtomicString& eventTyp e, Node* dragTarget, const PlatformMouseEvent& event, DataTransfer* dataTransfer )
1207 { 1177 {
1208 FrameView* view = m_frame->view(); 1178 FrameView* view = m_frame->view();
1209 1179
1210 // FIXME: We might want to dispatch a dragleave even if the view is gone. 1180 // FIXME: We might want to dispatch a dragleave even if the view is gone.
1211 if (!view) 1181 if (!view)
1212 return WebInputEventResult::NotHandled; 1182 return WebInputEventResult::NotHandled;
1213 1183
1214 DragEvent* me = DragEvent::create(eventType, 1184 DragEvent* me = DragEvent::create(eventType,
1215 true, true, m_frame->document()->domWindow(), 1185 true, true, m_frame->document()->domWindow(),
1216 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(), 1186 0, event.globalPosition().x(), event.globalPosition().y(), event.positio n().x(), event.position().y(),
1217 event.movementDelta().x(), event.movementDelta().y(), 1187 event.movementDelta().x(), event.movementDelta().y(),
1218 event.getModifiers(), 1188 event.getModifiers(),
1219 0, MouseEvent::platformModifiersToButtons(event.getModifiers()), nullptr , event.timestamp(), dataTransfer, event.getSyntheticEventType()); 1189 0, MouseEvent::platformModifiersToButtons(event.getModifiers()), nullptr , event.timestamp(), dataTransfer, event.getSyntheticEventType());
1220 1190
1221 return toWebInputEventResult(dragTarget->dispatchEvent(me)); 1191 return EventHandlingUtil::toWebInputEventResult(dragTarget->dispatchEvent(me ));
1222 } 1192 }
1223 1193
1224 static bool targetIsFrame(Node* target, LocalFrame*& frame) 1194 static bool targetIsFrame(Node* target, LocalFrame*& frame)
1225 { 1195 {
1226 if (!isHTMLFrameElementBase(target)) 1196 if (!isHTMLFrameElementBase(target))
1227 return false; 1197 return false;
1228 1198
1229 // Cross-process drag and drop is not yet supported. 1199 // Cross-process drag and drop is not yet supported.
1230 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame()) 1200 if (toHTMLFrameElementBase(target)->contentFrame() && !toHTMLFrameElementBas e(target)->contentFrame()->isLocalFrame())
1231 return false; 1201 return false;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 isFrameBoundaryTransition); 1440 isFrameBoundaryTransition);
1471 } 1441 }
1472 1442
1473 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent) 1443 WebInputEventResult EventHandler::dispatchMouseEvent(const AtomicString& eventTy pe, Node* targetNode, int clickCount, const PlatformMouseEvent& mouseEvent)
1474 { 1444 {
1475 updateMouseEventTargetNodeAndSendEvents(targetNode, mouseEvent); 1445 updateMouseEventTargetNodeAndSendEvents(targetNode, mouseEvent);
1476 if (!m_nodeUnderMouse) 1446 if (!m_nodeUnderMouse)
1477 return WebInputEventResult::NotHandled; 1447 return WebInputEventResult::NotHandled;
1478 1448
1479 MouseEvent* event = MouseEvent::create(eventType, m_nodeUnderMouse->document ().domWindow(), mouseEvent, clickCount, nullptr); 1449 MouseEvent* event = MouseEvent::create(eventType, m_nodeUnderMouse->document ().domWindow(), mouseEvent, clickCount, nullptr);
1480 return toWebInputEventResult(m_nodeUnderMouse->dispatchEvent(event)); 1450 return EventHandlingUtil::toWebInputEventResult(m_nodeUnderMouse->dispatchEv ent(event));
1481 } 1451 }
1482 1452
1483 bool EventHandler::isPointerEventActive(int pointerId) 1453 bool EventHandler::isPointerEventActive(int pointerId)
1484 { 1454 {
1485 return m_pointerEventManager.isActive(pointerId); 1455 return m_pointerEventManager.isActive(pointerId);
1486 } 1456 }
1487 1457
1488 void EventHandler::setPointerCapture(int pointerId, EventTarget* target) 1458 void EventHandler::setPointerCapture(int pointerId, EventTarget* target)
1489 { 1459 {
1490 // TODO(crbug.com/591387): This functionality should be per page not per fra me. 1460 // TODO(crbug.com/591387): This functionality should be per page not per fra me.
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 WebInputEventResult result = subframe->eventHandler().handleWheelEvent(e vent); 1625 WebInputEventResult result = subframe->eventHandler().handleWheelEvent(e vent);
1656 if (result != WebInputEventResult::NotHandled) 1626 if (result != WebInputEventResult::NotHandled)
1657 m_scrollManager.setFrameWasScrolledByUser(); 1627 m_scrollManager.setFrameWasScrolledByUser();
1658 return result; 1628 return result;
1659 } 1629 }
1660 1630
1661 if (node) { 1631 if (node) {
1662 WheelEvent* domEvent = WheelEvent::create(event, node->document().domWin dow()); 1632 WheelEvent* domEvent = WheelEvent::create(event, node->document().domWin dow());
1663 DispatchEventResult domEventResult = node->dispatchEvent(domEvent); 1633 DispatchEventResult domEventResult = node->dispatchEvent(domEvent);
1664 if (domEventResult != DispatchEventResult::NotCanceled) 1634 if (domEventResult != DispatchEventResult::NotCanceled)
1665 return toWebInputEventResult(domEventResult); 1635 return EventHandlingUtil::toWebInputEventResult(domEventResult);
1666 } 1636 }
1667 1637
1668 return WebInputEventResult::NotHandled; 1638 return WebInputEventResult::NotHandled;
1669 } 1639 }
1670 1640
1671 WebInputEventResult EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent) 1641 WebInputEventResult EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
1672 { 1642 {
1673 // Propagation to inner frames is handled below this function. 1643 // Propagation to inner frames is handled below this function.
1674 ASSERT(m_frame == m_frame->localFrameRoot()); 1644 ASSERT(m_frame == m_frame->localFrameRoot());
1675 1645
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 applyTouchAdjustment(&adjustedEvent, &hitTestResult); 1946 applyTouchAdjustment(&adjustedEvent, &hitTestResult);
1977 1947
1978 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa ry because 1948 // Do a new hit-test at the (adjusted) gesture co-ordinates. This is necessa ry because
1979 // rect-based hit testing and touch adjustment sometimes return a different node than 1949 // rect-based hit testing and touch adjustment sometimes return a different node than
1980 // what a point-based hit test would return for the same point. 1950 // what a point-based hit test would return for the same point.
1981 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h ttp://crbug.com/398914 1951 // FIXME: Fix touch adjustment to avoid the need for a redundant hit test. h ttp://crbug.com/398914
1982 if (shouldApplyTouchAdjustment(gestureEvent)) { 1952 if (shouldApplyTouchAdjustment(gestureEvent)) {
1983 LocalFrame* hitFrame = hitTestResult.innerNodeFrame(); 1953 LocalFrame* hitFrame = hitTestResult.innerNodeFrame();
1984 if (!hitFrame) 1954 if (!hitFrame)
1985 hitFrame = m_frame; 1955 hitFrame = m_frame;
1986 hitTestResult = hitTestResultInFrame(hitFrame, hitFrame->view()->rootFra meToContents(adjustedEvent.position()), (hitType | HitTestRequest::ReadOnly) & ~ HitTestRequest::ListBased); 1956 hitTestResult = EventHandlingUtil::hitTestResultInFrame(hitFrame, hitFra me->view()->rootFrameToContents(adjustedEvent.position()), (hitType | HitTestReq uest::ReadOnly) & ~HitTestRequest::ListBased);
1987 } 1957 }
1988 1958
1989 // If we did a rect-based hit test it must be resolved to the best single no de by now to 1959 // If we did a rect-based hit test it must be resolved to the best single no de by now to
1990 // ensure consumers don't accidentally use one of the other candidates. 1960 // ensure consumers don't accidentally use one of the other candidates.
1991 ASSERT(!hitTestResult.isRectBasedTest()); 1961 ASSERT(!hitTestResult.isRectBasedTest());
1992 1962
1993 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult); 1963 return GestureEventWithHitTestResults(adjustedEvent, hitTestResult);
1994 } 1964 }
1995 1965
1996 void EventHandler::applyTouchAdjustment(PlatformGestureEvent* gestureEvent, HitT estResult* hitTestResult) 1966 void EventHandler::applyTouchAdjustment(PlatformGestureEvent* gestureEvent, HitT estResult* hitTestResult)
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 m_lastScrollbarUnderMouse->mouseExited(); 2490 m_lastScrollbarUnderMouse->mouseExited();
2521 2491
2522 // Send mouse entered if we're setting a new scrollbar. 2492 // Send mouse entered if we're setting a new scrollbar.
2523 if (scrollbar && setLast) 2493 if (scrollbar && setLast)
2524 scrollbar->mouseEntered(); 2494 scrollbar->mouseEntered();
2525 2495
2526 m_lastScrollbarUnderMouse = setLast ? scrollbar : nullptr; 2496 m_lastScrollbarUnderMouse = setLast ? scrollbar : nullptr;
2527 } 2497 }
2528 } 2498 }
2529 2499
2530 HitTestResult EventHandler::hitTestResultInFrame(LocalFrame* frame, const Layout Point& point, HitTestRequest::HitTestRequestType hitType)
2531 {
2532 HitTestResult result(HitTestRequest(hitType), point);
2533
2534 if (!frame || frame->contentLayoutItem().isNull())
2535 return result;
2536 if (frame->view()) {
2537 IntRect rect = frame->view()->visibleContentRect(IncludeScrollbars);
2538 if (!rect.contains(roundedIntPoint(point)))
2539 return result;
2540 }
2541 frame->contentLayoutItem().hitTest(result);
2542 return result;
2543 }
2544
2545 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt) 2500 WebInputEventResult EventHandler::handleTouchEvent(const PlatformTouchEvent& eve nt)
2546 { 2501 {
2547 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent"); 2502 TRACE_EVENT0("blink", "EventHandler::handleTouchEvent");
2548 return m_pointerEventManager.handleTouchEvents(event); 2503 return m_pointerEventManager.handleTouchEvents(event);
2549 } 2504 }
2550 2505
2551 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) 2506 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event)
2552 { 2507 {
2553 m_mousePositionIsUnknown = false; 2508 m_mousePositionIsUnknown = false;
2554 m_lastKnownMousePosition = event.position(); 2509 m_lastKnownMousePosition = event.position();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 2552
2598 FrameHost* EventHandler::frameHost() const 2553 FrameHost* EventHandler::frameHost() const
2599 { 2554 {
2600 if (!m_frame->page()) 2555 if (!m_frame->page())
2601 return nullptr; 2556 return nullptr;
2602 2557
2603 return &m_frame->page()->frameHost(); 2558 return &m_frame->page()->frameHost();
2604 } 2559 }
2605 2560
2606 } // namespace blink 2561 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698