Title: [247568] trunk/Source/WebCore
Revision
247568
Author
grao...@webkit.org
Date
2019-07-18 11:57:35 -0700 (Thu, 18 Jul 2019)

Log Message

REGRESSION: Panning on an Amazon product image scrolls the page on iPadOS
https://bugs.webkit.org/show_bug.cgi?id=199905
<rdar://problem/49124529>

Reviewed by Dean Jackson.

Amazon product pages include images that the user can touch and pan to show zoomed details in a side image. This
currently works on iPadOS thanks to the dispatch of simulated "mousemove" events on the product image, but the site
doesn't call preventDefault() when handling those events as it wasn't necessary for macOS.

We add a new quirk that will indicate that a given element is such a product image.

* page/Quirks.cpp:
(WebCore::Quirks::isAmazon const):
(WebCore::Quirks::shouldDispatchSimulatedMouseEvents const):
(WebCore::Quirks::shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented const):
(WebCore::Quirks::simulatedMouseEventTypeForTarget const):
* page/Quirks.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (247567 => 247568)


--- trunk/Source/WebCore/ChangeLog	2019-07-18 18:41:31 UTC (rev 247567)
+++ trunk/Source/WebCore/ChangeLog	2019-07-18 18:57:35 UTC (rev 247568)
@@ -1,3 +1,24 @@
+2019-07-18  Antoine Quint  <grao...@apple.com>
+
+        REGRESSION: Panning on an Amazon product image scrolls the page on iPadOS
+        https://bugs.webkit.org/show_bug.cgi?id=199905
+        <rdar://problem/49124529>
+
+        Reviewed by Dean Jackson.
+
+        Amazon product pages include images that the user can touch and pan to show zoomed details in a side image. This
+        currently works on iPadOS thanks to the dispatch of simulated "mousemove" events on the product image, but the site
+        doesn't call preventDefault() when handling those events as it wasn't necessary for macOS.
+
+        We add a new quirk that will indicate that a given element is such a product image.
+
+        * page/Quirks.cpp:
+        (WebCore::Quirks::isAmazon const):
+        (WebCore::Quirks::shouldDispatchSimulatedMouseEvents const):
+        (WebCore::Quirks::shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented const):
+        (WebCore::Quirks::simulatedMouseEventTypeForTarget const):
+        * page/Quirks.h:
+
 2019-07-18  Youenn Fablet  <you...@apple.com>
 
         Make sure to set kCTFontFallbackOptionAttribute to kCTFontFallbackOptionSystem for system fonts

Modified: trunk/Source/WebCore/page/Quirks.cpp (247567 => 247568)


--- trunk/Source/WebCore/page/Quirks.cpp	2019-07-18 18:41:31 UTC (rev 247567)
+++ trunk/Source/WebCore/page/Quirks.cpp	2019-07-18 18:57:35 UTC (rev 247568)
@@ -227,6 +227,13 @@
 }
 
 #if ENABLE(TOUCH_EVENTS)
+bool Quirks::isAmazon() const
+{
+    auto& url = ""
+    auto host = url.host();
+    return equalLettersIgnoringASCIICase(host, "amazon.com") || host.endsWithIgnoringASCIICase(".amazon.com");
+}
+
 bool Quirks::shouldDispatchSimulatedMouseEvents() const
 {
     if (!needsQuirks())
@@ -236,11 +243,12 @@
     if (!loader || loader->simulatedMouseEventsDispatchPolicy() != SimulatedMouseEventsDispatchPolicy::Allow)
         return false;
 
+    if (isAmazon())
+        return true;
+
     auto& url = ""
     auto host = url.host();
 
-    if (equalLettersIgnoringASCIICase(host, "amazon.com") || host.endsWithIgnoringASCIICase(".amazon.com"))
-        return true;
     if (equalLettersIgnoringASCIICase(host, "wix.com") || host.endsWithIgnoringASCIICase(".wix.com"))
         return true;
     if ((equalLettersIgnoringASCIICase(host, "desmos.com") || host.endsWithIgnoringASCIICase(".desmos.com")) && url.path().startsWithIgnoringASCIICase("/calculator/"))
@@ -267,6 +275,24 @@
     return false;
 }
 
+bool Quirks::shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented(EventTarget* target) const
+{
+    if (!needsQuirks() || !shouldDispatchSimulatedMouseEvents())
+        return false;
+
+    if (isAmazon() && is<Element>(target)) {
+        // When panning on an Amazon product image, we're either touching on the #magnifierLens element
+        // or its previous sibling.
+        auto* element = downcast<Element>(target);
+        if (element->getIdAttribute() == "magnifierLens")
+            return true;
+        if (auto* sibling = element->nextElementSibling())
+            return sibling->getIdAttribute() == "magnifierLens";
+    }
+
+    return false;
+}
+
 Optional<Event::IsCancelable> Quirks::simulatedMouseEventTypeForTarget(EventTarget* target) const
 {
     if (!needsQuirks() || !shouldDispatchSimulatedMouseEvents())
@@ -285,7 +311,7 @@
         return Event::IsCancelable::No;
 
     return Event::IsCancelable::Yes;
-}   
+}
 #endif
 
 bool Quirks::shouldAvoidResizingWhenInputViewBoundsChange() const

Modified: trunk/Source/WebCore/page/Quirks.h (247567 => 247568)


--- trunk/Source/WebCore/page/Quirks.h	2019-07-18 18:41:31 UTC (rev 247567)
+++ trunk/Source/WebCore/page/Quirks.h	2019-07-18 18:57:35 UTC (rev 247568)
@@ -50,6 +50,7 @@
     bool hasBrokenEncryptedMediaAPISupportQuirk() const;
 #if ENABLE(TOUCH_EVENTS)
     bool shouldDispatchSimulatedMouseEvents() const;
+    bool shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented(EventTarget*) const;
     Optional<Event::IsCancelable> simulatedMouseEventTypeForTarget(EventTarget*) const;
 #endif
     bool shouldDisablePointerEventsQuirk() const;
@@ -70,6 +71,10 @@
 private:
     bool needsQuirks() const;
 
+#if ENABLE(TOUCH_EVENTS)
+    bool isAmazon() const;
+#endif
+
     WeakPtr<Document> m_document;
 
     mutable Optional<bool> m_hasBrokenEncryptedMediaAPISupportQuirk;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to