Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGScriptElement.cpp

Issue 2723793002: De-Element ScriptLoader (Closed)
Patch Set: ScriptLoaderClient->ScriptElementBase, pure virtual interface, add fixme Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA. 18 * Boston, MA 02110-1301, USA.
19 */ 19 */
20 20
21 #include "core/svg/SVGScriptElement.h" 21 #include "core/svg/SVGScriptElement.h"
22 22
23 #include "bindings/core/v8/HTMLScriptElementOrSVGScriptElement.h"
23 #include "bindings/core/v8/ScriptEventListener.h" 24 #include "bindings/core/v8/ScriptEventListener.h"
24 #include "core/HTMLNames.h" 25 #include "core/HTMLNames.h"
25 #include "core/XLinkNames.h" 26 #include "core/XLinkNames.h"
26 #include "core/dom/Attribute.h" 27 #include "core/dom/Attribute.h"
27 #include "core/dom/ScriptLoader.h" 28 #include "core/dom/ScriptLoader.h"
28 #include "core/dom/ScriptRunner.h" 29 #include "core/dom/ScriptRunner.h"
29 #include "core/events/Event.h" 30 #include "core/events/Event.h"
30 #include "core/frame/csp/ContentSecurityPolicy.h" 31 #include "core/frame/csp/ContentSecurityPolicy.h"
31 32
32 namespace blink { 33 namespace blink {
33 34
34 inline SVGScriptElement::SVGScriptElement(Document& document, 35 inline SVGScriptElement::SVGScriptElement(Document& document,
35 bool wasInsertedByParser, 36 bool wasInsertedByParser,
36 bool alreadyStarted) 37 bool alreadyStarted)
37 : SVGElement(SVGNames::scriptTag, document), 38 : SVGElement(SVGNames::scriptTag, document), SVGURIReference(this) {
38 SVGURIReference(this), 39 initializeScriptLoader(wasInsertedByParser, alreadyStarted, false);
39 m_loader( 40 }
40 ScriptLoader::create(this, wasInsertedByParser, alreadyStarted)) {}
41 41
42 SVGScriptElement* SVGScriptElement::create(Document& document, 42 SVGScriptElement* SVGScriptElement::create(Document& document,
43 bool insertedByParser) { 43 bool insertedByParser) {
44 return new SVGScriptElement(document, insertedByParser, false); 44 return new SVGScriptElement(document, insertedByParser, false);
45 } 45 }
46 46
47 void SVGScriptElement::parseAttribute( 47 void SVGScriptElement::parseAttribute(
48 const AttributeModificationParams& params) { 48 const AttributeModificationParams& params) {
49 if (params.name == HTMLNames::onerrorAttr) { 49 if (params.name == HTMLNames::onerrorAttr) {
50 setAttributeEventListener( 50 setAttributeEventListener(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 bool SVGScriptElement::haveLoadedRequiredResources() { 109 bool SVGScriptElement::haveLoadedRequiredResources() {
110 return m_loader->haveFiredLoadEvent(); 110 return m_loader->haveFiredLoadEvent();
111 } 111 }
112 112
113 String SVGScriptElement::sourceAttributeValue() const { 113 String SVGScriptElement::sourceAttributeValue() const {
114 return hrefString(); 114 return hrefString();
115 } 115 }
116 116
117 String SVGScriptElement::charsetAttributeValue() const {
118 return String();
119 }
120
121 String SVGScriptElement::typeAttributeValue() const { 117 String SVGScriptElement::typeAttributeValue() const {
122 return getAttribute(SVGNames::typeAttr).getString(); 118 return getAttribute(SVGNames::typeAttr).getString();
123 } 119 }
124 120
125 String SVGScriptElement::languageAttributeValue() const { 121 String SVGScriptElement::textFromChildren() {
126 return String(); 122 return Element::textFromChildren();
127 } 123 }
128 124
129 String SVGScriptElement::forAttributeValue() const { 125 String SVGScriptElement::textContent() const {
130 return String(); 126 return Node::textContent();
131 }
132
133 String SVGScriptElement::eventAttributeValue() const {
134 return String();
135 }
136
137 bool SVGScriptElement::asyncAttributeValue() const {
138 return false;
139 }
140
141 bool SVGScriptElement::deferAttributeValue() const {
142 return false;
143 } 127 }
144 128
145 bool SVGScriptElement::hasSourceAttribute() const { 129 bool SVGScriptElement::hasSourceAttribute() const {
146 return href()->isSpecified(); 130 return href()->isSpecified();
147 } 131 }
148 132
133 bool SVGScriptElement::isConnected() const {
134 return Node::isConnected();
135 }
136
137 bool SVGScriptElement::hasChildren() const {
138 return Node::hasChildren();
139 }
140
141 bool SVGScriptElement::isNonceableElement() const {
142 return ContentSecurityPolicy::isNonceableElement(this);
143 }
144
145 bool SVGScriptElement::allowInlineScriptForCSP(
146 const AtomicString& nonce,
147 const WTF::OrdinalNumber& contextLine,
148 const String& scriptContent) {
149 return document().contentSecurityPolicy()->allowInlineScript(
150 this, document().url(), nonce, contextLine, scriptContent);
151 }
152
153 AtomicString SVGScriptElement::initiatorName() const {
154 return Element::localName();
155 }
156
157 Document& SVGScriptElement::document() const {
158 return Node::document();
159 }
160
149 Element* SVGScriptElement::cloneElementWithoutAttributesAndChildren() { 161 Element* SVGScriptElement::cloneElementWithoutAttributesAndChildren() {
150 return new SVGScriptElement(document(), false, m_loader->alreadyStarted()); 162 return new SVGScriptElement(document(), false, m_loader->alreadyStarted());
151 } 163 }
152 164
153 void SVGScriptElement::dispatchLoadEvent() { 165 void SVGScriptElement::dispatchLoadEvent() {
154 dispatchEvent(Event::create(EventTypeNames::load)); 166 dispatchEvent(Event::create(EventTypeNames::load));
155 } 167 }
156 168
169 void SVGScriptElement::dispatchErrorEvent() {
170 dispatchEvent(Event::create(EventTypeNames::error));
171 }
172
173 void SVGScriptElement::setScriptElementForBinding(
174 HTMLScriptElementOrSVGScriptElement& element) {
175 if (!isInV1ShadowTree())
176 element.setSVGScriptElement(this);
177 }
178
157 #if DCHECK_IS_ON() 179 #if DCHECK_IS_ON()
158 bool SVGScriptElement::isAnimatableAttribute(const QualifiedName& name) const { 180 bool SVGScriptElement::isAnimatableAttribute(const QualifiedName& name) const {
159 if (name == SVGNames::typeAttr || name == SVGNames::hrefAttr || 181 if (name == SVGNames::typeAttr || name == SVGNames::hrefAttr ||
160 name == XLinkNames::hrefAttr) 182 name == XLinkNames::hrefAttr)
161 return false; 183 return false;
162 return SVGElement::isAnimatableAttribute(name); 184 return SVGElement::isAnimatableAttribute(name);
163 } 185 }
164 #endif 186 #endif
165 187
166 DEFINE_TRACE(SVGScriptElement) { 188 DEFINE_TRACE(SVGScriptElement) {
167 visitor->trace(m_loader);
168 SVGElement::trace(visitor); 189 SVGElement::trace(visitor);
169 SVGURIReference::trace(visitor); 190 SVGURIReference::trace(visitor);
191 ScriptElementBase::trace(visitor);
170 } 192 }
171 193
172 } // namespace blink 194 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGScriptElement.h ('k') | third_party/WebKit/Source/core/xml/parser/XMLDocumentParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698