Changeset 247568 in webkit


Ignore:
Timestamp:
Jul 18, 2019 11:57:35 AM (5 years ago)
Author:
graouts@webkit.org
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:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247566 r247568  
     12019-07-18  Antoine Quint  <graouts@apple.com>
     2
     3        REGRESSION: Panning on an Amazon product image scrolls the page on iPadOS
     4        https://bugs.webkit.org/show_bug.cgi?id=199905
     5        <rdar://problem/49124529>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Amazon product pages include images that the user can touch and pan to show zoomed details in a side image. This
     10        currently works on iPadOS thanks to the dispatch of simulated "mousemove" events on the product image, but the site
     11        doesn't call preventDefault() when handling those events as it wasn't necessary for macOS.
     12
     13        We add a new quirk that will indicate that a given element is such a product image.
     14
     15        * page/Quirks.cpp:
     16        (WebCore::Quirks::isAmazon const):
     17        (WebCore::Quirks::shouldDispatchSimulatedMouseEvents const):
     18        (WebCore::Quirks::shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented const):
     19        (WebCore::Quirks::simulatedMouseEventTypeForTarget const):
     20        * page/Quirks.h:
     21
    1222019-07-18  Youenn Fablet  <youenn@apple.com>
    223
  • trunk/Source/WebCore/page/Quirks.cpp

    r247530 r247568  
    228228
    229229#if ENABLE(TOUCH_EVENTS)
     230bool Quirks::isAmazon() const
     231{
     232    auto& url = m_document->topDocument().url();
     233    auto host = url.host();
     234    return equalLettersIgnoringASCIICase(host, "amazon.com") || host.endsWithIgnoringASCIICase(".amazon.com");
     235}
     236
    230237bool Quirks::shouldDispatchSimulatedMouseEvents() const
    231238{
     
    237244        return false;
    238245
    239     auto& url = m_document->topDocument().url();
    240     auto host = url.host();
    241 
    242     if (equalLettersIgnoringASCIICase(host, "amazon.com") || host.endsWithIgnoringASCIICase(".amazon.com"))
    243         return true;
     246    if (isAmazon())
     247        return true;
     248
     249    auto& url = m_document->topDocument().url();
     250    auto host = url.host();
     251
    244252    if (equalLettersIgnoringASCIICase(host, "wix.com") || host.endsWithIgnoringASCIICase(".wix.com"))
    245253        return true;
     
    265273    if (host.endsWithIgnoringASCIICase(".naver.com"))
    266274        return !equalLettersIgnoringASCIICase(host, "tv.naver.com");
     275    return false;
     276}
     277
     278bool Quirks::shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented(EventTarget* target) const
     279{
     280    if (!needsQuirks() || !shouldDispatchSimulatedMouseEvents())
     281        return false;
     282
     283    if (isAmazon() && is<Element>(target)) {
     284        // When panning on an Amazon product image, we're either touching on the #magnifierLens element
     285        // or its previous sibling.
     286        auto* element = downcast<Element>(target);
     287        if (element->getIdAttribute() == "magnifierLens")
     288            return true;
     289        if (auto* sibling = element->nextElementSibling())
     290            return sibling->getIdAttribute() == "magnifierLens";
     291    }
     292
    267293    return false;
    268294}
     
    286312
    287313    return Event::IsCancelable::Yes;
    288 }   
     314}
    289315#endif
    290316
  • trunk/Source/WebCore/page/Quirks.h

    r247530 r247568  
    5151#if ENABLE(TOUCH_EVENTS)
    5252    bool shouldDispatchSimulatedMouseEvents() const;
     53    bool shouldDispatchedSimulatedMouseEventsAssumeDefaultPrevented(EventTarget*) const;
    5354    Optional<Event::IsCancelable> simulatedMouseEventTypeForTarget(EventTarget*) const;
    5455#endif
     
    7172    bool needsQuirks() const;
    7273
     74#if ENABLE(TOUCH_EVENTS)
     75    bool isAmazon() const;
     76#endif
     77
    7378    WeakPtr<Document> m_document;
    7479
Note: See TracChangeset for help on using the changeset viewer.