| Index: third_party/WebKit/Source/core/css/parser/CSSParserContext.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserContext.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserContext.cpp
|
| index 66e3d2a87849e6ecf7608494b46e1e38a03c872a..cfd000757f607607c5d524d6104bb0a063a9560e 100644
|
| --- a/third_party/WebKit/Source/core/css/parser/CSSParserContext.cpp
|
| +++ b/third_party/WebKit/Source/core/css/parser/CSSParserContext.cpp
|
| @@ -4,69 +4,115 @@
|
|
|
| #include "core/css/parser/CSSParserContext.h"
|
|
|
| +#include "core/css/CSSStyleSheet.h"
|
| +#include "core/css/StyleSheetContents.h"
|
| #include "core/frame/Settings.h"
|
| #include "core/frame/csp/ContentSecurityPolicy.h"
|
| #include "core/html/imports/HTMLImportsController.h"
|
|
|
| namespace blink {
|
|
|
| -CSSParserContext::CSSParserContext(CSSParserMode mode,
|
| - UseCounter* useCounter,
|
| - SelectorProfile profile)
|
| - : m_mode(mode),
|
| - m_matchMode(mode),
|
| - m_profile(profile),
|
| - m_isHTMLDocument(false),
|
| - m_useLegacyBackgroundSizeShorthandBehavior(false),
|
| - m_shouldCheckContentSecurityPolicy(DoNotCheckContentSecurityPolicy),
|
| - m_useCounter(useCounter) {}
|
| +// static
|
| +CSSParserContext* CSSParserContext::createWithStyleSheet(
|
| + const CSSParserContext* other,
|
| + const CSSStyleSheet* styleSheet) {
|
| + return CSSParserContext::create(other, UseCounter::getFrom(styleSheet));
|
| +}
|
|
|
| -CSSParserContext::CSSParserContext(const Document& document,
|
| - UseCounter* useCounter,
|
| - const KURL& baseURL,
|
| - const String& charset,
|
| - SelectorProfile profile)
|
| - : m_baseURL(baseURL.isNull() ? document.baseURL() : baseURL),
|
| - m_charset(charset),
|
| - m_mode(document.inQuirksMode() ? HTMLQuirksMode : HTMLStandardMode),
|
| - m_profile(profile),
|
| - m_referrer(m_baseURL.strippedForUseAsReferrer(),
|
| - document.getReferrerPolicy()),
|
| - m_isHTMLDocument(document.isHTMLDocument()),
|
| - m_useLegacyBackgroundSizeShorthandBehavior(
|
| - document.settings()
|
| - ? document.settings()
|
| - ->getUseLegacyBackgroundSizeShorthandBehavior()
|
| - : false),
|
| - m_shouldCheckContentSecurityPolicy(DoNotCheckContentSecurityPolicy),
|
| - m_useCounter(useCounter) {
|
| - if (ContentSecurityPolicy::shouldBypassMainWorld(&document))
|
| - m_shouldCheckContentSecurityPolicy = DoNotCheckContentSecurityPolicy;
|
| - else
|
| - m_shouldCheckContentSecurityPolicy = CheckContentSecurityPolicy;
|
| +// static
|
| +CSSParserContext* CSSParserContext::createWithStyleSheetContents(
|
| + const CSSParserContext* other,
|
| + const StyleSheetContents* styleSheetContents) {
|
| + return CSSParserContext::create(other,
|
| + UseCounter::getFrom(styleSheetContents));
|
| +}
|
| +
|
| +// static
|
| +CSSParserContext* CSSParserContext::create(const CSSParserContext* other,
|
| + UseCounter* useCounter) {
|
| + return new CSSParserContext(
|
| + other->m_baseURL, other->m_charset, other->m_mode, other->m_matchMode,
|
| + other->m_profile, other->m_referrer, other->m_isHTMLDocument,
|
| + other->m_useLegacyBackgroundSizeShorthandBehavior,
|
| + other->m_shouldCheckContentSecurityPolicy, useCounter);
|
| +}
|
| +
|
| +// static
|
| +CSSParserContext* CSSParserContext::create(CSSParserMode mode,
|
| + SelectorProfile profile,
|
| + UseCounter* useCounter) {
|
| + return new CSSParserContext(KURL(), emptyString(), mode, mode, profile,
|
| + Referrer(), false, false,
|
| + DoNotCheckContentSecurityPolicy, useCounter);
|
| +}
|
| +
|
| +// static
|
| +CSSParserContext* CSSParserContext::create(const Document& document,
|
| + UseCounter* useCounter) {
|
| + return CSSParserContext::create(document, KURL(), emptyString(),
|
| + DynamicProfile, useCounter);
|
| +}
|
|
|
| +// static
|
| +CSSParserContext* CSSParserContext::create(const Document& document,
|
| + const KURL& baseURLOverride,
|
| + const String& charset,
|
| + SelectorProfile profile,
|
| + UseCounter* useCounter) {
|
| + const KURL baseURL =
|
| + baseURLOverride.isNull() ? document.baseURL() : baseURLOverride;
|
| +
|
| + CSSParserMode mode =
|
| + document.inQuirksMode() ? HTMLQuirksMode : HTMLStandardMode;
|
| + CSSParserMode matchMode;
|
| if (HTMLImportsController* importsController = document.importsController()) {
|
| - m_matchMode = importsController->master()->inQuirksMode()
|
| - ? HTMLQuirksMode
|
| - : HTMLStandardMode;
|
| + matchMode = importsController->master()->inQuirksMode() ? HTMLQuirksMode
|
| + : HTMLStandardMode;
|
| } else {
|
| - m_matchMode = m_mode;
|
| + matchMode = mode;
|
| }
|
| +
|
| + const Referrer referrer(baseURL.strippedForUseAsReferrer(),
|
| + document.getReferrerPolicy());
|
| +
|
| + bool useLegacyBackgroundSizeShorthandBehavior =
|
| + document.settings()
|
| + ? document.settings()->getUseLegacyBackgroundSizeShorthandBehavior()
|
| + : false;
|
| +
|
| + ContentSecurityPolicyDisposition policyDisposition;
|
| + if (ContentSecurityPolicy::shouldBypassMainWorld(&document))
|
| + policyDisposition = DoNotCheckContentSecurityPolicy;
|
| + else
|
| + policyDisposition = CheckContentSecurityPolicy;
|
| +
|
| + return new CSSParserContext(baseURL, charset, mode, matchMode, profile,
|
| + referrer, document.isHTMLDocument(),
|
| + useLegacyBackgroundSizeShorthandBehavior,
|
| + policyDisposition, useCounter);
|
| }
|
|
|
| -CSSParserContext::CSSParserContext(const CSSParserContext& other,
|
| - UseCounter* useCounter)
|
| - : m_baseURL(other.m_baseURL),
|
| - m_charset(other.m_charset),
|
| - m_mode(other.m_mode),
|
| - m_matchMode(other.m_matchMode),
|
| - m_profile(other.m_profile),
|
| - m_referrer(other.m_referrer),
|
| - m_isHTMLDocument(other.m_isHTMLDocument),
|
| +CSSParserContext::CSSParserContext(
|
| + const KURL& baseURL,
|
| + const String& charset,
|
| + CSSParserMode mode,
|
| + CSSParserMode matchMode,
|
| + SelectorProfile profile,
|
| + const Referrer& referrer,
|
| + bool isHTMLDocument,
|
| + bool useLegacyBackgroundSizeShorthandBehavior,
|
| + ContentSecurityPolicyDisposition policyDisposition,
|
| + UseCounter* useCounter)
|
| + : m_baseURL(baseURL),
|
| + m_charset(charset),
|
| + m_mode(mode),
|
| + m_matchMode(matchMode),
|
| + m_profile(profile),
|
| + m_referrer(referrer),
|
| + m_isHTMLDocument(isHTMLDocument),
|
| m_useLegacyBackgroundSizeShorthandBehavior(
|
| - other.m_useLegacyBackgroundSizeShorthandBehavior),
|
| - m_shouldCheckContentSecurityPolicy(
|
| - other.m_shouldCheckContentSecurityPolicy),
|
| + useLegacyBackgroundSizeShorthandBehavior),
|
| + m_shouldCheckContentSecurityPolicy(policyDisposition),
|
| m_useCounter(useCounter) {}
|
|
|
| bool CSSParserContext::operator==(const CSSParserContext& other) const {
|
| @@ -78,10 +124,10 @@ bool CSSParserContext::operator==(const CSSParserContext& other) const {
|
| other.m_useLegacyBackgroundSizeShorthandBehavior;
|
| }
|
|
|
| -const CSSParserContext& strictCSSParserContext() {
|
| +const CSSParserContext* strictCSSParserContext() {
|
| DEFINE_STATIC_LOCAL(CSSParserContext, strictContext,
|
| - (HTMLStandardMode, nullptr));
|
| - return strictContext;
|
| + (CSSParserContext::create(HTMLStandardMode)));
|
| + return &strictContext;
|
| }
|
|
|
| KURL CSSParserContext::completeURL(const String& url) const {
|
|
|