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, |
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/ScriptEventListener.h" | 23 #include "bindings/core/v8/ScriptEventListener.h" |
24 #include "core/HTMLNames.h" | 24 #include "core/HTMLNames.h" |
25 #include "core/XLinkNames.h" | |
25 #include "core/dom/Attribute.h" | 26 #include "core/dom/Attribute.h" |
26 #include "core/dom/ScriptLoader.h" | 27 #include "core/dom/ScriptLoader.h" |
27 #include "core/dom/ScriptRunner.h" | 28 #include "core/dom/ScriptRunner.h" |
28 #include "core/events/Event.h" | 29 #include "core/events/Event.h" |
29 | 30 |
30 namespace blink { | 31 namespace blink { |
31 | 32 |
32 inline SVGScriptElement::SVGScriptElement(Document& document, | 33 inline SVGScriptElement::SVGScriptElement(Document& document, |
33 bool wasInsertedByParser, | 34 bool wasInsertedByParser, |
34 bool alreadyStarted) | 35 bool alreadyStarted) |
35 : SVGElement(SVGNames::scriptTag, document), | 36 : SVGElement(SVGNames::scriptTag, document), |
36 SVGURIReference(this), | 37 SVGURIReference(this, SVGURIReference::DoNotAddToPropertyMap), |
37 m_loader( | 38 m_loader( |
38 ScriptLoader::create(this, wasInsertedByParser, alreadyStarted)) {} | 39 ScriptLoader::create(this, wasInsertedByParser, alreadyStarted)) {} |
39 | 40 |
40 SVGScriptElement* SVGScriptElement::create(Document& document, | 41 SVGScriptElement* SVGScriptElement::create(Document& document, |
41 bool insertedByParser) { | 42 bool insertedByParser) { |
42 return new SVGScriptElement(document, insertedByParser, false); | 43 return new SVGScriptElement(document, insertedByParser, false); |
43 } | 44 } |
44 | 45 |
45 void SVGScriptElement::parseAttribute(const QualifiedName& name, | 46 void SVGScriptElement::parseAttribute(const QualifiedName& name, |
46 const AtomicString& oldValue, | 47 const AtomicString& oldValue, |
47 const AtomicString& value) { | 48 const AtomicString& value) { |
48 if (name == HTMLNames::onerrorAttr) | 49 if (name == HTMLNames::onerrorAttr) { |
49 setAttributeEventListener( | 50 setAttributeEventListener( |
50 EventTypeNames::error, | 51 EventTypeNames::error, |
51 createAttributeEventListener(this, name, value, eventParameterName())); | 52 createAttributeEventListener(this, name, value, eventParameterName())); |
52 else | 53 } else if (name.matches(SVGNames::hrefAttr) || |
54 name.matches(XLinkNames::hrefAttr)) { | |
55 m_loader->handleSourceAttribute(sourceAttributeValue()); | |
56 } else { | |
53 SVGElement::parseAttribute(name, oldValue, value); | 57 SVGElement::parseAttribute(name, oldValue, value); |
54 } | |
55 | |
56 void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) { | |
57 if (SVGURIReference::isKnownAttribute(attrName)) { | |
58 SVGElement::InvalidationGuard invalidationGuard(this); | |
59 m_loader->handleSourceAttribute(hrefString()); | |
60 return; | |
61 } | 58 } |
62 | |
63 SVGElement::svgAttributeChanged(attrName); | |
64 } | 59 } |
65 | 60 |
66 Node::InsertionNotificationRequest SVGScriptElement::insertedInto( | 61 Node::InsertionNotificationRequest SVGScriptElement::insertedInto( |
67 ContainerNode* rootParent) { | 62 ContainerNode* rootParent) { |
68 SVGElement::insertedInto(rootParent); | 63 SVGElement::insertedInto(rootParent); |
69 return InsertionShouldCallDidNotifySubtreeInsertions; | 64 return InsertionShouldCallDidNotifySubtreeInsertions; |
70 } | 65 } |
71 | 66 |
72 void SVGScriptElement::didNotifySubtreeInsertionsToDocument() { | 67 void SVGScriptElement::didNotifySubtreeInsertionsToDocument() { |
73 m_loader->didNotifySubtreeInsertionsToDocument(); | 68 m_loader->didNotifySubtreeInsertionsToDocument(); |
74 | 69 |
75 if (!m_loader->isParserInserted()) | 70 if (!m_loader->isParserInserted()) |
76 m_loader->setHaveFiredLoadEvent(true); | 71 m_loader->setHaveFiredLoadEvent(true); |
77 } | 72 } |
78 | 73 |
79 void SVGScriptElement::childrenChanged(const ChildrenChange& change) { | 74 void SVGScriptElement::childrenChanged(const ChildrenChange& change) { |
80 SVGElement::childrenChanged(change); | 75 SVGElement::childrenChanged(change); |
81 m_loader->childrenChanged(); | 76 m_loader->childrenChanged(); |
82 } | 77 } |
83 | 78 |
84 void SVGScriptElement::didMoveToNewDocument(Document& oldDocument) { | 79 void SVGScriptElement::didMoveToNewDocument(Document& oldDocument) { |
85 ScriptRunner::movePendingScript(oldDocument, document(), m_loader.get()); | 80 ScriptRunner::movePendingScript(oldDocument, document(), m_loader.get()); |
86 SVGElement::didMoveToNewDocument(oldDocument); | 81 SVGElement::didMoveToNewDocument(oldDocument); |
87 } | 82 } |
88 | 83 |
89 bool SVGScriptElement::isURLAttribute(const Attribute& attribute) const { | 84 bool SVGScriptElement::isURLAttribute(const Attribute& attribute) const { |
85 // TODO(fs): Recover head rotation. | |
pdr.
2017/01/09 18:50:47
O_o
fs
2017/01/10 10:15:16
Yes, this function is obviously broken (or, when i
| |
90 return attribute.name() == AtomicString(sourceAttributeValue()); | 86 return attribute.name() == AtomicString(sourceAttributeValue()); |
91 } | 87 } |
92 | 88 |
93 void SVGScriptElement::finishParsingChildren() { | 89 void SVGScriptElement::finishParsingChildren() { |
94 SVGElement::finishParsingChildren(); | 90 SVGElement::finishParsingChildren(); |
95 m_loader->setHaveFiredLoadEvent(true); | 91 m_loader->setHaveFiredLoadEvent(true); |
96 } | 92 } |
97 | 93 |
98 bool SVGScriptElement::haveLoadedRequiredResources() { | 94 bool SVGScriptElement::haveLoadedRequiredResources() { |
99 return m_loader->haveFiredLoadEvent(); | 95 return m_loader->haveFiredLoadEvent(); |
100 } | 96 } |
101 | 97 |
102 String SVGScriptElement::sourceAttributeValue() const { | 98 String SVGScriptElement::sourceAttributeValue() const { |
103 return hrefString(); | 99 return SVGURIReference::legacyHrefString(*this).getString(); |
104 } | 100 } |
105 | 101 |
106 String SVGScriptElement::charsetAttributeValue() const { | 102 String SVGScriptElement::charsetAttributeValue() const { |
107 return String(); | 103 return String(); |
108 } | 104 } |
109 | 105 |
110 String SVGScriptElement::typeAttributeValue() const { | 106 String SVGScriptElement::typeAttributeValue() const { |
111 return getAttribute(SVGNames::typeAttr).getString(); | 107 return getAttribute(SVGNames::typeAttr).getString(); |
112 } | 108 } |
113 | 109 |
(...skipping 11 matching lines...) Expand all Loading... | |
125 | 121 |
126 bool SVGScriptElement::asyncAttributeValue() const { | 122 bool SVGScriptElement::asyncAttributeValue() const { |
127 return false; | 123 return false; |
128 } | 124 } |
129 | 125 |
130 bool SVGScriptElement::deferAttributeValue() const { | 126 bool SVGScriptElement::deferAttributeValue() const { |
131 return false; | 127 return false; |
132 } | 128 } |
133 | 129 |
134 bool SVGScriptElement::hasSourceAttribute() const { | 130 bool SVGScriptElement::hasSourceAttribute() const { |
135 return href()->isSpecified(); | 131 return fastHasAttribute(SVGNames::hrefAttr) || |
132 fastHasAttribute(XLinkNames::hrefAttr); | |
136 } | 133 } |
137 | 134 |
138 Element* SVGScriptElement::cloneElementWithoutAttributesAndChildren() { | 135 Element* SVGScriptElement::cloneElementWithoutAttributesAndChildren() { |
139 return new SVGScriptElement(document(), false, m_loader->alreadyStarted()); | 136 return new SVGScriptElement(document(), false, m_loader->alreadyStarted()); |
140 } | 137 } |
141 | 138 |
142 void SVGScriptElement::dispatchLoadEvent() { | 139 void SVGScriptElement::dispatchLoadEvent() { |
143 dispatchEvent(Event::create(EventTypeNames::load)); | 140 dispatchEvent(Event::create(EventTypeNames::load)); |
144 } | 141 } |
145 | 142 |
146 #if DCHECK_IS_ON() | 143 #if DCHECK_IS_ON() |
147 bool SVGScriptElement::isAnimatableAttribute(const QualifiedName& name) const { | 144 bool SVGScriptElement::isAnimatableAttribute(const QualifiedName& name) const { |
148 if (name == SVGNames::typeAttr) | 145 if (name == SVGNames::typeAttr || name == SVGNames::hrefAttr) |
Mike West
2017/01/09 19:31:19
XLinkNames::hrefAttr?
| |
149 return false; | 146 return false; |
150 | |
151 return SVGElement::isAnimatableAttribute(name); | 147 return SVGElement::isAnimatableAttribute(name); |
152 } | 148 } |
153 #endif | 149 #endif |
154 | 150 |
155 DEFINE_TRACE(SVGScriptElement) { | 151 DEFINE_TRACE(SVGScriptElement) { |
156 visitor->trace(m_loader); | 152 visitor->trace(m_loader); |
157 SVGElement::trace(visitor); | 153 SVGElement::trace(visitor); |
158 SVGURIReference::trace(visitor); | 154 SVGURIReference::trace(visitor); |
159 } | 155 } |
160 | 156 |
161 } // namespace blink | 157 } // namespace blink |
OLD | NEW |