| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/parser/CSSParserContext.h" | 5 #include "core/css/parser/CSSParserContext.h" |
| 6 | 6 |
| 7 #include "core/css/CSSStyleSheet.h" | 7 #include "core/css/CSSStyleSheet.h" |
| 8 #include "core/css/StyleSheetContents.h" | 8 #include "core/css/StyleSheetContents.h" |
| 9 #include "core/frame/Deprecation.h" | 9 #include "core/frame/Deprecation.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 return new CSSParserContext( | 36 return new CSSParserContext( |
| 37 other->m_baseURL, other->m_charset, other->m_mode, other->m_matchMode, | 37 other->m_baseURL, other->m_charset, other->m_mode, other->m_matchMode, |
| 38 other->m_profile, other->m_referrer, other->m_isHTMLDocument, | 38 other->m_profile, other->m_referrer, other->m_isHTMLDocument, |
| 39 other->m_useLegacyBackgroundSizeShorthandBehavior, | 39 other->m_useLegacyBackgroundSizeShorthandBehavior, |
| 40 other->m_shouldCheckContentSecurityPolicy, useCounterDocument); | 40 other->m_shouldCheckContentSecurityPolicy, useCounterDocument); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 CSSParserContext* CSSParserContext::create(const CSSParserContext* other, | 44 CSSParserContext* CSSParserContext::create(const CSSParserContext* other, |
| 45 const KURL& baseURL, | 45 const KURL& baseURL, |
| 46 ReferrerPolicy referrerPolicy, |
| 46 const String& charset, | 47 const String& charset, |
| 47 const Referrer& referrer, | |
| 48 const Document* useCounterDocument) { | 48 const Document* useCounterDocument) { |
| 49 return new CSSParserContext( | 49 return new CSSParserContext( |
| 50 baseURL, charset, other->m_mode, other->m_matchMode, other->m_profile, | 50 baseURL, charset, other->m_mode, other->m_matchMode, other->m_profile, |
| 51 referrer, other->m_isHTMLDocument, | 51 Referrer(baseURL.strippedForUseAsReferrer(), referrerPolicy), |
| 52 other->m_isHTMLDocument, |
| 52 other->m_useLegacyBackgroundSizeShorthandBehavior, | 53 other->m_useLegacyBackgroundSizeShorthandBehavior, |
| 53 other->m_shouldCheckContentSecurityPolicy, useCounterDocument); | 54 other->m_shouldCheckContentSecurityPolicy, useCounterDocument); |
| 54 } | 55 } |
| 55 | 56 |
| 56 // static | 57 // static |
| 57 CSSParserContext* CSSParserContext::create(CSSParserMode mode, | 58 CSSParserContext* CSSParserContext::create(CSSParserMode mode, |
| 58 SelectorProfile profile, | 59 SelectorProfile profile, |
| 59 const Document* useCounterDocument) { | 60 const Document* useCounterDocument) { |
| 60 return new CSSParserContext( | 61 return new CSSParserContext( |
| 61 KURL(), emptyString, mode, mode, profile, Referrer(), false, false, | 62 KURL(), emptyString, mode, mode, profile, Referrer(), false, false, |
| 62 DoNotCheckContentSecurityPolicy, useCounterDocument); | 63 DoNotCheckContentSecurityPolicy, useCounterDocument); |
| 63 } | 64 } |
| 64 | 65 |
| 65 // static | 66 // static |
| 66 CSSParserContext* CSSParserContext::create(const Document& document, | 67 CSSParserContext* CSSParserContext::create(const Document& document) { |
| 67 const Document* useCounterDocument) { | 68 return CSSParserContext::create(document, document.baseURL(), |
| 68 return CSSParserContext::create(document, KURL(), emptyString, DynamicProfile, | 69 document.getReferrerPolicy(), emptyString, |
| 69 useCounterDocument); | 70 DynamicProfile); |
| 70 } | 71 } |
| 71 | 72 |
| 72 // static | 73 // static |
| 73 CSSParserContext* CSSParserContext::create(const Document& document, | 74 CSSParserContext* CSSParserContext::create( |
| 74 const KURL& baseURLOverride, | 75 const Document& document, |
| 75 const String& charset, | 76 const KURL& baseURLOverride, |
| 76 SelectorProfile profile, | 77 ReferrerPolicy referrerPolicyOverride, |
| 77 const Document* useCounterDocument) { | 78 const String& charset, |
| 78 const KURL baseURL = | 79 SelectorProfile profile) { |
| 79 baseURLOverride.isNull() ? document.baseURL() : baseURLOverride; | |
| 80 | |
| 81 CSSParserMode mode = | 80 CSSParserMode mode = |
| 82 document.inQuirksMode() ? HTMLQuirksMode : HTMLStandardMode; | 81 document.inQuirksMode() ? HTMLQuirksMode : HTMLStandardMode; |
| 83 CSSParserMode matchMode; | 82 CSSParserMode matchMode; |
| 84 if (HTMLImportsController* importsController = document.importsController()) { | 83 if (HTMLImportsController* importsController = document.importsController()) { |
| 85 matchMode = importsController->master()->inQuirksMode() ? HTMLQuirksMode | 84 matchMode = importsController->master()->inQuirksMode() ? HTMLQuirksMode |
| 86 : HTMLStandardMode; | 85 : HTMLStandardMode; |
| 87 } else { | 86 } else { |
| 88 matchMode = mode; | 87 matchMode = mode; |
| 89 } | 88 } |
| 90 | 89 |
| 91 const Referrer referrer(baseURL.strippedForUseAsReferrer(), | 90 const Referrer referrer(baseURLOverride.strippedForUseAsReferrer(), |
| 92 document.getReferrerPolicy()); | 91 referrerPolicyOverride); |
| 93 | 92 |
| 94 bool useLegacyBackgroundSizeShorthandBehavior = | 93 bool useLegacyBackgroundSizeShorthandBehavior = |
| 95 document.settings() | 94 document.settings() |
| 96 ? document.settings()->getUseLegacyBackgroundSizeShorthandBehavior() | 95 ? document.settings()->getUseLegacyBackgroundSizeShorthandBehavior() |
| 97 : false; | 96 : false; |
| 98 | 97 |
| 99 ContentSecurityPolicyDisposition policyDisposition; | 98 ContentSecurityPolicyDisposition policyDisposition; |
| 100 if (ContentSecurityPolicy::shouldBypassMainWorld(&document)) | 99 if (ContentSecurityPolicy::shouldBypassMainWorld(&document)) |
| 101 policyDisposition = DoNotCheckContentSecurityPolicy; | 100 policyDisposition = DoNotCheckContentSecurityPolicy; |
| 102 else | 101 else |
| 103 policyDisposition = CheckContentSecurityPolicy; | 102 policyDisposition = CheckContentSecurityPolicy; |
| 104 | 103 |
| 105 return new CSSParserContext(baseURL, charset, mode, matchMode, profile, | 104 return new CSSParserContext(baseURLOverride, charset, mode, matchMode, |
| 106 referrer, document.isHTMLDocument(), | 105 profile, referrer, document.isHTMLDocument(), |
| 107 useLegacyBackgroundSizeShorthandBehavior, | 106 useLegacyBackgroundSizeShorthandBehavior, |
| 108 policyDisposition, useCounterDocument); | 107 policyDisposition, &document); |
| 109 } | 108 } |
| 110 | 109 |
| 111 CSSParserContext::CSSParserContext( | 110 CSSParserContext::CSSParserContext( |
| 112 const KURL& baseURL, | 111 const KURL& baseURL, |
| 113 const String& charset, | 112 const String& charset, |
| 114 CSSParserMode mode, | 113 CSSParserMode mode, |
| 115 CSSParserMode matchMode, | 114 CSSParserMode matchMode, |
| 116 SelectorProfile profile, | 115 SelectorProfile profile, |
| 117 const Referrer& referrer, | 116 const Referrer& referrer, |
| 118 bool isHTMLDocument, | 117 bool isHTMLDocument, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 173 |
| 175 bool CSSParserContext::isDocumentHandleEqual(const Document* other) const { | 174 bool CSSParserContext::isDocumentHandleEqual(const Document* other) const { |
| 176 return m_document.get() == other; | 175 return m_document.get() == other; |
| 177 } | 176 } |
| 178 | 177 |
| 179 DEFINE_TRACE(CSSParserContext) { | 178 DEFINE_TRACE(CSSParserContext) { |
| 180 visitor->trace(m_document); | 179 visitor->trace(m_document); |
| 181 } | 180 } |
| 182 | 181 |
| 183 } // namespace blink | 182 } // namespace blink |
| OLD | NEW |