Title: [275431] trunk/Source/WebCore
Revision
275431
Author
[email protected]
Date
2021-04-02 12:32:06 -0700 (Fri, 02 Apr 2021)

Log Message

[iPadOS] unable to reorder tabs on `*.mybinder.org`
https://bugs.webkit.org/show_bug.cgi?id=224034
<rdar://problem/51770057>

Reviewed by Brent Fulgham.

* page/Quirks.h:
* page/Quirks.cpp:
(WebCore::Quirks::shouldDispatchSimulatedMouseEvents const):
(WebCore::Quirks::shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented const):
(WebCore::Quirks::simulatedMouseEventTypeForTarget const):
Modify `Quirks::shouldDispatchSimulatedMouseEvents` to accept an `EventTarget` so that we
can limit dispatching touch events as mouse events on `*.mybinder.org` to only the tab bar.

* dom/EventNames.h:
(WebCore::EventNames::isTouchRelatedEventType const):
* dom/Node.cpp:
(WebCore::Node::moveNodeToNewDocument):
(WebCore::tryAddEventListener):
(WebCore::tryRemoveEventListener):
(WebCore::Node::defaultEventHandler):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::addEventListener):
(WebCore::DOMWindow::removeEventListener):
Pass in the `EventTarget` when calling `Quirks::shouldDispatchSimulatedMouseEvents`.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (275430 => 275431)


--- trunk/Source/WebCore/ChangeLog	2021-04-02 19:30:12 UTC (rev 275430)
+++ trunk/Source/WebCore/ChangeLog	2021-04-02 19:32:06 UTC (rev 275431)
@@ -1,3 +1,31 @@
+2021-04-02  Devin Rousso  <[email protected]>
+
+        [iPadOS] unable to reorder tabs on `*.mybinder.org`
+        https://bugs.webkit.org/show_bug.cgi?id=224034
+        <rdar://problem/51770057>
+
+        Reviewed by Brent Fulgham.
+
+        * page/Quirks.h:
+        * page/Quirks.cpp:
+        (WebCore::Quirks::shouldDispatchSimulatedMouseEvents const):
+        (WebCore::Quirks::shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented const):
+        (WebCore::Quirks::simulatedMouseEventTypeForTarget const):
+        Modify `Quirks::shouldDispatchSimulatedMouseEvents` to accept an `EventTarget` so that we
+        can limit dispatching touch events as mouse events on `*.mybinder.org` to only the tab bar.
+
+        * dom/EventNames.h:
+        (WebCore::EventNames::isTouchRelatedEventType const):
+        * dom/Node.cpp:
+        (WebCore::Node::moveNodeToNewDocument):
+        (WebCore::tryAddEventListener):
+        (WebCore::tryRemoveEventListener):
+        (WebCore::Node::defaultEventHandler):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::addEventListener):
+        (WebCore::DOMWindow::removeEventListener):
+        Pass in the `EventTarget` when calling `Quirks::shouldDispatchSimulatedMouseEvents`.
+
 2021-04-02  Zalan Bujtas  <[email protected]>
 
         [AspectRatio] Out-of-flow box with intrinsic width (e.g. <img>) may trigger infinite recursion

Modified: trunk/Source/WebCore/dom/EventNames.h (275430 => 275431)


--- trunk/Source/WebCore/dom/EventNames.h	2021-04-02 19:30:12 UTC (rev 275430)
+++ trunk/Source/WebCore/dom/EventNames.h	2021-04-02 19:32:06 UTC (rev 275431)
@@ -368,7 +368,7 @@
     // We should choose one term and stick to it.
     bool isWheelEventType(const AtomString& eventType) const;
     bool isGestureEventType(const AtomString& eventType) const;
-    bool isTouchRelatedEventType(const Document&, const AtomString& eventType) const;
+    bool isTouchRelatedEventType(const AtomString& eventType, EventTarget&) const;
     bool isTouchScrollBlockingEventType(const AtomString& eventType) const;
 #if ENABLE(GAMEPAD)
     bool isGamepadEventType(const AtomString& eventType) const;
@@ -403,15 +403,15 @@
         || eventType == touchmoveEvent;
 }
 
-inline bool EventNames::isTouchRelatedEventType(const Document& document, const AtomString& eventType) const
+inline bool EventNames::isTouchRelatedEventType(const AtomString& eventType, EventTarget& target) const
 {
 #if ENABLE(TOUCH_EVENTS)
-    if (document.quirks().shouldDispatchSimulatedMouseEvents()) {
+    if (is<Node>(target) && downcast<Node>(target).document().quirks().shouldDispatchSimulatedMouseEvents(&target)) {
         if (eventType == mousedownEvent || eventType == mousemoveEvent || eventType == mouseupEvent)
             return true;
     }
 #endif
-    UNUSED_PARAM(document);
+    UNUSED_PARAM(target);
     return eventType == touchstartEvent
         || eventType == touchmoveEvent
         || eventType == touchendEvent

Modified: trunk/Source/WebCore/dom/Node.cpp (275430 => 275431)


--- trunk/Source/WebCore/dom/Node.cpp	2021-04-02 19:30:12 UTC (rev 275430)
+++ trunk/Source/WebCore/dom/Node.cpp	2021-04-02 19:32:06 UTC (rev 275431)
@@ -2082,7 +2082,7 @@
 
         unsigned numTouchEventListeners = 0;
 #if ENABLE(TOUCH_EVENTS)
-        if (newDocument.quirks().shouldDispatchSimulatedMouseEvents()) {
+        if (newDocument.quirks().shouldDispatchSimulatedMouseEvents(this)) {
             for (auto& name : eventNames().extendedTouchRelatedEventNames())
                 numTouchEventListeners += eventListeners(name).size();
         } else {
@@ -2136,7 +2136,7 @@
     targetNode->document().addListenerTypeIfNeeded(eventType);
     if (eventNames().isWheelEventType(eventType))
         targetNode->document().didAddWheelEventHandler(*targetNode);
-    else if (eventNames().isTouchRelatedEventType(targetNode->document(), eventType))
+    else if (eventNames().isTouchRelatedEventType(eventType, *targetNode))
         targetNode->document().didAddTouchEventHandler(*targetNode);
 
 #if PLATFORM(IOS_FAMILY)
@@ -2146,7 +2146,7 @@
     }
 
 #if ENABLE(TOUCH_EVENTS)
-    if (eventNames().isTouchRelatedEventType(targetNode->document(), eventType))
+    if (eventNames().isTouchRelatedEventType(eventType, *targetNode))
         targetNode->document().addTouchEventListener(*targetNode);
 #endif
 #endif // PLATFORM(IOS_FAMILY)
@@ -2173,7 +2173,7 @@
     // listeners for each type, not just a bool - see https://bugs.webkit.org/show_bug.cgi?id=33861
     if (eventNames().isWheelEventType(eventType))
         targetNode->document().didRemoveWheelEventHandler(*targetNode);
-    else if (eventNames().isTouchRelatedEventType(targetNode->document(), eventType))
+    else if (eventNames().isTouchRelatedEventType(eventType, *targetNode))
         targetNode->document().didRemoveTouchEventHandler(*targetNode);
 
 #if PLATFORM(IOS_FAMILY)
@@ -2183,7 +2183,7 @@
     }
 
 #if ENABLE(TOUCH_EVENTS)
-    if (eventNames().isTouchRelatedEventType(targetNode->document(), eventType))
+    if (eventNames().isTouchRelatedEventType(eventType, *targetNode))
         targetNode->document().removeTouchEventListener(*targetNode);
 #endif
 #endif // PLATFORM(IOS_FAMILY)
@@ -2471,7 +2471,7 @@
                 frame->eventHandler().defaultWheelEventHandler(startNode, downcast<WheelEvent>(event));
         }
 #if ENABLE(TOUCH_EVENTS) && PLATFORM(IOS_FAMILY)
-    } else if (is<TouchEvent>(event) && eventNames().isTouchRelatedEventType(document(), eventType)) {
+    } else if (is<TouchEvent>(event) && eventNames().isTouchRelatedEventType(eventType, *this)) {
         // Capture the target node's visibility state before dispatching touchStart.
         if (is<Element>(*this) && eventType == eventNames().touchstartEvent) {
             auto& contentChangeObserver = document().contentChangeObserver(); 

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (275430 => 275431)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2021-04-02 19:30:12 UTC (rev 275430)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2021-04-02 19:32:06 UTC (rev 275431)
@@ -1950,7 +1950,7 @@
         document->addListenerTypeIfNeeded(eventType);
         if (eventNames().isWheelEventType(eventType))
             document->didAddWheelEventHandler(*document);
-        else if (eventNames().isTouchRelatedEventType(*document, eventType))
+        else if (eventNames().isTouchRelatedEventType(eventType, *document))
             document->didAddTouchEventHandler(*document);
         else if (eventType == eventNames().storageEvent)
             didAddStorageEventListener(*this);
@@ -1965,7 +1965,7 @@
         incrementScrollEventListenersCount();
 #endif
 #if ENABLE(IOS_TOUCH_EVENTS)
-    else if (document && eventNames().isTouchRelatedEventType(*document, eventType))
+    else if (document && eventNames().isTouchRelatedEventType(eventType, *document))
         ++m_touchAndGestureEventListenerCount;
 #endif
 #if ENABLE(IOS_GESTURE_EVENTS)
@@ -2193,7 +2193,7 @@
     if (document) {
         if (eventNames().isWheelEventType(eventType))
             document->didRemoveWheelEventHandler(*document);
-        else if (eventNames().isTouchRelatedEventType(*document, eventType))
+        else if (eventNames().isTouchRelatedEventType(eventType, *document))
             document->didRemoveTouchEventHandler(*document);
     }
 
@@ -2206,7 +2206,7 @@
         decrementScrollEventListenersCount();
 #endif
 #if ENABLE(IOS_TOUCH_EVENTS)
-    else if (document && eventNames().isTouchRelatedEventType(*document, eventType)) {
+    else if (document && eventNames().isTouchRelatedEventType(eventType, *document)) {
         ASSERT(m_touchAndGestureEventListenerCount > 0);
         --m_touchAndGestureEventListenerCount;
     }

Modified: trunk/Source/WebCore/page/Quirks.cpp (275430 => 275431)


--- trunk/Source/WebCore/page/Quirks.cpp	2021-04-02 19:30:12 UTC (rev 275430)
+++ trunk/Source/WebCore/page/Quirks.cpp	2021-04-02 19:32:06 UTC (rev 275431)
@@ -361,7 +361,7 @@
     return topPrivatelyControlledDomain(url.host().toString()).startsWith("google.") && url.path().startsWithIgnoringASCIICase("/maps/");
 }
 
-bool Quirks::shouldDispatchSimulatedMouseEvents() const
+bool Quirks::shouldDispatchSimulatedMouseEvents(EventTarget* target) const
 {
     if (RuntimeEnabledFeatures::sharedFeatures().mouseEventsSimulationEnabled())
         return true;
@@ -369,15 +369,15 @@
     if (!needsQuirks())
         return false;
 
-    auto doShouldDispatchChecks = [this] () -> bool {
+    auto doShouldDispatchChecks = [this] () -> ShouldDispatchSimulatedMouseEvents {
         auto* loader = m_document->loader();
         if (!loader || loader->simulatedMouseEventsDispatchPolicy() != SimulatedMouseEventsDispatchPolicy::Allow)
-            return false;
+            return ShouldDispatchSimulatedMouseEvents::No;
 
         if (isAmazon())
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         if (isGoogleMaps())
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
 
         auto& url = ""
         auto host = url.host().convertToASCIILowercase();
@@ -384,55 +384,80 @@
 
         if (host == "wix.com" || host.endsWith(".wix.com")) {
             // Disable simulated mouse dispatching for template selection.
-            return !url.path().startsWithIgnoringASCIICase("/website/templates/");
+            return url.path().startsWithIgnoringASCIICase("/website/templates/") ? ShouldDispatchSimulatedMouseEvents::No : ShouldDispatchSimulatedMouseEvents::Yes;
         }
 
         if ((host == "desmos.com" || host.endsWith(".desmos.com")) && url.path().startsWithIgnoringASCIICase("/calculator/"))
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         if (host == "figma.com" || host.endsWith(".figma.com"))
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         if (host == "trello.com" || host.endsWith(".trello.com"))
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         if (host == "airtable.com" || host.endsWith(".airtable.com"))
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         if (host == "msn.com" || host.endsWith(".msn.com"))
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         if (host == "flipkart.com" || host.endsWith(".flipkart.com"))
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         if (host == "iqiyi.com" || host.endsWith(".iqiyi.com"))
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         if (host == "trailers.apple.com")
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         if (host == "soundcloud.com")
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         if (host == "naver.com")
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         if (host == "nba.com" || host.endsWith(".nba.com"))
-            return true;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         if (host.endsWith(".naver.com")) {
             // Disable the quirk for tv.naver.com subdomain to be able to simulate hover on videos.
             if (host == "tv.naver.com")
-                return false;
+                return ShouldDispatchSimulatedMouseEvents::No;
             // Disable the quirk for mail.naver.com subdomain to be able to tap on mail subjects.
             if (host == "mail.naver.com")
-                return false;
+                return ShouldDispatchSimulatedMouseEvents::No;
             // Disable the quirk on the mobile site.
             // FIXME: Maybe this quirk should be disabled for "m." subdomains on all sites? These are generally mobile sites that don't need mouse events.
             if (host == "m.naver.com")
-                return false;
-            return true;
+                return ShouldDispatchSimulatedMouseEvents::No;
+            return ShouldDispatchSimulatedMouseEvents::Yes;
         }
-        return false;
+        if (host == "mybinder.org" || host.endsWith(".mybinder.org"))
+            return ShouldDispatchSimulatedMouseEvents::DependingOnTargetFor_mybinder_org;
+        return ShouldDispatchSimulatedMouseEvents::No;
     };
 
-    if (!m_shouldDispatchSimulatedMouseEventsQuirk)
+    if (m_shouldDispatchSimulatedMouseEventsQuirk == ShouldDispatchSimulatedMouseEvents::Unknown)
         m_shouldDispatchSimulatedMouseEventsQuirk = doShouldDispatchChecks();
-    return *m_shouldDispatchSimulatedMouseEventsQuirk;
+
+    switch (m_shouldDispatchSimulatedMouseEventsQuirk) {
+    case ShouldDispatchSimulatedMouseEvents::Unknown:
+        ASSERT_NOT_REACHED();
+        return false;
+
+    case ShouldDispatchSimulatedMouseEvents::No:
+        return false;
+
+    case ShouldDispatchSimulatedMouseEvents::DependingOnTargetFor_mybinder_org:
+        if (is<Node>(target)) {
+            for (auto* node = downcast<Node>(target); node; node = node->parentNode()) {
+                if (is<Element>(node) && downcast<Element>(*node).classList().contains("lm-DockPanel-tabBar"))
+                    return true;
+            }
+        }
+        return false;
+
+    case ShouldDispatchSimulatedMouseEvents::Yes:
+        return true;
+    }
+
+    ASSERT_NOT_REACHED();
+    return false;
 }
 
 bool Quirks::shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented(EventTarget* target) const
 {
-    if (!needsQuirks() || !shouldDispatchSimulatedMouseEvents())
+    if (!needsQuirks() || !shouldDispatchSimulatedMouseEvents(target))
         return false;
 
     if (isAmazon() && is<Element>(target)) {
@@ -453,7 +478,7 @@
 
 Optional<Event::IsCancelable> Quirks::simulatedMouseEventTypeForTarget(EventTarget* target) const
 {
-    if (!shouldDispatchSimulatedMouseEvents())
+    if (!needsQuirks() || !shouldDispatchSimulatedMouseEvents(target))
         return { };
 
     // On Google Maps, we want to limit simulated mouse events to dragging the little man that allows entering into Street View.

Modified: trunk/Source/WebCore/page/Quirks.h (275430 => 275431)


--- trunk/Source/WebCore/page/Quirks.h	2021-04-02 19:30:12 UTC (rev 275430)
+++ trunk/Source/WebCore/page/Quirks.h	2021-04-02 19:32:06 UTC (rev 275431)
@@ -62,7 +62,7 @@
     bool hasBrokenEncryptedMediaAPISupportQuirk() const;
     bool shouldStripQuotationMarkInFontFaceSetFamily() const;
 #if ENABLE(TOUCH_EVENTS)
-    bool shouldDispatchSimulatedMouseEvents() const;
+    bool shouldDispatchSimulatedMouseEvents(EventTarget*) const;
     bool shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented(EventTarget*) const;
     Optional<Event::IsCancelable> simulatedMouseEventTypeForTarget(EventTarget*) const;
     bool shouldMakeTouchEventNonCancelableForTarget(EventTarget*) const;
@@ -173,7 +173,13 @@
 #endif
     mutable Optional<bool> m_shouldDisableElementFullscreenQuirk;
 #if ENABLE(TOUCH_EVENTS)
-    mutable Optional<bool> m_shouldDispatchSimulatedMouseEventsQuirk;
+    enum class ShouldDispatchSimulatedMouseEvents : uint8_t {
+        Unknown,
+        No,
+        DependingOnTargetFor_mybinder_org,
+        Yes,
+    };
+    mutable ShouldDispatchSimulatedMouseEvents m_shouldDispatchSimulatedMouseEventsQuirk { ShouldDispatchSimulatedMouseEvents::Unknown };
 #endif
 #if ENABLE(IOS_TOUCH_EVENTS)
     mutable Optional<bool> m_shouldSynthesizeTouchEventsQuirk;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to