⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242792 in webkit


Ignore:
Timestamp:
Mar 12, 2019, 4:38:49 AM (7 years ago)
Author:
rniwa@webkit.org
Message:

Move the remaining code to decide whether site specific quirks are needed to Quirks class
https://bugs.webkit.org/show_bug.cgi?id=195610

Reviewed by Antti Koivisto.

Moved the remaining code scattered across WebCore to decide whether a site specific quirk
is needed or not to Quirks class introduced in r236818.

  • Modules/fetch/FetchRequest.cpp:

(WebCore::needsSignalQuirk): Deleted.
(WebCore::processInvalidSignal):

  • html/HTMLFormControlElement.cpp:

(WebCore::HTMLFormControlElement::needsMouseFocusableQuirk const):

  • html/HTMLMediaElement.cpp:

(WebCore::needsAutoplayPlayPauseEventsQuirk): Deleted.
(WebCore::HTMLMediaElement::dispatchPlayPauseEventsIfNeedsQuirks):
(WebCore::needsSeekingSupportQuirk): Deleted.
(WebCore::HTMLMediaElement::supportsSeeking const):

  • html/MediaElementSession.cpp:

(WebCore::needsArbitraryUserGestureAutoplayQuirk): Deleted.
(WebCore::needsPerDocumentAutoplayBehaviorQuirk): Deleted.
(WebCore::MediaElementSession::playbackPermitted const):

  • page/Quirks.cpp:

(WebCore::allowedAutoplayQuirks): Added.
(WebCore::Quirks::needsQuirks const): Added.
(WebCore::Quirks::shouldIgnoreInvalidSignal const): Added.
(WebCore::Quirks::needsFormControlToBeMouseFocusable const): Added.
(WebCore::Quirks::needsAutoplayPlayPauseEvents const): Added.
(WebCore::Quirks::needsSeekingSupportDisabled const): Addd.
(WebCore::Quirks::needsPerDocumentAutoplayBehavior const): Added.
(WebCore::Quirks::shouldAutoplayForArbitraryUserGesture const): Added.
(WebCore::Quirks::hasBrokenEncryptedMediaAPISupportQuirk const): Added.
(WebCore::Quirks::hasWebSQLSupportQuirk const): Fixed the coding style.

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242791 r242792  
     12019-03-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Move the remaining code to decide whether site specific quirks are needed to Quirks class
     4        https://bugs.webkit.org/show_bug.cgi?id=195610
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Moved the remaining code scattered across WebCore to decide whether a site specific quirk
     9        is needed or not to Quirks class introduced in r236818.
     10
     11        * Modules/fetch/FetchRequest.cpp:
     12        (WebCore::needsSignalQuirk): Deleted.
     13        (WebCore::processInvalidSignal):
     14        * html/HTMLFormControlElement.cpp:
     15        (WebCore::HTMLFormControlElement::needsMouseFocusableQuirk const):
     16        * html/HTMLMediaElement.cpp:
     17        (WebCore::needsAutoplayPlayPauseEventsQuirk): Deleted.
     18        (WebCore::HTMLMediaElement::dispatchPlayPauseEventsIfNeedsQuirks):
     19        (WebCore::needsSeekingSupportQuirk): Deleted.
     20        (WebCore::HTMLMediaElement::supportsSeeking const):
     21        * html/MediaElementSession.cpp:
     22        (WebCore::needsArbitraryUserGestureAutoplayQuirk): Deleted.
     23        (WebCore::needsPerDocumentAutoplayBehaviorQuirk): Deleted.
     24        (WebCore::MediaElementSession::playbackPermitted const):
     25        * page/Quirks.cpp:
     26        (WebCore::allowedAutoplayQuirks): Added.
     27        (WebCore::Quirks::needsQuirks const): Added.
     28        (WebCore::Quirks::shouldIgnoreInvalidSignal const): Added.
     29        (WebCore::Quirks::needsFormControlToBeMouseFocusable const): Added.
     30        (WebCore::Quirks::needsAutoplayPlayPauseEvents const): Added.
     31        (WebCore::Quirks::needsSeekingSupportDisabled const): Addd.
     32        (WebCore::Quirks::needsPerDocumentAutoplayBehavior const): Added.
     33        (WebCore::Quirks::shouldAutoplayForArbitraryUserGesture const): Added.
     34        (WebCore::Quirks::hasBrokenEncryptedMediaAPISupportQuirk const): Added.
     35        (WebCore::Quirks::hasWebSQLSupportQuirk const): Fixed the coding style.
     36        * page/Quirks.h:
     37
    1382019-03-12  Enrique Ocaña González  <eocanha@igalia.com>
    239
  • trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp

    r242145 r242792  
    3434#include "JSAbortSignal.h"
    3535#include "Logging.h"
     36#include "Quirks.h"
    3637#include "ScriptExecutionContext.h"
    3738#include "SecurityOrigin.h"
     
    145146}
    146147
    147 static inline bool needsSignalQuirk(ScriptExecutionContext& context)
    148 {
    149     if (!is<Document>(context))
    150         return false;
    151 
    152     auto& document = downcast<Document>(context);
    153     if (!document.settings().needsSiteSpecificQuirks())
    154         return false;
    155 
    156     auto host = document.topDocument().url().host();
    157     return equalLettersIgnoringASCIICase(host, "www.thrivepatientportal.com");
    158 }
    159 
    160148static inline Optional<Exception> processInvalidSignal(ScriptExecutionContext& context)
    161149{
     
    163151    context.addConsoleMessage(MessageSource::JS, MessageLevel::Warning, message);
    164152
    165     if (needsSignalQuirk(context))
     153    if (is<Document>(context) && downcast<Document>(context).quirks().shouldIgnoreInvalidSignal())
    166154        return { };
    167155
  • trunk/Source/WebCore/html/HTMLFormControlElement.cpp

    r242309 r242792  
    3939#include "HTMLLegendElement.h"
    4040#include "HTMLTextAreaElement.h"
     41#include "Quirks.h"
    4142#include "RenderBox.h"
    4243#include "RenderTheme.h"
     
    673674bool HTMLFormControlElement::needsMouseFocusableQuirk() const
    674675{
    675 #if PLATFORM(MAC)
    676     if (!document().settings().needsSiteSpecificQuirks())
    677         return false;
    678 
    679     auto host = document().url().host();
    680     return equalLettersIgnoringASCIICase(host, "ceac.state.gov") || host.endsWithIgnoringASCIICase(".ceac.state.gov");
    681 #else
    682     return false;
    683 #endif
     676    return document().quirks().needsFormControlToBeMouseFocusable();
    684677}
    685678
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r242791 r242792  
    662662    schedulePlaybackControlsManagerUpdate();
    663663}
    664 
    665 static bool needsAutoplayPlayPauseEventsQuirk(const Document& document)
    666 {
    667     auto* page = document.page();
    668     if (!page || !page->settings().needsSiteSpecificQuirks())
    669         return false;
    670 
    671     auto loader = makeRefPtr(document.loader());
    672     return loader && loader->allowedAutoplayQuirks().contains(AutoplayQuirk::SynthesizedPauseEvents);
    673 }
    674 
    675664RefPtr<HTMLMediaElement> HTMLMediaElement::bestMediaElementForShowingPlaybackControlsManager(MediaElementSession::PlaybackControlsPurpose purpose)
    676665{
     
    24512440void HTMLMediaElement::dispatchPlayPauseEventsIfNeedsQuirks()
    24522441{
    2453     auto& document = this->document();
    2454     if (!needsAutoplayPlayPauseEventsQuirk(document) && !needsAutoplayPlayPauseEventsQuirk(document.topDocument()))
     2442    if (!document().quirks().needsAutoplayPlayPauseEvents())
    24552443        return;
    24562444
     
    77197707}
    77207708
    7721 static bool needsSeekingSupportQuirk(Document& document)
    7722 {
    7723     if (!document.settings().needsSiteSpecificQuirks())
    7724         return false;
    7725 
    7726     auto host = document.topDocument().url().host();
    7727     return equalLettersIgnoringASCIICase(host, "netflix.com") || host.endsWithIgnoringASCIICase(".netflix.com");
    7728 }
    7729 
    77307709bool HTMLMediaElement::supportsSeeking() const
    77317710{
    7732     return !needsSeekingSupportQuirk(document()) && !isLiveStream();
     7711    return !document().quirks().needsSeekingSupportDisabled() && !isLiveStream();
    77337712}
    77347713
  • trunk/Source/WebCore/html/MediaElementSession.cpp

    r242355 r242792  
    4242#include "Page.h"
    4343#include "PlatformMediaSessionManager.h"
     44#include "Quirks.h"
    4445#include "RenderMedia.h"
    4546#include "RenderView.h"
     
    245246}
    246247
    247 #if PLATFORM(MAC)
    248 static bool needsArbitraryUserGestureAutoplayQuirk(const Document& document)
    249 {
    250     if (!document.settings().needsSiteSpecificQuirks())
    251         return false;
    252 
    253     auto loader = makeRefPtr(document.loader());
    254     return loader && loader->allowedAutoplayQuirks().contains(AutoplayQuirk::ArbitraryUserGestures);
    255 }
    256 #endif // PLATFORM(MAC)
    257 
    258 static bool needsPerDocumentAutoplayBehaviorQuirk(const Document& document)
    259 {
    260     if (!document.settings().needsSiteSpecificQuirks())
    261         return false;
    262 
    263     auto loader = makeRefPtr(document.loader());
    264     return loader && loader->allowedAutoplayQuirks().contains(AutoplayQuirk::PerDocumentAutoplayBehavior);
    265 }
    266 
    267248SuccessOr<MediaPlaybackDenialReason> MediaElementSession::playbackPermitted() const
    268249{
     
    302283#endif
    303284
     285    // FIXME: Why are we checking top-level document only for PerDocumentAutoplayBehavior?
    304286    const auto& topDocument = document.topDocument();
    305     if (topDocument.mediaState() & MediaProducer::HasUserInteractedWithMediaElement && needsPerDocumentAutoplayBehaviorQuirk(topDocument))
     287    if (topDocument.mediaState() & MediaProducer::HasUserInteractedWithMediaElement && topDocument.quirks().needsPerDocumentAutoplayBehavior())
    306288        return { };
    307289
    308 #if PLATFORM(MAC)
    309     if (document.hasHadUserInteraction() && needsArbitraryUserGestureAutoplayQuirk(document))
     290    if (document.hasHadUserInteraction() && document.quirks().shouldAutoplayForArbitraryUserGesture())
    310291        return { };
    311 #endif
    312292
    313293    if (m_restrictions & RequireUserGestureForVideoRateChange && m_element.isVideo() && !document.processingUserGestureForMedia()) {
  • trunk/Source/WebCore/page/Quirks.cpp

    r242770 r242792  
    2828
    2929#include "Document.h"
     30#include "DocumentLoader.h"
     31#include "HTMLMetaElement.h"
     32#include "HTMLObjectElement.h"
    3033#include "Settings.h"
    3134
    3235namespace WebCore {
     36
     37static inline OptionSet<AutoplayQuirk> allowedAutoplayQuirks(Document& document)
     38{
     39    auto* loader = document.loader();
     40    if (!loader)
     41        return { };
     42
     43    return loader->allowedAutoplayQuirks();
     44}
    3345
    3446Quirks::Quirks(Document& document)
     
    3951Quirks::~Quirks() = default;
    4052
     53inline bool Quirks::needsQuirks() const
     54{
     55    return m_document && m_document->settings().needsSiteSpecificQuirks();
     56}
     57
     58bool Quirks::shouldIgnoreInvalidSignal() const
     59{
     60    if (!needsQuirks())
     61        return false;
     62
     63    auto host = m_document->topDocument().url().host();
     64    return equalLettersIgnoringASCIICase(host, "www.thrivepatientportal.com");
     65}
     66
     67bool Quirks::needsFormControlToBeMouseFocusable() const
     68{
     69#if PLATFORM(MAC)
     70    if (!needsQuirks())
     71        return false;
     72
     73    auto host = m_document->url().host();
     74    return equalLettersIgnoringASCIICase(host, "ceac.state.gov") || host.endsWithIgnoringASCIICase(".ceac.state.gov");
     75#else
     76    return false;
     77#endif
     78}
     79
     80bool Quirks::needsAutoplayPlayPauseEvents() const
     81{
     82    if (!needsQuirks())
     83        return false;
     84
     85    if (allowedAutoplayQuirks(*m_document).contains(AutoplayQuirk::SynthesizedPauseEvents))
     86        return true;
     87
     88    return allowedAutoplayQuirks(m_document->topDocument()).contains(AutoplayQuirk::SynthesizedPauseEvents);
     89}
     90
     91bool Quirks::needsSeekingSupportDisabled() const
     92{
     93    if (!needsQuirks())
     94        return false;
     95
     96    auto host = m_document->topDocument().url().host();
     97    return equalLettersIgnoringASCIICase(host, "netflix.com") || host.endsWithIgnoringASCIICase(".netflix.com");
     98}
     99
     100bool Quirks::needsPerDocumentAutoplayBehavior() const
     101{
     102#if PLATFORM(MAC)
     103    ASSERT(m_document == &m_document->topDocument());
     104    return needsQuirks() && allowedAutoplayQuirks(*m_document).contains(AutoplayQuirk::PerDocumentAutoplayBehavior);
     105#else
     106    return false;
     107#endif
     108}
     109
     110bool Quirks::shouldAutoplayForArbitraryUserGesture() const
     111{
     112#if PLATFORM(MAC)
     113    return needsQuirks() && allowedAutoplayQuirks(*m_document).contains(AutoplayQuirk::ArbitraryUserGestures);
     114#else
     115    return false;
     116#endif
     117}
     118
    41119bool Quirks::hasBrokenEncryptedMediaAPISupportQuirk() const
    42120{
    43     if (!m_document || !m_document->settings().needsSiteSpecificQuirks())
     121    if (!needsQuirks())
    44122        return false;
    45123
     
    61139bool Quirks::hasWebSQLSupportQuirk() const
    62140{
    63     if (!m_document || !m_document->settings().needsSiteSpecificQuirks())
     141    if (!needsQuirks())
    64142        return false;
    65143   
     
    70148   
    71149    m_hasWebSQLSupportQuirk = domain == "bostonglobe.com"
    72     || domain.endsWith(".bostonglobe.com")
    73     || domain == "latimes.com"
    74     || domain.endsWith(".latimes.com");
     150        || domain.endsWith(".bostonglobe.com")
     151        || domain == "latimes.com"
     152        || domain.endsWith(".latimes.com");
    75153   
    76154    return m_hasWebSQLSupportQuirk.value();
  • trunk/Source/WebCore/page/Quirks.h

    r242278 r242792  
    3838    ~Quirks();
    3939
     40    bool shouldIgnoreInvalidSignal() const;
     41    bool needsFormControlToBeMouseFocusable() const;
     42    bool needsAutoplayPlayPauseEvents() const;
     43    bool needsSeekingSupportDisabled() const;
     44    bool needsPerDocumentAutoplayBehavior() const;
     45    bool shouldAutoplayForArbitraryUserGesture() const;
    4046    bool hasBrokenEncryptedMediaAPISupportQuirk() const;
    4147    bool hasWebSQLSupportQuirk() const;
    4248
    4349private:
     50    bool needsQuirks() const;
     51
    4452    WeakPtr<Document> m_document;
    4553
Note: See TracChangeset for help on using the changeset viewer.