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

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

Issue 18676002: Refactoring: Decouple ScriptElement from HTMLScriptElement and SVGScriptElement. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed a crash Created 7 years, 5 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 25 matching lines...) Expand all
36 DEFINE_ANIMATED_STRING(SVGScriptElement, XLinkNames::hrefAttr, Href, href) 36 DEFINE_ANIMATED_STRING(SVGScriptElement, XLinkNames::hrefAttr, Href, href)
37 DEFINE_ANIMATED_BOOLEAN(SVGScriptElement, SVGNames::externalResourcesRequiredAtt r, ExternalResourcesRequired, externalResourcesRequired) 37 DEFINE_ANIMATED_BOOLEAN(SVGScriptElement, SVGNames::externalResourcesRequiredAtt r, ExternalResourcesRequired, externalResourcesRequired)
38 38
39 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGScriptElement) 39 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGScriptElement)
40 REGISTER_LOCAL_ANIMATED_PROPERTY(href) 40 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
41 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired) 41 REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
42 END_REGISTER_ANIMATED_PROPERTIES 42 END_REGISTER_ANIMATED_PROPERTIES
43 43
44 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)
45 : SVGElement(tagName, document) 45 : SVGElement(tagName, document)
46 , ScriptElement(this, wasInsertedByParser, alreadyStarted)
47 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired) 46 , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired)
47 , m_scriptElement(ScriptElement::create(this, wasInsertedByParser, alreadySt arted))
48 { 48 {
49 ASSERT(hasTagName(SVGNames::scriptTag)); 49 ASSERT(hasTagName(SVGNames::scriptTag));
50 ScriptWrappable::init(this); 50 ScriptWrappable::init(this);
51 registerAnimatedPropertiesForSVGScriptElement(); 51 registerAnimatedPropertiesForSVGScriptElement();
52 } 52 }
53 53
54 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)
55 { 55 {
56 return adoptRef(new SVGScriptElement(tagName, document, insertedByParser, fa lse)); 56 return adoptRef(new SVGScriptElement(tagName, document, insertedByParser, fa lse));
57 } 57 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 SVGElement::svgAttributeChanged(attrName); 99 SVGElement::svgAttributeChanged(attrName);
100 return; 100 return;
101 } 101 }
102 102
103 SVGElementInstance::InvalidationGuard invalidationGuard(this); 103 SVGElementInstance::InvalidationGuard invalidationGuard(this);
104 104
105 if (attrName == SVGNames::typeAttr || attrName == HTMLNames::onerrorAttr) 105 if (attrName == SVGNames::typeAttr || attrName == HTMLNames::onerrorAttr)
106 return; 106 return;
107 107
108 if (SVGURIReference::isKnownAttribute(attrName)) { 108 if (SVGURIReference::isKnownAttribute(attrName)) {
109 handleSourceAttribute(href()); 109 if (m_scriptElement)
110 m_scriptElement->handleSourceAttribute(href());
110 return; 111 return;
111 } 112 }
112 113
113 if (SVGExternalResourcesRequired::handleAttributeChange(this, attrName)) 114 if (SVGExternalResourcesRequired::handleAttributeChange(this, attrName))
114 return; 115 return;
115 116
116 ASSERT_NOT_REACHED(); 117 ASSERT_NOT_REACHED();
117 } 118 }
118 119
119 Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode* rootParent) 120 Node::InsertionNotificationRequest SVGScriptElement::insertedInto(ContainerNode* rootParent)
120 { 121 {
121 SVGElement::insertedInto(rootParent); 122 SVGElement::insertedInto(rootParent);
122 ScriptElement::insertedInto(rootParent); 123 if (m_scriptElement)
124 m_scriptElement->insertedInto(rootParent);
123 if (rootParent->inDocument()) 125 if (rootParent->inDocument())
124 SVGExternalResourcesRequired::insertedIntoDocument(this); 126 SVGExternalResourcesRequired::insertedIntoDocument(this);
125 return InsertionDone; 127 return InsertionDone;
126 } 128 }
127 129
128 void SVGScriptElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) 130 void SVGScriptElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
129 { 131 {
130 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil dCountDelta); 132 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil dCountDelta);
131 ScriptElement::childrenChanged(); 133 if (m_scriptElement)
134 m_scriptElement->childrenChanged();
132 } 135 }
133 136
134 bool SVGScriptElement::isURLAttribute(const Attribute& attribute) const 137 bool SVGScriptElement::isURLAttribute(const Attribute& attribute) const
135 { 138 {
136 return attribute.name() == sourceAttributeValue(); 139 return attribute.name() == sourceAttributeValue();
137 } 140 }
138 141
139 void SVGScriptElement::finishParsingChildren() 142 void SVGScriptElement::finishParsingChildren()
140 { 143 {
141 SVGElement::finishParsingChildren(); 144 SVGElement::finishParsingChildren();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return false; 202 return false;
200 } 203 }
201 204
202 bool SVGScriptElement::hasSourceAttribute() const 205 bool SVGScriptElement::hasSourceAttribute() const
203 { 206 {
204 return hasAttribute(XLinkNames::hrefAttr); 207 return hasAttribute(XLinkNames::hrefAttr);
205 } 208 }
206 209
207 PassRefPtr<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren() 210 PassRefPtr<Element> SVGScriptElement::cloneElementWithoutAttributesAndChildren()
208 { 211 {
209 return adoptRef(new SVGScriptElement(tagQName(), document(), false, alreadyS tarted())); 212 return adoptRef(new SVGScriptElement(tagQName(), document(), false, m_script Element && m_scriptElement->alreadyStarted()));
210 } 213 }
211 214
212 } 215 }
OLDNEW
« Source/core/svg/SVGScriptElement.h ('K') | « Source/core/svg/SVGScriptElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698