| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | |
| 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | |
| 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. | |
| 5 * All rights reserved. | |
| 6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | |
| 7 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | |
| 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. | |
| 9 * (http://www.torchmobile.com/) | |
| 10 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | |
| 11 * Copyright (C) 2012 Intel Corporation. All rights reserved. | |
| 12 * | |
| 13 * This library is free software; you can redistribute it and/or | |
| 14 * modify it under the terms of the GNU Library General Public | |
| 15 * License as published by the Free Software Foundation; either | |
| 16 * version 2 of the License, or (at your option) any later version. | |
| 17 * | |
| 18 * This library is distributed in the hope that it will be useful, | |
| 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 21 * Library General Public License for more details. | |
| 22 * | |
| 23 * You should have received a copy of the GNU Library General Public License | |
| 24 * along with this library; see the file COPYING.LIB. If not, write to | |
| 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 26 * Boston, MA 02110-1301, USA. | |
| 27 */ | |
| 28 | |
| 29 #include "core/css/parser/CSSParserMode.h" | |
| 30 | |
| 31 #include "core/dom/Document.h" | |
| 32 #include "core/frame/Settings.h" | |
| 33 #include "core/frame/csp/ContentSecurityPolicy.h" | |
| 34 #include "core/html/imports/HTMLImportTreeRoot.h" | |
| 35 #include "core/html/imports/HTMLImportsController.h" | |
| 36 | |
| 37 namespace blink { | |
| 38 | |
| 39 CSSParserContext::CSSParserContext(CSSParserMode mode, | |
| 40 UseCounter* useCounter, | |
| 41 SelectorProfile profile) | |
| 42 : m_mode(mode), | |
| 43 m_matchMode(mode), | |
| 44 m_profile(profile), | |
| 45 m_isHTMLDocument(false), | |
| 46 m_useLegacyBackgroundSizeShorthandBehavior(false), | |
| 47 m_shouldCheckContentSecurityPolicy(DoNotCheckContentSecurityPolicy), | |
| 48 m_useCounter(useCounter) {} | |
| 49 | |
| 50 CSSParserContext::CSSParserContext(const Document& document, | |
| 51 UseCounter* useCounter, | |
| 52 const KURL& baseURL, | |
| 53 const String& charset, | |
| 54 SelectorProfile profile) | |
| 55 : m_baseURL(baseURL.isNull() ? document.baseURL() : baseURL), | |
| 56 m_charset(charset), | |
| 57 m_mode(document.inQuirksMode() ? HTMLQuirksMode : HTMLStandardMode), | |
| 58 m_profile(profile), | |
| 59 m_referrer(m_baseURL.strippedForUseAsReferrer(), | |
| 60 document.getReferrerPolicy()), | |
| 61 m_isHTMLDocument(document.isHTMLDocument()), | |
| 62 m_useLegacyBackgroundSizeShorthandBehavior( | |
| 63 document.settings() | |
| 64 ? document.settings()->useLegacyBackgroundSizeShorthandBehavior() | |
| 65 : false), | |
| 66 m_shouldCheckContentSecurityPolicy(DoNotCheckContentSecurityPolicy), | |
| 67 m_useCounter(useCounter) { | |
| 68 if (ContentSecurityPolicy::shouldBypassMainWorld(&document)) | |
| 69 m_shouldCheckContentSecurityPolicy = DoNotCheckContentSecurityPolicy; | |
| 70 else | |
| 71 m_shouldCheckContentSecurityPolicy = CheckContentSecurityPolicy; | |
| 72 | |
| 73 if (HTMLImportsController* importsController = document.importsController()) | |
| 74 m_matchMode = importsController->master()->inQuirksMode() | |
| 75 ? HTMLQuirksMode | |
| 76 : HTMLStandardMode; | |
| 77 else | |
| 78 m_matchMode = m_mode; | |
| 79 } | |
| 80 | |
| 81 CSSParserContext::CSSParserContext(const CSSParserContext& other, | |
| 82 UseCounter* useCounter) | |
| 83 : m_baseURL(other.m_baseURL), | |
| 84 m_charset(other.m_charset), | |
| 85 m_mode(other.m_mode), | |
| 86 m_matchMode(other.m_matchMode), | |
| 87 m_profile(other.m_profile), | |
| 88 m_referrer(other.m_referrer), | |
| 89 m_isHTMLDocument(other.m_isHTMLDocument), | |
| 90 m_useLegacyBackgroundSizeShorthandBehavior( | |
| 91 other.m_useLegacyBackgroundSizeShorthandBehavior), | |
| 92 m_shouldCheckContentSecurityPolicy( | |
| 93 other.m_shouldCheckContentSecurityPolicy), | |
| 94 m_useCounter(useCounter) {} | |
| 95 | |
| 96 bool CSSParserContext::operator==(const CSSParserContext& other) const { | |
| 97 return m_baseURL == other.m_baseURL && m_charset == other.m_charset && | |
| 98 m_mode == other.m_mode && m_matchMode == other.m_matchMode && | |
| 99 m_profile == other.m_profile && | |
| 100 m_isHTMLDocument == other.m_isHTMLDocument && | |
| 101 m_useLegacyBackgroundSizeShorthandBehavior == | |
| 102 other.m_useLegacyBackgroundSizeShorthandBehavior; | |
| 103 } | |
| 104 | |
| 105 const CSSParserContext& strictCSSParserContext() { | |
| 106 DEFINE_STATIC_LOCAL(CSSParserContext, strictContext, | |
| 107 (HTMLStandardMode, nullptr)); | |
| 108 return strictContext; | |
| 109 } | |
| 110 | |
| 111 KURL CSSParserContext::completeURL(const String& url) const { | |
| 112 if (url.isNull()) | |
| 113 return KURL(); | |
| 114 if (charset().isEmpty()) | |
| 115 return KURL(baseURL(), url); | |
| 116 return KURL(baseURL(), url, charset()); | |
| 117 } | |
| 118 | |
| 119 } // namespace blink | |
| OLD | NEW |