diff options
Diffstat (limited to 'Source/WebCore/css/StyleRuleImport.cpp')
-rw-r--r-- | Source/WebCore/css/StyleRuleImport.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/Source/WebCore/css/StyleRuleImport.cpp b/Source/WebCore/css/StyleRuleImport.cpp index ae151400b..00a9e348f 100644 --- a/Source/WebCore/css/StyleRuleImport.cpp +++ b/Source/WebCore/css/StyleRuleImport.cpp @@ -28,23 +28,24 @@ #include "CachedResourceRequest.h" #include "CachedResourceRequestInitiators.h" #include "Document.h" +#include "MediaList.h" #include "SecurityOrigin.h" #include "StyleSheetContents.h" #include <wtf/StdLibExtras.h> namespace WebCore { -PassRef<StyleRuleImport> StyleRuleImport::create(const String& href, PassRefPtr<MediaQuerySet> media) +Ref<StyleRuleImport> StyleRuleImport::create(const String& href, Ref<MediaQuerySet>&& media) { - return adoptRef(*new StyleRuleImport(href, media)); + return adoptRef(*new StyleRuleImport(href, WTFMove(media))); } -StyleRuleImport::StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet> media) - : StyleRuleBase(Import, 0) +StyleRuleImport::StyleRuleImport(const String& href, Ref<MediaQuerySet>&& media) + : StyleRuleBase(Import) , m_parentStyleSheet(0) , m_styleSheetClient(this) , m_strHref(href) - , m_mediaQueries(media) + , m_mediaQueries(WTFMove(media)) , m_cachedSheet(0) , m_loading(false) { @@ -57,7 +58,7 @@ StyleRuleImport::~StyleRuleImport() if (m_styleSheet) m_styleSheet->clearOwnerRule(); if (m_cachedSheet) - m_cachedSheet->removeClient(&m_styleSheetClient); + m_cachedSheet->removeClient(m_styleSheetClient); } void StyleRuleImport::setCSSStyleSheet(const String& href, const URL& baseURL, const String& charset, const CachedCSSStyleSheet* cachedStyleSheet) @@ -65,15 +66,14 @@ void StyleRuleImport::setCSSStyleSheet(const String& href, const URL& baseURL, c if (m_styleSheet) m_styleSheet->clearOwnerRule(); - CSSParserContext context = m_parentStyleSheet ? m_parentStyleSheet->parserContext() : CSSStrictMode; + CSSParserContext context = m_parentStyleSheet ? m_parentStyleSheet->parserContext() : HTMLStandardMode; context.charset = charset; if (!baseURL.isNull()) context.baseURL = baseURL; + Document* document = m_parentStyleSheet ? m_parentStyleSheet->singleOwnerDocument() : nullptr; m_styleSheet = StyleSheetContents::create(this, href, context); - - Document* document = m_parentStyleSheet ? m_parentStyleSheet->singleOwnerDocument() : 0; - m_styleSheet->parseAuthorStyleSheet(cachedStyleSheet, document ? document->securityOrigin() : 0); + m_styleSheet->parseAuthorStyleSheet(cachedStyleSheet, document ? &document->securityOrigin() : nullptr); m_loading = false; @@ -96,10 +96,6 @@ void StyleRuleImport::requestStyleSheet() if (!document) return; - CachedResourceLoader* cachedResourceLoader = document->cachedResourceLoader(); - if (!cachedResourceLoader) - return; - URL absURL; if (!m_parentStyleSheet->baseURL().isNull()) // use parent styleheet's URL as the base URL @@ -117,14 +113,17 @@ void StyleRuleImport::requestStyleSheet() rootSheet = sheet; } - CachedResourceRequest request(ResourceRequest(absURL), m_parentStyleSheet->charset()); + // FIXME: Skip Content Security Policy check when stylesheet is in a user agent shadow tree. + // See <https://bugs.webkit.org/show_bug.cgi?id=146663>. + CachedResourceRequest request(absURL, CachedResourceLoader::defaultCachedResourceOptions(), std::nullopt, String(m_parentStyleSheet->charset())); request.setInitiator(cachedResourceRequestInitiators().css); if (m_cachedSheet) - m_cachedSheet->removeClient(&m_styleSheetClient); - if (m_parentStyleSheet->isUserStyleSheet()) - m_cachedSheet = cachedResourceLoader->requestUserCSSStyleSheet(request); - else - m_cachedSheet = cachedResourceLoader->requestCSSStyleSheet(request); + m_cachedSheet->removeClient(m_styleSheetClient); + if (m_parentStyleSheet->isUserStyleSheet()) { + request.setOptions(ResourceLoaderOptions(DoNotSendCallbacks, SniffContent, BufferData, AllowStoredCredentials, ClientCredentialPolicy::MayAskClientForCredentials, FetchOptions::Credentials::Include, SkipSecurityCheck, FetchOptions::Mode::NoCors, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::SkipPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::AllowCaching)); + m_cachedSheet = document->cachedResourceLoader().requestUserCSSStyleSheet(WTFMove(request)); + } else + m_cachedSheet = document->cachedResourceLoader().requestCSSStyleSheet(WTFMove(request)); if (m_cachedSheet) { // if the import rule is issued dynamically, the sheet may be // removed from the pending sheet count, so let the doc know @@ -132,7 +131,7 @@ void StyleRuleImport::requestStyleSheet() if (m_parentStyleSheet && m_parentStyleSheet->loadCompleted() && rootSheet == m_parentStyleSheet) m_parentStyleSheet->startLoadingDynamicSheet(); m_loading = true; - m_cachedSheet->addClient(&m_styleSheetClient); + m_cachedSheet->addClient(m_styleSheetClient); } } |