OLD | NEW |
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 Loading... |
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 SVGParsingError parseError = NoError; |
| 77 |
| 78 if (name == SVGNames::typeAttr) |
77 setType(value); | 79 setType(value); |
78 return; | 80 else if (name == HTMLNames::onerrorAttr) |
79 } | 81 setAttributeEventListener(EventTypeNames::error, createAttributeEventLis
tener(this, name, value)); |
| 82 else if (name.matches(XLinkNames::hrefAttr)) |
| 83 m_href->setBaseValueAsString(value, parseError); |
| 84 else |
| 85 ASSERT_NOT_REACHED(); |
80 | 86 |
81 if (name == HTMLNames::onerrorAttr) { | 87 reportAttributeParsingError(parseError, name, value); |
82 setAttributeEventListener(EventTypeNames::error, createAttributeEventLis
tener(this, name, value)); | |
83 return; | |
84 } | |
85 | |
86 if (SVGURIReference::parseAttribute(name, value)) | |
87 return; | |
88 | |
89 ASSERT_NOT_REACHED(); | |
90 } | 88 } |
91 | 89 |
92 void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) | 90 void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) |
93 { | 91 { |
94 if (!isSupportedAttribute(attrName)) { | 92 if (!isSupportedAttribute(attrName)) { |
95 SVGElement::svgAttributeChanged(attrName); | 93 SVGElement::svgAttributeChanged(attrName); |
96 return; | 94 return; |
97 } | 95 } |
98 | 96 |
99 SVGElementInstance::InvalidationGuard invalidationGuard(this); | 97 SVGElementInstance::InvalidationGuard invalidationGuard(this); |
100 | 98 |
101 if (attrName == SVGNames::typeAttr || attrName == HTMLNames::onerrorAttr) | 99 if (attrName == SVGNames::typeAttr || attrName == HTMLNames::onerrorAttr) |
102 return; | 100 return; |
103 | 101 |
104 if (SVGURIReference::isKnownAttribute(attrName)) { | 102 if (SVGURIReference::isKnownAttribute(attrName)) { |
105 m_loader->handleSourceAttribute(hrefCurrentValue()); | 103 m_loader->handleSourceAttribute(m_href->currentValue()->value()); |
106 return; | 104 return; |
107 } | 105 } |
108 | 106 |
109 ASSERT_NOT_REACHED(); | 107 ASSERT_NOT_REACHED(); |
110 } | 108 } |
111 | 109 |
112 Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode*
rootParent) | 110 Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode*
rootParent) |
113 { | 111 { |
114 SVGElement::insertedInto(rootParent); | 112 SVGElement::insertedInto(rootParent); |
115 return InsertionShouldCallDidNotifySubtreeInsertions; | 113 return InsertionShouldCallDidNotifySubtreeInsertions; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 m_type = type; | 150 m_type = type; |
153 } | 151 } |
154 | 152 |
155 bool SVGScriptElement::haveLoadedRequiredResources() | 153 bool SVGScriptElement::haveLoadedRequiredResources() |
156 { | 154 { |
157 return m_loader->haveFiredLoadEvent(); | 155 return m_loader->haveFiredLoadEvent(); |
158 } | 156 } |
159 | 157 |
160 String SVGScriptElement::sourceAttributeValue() const | 158 String SVGScriptElement::sourceAttributeValue() const |
161 { | 159 { |
162 return hrefCurrentValue(); | 160 return m_href->currentValue()->value(); |
163 } | 161 } |
164 | 162 |
165 String SVGScriptElement::charsetAttributeValue() const | 163 String SVGScriptElement::charsetAttributeValue() const |
166 { | 164 { |
167 return String(); | 165 return String(); |
168 } | 166 } |
169 | 167 |
170 String SVGScriptElement::typeAttributeValue() const | 168 String SVGScriptElement::typeAttributeValue() const |
171 { | 169 { |
172 return type(); | 170 return type(); |
(...skipping 19 matching lines...) Expand all Loading... |
192 return false; | 190 return false; |
193 } | 191 } |
194 | 192 |
195 bool SVGScriptElement::deferAttributeValue() const | 193 bool SVGScriptElement::deferAttributeValue() const |
196 { | 194 { |
197 return false; | 195 return false; |
198 } | 196 } |
199 | 197 |
200 bool SVGScriptElement::hasSourceAttribute() const | 198 bool SVGScriptElement::hasSourceAttribute() const |
201 { | 199 { |
202 return hasAttribute(XLinkNames::hrefAttr); | 200 return m_href->isSpecified(); |
203 } | 201 } |
204 | 202 |
205 PassRefPtr<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren() | 203 PassRefPtr<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren() |
206 { | 204 { |
207 return adoptRef(new SVGScriptElement(document(), false, m_loader->alreadySta
rted())); | 205 return adoptRef(new SVGScriptElement(document(), false, m_loader->alreadySta
rted())); |
208 } | 206 } |
209 | 207 |
210 void SVGScriptElement::dispatchLoadEvent() | 208 void SVGScriptElement::dispatchLoadEvent() |
211 { | 209 { |
212 dispatchEvent(Event::create(EventTypeNames::load)); | 210 dispatchEvent(Event::create(EventTypeNames::load)); |
213 } | 211 } |
214 | 212 |
215 } | 213 } |
OLD | NEW |