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

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

Issue 132233016: [SVG] SVGAnimatedPointList migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: set NeedsRebaseline Created 6 years, 11 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
« no previous file with comments | « Source/core/svg/SVGPolyElement.h ('k') | Source/core/svg/SVGPolygonElement.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 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 12 matching lines...) Expand all
23 #include "core/svg/SVGPolyElement.h" 23 #include "core/svg/SVGPolyElement.h"
24 24
25 #include "core/dom/Document.h" 25 #include "core/dom/Document.h"
26 #include "core/rendering/svg/RenderSVGResource.h" 26 #include "core/rendering/svg/RenderSVGResource.h"
27 #include "core/svg/SVGAnimatedPointList.h" 27 #include "core/svg/SVGAnimatedPointList.h"
28 #include "core/svg/SVGElementInstance.h" 28 #include "core/svg/SVGElementInstance.h"
29 #include "core/svg/SVGParserUtilities.h" 29 #include "core/svg/SVGParserUtilities.h"
30 30
31 namespace WebCore { 31 namespace WebCore {
32 32
33 // Define custom animated property 'points'.
34 const SVGPropertyInfo* SVGPolyElement::pointsPropertyInfo()
35 {
36 static const SVGPropertyInfo* s_propertyInfo = 0;
37 if (!s_propertyInfo) {
38 s_propertyInfo = new SVGPropertyInfo(AnimatedPoints,
39 PropertyIsReadWrite,
40 SVGNames::pointsAttr,
41 SVGNames::pointsAttr.localName(),
42 &SVGPolyElement::synchronizePoints,
43 &SVGPolyElement::lookupOrCreatePoin tsWrapper);
44 }
45 return s_propertyInfo;
46 }
47
48 SVGPointList& SVGPolyElement::pointsCurrentValue()
49 {
50 SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<SVGPolyEle ment, SVGAnimatedPointList>(this, pointsPropertyInfo());
51 if (wrapper && wrapper->isAnimating()) {
52 if (SVGListPropertyTearOff<SVGPointList>* ap = animatedPoints())
53 return ap->values();
54 }
55
56 return m_points.value;
57 }
58
59 // Animated property definitions 33 // Animated property definitions
60 34
61 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPolyElement) 35 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPolyElement)
62 REGISTER_LOCAL_ANIMATED_PROPERTY(points)
63 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) 36 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
64 END_REGISTER_ANIMATED_PROPERTIES 37 END_REGISTER_ANIMATED_PROPERTIES
65 38
66 SVGPolyElement::SVGPolyElement(const QualifiedName& tagName, Document& document) 39 SVGPolyElement::SVGPolyElement(const QualifiedName& tagName, Document& document)
67 : SVGGeometryElement(tagName, document) 40 : SVGGeometryElement(tagName, document)
41 , m_points(SVGAnimatedPointList::create(this, SVGNames::pointsAttr, SVGPoint List::create()))
68 { 42 {
43 addToPropertyMap(m_points);
69 registerAnimatedPropertiesForSVGPolyElement(); 44 registerAnimatedPropertiesForSVGPolyElement();
70 } 45 }
71 46
72 bool SVGPolyElement::isSupportedAttribute(const QualifiedName& attrName) 47 bool SVGPolyElement::isSupportedAttribute(const QualifiedName& attrName)
73 { 48 {
74 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 49 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
75 if (supportedAttributes.isEmpty()) { 50 if (supportedAttributes.isEmpty()) {
76 supportedAttributes.add(SVGNames::pointsAttr); 51 supportedAttributes.add(SVGNames::pointsAttr);
77 } 52 }
78 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 53 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
79 } 54 }
80 55
81 void SVGPolyElement::parseAttribute(const QualifiedName& name, const AtomicStrin g& value) 56 void SVGPolyElement::parseAttribute(const QualifiedName& name, const AtomicStrin g& value)
82 { 57 {
83 if (!isSupportedAttribute(name)) { 58 if (!isSupportedAttribute(name)) {
84 SVGGeometryElement::parseAttribute(name, value); 59 SVGGeometryElement::parseAttribute(name, value);
85 return; 60 return;
86 } 61 }
87 62
88 if (name == SVGNames::pointsAttr) { 63 if (name == SVGNames::pointsAttr) {
89 SVGPointList newList; 64 SVGParsingError parseError = NoError;
90 if (!pointsListFromSVGData(newList, value)) 65 m_points->setBaseValueAsString(value, parseError);
91 document().accessSVGExtensions()->reportError("Problem parsing point s=\"" + value + "\""); 66 reportAttributeParsingError(parseError, name, value);
92
93 if (SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<SV GPolyElement, SVGAnimatedPointList>(this, pointsPropertyInfo()))
94 static_cast<SVGAnimatedPointList*>(wrapper)->detachListWrappers(newL ist.size());
95
96 m_points.value = newList;
97 return; 67 return;
98 } 68 }
99 69
100 ASSERT_NOT_REACHED(); 70 ASSERT_NOT_REACHED();
101 } 71 }
102 72
103 void SVGPolyElement::svgAttributeChanged(const QualifiedName& attrName) 73 void SVGPolyElement::svgAttributeChanged(const QualifiedName& attrName)
104 { 74 {
105 if (!isSupportedAttribute(attrName)) { 75 if (!isSupportedAttribute(attrName)) {
106 SVGGeometryElement::svgAttributeChanged(attrName); 76 SVGGeometryElement::svgAttributeChanged(attrName);
107 return; 77 return;
108 } 78 }
109 79
110 SVGElementInstance::InvalidationGuard invalidationGuard(this); 80 SVGElementInstance::InvalidationGuard invalidationGuard(this);
111 81
112 RenderSVGShape* renderer = toRenderSVGShape(this->renderer()); 82 RenderSVGShape* renderer = toRenderSVGShape(this->renderer());
113 if (!renderer) 83 if (!renderer)
114 return; 84 return;
115 85
116 if (attrName == SVGNames::pointsAttr) { 86 if (attrName == SVGNames::pointsAttr) {
117 renderer->setNeedsShapeUpdate(); 87 renderer->setNeedsShapeUpdate();
118 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); 88 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
119 return; 89 return;
120 } 90 }
121 91
122 ASSERT_NOT_REACHED(); 92 ASSERT_NOT_REACHED();
123 } 93 }
124 94
125 void SVGPolyElement::synchronizePoints(SVGElement* contextElement)
126 {
127 ASSERT(contextElement);
128 SVGPolyElement* ownerType = toSVGPolyElement(contextElement);
129 if (!ownerType->m_points.shouldSynchronize)
130 return;
131 ownerType->m_points.synchronize(ownerType, pointsPropertyInfo()->attributeNa me, AtomicString(ownerType->m_points.value.valueAsString()));
132 } 95 }
133
134 PassRefPtr<SVGAnimatedProperty> SVGPolyElement::lookupOrCreatePointsWrapper(SVGE lement* contextElement)
135 {
136 ASSERT(contextElement);
137 SVGPolyElement* ownerType = toSVGPolyElement(contextElement);
138 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGPolyElement, SVGAnimate dPointList, SVGPointList>
139 (ownerType, pointsPropertyInfo(), ownerType->m_points.value);
140 }
141
142 SVGListPropertyTearOff<SVGPointList>* SVGPolyElement::points()
143 {
144 m_points.shouldSynchronize = true;
145 return static_cast<SVGListPropertyTearOff<SVGPointList>*>(static_pointer_cas t<SVGAnimatedPointList>(lookupOrCreatePointsWrapper(this))->baseVal());
146 }
147
148 SVGListPropertyTearOff<SVGPointList>* SVGPolyElement::animatedPoints()
149 {
150 m_points.shouldSynchronize = true;
151 return static_cast<SVGListPropertyTearOff<SVGPointList>*>(static_pointer_cas t<SVGAnimatedPointList>(lookupOrCreatePointsWrapper(this))->animVal());
152 }
153
154 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGPolyElement.h ('k') | Source/core/svg/SVGPolygonElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698