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 |
11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
12 * | 12 * |
13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 * Library General Public License for more details. | 16 * Library General Public License for more details. |
17 * | 17 * |
18 * You should have received a copy of the GNU Library General Public License | 18 * You should have received a copy of the GNU Library General Public License |
19 * along with this library; see the file COPYING.LIB. If not, write to | 19 * along with this library; see the file COPYING.LIB. If not, write to |
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
21 * Boston, MA 02110-1301, USA. | 21 * Boston, MA 02110-1301, USA. |
22 */ | 22 */ |
23 | 23 |
24 #include "core/html/HTMLScriptElement.h" | 24 #include "core/html/HTMLScriptElement.h" |
25 | 25 |
26 #include "bindings/core/v8/ExceptionState.h" | 26 #include "bindings/core/v8/ExceptionState.h" |
| 27 #include "bindings/core/v8/HTMLScriptElementOrSVGScriptElement.h" |
27 #include "bindings/core/v8/ScriptEventListener.h" | 28 #include "bindings/core/v8/ScriptEventListener.h" |
28 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
29 #include "core/dom/Attribute.h" | 30 #include "core/dom/Attribute.h" |
30 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
31 #include "core/dom/ScriptLoader.h" | 32 #include "core/dom/ScriptLoader.h" |
32 #include "core/dom/ScriptRunner.h" | 33 #include "core/dom/ScriptRunner.h" |
33 #include "core/dom/Text.h" | 34 #include "core/dom/Text.h" |
34 #include "core/events/Event.h" | 35 #include "core/events/Event.h" |
35 #include "core/frame/UseCounter.h" | 36 #include "core/frame/UseCounter.h" |
36 #include "core/frame/csp/ContentSecurityPolicy.h" | 37 #include "core/frame/csp/ContentSecurityPolicy.h" |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
39 | 40 |
40 using namespace HTMLNames; | 41 using namespace HTMLNames; |
41 | 42 |
42 inline HTMLScriptElement::HTMLScriptElement(Document& document, | 43 inline HTMLScriptElement::HTMLScriptElement(Document& document, |
43 bool wasInsertedByParser, | 44 bool wasInsertedByParser, |
44 bool alreadyStarted, | 45 bool alreadyStarted, |
45 bool createdDuringDocumentWrite) | 46 bool createdDuringDocumentWrite) |
46 : HTMLElement(scriptTag, document), | 47 : HTMLElement(scriptTag, document) { |
47 m_loader(ScriptLoader::create(this, | 48 initializeScriptLoader(wasInsertedByParser, alreadyStarted, |
48 wasInsertedByParser, | 49 createdDuringDocumentWrite); |
49 alreadyStarted, | 50 } |
50 createdDuringDocumentWrite)) {} | |
51 | 51 |
52 HTMLScriptElement* HTMLScriptElement::create(Document& document, | 52 HTMLScriptElement* HTMLScriptElement::create(Document& document, |
53 bool wasInsertedByParser, | 53 bool wasInsertedByParser, |
54 bool alreadyStarted, | 54 bool alreadyStarted, |
55 bool createdDuringDocumentWrite) { | 55 bool createdDuringDocumentWrite) { |
56 return new HTMLScriptElement(document, wasInsertedByParser, alreadyStarted, | 56 return new HTMLScriptElement(document, wasInsertedByParser, alreadyStarted, |
57 createdDuringDocumentWrite); | 57 createdDuringDocumentWrite); |
58 } | 58 } |
59 | 59 |
60 bool HTMLScriptElement::isURLAttribute(const Attribute& attribute) const { | 60 bool HTMLScriptElement::isURLAttribute(const Attribute& attribute) const { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 150 } |
151 | 151 |
152 String HTMLScriptElement::forAttributeValue() const { | 152 String HTMLScriptElement::forAttributeValue() const { |
153 return getAttribute(forAttr).getString(); | 153 return getAttribute(forAttr).getString(); |
154 } | 154 } |
155 | 155 |
156 String HTMLScriptElement::eventAttributeValue() const { | 156 String HTMLScriptElement::eventAttributeValue() const { |
157 return getAttribute(eventAttr).getString(); | 157 return getAttribute(eventAttr).getString(); |
158 } | 158 } |
159 | 159 |
| 160 String HTMLScriptElement::crossOriginAttributeValue() const { |
| 161 return getAttribute(crossoriginAttr); |
| 162 } |
| 163 |
| 164 String HTMLScriptElement::integrityAttributeValue() const { |
| 165 return getAttribute(integrityAttr); |
| 166 } |
| 167 |
| 168 String HTMLScriptElement::textFromChildren() { |
| 169 return Element::textFromChildren(); |
| 170 } |
| 171 |
| 172 String HTMLScriptElement::textContent() const { |
| 173 return Element::textContent(); |
| 174 } |
| 175 |
160 bool HTMLScriptElement::asyncAttributeValue() const { | 176 bool HTMLScriptElement::asyncAttributeValue() const { |
161 return fastHasAttribute(asyncAttr); | 177 return fastHasAttribute(asyncAttr); |
162 } | 178 } |
163 | 179 |
164 bool HTMLScriptElement::deferAttributeValue() const { | 180 bool HTMLScriptElement::deferAttributeValue() const { |
165 return fastHasAttribute(deferAttr); | 181 return fastHasAttribute(deferAttr); |
166 } | 182 } |
167 | 183 |
168 bool HTMLScriptElement::hasSourceAttribute() const { | 184 bool HTMLScriptElement::hasSourceAttribute() const { |
169 return fastHasAttribute(srcAttr); | 185 return fastHasAttribute(srcAttr); |
170 } | 186 } |
171 | 187 |
| 188 bool HTMLScriptElement::isConnected() const { |
| 189 return Node::isConnected(); |
| 190 } |
| 191 |
| 192 bool HTMLScriptElement::hasChildren() const { |
| 193 return Node::hasChildren(); |
| 194 } |
| 195 |
| 196 bool HTMLScriptElement::isNonceableElement() const { |
| 197 return ContentSecurityPolicy::isNonceableElement(this); |
| 198 } |
| 199 |
| 200 bool HTMLScriptElement::allowInlineScriptForCSP( |
| 201 const AtomicString& nonce, |
| 202 const WTF::OrdinalNumber& contextLine, |
| 203 const String& scriptContent) { |
| 204 return document().contentSecurityPolicy()->allowInlineScript( |
| 205 this, document().url(), nonce, contextLine, scriptContent); |
| 206 } |
| 207 |
| 208 AtomicString HTMLScriptElement::initiatorName() const { |
| 209 return Element::localName(); |
| 210 } |
| 211 |
| 212 Document& HTMLScriptElement::document() const { |
| 213 return Node::document(); |
| 214 } |
| 215 |
172 void HTMLScriptElement::dispatchLoadEvent() { | 216 void HTMLScriptElement::dispatchLoadEvent() { |
173 DCHECK(!m_loader->haveFiredLoadEvent()); | 217 DCHECK(!m_loader->haveFiredLoadEvent()); |
174 dispatchEvent(Event::create(EventTypeNames::load)); | 218 dispatchEvent(Event::create(EventTypeNames::load)); |
175 } | 219 } |
176 | 220 |
| 221 void HTMLScriptElement::dispatchErrorEvent() { |
| 222 dispatchEvent(Event::create(EventTypeNames::error)); |
| 223 } |
| 224 |
| 225 void HTMLScriptElement::setScriptElementForBinding( |
| 226 HTMLScriptElementOrSVGScriptElement& element) { |
| 227 if (!isInV1ShadowTree()) |
| 228 element.setHTMLScriptElement(this); |
| 229 } |
| 230 |
177 Element* HTMLScriptElement::cloneElementWithoutAttributesAndChildren() { | 231 Element* HTMLScriptElement::cloneElementWithoutAttributesAndChildren() { |
178 return new HTMLScriptElement(document(), false, m_loader->alreadyStarted(), | 232 return new HTMLScriptElement(document(), false, m_loader->alreadyStarted(), |
179 false); | 233 false); |
180 } | 234 } |
181 | 235 |
182 DEFINE_TRACE(HTMLScriptElement) { | 236 DEFINE_TRACE(HTMLScriptElement) { |
183 visitor->trace(m_loader); | |
184 HTMLElement::trace(visitor); | 237 HTMLElement::trace(visitor); |
| 238 ScriptElementBase::trace(visitor); |
185 } | 239 } |
186 | 240 |
187 } // namespace blink | 241 } // namespace blink |
OLD | NEW |