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

Side by Side Diff: Source/core/svg/SVGMPathElement.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) 2007 Eric Seidel <eric@webkit.org> 2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 12 matching lines...) Expand all
23 23
24 #include "XLinkNames.h" 24 #include "XLinkNames.h"
25 #include "core/dom/Document.h" 25 #include "core/dom/Document.h"
26 #include "core/svg/SVGAnimateMotionElement.h" 26 #include "core/svg/SVGAnimateMotionElement.h"
27 #include "core/svg/SVGDocumentExtensions.h" 27 #include "core/svg/SVGDocumentExtensions.h"
28 #include "core/svg/SVGPathElement.h" 28 #include "core/svg/SVGPathElement.h"
29 29
30 namespace WebCore { 30 namespace WebCore {
31 31
32 // Animated property definitions 32 // Animated property definitions
33 DEFINE_ANIMATED_STRING(SVGMPathElement, XLinkNames::hrefAttr, Href, href)
34 33
35 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGMPathElement) 34 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGMPathElement)
36 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
37 END_REGISTER_ANIMATED_PROPERTIES 35 END_REGISTER_ANIMATED_PROPERTIES
38 36
39 inline SVGMPathElement::SVGMPathElement(Document& document) 37 inline SVGMPathElement::SVGMPathElement(Document& document)
40 : SVGElement(SVGNames::mpathTag, document) 38 : SVGElement(SVGNames::mpathTag, document)
39 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr eate()))
41 { 40 {
42 ScriptWrappable::init(this); 41 ScriptWrappable::init(this);
42 addToPropertyMap(m_href);
43 registerAnimatedPropertiesForSVGMPathElement(); 43 registerAnimatedPropertiesForSVGMPathElement();
44 } 44 }
45 45
46 PassRefPtr<SVGMPathElement> SVGMPathElement::create(Document& document) 46 PassRefPtr<SVGMPathElement> SVGMPathElement::create(Document& document)
47 { 47 {
48 return adoptRef(new SVGMPathElement(document)); 48 return adoptRef(new SVGMPathElement(document));
49 } 49 }
50 50
51 SVGMPathElement::~SVGMPathElement() 51 SVGMPathElement::~SVGMPathElement()
52 { 52 {
53 clearResourceReferences(); 53 clearResourceReferences();
54 } 54 }
55 55
56 void SVGMPathElement::buildPendingResource() 56 void SVGMPathElement::buildPendingResource()
57 { 57 {
58 clearResourceReferences(); 58 clearResourceReferences();
59 if (!inDocument()) 59 if (!inDocument())
60 return; 60 return;
61 61
62 AtomicString id; 62 AtomicString id;
63 Element* target = SVGURIReference::targetElementFromIRIString(hrefCurrentVal ue(), document(), &id); 63 Element* target = SVGURIReference::targetElementFromIRIString(m_href->curren tValue()->value(), document(), &id);
64 if (!target) { 64 if (!target) {
65 // Do not register as pending if we are already pending this resource. 65 // Do not register as pending if we are already pending this resource.
66 if (document().accessSVGExtensions()->isElementPendingResource(this, id) ) 66 if (document().accessSVGExtensions()->isElementPendingResource(this, id) )
67 return; 67 return;
68 68
69 if (!id.isEmpty()) { 69 if (!id.isEmpty()) {
70 document().accessSVGExtensions()->addPendingResource(id, this); 70 document().accessSVGExtensions()->addPendingResource(id, this);
71 ASSERT(hasPendingResources()); 71 ASSERT(hasPendingResources());
72 } 72 }
73 } else if (target->isSVGElement()) { 73 } else if (target->isSVGElement()) {
(...skipping 30 matching lines...) Expand all
104 { 104 {
105 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 105 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
106 if (supportedAttributes.isEmpty()) { 106 if (supportedAttributes.isEmpty()) {
107 SVGURIReference::addSupportedAttributes(supportedAttributes); 107 SVGURIReference::addSupportedAttributes(supportedAttributes);
108 } 108 }
109 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 109 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
110 } 110 }
111 111
112 void SVGMPathElement::parseAttribute(const QualifiedName& name, const AtomicStri ng& value) 112 void SVGMPathElement::parseAttribute(const QualifiedName& name, const AtomicStri ng& value)
113 { 113 {
114 if (!isSupportedAttribute(name)) { 114 if (!isSupportedAttribute(name)) {
haraken 2014/01/29 05:18:00 Can you move this check to line 121?
kouhei (in TOK) 2014/01/30 08:18:56 Done.
115 SVGElement::parseAttribute(name, value); 115 SVGElement::parseAttribute(name, value);
116 return; 116 return;
117 } 117 }
118 118
119 if (SVGURIReference::parseAttribute(name, value)) 119 SVGParsingError parseError = NoError;
120 return;
121 120
122 ASSERT_NOT_REACHED(); 121 if (name.matches(XLinkNames::hrefAttr))
122 m_href->setBaseValueAsString(value, parseError);
123 else
124 ASSERT_NOT_REACHED();
125
126 reportAttributeParsingError(parseError, name, value);
123 } 127 }
124 128
125 void SVGMPathElement::svgAttributeChanged(const QualifiedName& attrName) 129 void SVGMPathElement::svgAttributeChanged(const QualifiedName& attrName)
126 { 130 {
127 if (!isSupportedAttribute(attrName)) { 131 if (!isSupportedAttribute(attrName)) {
128 SVGElement::svgAttributeChanged(attrName); 132 SVGElement::svgAttributeChanged(attrName);
129 return; 133 return;
130 } 134 }
131 135
132 SVGElementInstance::InvalidationGuard invalidationGuard(this); 136 SVGElementInstance::InvalidationGuard invalidationGuard(this);
133 137
134 if (SVGURIReference::isKnownAttribute(attrName)) { 138 if (SVGURIReference::isKnownAttribute(attrName)) {
135 buildPendingResource(); 139 buildPendingResource();
136 return; 140 return;
137 } 141 }
138 142
139 ASSERT_NOT_REACHED(); 143 ASSERT_NOT_REACHED();
140 } 144 }
141 145
142 SVGPathElement* SVGMPathElement::pathElement() 146 SVGPathElement* SVGMPathElement::pathElement()
143 { 147 {
144 Element* target = targetElementFromIRIString(hrefCurrentValue(), document()) ; 148 Element* target = targetElementFromIRIString(m_href->currentValue()->value() , document());
145 if (target && target->hasTagName(SVGNames::pathTag)) 149 if (target && target->hasTagName(SVGNames::pathTag))
146 return toSVGPathElement(target); 150 return toSVGPathElement(target);
147 return 0; 151 return 0;
148 } 152 }
149 153
150 void SVGMPathElement::targetPathChanged() 154 void SVGMPathElement::targetPathChanged()
151 { 155 {
152 notifyParentOfPathChange(parentNode()); 156 notifyParentOfPathChange(parentNode());
153 } 157 }
154 158
155 void SVGMPathElement::notifyParentOfPathChange(ContainerNode* parent) 159 void SVGMPathElement::notifyParentOfPathChange(ContainerNode* parent)
156 { 160 {
157 if (parent && parent->hasTagName(SVGNames::animateMotionTag)) 161 if (parent && parent->hasTagName(SVGNames::animateMotionTag))
158 toSVGAnimateMotionElement(parent)->updateAnimationPath(); 162 toSVGAnimateMotionElement(parent)->updateAnimationPath();
159 } 163 }
160 164
161 } // namespace WebCore 165 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698