OLD | NEW |
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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire
d) | 230 , m_fakeMouseMoveEventTimer(this, &EventHandler::fakeMouseMoveEventTimerFire
d) |
231 , m_svgPan(false) | 231 , m_svgPan(false) |
232 , m_resizeScrollableArea(nullptr) | 232 , m_resizeScrollableArea(nullptr) |
233 , m_eventHandlerWillResetCapturingMouseEventsNode(0) | 233 , m_eventHandlerWillResetCapturingMouseEventsNode(0) |
234 , m_clickCount(0) | 234 , m_clickCount(0) |
235 , m_shouldOnlyFireDragOverEvent(false) | 235 , m_shouldOnlyFireDragOverEvent(false) |
236 , m_accumulatedRootOverscroll(FloatSize()) | 236 , m_accumulatedRootOverscroll(FloatSize()) |
237 , m_mousePositionIsUnknown(true) | 237 , m_mousePositionIsUnknown(true) |
238 , m_mouseDownTimestamp(0) | 238 , m_mouseDownTimestamp(0) |
239 , m_touchPressed(false) | 239 , m_touchPressed(false) |
| 240 , m_preventMouseEventForPointerTypeMouse(false) |
240 , m_inPointerCanceledState(false) | 241 , m_inPointerCanceledState(false) |
241 , m_scrollGestureHandlingNode(nullptr) | 242 , m_scrollGestureHandlingNode(nullptr) |
242 , m_lastGestureScrollOverWidget(false) | 243 , m_lastGestureScrollOverWidget(false) |
243 , m_longTapShouldInvokeContextMenu(false) | 244 , m_longTapShouldInvokeContextMenu(false) |
244 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) | 245 , m_activeIntervalTimer(this, &EventHandler::activeIntervalTimerFired) |
245 , m_lastShowPressTimestamp(0) | 246 , m_lastShowPressTimestamp(0) |
246 , m_deltaConsumedForScrollSequence(false) | 247 , m_deltaConsumedForScrollSequence(false) |
247 { | 248 { |
248 } | 249 } |
249 | 250 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 m_capturingMouseEventsNode = nullptr; | 309 m_capturingMouseEventsNode = nullptr; |
309 m_previousWheelScrolledNode = nullptr; | 310 m_previousWheelScrolledNode = nullptr; |
310 m_targetForTouchID.clear(); | 311 m_targetForTouchID.clear(); |
311 m_touchSequenceDocument.clear(); | 312 m_touchSequenceDocument.clear(); |
312 m_touchSequenceUserGestureToken.clear(); | 313 m_touchSequenceUserGestureToken.clear(); |
313 clearGestureScrollState(); | 314 clearGestureScrollState(); |
314 m_lastGestureScrollOverWidget = false; | 315 m_lastGestureScrollOverWidget = false; |
315 m_scrollbarHandlingScrollGesture = nullptr; | 316 m_scrollbarHandlingScrollGesture = nullptr; |
316 m_touchPressed = false; | 317 m_touchPressed = false; |
317 m_pointerIdManager.clear(); | 318 m_pointerIdManager.clear(); |
| 319 m_preventMouseEventForPointerTypeMouse = false; |
318 m_inPointerCanceledState = false; | 320 m_inPointerCanceledState = false; |
319 m_mouseDownMayStartDrag = false; | 321 m_mouseDownMayStartDrag = false; |
320 m_lastShowPressTimestamp = 0; | 322 m_lastShowPressTimestamp = 0; |
321 m_lastDeferredTapElement = nullptr; | 323 m_lastDeferredTapElement = nullptr; |
322 m_eventHandlerWillResetCapturingMouseEventsNode = false; | 324 m_eventHandlerWillResetCapturingMouseEventsNode = false; |
323 m_mouseDownMayStartAutoscroll = false; | 325 m_mouseDownMayStartAutoscroll = false; |
324 m_svgPan = false; | 326 m_svgPan = false; |
325 m_mouseDownPos = IntPoint(); | 327 m_mouseDownPos = IntPoint(); |
326 m_mouseDownTimestamp = 0; | 328 m_mouseDownTimestamp = 0; |
327 m_longTapShouldInvokeContextMenu = false; | 329 m_longTapShouldInvokeContextMenu = false; |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 m_resizeScrollableArea = layer->scrollableArea(); | 964 m_resizeScrollableArea = layer->scrollableArea(); |
963 m_resizeScrollableArea->setInResizeMode(true); | 965 m_resizeScrollableArea->setInResizeMode(true); |
964 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset
FromResizeCorner(p)); | 966 m_offsetFromResizeCorner = LayoutSize(m_resizeScrollableArea->offset
FromResizeCorner(p)); |
965 invalidateClick(); | 967 invalidateClick(); |
966 return true; | 968 return true; |
967 } | 969 } |
968 } | 970 } |
969 | 971 |
970 m_frame->selection().setCaretBlinkingSuspended(true); | 972 m_frame->selection().setCaretBlinkingSuspended(true); |
971 | 973 |
972 bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.inner
Node(), m_clickCount, mouseEvent); | 974 bool swallowEvent = dispatchPointerEventForMouseEvent(mev.innerNode(), Event
TypeNames::pointerdown, 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 |
973 // m_selectionInitiationState is initialized after dispatching mousedown | 982 // m_selectionInitiationState is initialized after dispatching mousedown |
974 // event in order not to keep the selection by DOM APIs Because we can't | 983 // event in order not to keep the selection by DOM APIs Because we can't |
975 // give the user the chance to handle the selection by user action like | 984 // give the user the chance to handle the selection by user action like |
976 // dragging if we keep the selection in case of mousedown. FireFox also has | 985 // dragging if we keep the selection in case of mousedown. FireFox also has |
977 // the same behavior and it's more compatible with other browsers. | 986 // the same behavior and it's more compatible with other browsers. |
978 selectionController().initializeSelectionState(); | 987 selectionController().initializeSelectionState(); |
979 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H
itTestRequest::ReadOnly); | 988 HitTestResult hitTestResult = hitTestResultInFrame(m_frame, documentPoint, H
itTestRequest::ReadOnly); |
980 InputDeviceCapabilities* sourceCapabilities = mouseEvent.syntheticEventType(
) == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEventsSo
urceCapabilities() : | 989 InputDeviceCapabilities* sourceCapabilities = mouseEvent.syntheticEventType(
) == PlatformMouseEvent::FromTouch ? InputDeviceCapabilities::firesTouchEventsSo
urceCapabilities() : |
981 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); | 990 InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities(); |
982 swallowEvent = swallowEvent || handleMouseFocus(MouseEventWithHitTestResults
(mouseEvent, hitTestResult), sourceCapabilities); | 991 swallowEvent = swallowEvent || handleMouseFocus(MouseEventWithHitTestResults
(mouseEvent, hitTestResult), sourceCapabilities); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 return scrollableArea; | 1049 return scrollableArea; |
1041 } | 1050 } |
1042 | 1051 |
1043 return nullptr; | 1052 return nullptr; |
1044 } | 1053 } |
1045 | 1054 |
1046 bool EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& event) | 1055 bool EventHandler::handleMouseMoveEvent(const PlatformMouseEvent& event) |
1047 { | 1056 { |
1048 TRACE_EVENT0("blink", "EventHandler::handleMouseMoveEvent"); | 1057 TRACE_EVENT0("blink", "EventHandler::handleMouseMoveEvent"); |
1049 | 1058 |
| 1059 conditionallyEnableMouseEventForPointerTypeMouse(event); |
| 1060 |
1050 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 1061 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
1051 | 1062 |
1052 HitTestResult hoveredNode = HitTestResult(); | 1063 HitTestResult hoveredNode = HitTestResult(); |
1053 bool result = handleMouseMoveOrLeaveEvent(event, &hoveredNode); | 1064 bool result = handleMouseMoveOrLeaveEvent(event, &hoveredNode); |
1054 | 1065 |
1055 Page* page = m_frame->page(); | 1066 Page* page = m_frame->page(); |
1056 if (!page) | 1067 if (!page) |
1057 return result; | 1068 return result; |
1058 | 1069 |
1059 if (PaintLayer* layer = layerForNode(hoveredNode.innerNode())) { | 1070 if (PaintLayer* layer = layerForNode(hoveredNode.innerNode())) { |
1060 if (ScrollableArea* layerScrollableArea = associatedScrollableArea(layer
)) | 1071 if (ScrollableArea* layerScrollableArea = associatedScrollableArea(layer
)) |
1061 layerScrollableArea->mouseMovedInContentArea(); | 1072 layerScrollableArea->mouseMovedInContentArea(); |
1062 } | 1073 } |
1063 | 1074 |
1064 if (FrameView* frameView = m_frame->view()) | 1075 if (FrameView* frameView = m_frame->view()) |
1065 frameView->mouseMovedInContentArea(); | 1076 frameView->mouseMovedInContentArea(); |
1066 | 1077 |
1067 hoveredNode.setToShadowHostIfInUserAgentShadowRoot(); | 1078 hoveredNode.setToShadowHostIfInUserAgentShadowRoot(); |
1068 page->chromeClient().mouseDidMoveOverElement(hoveredNode); | 1079 page->chromeClient().mouseDidMoveOverElement(hoveredNode); |
1069 | 1080 |
1070 return result; | 1081 return result; |
1071 } | 1082 } |
1072 | 1083 |
1073 void EventHandler::handleMouseLeaveEvent(const PlatformMouseEvent& event) | 1084 void EventHandler::handleMouseLeaveEvent(const PlatformMouseEvent& event) |
1074 { | 1085 { |
1075 TRACE_EVENT0("blink", "EventHandler::handleMouseLeaveEvent"); | 1086 TRACE_EVENT0("blink", "EventHandler::handleMouseLeaveEvent"); |
1076 | 1087 |
| 1088 conditionallyEnableMouseEventForPointerTypeMouse(event); |
| 1089 |
1077 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); | 1090 RefPtrWillBeRawPtr<FrameView> protector(m_frame->view()); |
1078 handleMouseMoveOrLeaveEvent(event, 0, false, true); | 1091 handleMouseMoveOrLeaveEvent(event, 0, false, true); |
1079 } | 1092 } |
1080 | 1093 |
1081 bool EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMouseEvent& mouseEv
ent, HitTestResult* hoveredNode, bool onlyUpdateScrollbars, bool forceLeave) | 1094 bool EventHandler::handleMouseMoveOrLeaveEvent(const PlatformMouseEvent& mouseEv
ent, HitTestResult* hoveredNode, bool onlyUpdateScrollbars, bool forceLeave) |
1082 { | 1095 { |
1083 ASSERT(m_frame); | 1096 ASSERT(m_frame); |
1084 ASSERT(m_frame->view()); | 1097 ASSERT(m_frame->view()); |
1085 | 1098 |
1086 setLastKnownMousePosition(mouseEvent); | 1099 setLastKnownMousePosition(mouseEvent); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 | 1259 |
1247 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release; | 1260 HitTestRequest::HitTestRequestType hitType = HitTestRequest::Release; |
1248 HitTestRequest request(hitType); | 1261 HitTestRequest request(hitType); |
1249 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); | 1262 MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); |
1250 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN
ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); | 1263 LocalFrame* subframe = m_capturingMouseEventsNode.get() ? subframeForTargetN
ode(m_capturingMouseEventsNode.get()) : subframeForHitTestResult(mev); |
1251 if (m_eventHandlerWillResetCapturingMouseEventsNode) | 1264 if (m_eventHandlerWillResetCapturingMouseEventsNode) |
1252 m_capturingMouseEventsNode = nullptr; | 1265 m_capturingMouseEventsNode = nullptr; |
1253 if (subframe && passMouseReleaseEventToSubframe(mev, subframe)) | 1266 if (subframe && passMouseReleaseEventToSubframe(mev, subframe)) |
1254 return true; | 1267 return true; |
1255 | 1268 |
1256 bool swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, mev.
innerNode(), m_clickCount, mouseEvent); | 1269 bool swallowPointerUpEvent = dispatchPointerEventForMouseEvent(mev.innerNode
(), EventTypeNames::pointerup, mouseEvent); |
| 1270 bool swallowMouseUpEvent = false; |
| 1271 if (!m_preventMouseEventForPointerTypeMouse) { |
| 1272 swallowMouseUpEvent = !dispatchMouseEvent(EventTypeNames::mouseup, mev.i
nnerNode(), m_clickCount, mouseEvent); |
| 1273 } else { |
| 1274 // TODO(crbug/545647): This state should reset with pointercancel too. |
| 1275 m_preventMouseEventForPointerTypeMouse = false; |
| 1276 } |
1257 | 1277 |
1258 bool contextMenuEvent = mouseEvent.button() == RightButton; | 1278 bool contextMenuEvent = mouseEvent.button() == RightButton; |
1259 #if OS(MACOSX) | 1279 #if OS(MACOSX) |
1260 // 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. | 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. |
1261 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv
ent::CtrlKey) | 1281 if (mouseEvent.button() == LeftButton && mouseEvent.modifiers() & PlatformEv
ent::CtrlKey) |
1262 contextMenuEvent = true; | 1282 contextMenuEvent = true; |
1263 #endif | 1283 #endif |
1264 | 1284 |
1265 bool swallowClickEvent = false; | 1285 bool swallowClickEvent = false; |
1266 if (m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode
&& mev.innerNode()->canParticipateInComposedTree() && m_clickNode->canParticipat
eInComposedTree()) { | 1286 if (m_clickCount > 0 && !contextMenuEvent && mev.innerNode() && m_clickNode
&& mev.innerNode()->canParticipateInComposedTree() && m_clickNode->canParticipat
eInComposedTree()) { |
(...skipping 14 matching lines...) Expand all Loading... |
1281 EventTypeNames::click, m_clickCount); | 1301 EventTypeNames::click, m_clickCount); |
1282 } | 1302 } |
1283 } | 1303 } |
1284 | 1304 |
1285 if (m_resizeScrollableArea) { | 1305 if (m_resizeScrollableArea) { |
1286 m_resizeScrollableArea->setInResizeMode(false); | 1306 m_resizeScrollableArea->setInResizeMode(false); |
1287 m_resizeScrollableArea = nullptr; | 1307 m_resizeScrollableArea = nullptr; |
1288 } | 1308 } |
1289 | 1309 |
1290 bool swallowMouseReleaseEvent = false; | 1310 bool swallowMouseReleaseEvent = false; |
1291 if (!swallowMouseUpEvent) | 1311 if (!swallowPointerUpEvent && !swallowMouseUpEvent) |
1292 swallowMouseReleaseEvent = handleMouseReleaseEvent(mev); | 1312 swallowMouseReleaseEvent = handleMouseReleaseEvent(mev); |
1293 | 1313 |
1294 invalidateClick(); | 1314 invalidateClick(); |
1295 | 1315 |
1296 return swallowMouseUpEvent || swallowClickEvent || swallowMouseReleaseEvent; | 1316 return swallowPointerUpEvent || swallowMouseUpEvent || swallowClickEvent ||
swallowMouseReleaseEvent; |
1297 } | 1317 } |
1298 | 1318 |
1299 bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTa
rget, const PlatformMouseEvent& event, DataTransfer* dataTransfer) | 1319 bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTa
rget, const PlatformMouseEvent& event, DataTransfer* dataTransfer) |
1300 { | 1320 { |
1301 FrameView* view = m_frame->view(); | 1321 FrameView* view = m_frame->view(); |
1302 | 1322 |
1303 // FIXME: We might want to dispatch a dragleave even if the view is gone. | 1323 // FIXME: We might want to dispatch a dragleave even if the view is gone. |
1304 if (!view) | 1324 if (!view) |
1305 return false; | 1325 return false; |
1306 | 1326 |
(...skipping 2647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3954 return swallowedTouchEvent; | 3974 return swallowedTouchEvent; |
3955 } | 3975 } |
3956 | 3976 |
3957 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) | 3977 void EventHandler::setLastKnownMousePosition(const PlatformMouseEvent& event) |
3958 { | 3978 { |
3959 m_mousePositionIsUnknown = false; | 3979 m_mousePositionIsUnknown = false; |
3960 m_lastKnownMousePosition = event.position(); | 3980 m_lastKnownMousePosition = event.position(); |
3961 m_lastKnownMouseGlobalPosition = event.globalPosition(); | 3981 m_lastKnownMouseGlobalPosition = event.globalPosition(); |
3962 } | 3982 } |
3963 | 3983 |
| 3984 void EventHandler::conditionallyEnableMouseEventForPointerTypeMouse(const Platfo
rmMouseEvent& event) |
| 3985 { |
| 3986 if (event.button() == NoButton) |
| 3987 m_preventMouseEventForPointerTypeMouse = false; |
| 3988 } |
| 3989 |
3964 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m
ev, LocalFrame* subframe) | 3990 bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& m
ev, LocalFrame* subframe) |
3965 { | 3991 { |
3966 selectionController().passMousePressEventToSubframe(mev); | 3992 selectionController().passMousePressEventToSubframe(mev); |
3967 subframe->eventHandler().handleMousePressEvent(mev.event()); | 3993 subframe->eventHandler().handleMousePressEvent(mev.event()); |
3968 return true; | 3994 return true; |
3969 } | 3995 } |
3970 | 3996 |
3971 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& me
v, LocalFrame* subframe, HitTestResult* hoveredNode) | 3997 bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& me
v, LocalFrame* subframe, HitTestResult* hoveredNode) |
3972 { | 3998 { |
3973 if (m_mouseDownMayStartDrag) | 3999 if (m_mouseDownMayStartDrag) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4008 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() | 4034 PlatformEvent::Modifiers EventHandler::accessKeyModifiers() |
4009 { | 4035 { |
4010 #if OS(MACOSX) | 4036 #if OS(MACOSX) |
4011 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); | 4037 return static_cast<PlatformEvent::Modifiers>(PlatformEvent::CtrlKey | Platfo
rmEvent::AltKey); |
4012 #else | 4038 #else |
4013 return PlatformEvent::AltKey; | 4039 return PlatformEvent::AltKey; |
4014 #endif | 4040 #endif |
4015 } | 4041 } |
4016 | 4042 |
4017 } // namespace blink | 4043 } // namespace blink |
OLD | NEW |