OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
10 * | 10 * |
(...skipping 10 matching lines...) Expand all Loading... |
21 * You should have received a copy of the GNU Library General Public License | 21 * You should have received a copy of the GNU Library General Public License |
22 * along with this library; see the file COPYING.LIB. If not, write to | 22 * along with this library; see the file COPYING.LIB. If not, write to |
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 * Boston, MA 02110-1301, USA. | 24 * Boston, MA 02110-1301, USA. |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/css/parser/CSSParserMode.h" | 28 #include "core/css/parser/CSSParserMode.h" |
29 | 29 |
30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 #include "core/frame/LocalFrame.h" |
31 #include "core/frame/Settings.h" | 32 #include "core/frame/Settings.h" |
32 #include "core/frame/csp/ContentSecurityPolicy.h" | 33 #include "core/frame/csp/ContentSecurityPolicy.h" |
33 | 34 |
34 namespace blink { | 35 namespace blink { |
35 | 36 |
36 CSSParserContext::CSSParserContext(CSSParserMode mode, UseCounter* useCounter) | 37 CSSParserContext::CSSParserContext(CSSParserMode mode, UseCounter* useCounter) |
37 : m_mode(mode) | 38 : m_mode(mode) |
38 , m_isHTMLDocument(false) | 39 , m_isHTMLDocument(false) |
39 , m_useLegacyBackgroundSizeShorthandBehavior(false) | 40 , m_useLegacyBackgroundSizeShorthandBehavior(false) |
40 , m_shouldCheckContentSecurityPolicy(DoNotCheckContentSecurityPolicy) | 41 , m_shouldCheckContentSecurityPolicy(DoNotCheckContentSecurityPolicy) |
41 , m_useCounter(useCounter) | 42 , m_useCounter(useCounter) |
42 { | 43 { |
43 } | 44 } |
44 | 45 |
45 CSSParserContext::CSSParserContext(const Document& document, UseCounter* useCoun
ter, const KURL& baseURL, const String& charset) | 46 CSSParserContext::CSSParserContext(const Document& document, UseCounter* useCoun
ter, const KURL& baseURL, const String& charset) |
46 : m_baseURL(baseURL.isNull() ? document.baseURL() : baseURL) | 47 : m_baseURL(baseURL.isNull() ? document.baseURL() : baseURL) |
47 , m_charset(charset) | 48 , m_charset(charset) |
48 , m_mode(document.inQuirksMode() ? HTMLQuirksMode : HTMLStandardMode) | 49 , m_mode(document.inQuirksMode() ? HTMLQuirksMode : HTMLStandardMode) |
49 , m_referrer(m_baseURL.strippedForUseAsReferrer(), document.referrerPolicy()
) | 50 , m_referrer(m_baseURL.strippedForUseAsReferrer(), document.referrerPolicy()
) |
50 , m_isHTMLDocument(document.isHTMLDocument()) | 51 , m_isHTMLDocument(document.isHTMLDocument()) |
51 , m_useLegacyBackgroundSizeShorthandBehavior(document.settings() ? document.
settings()->useLegacyBackgroundSizeShorthandBehavior() : false) | 52 , m_useLegacyBackgroundSizeShorthandBehavior(document.settings() ? document.
settings()->useLegacyBackgroundSizeShorthandBehavior() : false) |
52 , m_shouldCheckContentSecurityPolicy(DoNotCheckContentSecurityPolicy) | 53 , m_shouldCheckContentSecurityPolicy(DoNotCheckContentSecurityPolicy) |
53 , m_useCounter(useCounter) | 54 , m_useCounter(useCounter) |
54 { | 55 { |
55 if (ContentSecurityPolicy::shouldBypassMainWorld(&document)) | 56 if (ContentSecurityPolicy::shouldBypassMainWorld(&document)) |
56 m_shouldCheckContentSecurityPolicy = DoNotCheckContentSecurityPolicy; | 57 m_shouldCheckContentSecurityPolicy = DoNotCheckContentSecurityPolicy; |
57 else | 58 else |
58 m_shouldCheckContentSecurityPolicy = CheckContentSecurityPolicy; | 59 m_shouldCheckContentSecurityPolicy = CheckContentSecurityPolicy; |
| 60 m_frame = document.frame(); |
59 } | 61 } |
60 | 62 |
61 CSSParserContext::CSSParserContext(const CSSParserContext& other, UseCounter* us
eCounter) | 63 CSSParserContext::CSSParserContext(const CSSParserContext& other, LocalFrame* fr
ame, UseCounter* useCounter) |
62 : m_baseURL(other.m_baseURL) | 64 : m_baseURL(other.m_baseURL) |
63 , m_charset(other.m_charset) | 65 , m_charset(other.m_charset) |
64 , m_mode(other.m_mode) | 66 , m_mode(other.m_mode) |
65 , m_referrer(other.m_referrer) | 67 , m_referrer(other.m_referrer) |
66 , m_isHTMLDocument(other.m_isHTMLDocument) | 68 , m_isHTMLDocument(other.m_isHTMLDocument) |
67 , m_useLegacyBackgroundSizeShorthandBehavior(other.m_useLegacyBackgroundSize
ShorthandBehavior) | 69 , m_useLegacyBackgroundSizeShorthandBehavior(other.m_useLegacyBackgroundSize
ShorthandBehavior) |
68 , m_shouldCheckContentSecurityPolicy(other.m_shouldCheckContentSecurityPolic
y) | 70 , m_shouldCheckContentSecurityPolicy(other.m_shouldCheckContentSecurityPolic
y) |
| 71 , m_frame(frame) |
69 , m_useCounter(useCounter) | 72 , m_useCounter(useCounter) |
70 { | 73 { |
71 } | 74 } |
72 | 75 |
| 76 CSSParserContext::~CSSParserContext() |
| 77 { |
| 78 } |
| 79 |
73 bool CSSParserContext::operator==(const CSSParserContext& other) const | 80 bool CSSParserContext::operator==(const CSSParserContext& other) const |
74 { | 81 { |
75 return m_baseURL == other.m_baseURL | 82 return m_baseURL == other.m_baseURL |
76 && m_charset == other.m_charset | 83 && m_charset == other.m_charset |
77 && m_mode == other.m_mode | 84 && m_mode == other.m_mode |
78 && m_isHTMLDocument == other.m_isHTMLDocument | 85 && m_isHTMLDocument == other.m_isHTMLDocument |
79 && m_useLegacyBackgroundSizeShorthandBehavior == other.m_useLegacyBackgr
oundSizeShorthandBehavior; | 86 && m_useLegacyBackgroundSizeShorthandBehavior == other.m_useLegacyBackgr
oundSizeShorthandBehavior |
| 87 && m_frame == other.m_frame; |
80 } | 88 } |
81 | 89 |
82 const CSSParserContext& strictCSSParserContext() | 90 const CSSParserContext& strictCSSParserContext() |
83 { | 91 { |
84 DEFINE_STATIC_LOCAL(CSSParserContext, strictContext, (HTMLStandardMode, 0)); | 92 DEFINE_STATIC_LOCAL(CSSParserContext, strictContext, (HTMLStandardMode, 0)); |
85 return strictContext; | 93 return strictContext; |
86 } | 94 } |
87 | 95 |
88 KURL CSSParserContext::completeURL(const String& url) const | 96 KURL CSSParserContext::completeURL(const String& url) const |
89 { | 97 { |
90 if (url.isNull()) | 98 if (url.isNull()) |
91 return KURL(); | 99 return KURL(); |
92 if (charset().isEmpty()) | 100 if (charset().isEmpty()) |
93 return KURL(baseURL(), url); | 101 return KURL(baseURL(), url); |
94 return KURL(baseURL(), url, charset()); | 102 return KURL(baseURL(), url, charset()); |
95 } | 103 } |
96 | 104 |
97 } // namespace blink | 105 } // namespace blink |
OLD | NEW |