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

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

Issue 148173018: [SVG] SVGAnimatedString{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove if 0 Created 6 years, 10 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 | Annotate | Revision Log
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 17 matching lines...) Expand all
28 #include "core/dom/Attribute.h" 28 #include "core/dom/Attribute.h"
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)
39 38
40 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGScriptElement) 39 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGScriptElement)
41 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
42 END_REGISTER_ANIMATED_PROPERTIES 40 END_REGISTER_ANIMATED_PROPERTIES
43 41
44 inline SVGScriptElement::SVGScriptElement(Document& document, bool wasInsertedBy Parser, bool alreadyStarted) 42 inline SVGScriptElement::SVGScriptElement(Document& document, bool wasInsertedBy Parser, bool alreadyStarted)
45 : SVGElement(SVGNames::scriptTag, document) 43 : SVGElement(SVGNames::scriptTag, document)
44 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr eate()))
46 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired) 45 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired)
47 , m_loader(ScriptLoader::create(this, wasInsertedByParser, alreadyStarted)) 46 , m_loader(ScriptLoader::create(this, wasInsertedByParser, alreadyStarted))
48 { 47 {
49 ScriptWrappable::init(this); 48 ScriptWrappable::init(this);
49 addToPropertyMap(m_href);
50 registerAnimatedPropertiesForSVGScriptElement(); 50 registerAnimatedPropertiesForSVGScriptElement();
51 } 51 }
52 52
53 PassRefPtr<SVGScriptElement> SVGScriptElement::create(Document& document, bool i nsertedByParser) 53 PassRefPtr<SVGScriptElement> SVGScriptElement::create(Document& document, bool i nsertedByParser)
54 { 54 {
55 return adoptRef(new SVGScriptElement(document, insertedByParser, false)); 55 return adoptRef(new SVGScriptElement(document, insertedByParser, false));
56 } 56 }
57 57
58 bool SVGScriptElement::isSupportedAttribute(const QualifiedName& attrName) 58 bool SVGScriptElement::isSupportedAttribute(const QualifiedName& attrName)
59 { 59 {
60 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 60 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
61 if (supportedAttributes.isEmpty()) { 61 if (supportedAttributes.isEmpty()) {
62 SVGURIReference::addSupportedAttributes(supportedAttributes); 62 SVGURIReference::addSupportedAttributes(supportedAttributes);
63 supportedAttributes.add(SVGNames::typeAttr); 63 supportedAttributes.add(SVGNames::typeAttr);
64 supportedAttributes.add(HTMLNames::onerrorAttr); 64 supportedAttributes.add(HTMLNames::onerrorAttr);
65 } 65 }
66 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 66 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
67 } 67 }
68 68
69 void SVGScriptElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) 69 void SVGScriptElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value)
70 { 70 {
71 if (!isSupportedAttribute(name)) { 71 if (!isSupportedAttribute(name)) {
72 SVGElement::parseAttribute(name, value); 72 SVGElement::parseAttribute(name, value);
73 return; 73 return;
74 } 74 }
75 75
76 if (name == SVGNames::typeAttr) { 76 if (name == SVGNames::typeAttr) {
haraken 2014/01/29 05:18:00 Can you move this check to line 88?
77 setType(value); 77 setType(value);
78 return; 78 return;
79 } 79 }
80 80
81 if (name == HTMLNames::onerrorAttr) { 81 if (name == HTMLNames::onerrorAttr) {
haraken 2014/01/29 05:18:00 Ditto.
82 setAttributeEventListener(EventTypeNames::error, createAttributeEventLis tener(this, name, value)); 82 setAttributeEventListener(EventTypeNames::error, createAttributeEventLis tener(this, name, value));
83 return; 83 return;
84 } 84 }
85 85
86 if (SVGURIReference::parseAttribute(name, value)) 86 SVGParsingError parseError = NoError;
87 return;
88 87
89 ASSERT_NOT_REACHED(); 88 if (name.matches(XLinkNames::hrefAttr))
89 m_href->setBaseValueAsString(value, parseError);
90 else
91 ASSERT_NOT_REACHED();
92
93 reportAttributeParsingError(parseError, name, value);
90 } 94 }
91 95
92 void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) 96 void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName)
93 { 97 {
94 if (!isSupportedAttribute(attrName)) { 98 if (!isSupportedAttribute(attrName)) {
95 SVGElement::svgAttributeChanged(attrName); 99 SVGElement::svgAttributeChanged(attrName);
96 return; 100 return;
97 } 101 }
98 102
99 SVGElementInstance::InvalidationGuard invalidationGuard(this); 103 SVGElementInstance::InvalidationGuard invalidationGuard(this);
100 104
101 if (attrName == SVGNames::typeAttr || attrName == HTMLNames::onerrorAttr) 105 if (attrName == SVGNames::typeAttr || attrName == HTMLNames::onerrorAttr)
102 return; 106 return;
103 107
104 if (SVGURIReference::isKnownAttribute(attrName)) { 108 if (SVGURIReference::isKnownAttribute(attrName)) {
105 m_loader->handleSourceAttribute(hrefCurrentValue()); 109 m_loader->handleSourceAttribute(m_href->currentValue()->value());
106 return; 110 return;
107 } 111 }
108 112
109 ASSERT_NOT_REACHED(); 113 ASSERT_NOT_REACHED();
110 } 114 }
111 115
112 Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode* rootParent) 116 Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode* rootParent)
113 { 117 {
114 SVGElement::insertedInto(rootParent); 118 SVGElement::insertedInto(rootParent);
115 return InsertionShouldCallDidNotifySubtreeInsertions; 119 return InsertionShouldCallDidNotifySubtreeInsertions;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 m_type = type; 156 m_type = type;
153 } 157 }
154 158
155 bool SVGScriptElement::haveLoadedRequiredResources() 159 bool SVGScriptElement::haveLoadedRequiredResources()
156 { 160 {
157 return m_loader->haveFiredLoadEvent(); 161 return m_loader->haveFiredLoadEvent();
158 } 162 }
159 163
160 String SVGScriptElement::sourceAttributeValue() const 164 String SVGScriptElement::sourceAttributeValue() const
161 { 165 {
162 return hrefCurrentValue(); 166 return m_href->currentValue()->value();
163 } 167 }
164 168
165 String SVGScriptElement::charsetAttributeValue() const 169 String SVGScriptElement::charsetAttributeValue() const
166 { 170 {
167 return String(); 171 return String();
168 } 172 }
169 173
170 String SVGScriptElement::typeAttributeValue() const 174 String SVGScriptElement::typeAttributeValue() const
171 { 175 {
172 return type(); 176 return type();
(...skipping 19 matching lines...) Expand all
192 return false; 196 return false;
193 } 197 }
194 198
195 bool SVGScriptElement::deferAttributeValue() const 199 bool SVGScriptElement::deferAttributeValue() const
196 { 200 {
197 return false; 201 return false;
198 } 202 }
199 203
200 bool SVGScriptElement::hasSourceAttribute() const 204 bool SVGScriptElement::hasSourceAttribute() const
201 { 205 {
202 return hasAttribute(XLinkNames::hrefAttr); 206 return m_href->isSpecified();
203 } 207 }
204 208
205 PassRefPtr<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren() 209 PassRefPtr<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren()
206 { 210 {
207 return adoptRef(new SVGScriptElement(document(), false, m_loader->alreadySta rted())); 211 return adoptRef(new SVGScriptElement(document(), false, m_loader->alreadySta rted()));
208 } 212 }
209 213
210 void SVGScriptElement::dispatchLoadEvent() 214 void SVGScriptElement::dispatchLoadEvent()
211 { 215 {
212 dispatchEvent(Event::create(EventTypeNames::load)); 216 dispatchEvent(Event::create(EventTypeNames::load));
213 } 217 }
214 218
215 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698