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

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

Issue 62083002: Remove support for the externalResourcesRequired attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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,
(...skipping 18 matching lines...) Expand all
29 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/dom/ScriptLoader.h" 30 #include "core/dom/ScriptLoader.h"
31 #include "core/events/ThreadLocalEventNames.h" 31 #include "core/events/ThreadLocalEventNames.h"
32 #include "core/svg/SVGElementInstance.h" 32 #include "core/svg/SVGElementInstance.h"
33 #include "core/svg/properties/SVGAnimatedStaticPropertyTearOff.h" 33 #include "core/svg/properties/SVGAnimatedStaticPropertyTearOff.h"
34 34
35 namespace WebCore { 35 namespace WebCore {
36 36
37 // Animated property definitions 37 // Animated property definitions
38 DEFINE_ANIMATED_STRING(SVGScriptElement, XLinkNames::hrefAttr, Href, href) 38 DEFINE_ANIMATED_STRING(SVGScriptElement, XLinkNames::hrefAttr, Href, href)
39 DEFINE_ANIMATED_BOOLEAN(SVGScriptElement, SVGNames::externalResourcesRequiredAtt r, ExternalResourcesRequired, externalResourcesRequired)
40 39
41 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGScriptElement) 40 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGScriptElement)
42 REGISTER_LOCAL_ANIMATED_PROPERTY(href) 41 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
43 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
44 END_REGISTER_ANIMATED_PROPERTIES 42 END_REGISTER_ANIMATED_PROPERTIES
45 43
46 inline SVGScriptElement::SVGScriptElement(const QualifiedName& tagName, Document & document, bool wasInsertedByParser, bool alreadyStarted) 44 inline SVGScriptElement::SVGScriptElement(const QualifiedName& tagName, Document & document, bool wasInsertedByParser, bool alreadyStarted)
47 : SVGElement(tagName, document) 45 : SVGElement(tagName, document)
48 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired) 46 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired)
49 , m_loader(ScriptLoader::create(this, wasInsertedByParser, alreadyStarted)) 47 , m_loader(ScriptLoader::create(this, wasInsertedByParser, alreadyStarted))
50 { 48 {
51 ASSERT(hasTagName(SVGNames::scriptTag)); 49 ASSERT(hasTagName(SVGNames::scriptTag));
52 ScriptWrappable::init(this); 50 ScriptWrappable::init(this);
53 registerAnimatedPropertiesForSVGScriptElement(); 51 registerAnimatedPropertiesForSVGScriptElement();
54 } 52 }
55 53
56 PassRefPtr<SVGScriptElement> SVGScriptElement::create(const QualifiedName& tagNa me, Document& document, bool insertedByParser) 54 PassRefPtr<SVGScriptElement> SVGScriptElement::create(const QualifiedName& tagNa me, Document& document, bool insertedByParser)
57 { 55 {
58 return adoptRef(new SVGScriptElement(tagName, document, insertedByParser, fa lse)); 56 return adoptRef(new SVGScriptElement(tagName, document, insertedByParser, fa lse));
59 } 57 }
60 58
61 bool SVGScriptElement::isSupportedAttribute(const QualifiedName& attrName) 59 bool SVGScriptElement::isSupportedAttribute(const QualifiedName& attrName)
62 { 60 {
63 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 61 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
64 if (supportedAttributes.isEmpty()) { 62 if (supportedAttributes.isEmpty()) {
65 SVGURIReference::addSupportedAttributes(supportedAttributes); 63 SVGURIReference::addSupportedAttributes(supportedAttributes);
66 SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes );
67 supportedAttributes.add(SVGNames::typeAttr); 64 supportedAttributes.add(SVGNames::typeAttr);
68 supportedAttributes.add(HTMLNames::onerrorAttr); 65 supportedAttributes.add(HTMLNames::onerrorAttr);
69 } 66 }
70 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 67 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
71 } 68 }
72 69
73 void SVGScriptElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) 70 void SVGScriptElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value)
74 { 71 {
75 if (!isSupportedAttribute(name)) { 72 if (!isSupportedAttribute(name)) {
76 SVGElement::parseAttribute(name, value); 73 SVGElement::parseAttribute(name, value);
77 return; 74 return;
78 } 75 }
79 76
80 if (name == SVGNames::typeAttr) { 77 if (name == SVGNames::typeAttr) {
81 setType(value); 78 setType(value);
82 return; 79 return;
83 } 80 }
84 81
85 if (name == HTMLNames::onerrorAttr) { 82 if (name == HTMLNames::onerrorAttr) {
86 setAttributeEventListener(EventTypeNames::error, createAttributeEventLis tener(this, name, value)); 83 setAttributeEventListener(EventTypeNames::error, createAttributeEventLis tener(this, name, value));
87 return; 84 return;
88 } 85 }
89 86
90 if (SVGURIReference::parseAttribute(name, value)) 87 if (SVGURIReference::parseAttribute(name, value))
91 return; 88 return;
92 if (SVGExternalResourcesRequired::parseAttribute(name, value))
93 return;
94 89
95 ASSERT_NOT_REACHED(); 90 ASSERT_NOT_REACHED();
96 } 91 }
97 92
98 void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) 93 void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName)
99 { 94 {
100 if (!isSupportedAttribute(attrName)) { 95 if (!isSupportedAttribute(attrName)) {
101 SVGElement::svgAttributeChanged(attrName); 96 SVGElement::svgAttributeChanged(attrName);
102 return; 97 return;
103 } 98 }
104 99
105 SVGElementInstance::InvalidationGuard invalidationGuard(this); 100 SVGElementInstance::InvalidationGuard invalidationGuard(this);
106 101
107 if (attrName == SVGNames::typeAttr || attrName == HTMLNames::onerrorAttr) 102 if (attrName == SVGNames::typeAttr || attrName == HTMLNames::onerrorAttr)
108 return; 103 return;
109 104
110 if (SVGURIReference::isKnownAttribute(attrName)) { 105 if (SVGURIReference::isKnownAttribute(attrName)) {
111 m_loader->handleSourceAttribute(hrefCurrentValue()); 106 m_loader->handleSourceAttribute(hrefCurrentValue());
112 return; 107 return;
113 } 108 }
114 109
115 if (SVGExternalResourcesRequired::handleAttributeChange(this, attrName))
116 return;
117
118 ASSERT_NOT_REACHED(); 110 ASSERT_NOT_REACHED();
119 } 111 }
120 112
121 Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode* rootParent) 113 Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode* rootParent)
122 { 114 {
123 SVGElement::insertedInto(rootParent); 115 SVGElement::insertedInto(rootParent);
124 return InsertionShouldCallDidNotifySubtreeInsertions; 116 return InsertionShouldCallDidNotifySubtreeInsertions;
125 } 117 }
126 118
127 void SVGScriptElement::didNotifySubtreeInsertionsToDocument() 119 void SVGScriptElement::didNotifySubtreeInsertionsToDocument()
128 { 120 {
129 m_loader->didNotifySubtreeInsertionsToDocument(); 121 m_loader->didNotifySubtreeInsertionsToDocument();
130 SVGExternalResourcesRequired::insertedIntoDocument(this); 122
123 if (!m_loader->isParserInserted()) {
124 m_loader->setHaveFiredLoadEvent(true);
125 sendSVGLoadEventIfPossibleAsynchronously();
126 }
131 } 127 }
132 128
133 void SVGScriptElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) 129 void SVGScriptElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
134 { 130 {
135 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil dCountDelta); 131 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil dCountDelta);
136 m_loader->childrenChanged(); 132 m_loader->childrenChanged();
137 } 133 }
138 134
139 bool SVGScriptElement::isURLAttribute(const Attribute& attribute) const 135 bool SVGScriptElement::isURLAttribute(const Attribute& attribute) const
140 { 136 {
141 return attribute.name() == sourceAttributeValue(); 137 return attribute.name() == sourceAttributeValue();
142 } 138 }
143 139
144 void SVGScriptElement::finishParsingChildren() 140 void SVGScriptElement::finishParsingChildren()
145 { 141 {
146 SVGElement::finishParsingChildren(); 142 SVGElement::finishParsingChildren();
147 SVGExternalResourcesRequired::finishParsingChildren(); 143 m_loader->setHaveFiredLoadEvent(true);
148 } 144 }
149 145
150 String SVGScriptElement::type() const 146 String SVGScriptElement::type() const
151 { 147 {
152 return m_type; 148 return m_type;
153 } 149 }
154 150
155 void SVGScriptElement::setType(const String& type) 151 void SVGScriptElement::setType(const String& type)
156 { 152 {
157 m_type = type; 153 m_type = type;
158 } 154 }
159 155
160 void SVGScriptElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons t 156 void SVGScriptElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) cons t
161 { 157 {
162 SVGElement::addSubresourceAttributeURLs(urls); 158 SVGElement::addSubresourceAttributeURLs(urls);
163 159
164 addSubresourceURL(urls, document().completeURL(hrefCurrentValue())); 160 addSubresourceURL(urls, document().completeURL(hrefCurrentValue()));
165 } 161 }
166 162
163 bool SVGScriptElement::haveLoadedRequiredResources()
164 {
165 return m_loader->haveFiredLoadEvent();
166 }
167
167 String SVGScriptElement::sourceAttributeValue() const 168 String SVGScriptElement::sourceAttributeValue() const
168 { 169 {
169 return hrefCurrentValue(); 170 return hrefCurrentValue();
170 } 171 }
171 172
172 String SVGScriptElement::charsetAttributeValue() const 173 String SVGScriptElement::charsetAttributeValue() const
173 { 174 {
174 return String(); 175 return String();
175 } 176 }
176 177
(...skipping 30 matching lines...) Expand all
207 bool SVGScriptElement::hasSourceAttribute() const 208 bool SVGScriptElement::hasSourceAttribute() const
208 { 209 {
209 return hasAttribute(XLinkNames::hrefAttr); 210 return hasAttribute(XLinkNames::hrefAttr);
210 } 211 }
211 212
212 PassRefPtr<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren() 213 PassRefPtr<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren()
213 { 214 {
214 return adoptRef(new SVGScriptElement(tagQName(), document(), false, m_loader ->alreadyStarted())); 215 return adoptRef(new SVGScriptElement(tagQName(), document(), false, m_loader ->alreadyStarted()));
215 } 216 }
216 217
217 void SVGScriptElement::setHaveFiredLoadEvent(bool haveFiredLoadEvent) 218 void SVGScriptElement::dispatchLoadEvent()
Stephen Chennney 2013/11/06 16:45:43 This effectively does nothing except assert. What
Erik Dahlström (inactive) 2013/11/07 09:38:04 I've copied the code from SVGExternalResourcesRequ
218 { 219 {
219 m_loader->setHaveFiredLoadEvent(haveFiredLoadEvent); 220 if (!m_loader->isParserInserted())
220 } 221 ASSERT(m_loader->haveFiredLoadEvent());
221 222 else if (m_loader->haveFiredLoadEvent())
222 bool SVGScriptElement::isParserInserted() const 223 return;
223 {
224 return m_loader->isParserInserted();
225 }
226
227 bool SVGScriptElement::haveFiredLoadEvent() const
228 {
229 return m_loader->haveFiredLoadEvent();
230 }
231
232 Timer<SVGElement>* SVGScriptElement::svgLoadEventTimer()
233 {
234 return &m_svgLoadEventTimer;
235 } 224 }
236 225
237 } 226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698