OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights |
6 * reserved. | 6 * reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 HTMLElement::DidMoveToNewDocument(old_document); | 82 HTMLElement::DidMoveToNewDocument(old_document); |
83 } | 83 } |
84 | 84 |
85 void HTMLScriptElement::ParseAttribute( | 85 void HTMLScriptElement::ParseAttribute( |
86 const AttributeModificationParams& params) { | 86 const AttributeModificationParams& params) { |
87 if (params.name == srcAttr) { | 87 if (params.name == srcAttr) { |
88 loader_->HandleSourceAttribute(params.new_value); | 88 loader_->HandleSourceAttribute(params.new_value); |
89 LogUpdateAttributeIfIsolatedWorldAndInDocument("script", params); | 89 LogUpdateAttributeIfIsolatedWorldAndInDocument("script", params); |
90 } else if (params.name == asyncAttr) { | 90 } else if (params.name == asyncAttr) { |
91 loader_->HandleAsyncAttribute(); | 91 loader_->HandleAsyncAttribute(); |
92 } else if (params.name == nonceAttr) { | |
93 if (params.new_value == ContentSecurityPolicy::GetNonceReplacementString()) | |
94 return; | |
95 setNonce(params.new_value); | |
96 if (RuntimeEnabledFeatures::hideNonceContentAttributeEnabled()) { | |
97 setAttribute(nonceAttr, | |
98 ContentSecurityPolicy::GetNonceReplacementString()); | |
99 } | |
100 } else { | 92 } else { |
101 HTMLElement::ParseAttribute(params); | 93 HTMLElement::ParseAttribute(params); |
102 } | 94 } |
103 } | 95 } |
104 | 96 |
105 Node::InsertionNotificationRequest HTMLScriptElement::InsertedInto( | 97 Node::InsertionNotificationRequest HTMLScriptElement::InsertedInto( |
106 ContainerNode* insertion_point) { | 98 ContainerNode* insertion_point) { |
107 if (insertion_point->isConnected() && HasSourceAttribute() && | 99 if (insertion_point->isConnected() && HasSourceAttribute() && |
108 !Loader()->IsScriptTypeSupported( | 100 !Loader()->IsScriptTypeSupported( |
109 ScriptLoader::kDisallowLegacyTypeInTypeAttribute)) | 101 ScriptLoader::kDisallowLegacyTypeInTypeAttribute)) |
110 UseCounter::Count(GetDocument(), | 102 UseCounter::Count(GetDocument(), |
111 UseCounter::kScriptElementWithInvalidTypeHasSrc); | 103 UseCounter::kScriptElementWithInvalidTypeHasSrc); |
112 HTMLElement::InsertedInto(insertion_point); | 104 HTMLElement::InsertedInto(insertion_point); |
113 LogAddElementIfIsolatedWorldAndInDocument("script", srcAttr); | 105 LogAddElementIfIsolatedWorldAndInDocument("script", srcAttr); |
| 106 |
114 return kInsertionShouldCallDidNotifySubtreeInsertions; | 107 return kInsertionShouldCallDidNotifySubtreeInsertions; |
115 } | 108 } |
116 | 109 |
117 void HTMLScriptElement::DidNotifySubtreeInsertionsToDocument() { | 110 void HTMLScriptElement::DidNotifySubtreeInsertionsToDocument() { |
118 loader_->DidNotifySubtreeInsertionsToDocument(); | 111 loader_->DidNotifySubtreeInsertionsToDocument(); |
119 } | 112 } |
120 | 113 |
121 void HTMLScriptElement::setText(const String& value) { | 114 void HTMLScriptElement::setText(const String& value) { |
122 setTextContent(value); | 115 setTextContent(value); |
123 } | 116 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 } | 181 } |
189 | 182 |
190 bool HTMLScriptElement::IsConnected() const { | 183 bool HTMLScriptElement::IsConnected() const { |
191 return Node::isConnected(); | 184 return Node::isConnected(); |
192 } | 185 } |
193 | 186 |
194 bool HTMLScriptElement::HasChildren() const { | 187 bool HTMLScriptElement::HasChildren() const { |
195 return Node::hasChildren(); | 188 return Node::hasChildren(); |
196 } | 189 } |
197 | 190 |
198 bool HTMLScriptElement::IsNonceableElement() const { | 191 const AtomicString& HTMLScriptElement::GetNonceForElement() const { |
199 return ContentSecurityPolicy::IsNonceableElement(this); | 192 return ContentSecurityPolicy::IsNonceableElement(this) ? nonce() |
| 193 : g_null_atom; |
200 } | 194 } |
201 | 195 |
202 bool HTMLScriptElement::AllowInlineScriptForCSP( | 196 bool HTMLScriptElement::AllowInlineScriptForCSP( |
203 const AtomicString& nonce, | 197 const AtomicString& nonce, |
204 const WTF::OrdinalNumber& context_line, | 198 const WTF::OrdinalNumber& context_line, |
205 const String& script_content) { | 199 const String& script_content) { |
206 return GetDocument().GetContentSecurityPolicy()->AllowInlineScript( | 200 return GetDocument().GetContentSecurityPolicy()->AllowInlineScript( |
207 this, GetDocument().Url(), nonce, context_line, script_content); | 201 this, GetDocument().Url(), nonce, context_line, script_content); |
208 } | 202 } |
209 | 203 |
(...skipping 24 matching lines...) Expand all Loading... |
234 return new HTMLScriptElement(GetDocument(), false, loader_->AlreadyStarted(), | 228 return new HTMLScriptElement(GetDocument(), false, loader_->AlreadyStarted(), |
235 false); | 229 false); |
236 } | 230 } |
237 | 231 |
238 DEFINE_TRACE(HTMLScriptElement) { | 232 DEFINE_TRACE(HTMLScriptElement) { |
239 HTMLElement::Trace(visitor); | 233 HTMLElement::Trace(visitor); |
240 ScriptElementBase::Trace(visitor); | 234 ScriptElementBase::Trace(visitor); |
241 } | 235 } |
242 | 236 |
243 } // namespace blink | 237 } // namespace blink |
OLD | NEW |