Changeset 247621 in webkit


Ignore:
Timestamp:
Jul 18, 2019 2:56:36 PM (5 years ago)
Author:
graouts@webkit.org
Message:

Ensure Quirks::shouldDispatchSimulatedMouseEvents() works for all Google Maps and Amazon domains
https://bugs.webkit.org/show_bug.cgi?id=199904
<rdar://problem/53250104>

Reviewed by Dean Jackson.

Use topPrivatelyControlledDomain() to determine whether the URL is a Google or Amazon domain so as to apply
Google Maps and Amazon quirks to all the various domain names used.

  • page/Quirks.cpp:

(WebCore::Quirks::isAmazon const):
(WebCore::Quirks::isGoogleMaps const):
(WebCore::Quirks::shouldDispatchSimulatedMouseEvents const):
(WebCore::Quirks::simulatedMouseEventTypeForTarget const):

  • page/Quirks.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247620 r247621  
     12019-07-18  Antoine Quint  <graouts@apple.com>
     2
     3        Ensure Quirks::shouldDispatchSimulatedMouseEvents() works for all Google Maps and Amazon domains
     4        https://bugs.webkit.org/show_bug.cgi?id=199904
     5        <rdar://problem/53250104>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Use topPrivatelyControlledDomain() to determine whether the URL is a Google or Amazon domain so as to apply
     10        Google Maps and Amazon quirks to all the various domain names used.
     11
     12        * page/Quirks.cpp:
     13        (WebCore::Quirks::isAmazon const):
     14        (WebCore::Quirks::isGoogleMaps const):
     15        (WebCore::Quirks::shouldDispatchSimulatedMouseEvents const):
     16        (WebCore::Quirks::simulatedMouseEventTypeForTarget const):
     17        * page/Quirks.h:
     18
    1192019-07-18  Per Arne Vollan  <pvollan@apple.com>
    220
  • trunk/Source/WebCore/page/Quirks.cpp

    r247572 r247621  
    231231bool Quirks::isAmazon() const
    232232{
     233    return topPrivatelyControlledDomain(m_document->topDocument().url().host().toString()).startsWith("amazon.");
     234}
     235
     236bool Quirks::isGoogleMaps() const
     237{
     238    auto& url = m_document->topDocument().url();
     239    return topPrivatelyControlledDomain(url.host().toString()).startsWith("google.") && url.path().startsWithIgnoringASCIICase("/maps/");
     240}
     241
     242bool Quirks::shouldDispatchSimulatedMouseEvents() const
     243{
     244    if (RuntimeEnabledFeatures::sharedFeatures().mouseEventsSimulationEnabled())
     245        return true;
     246
     247    if (!needsQuirks())
     248        return false;
     249
     250    auto* loader = m_document->loader();
     251    if (!loader || loader->simulatedMouseEventsDispatchPolicy() != SimulatedMouseEventsDispatchPolicy::Allow)
     252        return false;
     253
     254    if (isAmazon())
     255        return true;
     256    if (isGoogleMaps())
     257        return true;
     258
    233259    auto& url = m_document->topDocument().url();
    234260    auto host = url.host();
    235     return equalLettersIgnoringASCIICase(host, "amazon.com") || host.endsWithIgnoringASCIICase(".amazon.com");
    236 }
    237 
    238 bool Quirks::shouldDispatchSimulatedMouseEvents() const
    239 {
    240     if (RuntimeEnabledFeatures::sharedFeatures().mouseEventsSimulationEnabled())
    241         return true;
    242 
    243     if (!needsQuirks())
    244         return false;
    245 
    246     auto* loader = m_document->loader();
    247     if (!loader || loader->simulatedMouseEventsDispatchPolicy() != SimulatedMouseEventsDispatchPolicy::Allow)
    248         return false;
    249 
    250     if (isAmazon())
    251         return true;
    252 
    253     auto& url = m_document->topDocument().url();
    254     auto host = url.host();
    255261
    256262    if (equalLettersIgnoringASCIICase(host, "wix.com") || host.endsWithIgnoringASCIICase(".wix.com"))
     
    267273        return true;
    268274    if (equalLettersIgnoringASCIICase(host, "flipkart.com") || host.endsWithIgnoringASCIICase(".flipkart.com"))
    269         return true;
    270     if (equalLettersIgnoringASCIICase(host, "www.google.com") && url.path().startsWithIgnoringASCIICase("/maps/"))
    271275        return true;
    272276    if (equalLettersIgnoringASCIICase(host, "trailers.apple.com"))
     
    304308
    305309    // On Google Maps, we want to limit simulated mouse events to dragging the little man that allows entering into Street View.
    306     auto& url = m_document->topDocument().url();
    307     auto host = url.host();
    308     if (equalLettersIgnoringASCIICase(host, "www.google.com") && url.path().startsWithIgnoringASCIICase("/maps/")) {
     310    if (isGoogleMaps()) {
    309311        if (is<Element>(target) && downcast<Element>(target)->getAttribute("class") == "widget-expand-button-pegman-icon")
    310312            return Event::IsCancelable::Yes;
     
    312314    }
    313315
     316    auto host = m_document->topDocument().url().host();
    314317    if (equalLettersIgnoringASCIICase(host, "desmos.com") || host.endsWithIgnoringASCIICase(".desmos.com"))
    315318        return Event::IsCancelable::No;
  • trunk/Source/WebCore/page/Quirks.h

    r247568 r247621  
    7474#if ENABLE(TOUCH_EVENTS)
    7575    bool isAmazon() const;
     76    bool isGoogleMaps() const;
    7677#endif
    7778
Note: See TracChangeset for help on using the changeset viewer.