Changeset 241432 in webkit
- Timestamp:
- Feb 13, 2019 5:34:43 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r241430 r241432 1 2019-02-13 Antoine Quint <graouts@apple.com> 2 3 Support simulated mouse events on iOS based on a PlatformTouchEvent 4 https://bugs.webkit.org/show_bug.cgi?id=194501 5 <rdar://problem/46910790> 6 7 Reviewed by Dean Jackson. 8 9 Add a new test to check that we correctly dispatch mouse events as touches occur. 10 11 * fast/events/touch/ios/mouse-events-dispatch-with-touch-expected.txt: Added. 12 * fast/events/touch/ios/mouse-events-dispatch-with-touch.html: Added. 13 * pointerevents/utils.js: 14 (prototype.handleEvent): 15 (prototype._handlePointerEvent): 16 (prototype._handleMouseEvent): 17 1 18 2019-02-13 Fujii Hironori <Hironori.Fujii@sony.com> 2 19 -
trunk/LayoutTests/pointerevents/utils.js
r240632 r241432 47 47 handleEvent(event) 48 48 { 49 if (event instanceof PointerEvent) 50 this._handlePointerEvent(event); 51 else if (event instanceof MouseEvent) 52 this._handleMouseEvent(event); 53 } 54 55 _handlePointerEvent(event) 56 { 49 57 if (!this.pointerIdToTouchIdMap[event.pointerId]) 50 58 this.pointerIdToTouchIdMap[event.pointerId] = Object.keys(this.pointerIdToTouchIdMap).length + 1; 51 59 52 const id = this.pointerIdToTouchIdMap[event.pointerId];53 60 this.events.push({ 54 id ,61 id: this.pointerIdToTouchIdMap[event.pointerId], 55 62 type: event.type, 56 63 x: event.clientX, 57 64 y: event.clientY, 58 65 isPrimary: event.isPrimary 66 }); 67 } 68 69 _handleMouseEvent(event) 70 { 71 this.events.push({ 72 type: event.type, 73 x: event.clientX, 74 y: event.clientY, 59 75 }); 60 76 } -
trunk/Source/WebCore/ChangeLog
r241402 r241432 1 2019-02-13 Antoine Quint <graouts@apple.com> 2 3 Support simulated mouse events on iOS based on a PlatformTouchEvent 4 https://bugs.webkit.org/show_bug.cgi?id=194501 5 <rdar://problem/46910790> 6 7 Reviewed by Dean Jackson. 8 9 Add support for two new internal runtime flags to control whether simulated mouse events should be dipatched along with touch events and 10 whether simulated mousemove events dispatched should automatically trigger the behavior preventDefault() would also trigger. To facilitate 11 that, we allow for a MouseEvent to be created, much like a PointerEvent, based on a PlatformTouchEvent. Then, we set a flag on Event within 12 EventTarget::innerInvokeEventListeners() to see whether any page code has been evaluated as a result of a mousemove event being dispatched. 13 Finally, we also track mouse events when invalidating touch regions provided the required internal runtime flag is on. 14 15 Test: fast/events/touch/ios/mouse-events-dispatch-with-touch.html 16 17 * SourcesCocoa.txt: 18 * WebCore.xcodeproj/project.pbxproj: 19 * dom/Event.cpp: 20 * dom/Event.h: 21 (WebCore::Event::hasEncounteredListener const): 22 (WebCore::Event::setHasEncounteredListener): 23 * dom/EventNames.h: 24 (WebCore::EventNames::isTouchRelatedEventType const): 25 (WebCore::EventNames::touchRelatedEventNames const): 26 (WebCore::EventNames::extendedTouchRelatedEventNames const): 27 (WebCore::EventNames::isTouchEventType const): Deleted. 28 (WebCore::EventNames::touchAndPointerEventNames const): Deleted. 29 * dom/EventTarget.cpp: 30 (WebCore::EventTarget::innerInvokeEventListeners): 31 * dom/MouseEvent.h: 32 * dom/Node.cpp: 33 (WebCore::Node::moveNodeToNewDocument): 34 (WebCore::tryAddEventListener): 35 (WebCore::tryRemoveEventListener): 36 (WebCore::Node::defaultEventHandler): 37 * dom/ios/MouseEventIOS.cpp: Added. 38 (WebCore::mouseEventType): 39 (WebCore::MouseEvent::create): 40 * dom/ios/PointerEventIOS.cpp: 41 (WebCore::pointerEventType): 42 (WebCore::PointerEvent::create): 43 (WebCore::eventType): Deleted. 44 * page/DOMWindow.cpp: 45 (WebCore::DOMWindow::addEventListener): 46 (WebCore::DOMWindow::removeEventListener): 47 * page/EventHandler.h: 48 * page/RuntimeEnabledFeatures.h: 49 (WebCore::RuntimeEnabledFeatures::mouseEventsSimulationEnabled const): 50 (WebCore::RuntimeEnabledFeatures::setMouseEventsSimulationEnabled): 51 (WebCore::RuntimeEnabledFeatures::mousemoveEventHandlingPreventsDefaultEnabled const): 52 (WebCore::RuntimeEnabledFeatures::setMousemoveEventHandlingPreventsDefaultEnabled): 53 1 54 2019-02-13 Carlos Garcia Campos <cgarcia@igalia.com> 2 55 -
trunk/Source/WebCore/SourcesCocoa.txt
r241321 r241432 72 72 dom/DataTransferMac.mm 73 73 74 dom/ios/MouseEventIOS.cpp 74 75 dom/ios/PointerEventIOS.cpp 75 76 dom/ios/TouchEvents.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r241328 r241432 9433 9433 71C916071D1483A300ACA47D /* UserInterfaceLayoutDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserInterfaceLayoutDirection.h; sourceTree = "<group>"; }; 9434 9434 71CC7A1F152A0BFE009EEAF9 /* SVGAnimatedEnumeration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedEnumeration.cpp; sourceTree = "<group>"; }; 9435 71CE2C512209DC7F00C494BD /* MouseEventIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseEventIOS.cpp; sourceTree = "<group>"; }; 9435 9436 71D02D901DB55C4E00DD5CF5 /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = main.js; sourceTree = "<group>"; }; 9436 9437 71D02D921DB55C4E00DD5CF5 /* media-controller.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "media-controller.js"; sourceTree = "<group>"; }; … … 26067 26068 isa = PBXGroup; 26068 26069 children = ( 26070 71CE2C512209DC7F00C494BD /* MouseEventIOS.cpp */, 26069 26071 315574CC218F66D000D88F66 /* PointerEventIOS.cpp */, 26070 26072 A1DE712B18612AC100734192 /* TouchEvents.cpp */, -
trunk/Source/WebCore/dom/Event.cpp
r237431 r241432 47 47 , m_isTrusted { isTrusted == IsTrusted::Yes } 48 48 , m_isExecutingPassiveEventListener { false } 49 , m_hasEncounteredListener { false } 49 50 , m_eventPhase { NONE } 50 51 , m_type { type } -
trunk/Source/WebCore/dom/Event.h
r236378 r241432 129 129 void setInPassiveListener(bool value) { m_isExecutingPassiveEventListener = value; } 130 130 131 bool hasEncounteredListener() const { return m_hasEncounteredListener; } 132 void setHasEncounteredListener() { m_hasEncounteredListener = true; } 133 131 134 bool cancelBubble() const { return propagationStopped(); } 132 135 void setCancelBubble(bool); … … 167 170 unsigned m_isTrusted : 1; 168 171 unsigned m_isExecutingPassiveEventListener : 1; 172 unsigned m_hasEncounteredListener : 1; 169 173 170 174 unsigned m_eventPhase : 2; -
trunk/Source/WebCore/dom/EventNames.h
r240634 r241432 26 26 #include <functional> 27 27 #include <wtf/text/AtomicString.h> 28 29 #if ENABLE(TOUCH_EVENTS) 30 #include "RuntimeEnabledFeatures.h" 31 #endif 28 32 29 33 namespace WebCore { … … 356 360 bool isWheelEventType(const AtomicString& eventType) const; 357 361 bool isGestureEventType(const AtomicString& eventType) const; 358 bool isTouch EventType(const AtomicString& eventType) const;362 bool isTouchRelatedEventType(const AtomicString& eventType) const; 359 363 bool isTouchScrollBlockingEventType(const AtomicString& eventType) const; 360 364 #if ENABLE(GAMEPAD) … … 362 366 #endif 363 367 364 std::array<std::reference_wrapper<const AtomicString>, 9> touchAndPointerEventNames() const; 368 std::array<std::reference_wrapper<const AtomicString>, 9> touchRelatedEventNames() const; 369 std::array<std::reference_wrapper<const AtomicString>, 12> extendedTouchRelatedEventNames() const; 365 370 std::array<std::reference_wrapper<const AtomicString>, 3> gestureEventNames() const; 366 371 … … 390 395 } 391 396 392 inline bool EventNames::isTouchEventType(const AtomicString& eventType) const 393 { 397 inline bool EventNames::isTouchRelatedEventType(const AtomicString& eventType) const 398 { 399 #if ENABLE(TOUCH_EVENTS) 400 if (RuntimeEnabledFeatures::sharedFeatures().mouseEventsSimulationEnabled()) { 401 if (eventType == mousedownEvent || eventType == mousemoveEvent || eventType == mouseupEvent) 402 return true; 403 } 404 #endif 394 405 return eventType == touchstartEvent 395 406 || eventType == touchmoveEvent … … 409 420 } 410 421 411 inline std::array<std::reference_wrapper<const AtomicString>, 9> EventNames::touch AndPointerEventNames() const422 inline std::array<std::reference_wrapper<const AtomicString>, 9> EventNames::touchRelatedEventNames() const 412 423 { 413 424 return { { touchstartEvent, touchmoveEvent, touchendEvent, touchcancelEvent, touchforcechangeEvent, pointerdownEvent, pointermoveEvent, pointerupEvent, pointercancelEvent } }; 414 425 } 415 426 427 inline std::array<std::reference_wrapper<const AtomicString>, 12> EventNames::extendedTouchRelatedEventNames() const 428 { 429 return { { touchstartEvent, touchmoveEvent, touchendEvent, touchcancelEvent, touchforcechangeEvent, pointerdownEvent, pointermoveEvent, pointerupEvent, pointercancelEvent, mousedownEvent, mousemoveEvent, mouseupEvent } }; 430 } 431 416 432 inline std::array<std::reference_wrapper<const AtomicString>, 3> EventNames::gestureEventNames() const 417 433 { -
trunk/Source/WebCore/dom/EventTarget.cpp
r240641 r241432 36 36 #include "EventNames.h" 37 37 #include "HTMLBodyElement.h" 38 #include "HTMLHtmlElement.h" 38 39 #include "InspectorInstrumentation.h" 39 40 #include "JSEventListener.h" 41 #include "RuntimeEnabledFeatures.h" 40 42 #include "ScriptController.h" 41 43 #include "ScriptDisallowedScope.h" … … 300 302 InspectorInstrumentation::didHandleEvent(context); 301 303 304 #if ENABLE(TOUCH_EVENTS) 305 if (RuntimeEnabledFeatures::sharedFeatures().mousemoveEventHandlingPreventsDefaultEnabled() && event.type() == eventNames().mousemoveEvent) { 306 if (is<Element>(event.currentTarget())) { 307 auto* element = downcast<Element>(event.currentTarget()); 308 if (!is<HTMLBodyElement>(element) && !is<HTMLHtmlElement>(element)) 309 event.setHasEncounteredListener(); 310 } 311 } 312 #endif 313 302 314 if (registeredListener->isPassive()) 303 315 event.setInPassiveListener(false); -
trunk/Source/WebCore/dom/MouseEvent.h
r235335 r241432 27 27 #include "MouseRelatedEvent.h" 28 28 29 #if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY) 30 #include "PlatformTouchEventIOS.h" 31 #endif 32 29 33 namespace WebCore { 30 34 … … 48 52 49 53 static Ref<MouseEvent> create(const AtomicString& eventType, const MouseEventInit&); 54 55 #if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY) 56 static Ref<MouseEvent> create(const PlatformTouchEvent&, unsigned touchIndex, Ref<WindowProxy>&&); 57 #endif 50 58 51 59 virtual ~MouseEvent(); -
trunk/Source/WebCore/dom/Node.cpp
r240237 r241432 2080 2080 2081 2081 unsigned numTouchEventListeners = 0; 2082 for (auto& name : eventNames().touchAndPointerEventNames()) 2083 numTouchEventListeners += eventListeners(name).size(); 2082 #if ENABLE(TOUCH_EVENTS) 2083 if (RuntimeEnabledFeatures::sharedFeatures().mouseEventsSimulationEnabled()) { 2084 for (auto& name : eventNames().extendedTouchRelatedEventNames()) 2085 numTouchEventListeners += eventListeners(name).size(); 2086 } else { 2087 #endif 2088 for (auto& name : eventNames().touchRelatedEventNames()) 2089 numTouchEventListeners += eventListeners(name).size(); 2090 #if ENABLE(TOUCH_EVENTS) 2091 } 2092 #endif 2084 2093 2085 2094 for (unsigned i = 0; i < numTouchEventListeners; ++i) { … … 2126 2135 if (eventNames().isWheelEventType(eventType)) 2127 2136 targetNode->document().didAddWheelEventHandler(*targetNode); 2128 else if (eventNames().isTouch EventType(eventType))2137 else if (eventNames().isTouchRelatedEventType(eventType)) 2129 2138 targetNode->document().didAddTouchEventHandler(*targetNode); 2130 2139 … … 2141 2150 2142 2151 #if ENABLE(TOUCH_EVENTS) 2143 if (eventNames().isTouch EventType(eventType))2152 if (eventNames().isTouchRelatedEventType(eventType)) 2144 2153 targetNode->document().addTouchEventListener(*targetNode); 2145 2154 #endif … … 2168 2177 if (eventNames().isWheelEventType(eventType)) 2169 2178 targetNode->document().didRemoveWheelEventHandler(*targetNode); 2170 else if (eventNames().isTouch EventType(eventType))2179 else if (eventNames().isTouchRelatedEventType(eventType)) 2171 2180 targetNode->document().didRemoveTouchEventHandler(*targetNode); 2172 2181 … … 2182 2191 2183 2192 #if ENABLE(TOUCH_EVENTS) 2184 if (eventNames().isTouch EventType(eventType))2193 if (eventNames().isTouchRelatedEventType(eventType)) 2185 2194 targetNode->document().removeTouchEventListener(*targetNode); 2186 2195 #endif … … 2478 2487 frame->eventHandler().defaultWheelEventHandler(startNode, downcast<WheelEvent>(event)); 2479 2488 #if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY) 2480 } else if (is<TouchEvent>(event) && eventNames().isTouch EventType(eventType)) {2489 } else if (is<TouchEvent>(event) && eventNames().isTouchRelatedEventType(eventType)) { 2481 2490 RenderObject* renderer = this->renderer(); 2482 2491 while (renderer && (!is<RenderBox>(*renderer) || !downcast<RenderBox>(*renderer).canBeScrolledAndHasScrollableArea())) -
trunk/Source/WebCore/dom/ios/PointerEventIOS.cpp
r240943 r241432 33 33 namespace WebCore { 34 34 35 static AtomicString eventType(PlatformTouchPoint::TouchPhaseType phase)35 static AtomicString pointerEventType(PlatformTouchPoint::TouchPhaseType phase) 36 36 { 37 37 switch (phase) { … … 61 61 { 62 62 auto phase = event.touchPhaseAtIndex(index); 63 return adoptRef(*new PointerEvent( eventType(phase), event, phaseIsCancelable(phase), index, isPrimary, WTFMove(view)));63 return adoptRef(*new PointerEvent(pointerEventType(phase), event, phaseIsCancelable(phase), index, isPrimary, WTFMove(view))); 64 64 } 65 65 -
trunk/Source/WebCore/page/DOMWindow.cpp
r240661 r241432 1812 1812 if (eventNames().isWheelEventType(eventType)) 1813 1813 document->didAddWheelEventHandler(*document); 1814 else if (eventNames().isTouch EventType(eventType))1814 else if (eventNames().isTouchRelatedEventType(eventType)) 1815 1815 document->didAddTouchEventHandler(*document); 1816 1816 else if (eventType == eventNames().storageEvent) … … 1827 1827 #endif 1828 1828 #if ENABLE(IOS_TOUCH_EVENTS) 1829 else if (eventNames().isTouch EventType(eventType))1829 else if (eventNames().isTouchRelatedEventType(eventType)) 1830 1830 ++m_touchAndGestureEventListenerCount; 1831 1831 #endif … … 1921 1921 if (eventNames().isWheelEventType(eventType)) 1922 1922 document->didRemoveWheelEventHandler(*document); 1923 else if (eventNames().isTouch EventType(eventType))1923 else if (eventNames().isTouchRelatedEventType(eventType)) 1924 1924 document->didRemoveTouchEventHandler(*document); 1925 1925 } … … 1950 1950 #endif 1951 1951 #if ENABLE(IOS_TOUCH_EVENTS) 1952 else if (eventNames().isTouch EventType(eventType)) {1952 else if (eventNames().isTouchRelatedEventType(eventType)) { 1953 1953 ASSERT(m_touchAndGestureEventListenerCount > 0); 1954 1954 --m_touchAndGestureEventListenerCount; -
trunk/Source/WebCore/page/EventHandler.h
r240491 r241432 607 607 #endif 608 608 609 #if ENABLE(IOS_TOUCH_EVENTS) 610 unsigned touchIdentifierForMouseEvents { 0 }; 611 #endif 612 609 613 double m_maxMouseMovedDuration { 0 }; 610 614 bool m_didStartDrag { false }; -
trunk/Source/WebCore/page/RuntimeEnabledFeatures.h
r240444 r241432 345 345 void setAdClickAttributionEnabled(bool isEnabled) { m_adClickAttributionEnabled = isEnabled; } 346 346 347 #if ENABLE(TOUCH_EVENTS) 348 bool mouseEventsSimulationEnabled() const { return m_mouseEventsSimulationEnabled; } 349 void setMouseEventsSimulationEnabled(bool isEnabled) { m_mouseEventsSimulationEnabled = isEnabled; } 350 351 bool mousemoveEventHandlingPreventsDefaultEnabled() const { return m_mousemoveEventHandlingPreventsDefaultEnabled; } 352 void setMousemoveEventHandlingPreventsDefaultEnabled(bool isEnabled) { m_mousemoveEventHandlingPreventsDefaultEnabled = isEnabled; } 353 #endif 354 347 355 WEBCORE_EXPORT static RuntimeEnabledFeatures& sharedFeatures(); 348 356 … … 522 530 bool m_adClickAttributionEnabled { false }; 523 531 532 #if ENABLE(TOUCH_EVENTS) 533 bool m_mouseEventsSimulationEnabled { false }; 534 bool m_mousemoveEventHandlingPreventsDefaultEnabled { false }; 535 #endif 536 524 537 friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>; 525 538 }; -
trunk/Source/WebKit/ChangeLog
r241401 r241432 1 2019-02-13 Antoine Quint <graouts@apple.com> 2 3 Support simulated mouse events on iOS based on a PlatformTouchEvent 4 https://bugs.webkit.org/show_bug.cgi?id=194501 5 <rdar://problem/46910790> 6 7 Reviewed by Dean Jackson. 8 9 Add two new internal runtime flags to control whether simulated mouse events should be dipatched along with touch events and whether 10 simulated mousemove events dispatched should automatically trigger the behavior preventDefault() would also trigger. We also ensure 11 that we correctly create touch tracking regions for mouse events. 12 13 * Shared/WebPreferences.yaml: 14 * UIProcess/WebPageProxy.cpp: 15 (WebKit::WebPageProxy::updateTouchEventTracking): 16 1 17 2019-02-13 Ryosuke Niwa <rniwa@webkit.org> 2 18 -
trunk/Source/WebKit/Shared/WebPreferences.yaml
r241320 r241432 1542 1542 category: internal 1543 1543 1544 MouseEventsSimulationEnabled: 1545 type: bool 1546 defaultValue: false 1547 humanReadableName: "Mouse events simulation" 1548 humanReadableDescription: "Enable mouse events dispatch along with touch events on iOS" 1549 webcoreBinding: RuntimeEnabledFeatures 1550 category: internal 1551 condition: ENABLE(TOUCH_EVENTS) 1552 1553 MousemoveEventHandlingPreventsDefaultEnabled: 1554 type: bool 1555 defaultValue: false 1556 humanReadableName: "Prevent default for mousemove events" 1557 humanReadableDescription: "Allows handling of mousemove events to implicitly call preventDefault() on iOS" 1558 webcoreBinding: RuntimeEnabledFeatures 1559 category: internal 1560 condition: ENABLE(TOUCH_EVENTS) 1561 1544 1562 # Deprecated 1545 1563 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r241351 r241432 2510 2510 updateTrackingType(m_touchAndPointerEventTracking.touchMoveTracking, names.pointermoveEvent); 2511 2511 updateTrackingType(m_touchAndPointerEventTracking.touchEndTracking, names.pointerupEvent); 2512 updateTrackingType(m_touchAndPointerEventTracking.touchStartTracking, names.mousedownEvent); 2513 updateTrackingType(m_touchAndPointerEventTracking.touchMoveTracking, names.mousemoveEvent); 2514 updateTrackingType(m_touchAndPointerEventTracking.touchEndTracking, names.mouseupEvent); 2512 2515 } 2513 2516 #else
Note: See TracChangeset
for help on using the changeset viewer.