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

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

Issue 112003003: [SVG] SVGLength{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: revert aggressive svgAttributeChanged, add 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/SVGPatternElement.h ('k') | Source/core/svg/SVGRadialGradientElement.h » ('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, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> 2 * Copyright (C) 2004, 2005, 2006, 2007, 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 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 14 matching lines...) Expand all
25 25
26 #include "XLinkNames.h" 26 #include "XLinkNames.h"
27 #include "core/rendering/svg/RenderSVGResourcePattern.h" 27 #include "core/rendering/svg/RenderSVGResourcePattern.h"
28 #include "core/svg/PatternAttributes.h" 28 #include "core/svg/PatternAttributes.h"
29 #include "core/svg/SVGElementInstance.h" 29 #include "core/svg/SVGElementInstance.h"
30 #include "platform/transforms/AffineTransform.h" 30 #include "platform/transforms/AffineTransform.h"
31 31
32 namespace WebCore { 32 namespace WebCore {
33 33
34 // Animated property definitions 34 // Animated property definitions
35 DEFINE_ANIMATED_LENGTH(SVGPatternElement, SVGNames::xAttr, X, x)
36 DEFINE_ANIMATED_LENGTH(SVGPatternElement, SVGNames::yAttr, Y, y)
37 DEFINE_ANIMATED_LENGTH(SVGPatternElement, SVGNames::widthAttr, Width, width)
38 DEFINE_ANIMATED_LENGTH(SVGPatternElement, SVGNames::heightAttr, Height, height)
39 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternUnitsAttr, Patte rnUnits, patternUnits, SVGUnitTypes::SVGUnitType) 35 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternUnitsAttr, Patte rnUnits, patternUnits, SVGUnitTypes::SVGUnitType)
40 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternContentUnitsAttr , PatternContentUnits, patternContentUnits, SVGUnitTypes::SVGUnitType) 36 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternContentUnitsAttr , PatternContentUnits, patternContentUnits, SVGUnitTypes::SVGUnitType)
41 DEFINE_ANIMATED_TRANSFORM_LIST(SVGPatternElement, SVGNames::patternTransformAttr , PatternTransform, patternTransform) 37 DEFINE_ANIMATED_TRANSFORM_LIST(SVGPatternElement, SVGNames::patternTransformAttr , PatternTransform, patternTransform)
42 DEFINE_ANIMATED_STRING(SVGPatternElement, XLinkNames::hrefAttr, Href, href) 38 DEFINE_ANIMATED_STRING(SVGPatternElement, XLinkNames::hrefAttr, Href, href)
43 DEFINE_ANIMATED_RECT(SVGPatternElement, SVGNames::viewBoxAttr, ViewBox, viewBox) 39 DEFINE_ANIMATED_RECT(SVGPatternElement, SVGNames::viewBoxAttr, ViewBox, viewBox)
44 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGPatternElement, SVGNames::preserveAspectR atioAttr, PreserveAspectRatio, preserveAspectRatio) 40 DEFINE_ANIMATED_PRESERVEASPECTRATIO(SVGPatternElement, SVGNames::preserveAspectR atioAttr, PreserveAspectRatio, preserveAspectRatio)
45 41
46 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPatternElement) 42 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPatternElement)
47 REGISTER_LOCAL_ANIMATED_PROPERTY(x)
48 REGISTER_LOCAL_ANIMATED_PROPERTY(y)
49 REGISTER_LOCAL_ANIMATED_PROPERTY(width)
50 REGISTER_LOCAL_ANIMATED_PROPERTY(height)
51 REGISTER_LOCAL_ANIMATED_PROPERTY(patternUnits) 43 REGISTER_LOCAL_ANIMATED_PROPERTY(patternUnits)
52 REGISTER_LOCAL_ANIMATED_PROPERTY(patternContentUnits) 44 REGISTER_LOCAL_ANIMATED_PROPERTY(patternContentUnits)
53 REGISTER_LOCAL_ANIMATED_PROPERTY(patternTransform) 45 REGISTER_LOCAL_ANIMATED_PROPERTY(patternTransform)
54 REGISTER_LOCAL_ANIMATED_PROPERTY(href) 46 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
55 REGISTER_LOCAL_ANIMATED_PROPERTY(viewBox) 47 REGISTER_LOCAL_ANIMATED_PROPERTY(viewBox)
56 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio) 48 REGISTER_LOCAL_ANIMATED_PROPERTY(preserveAspectRatio)
57 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) 49 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement)
58 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests) 50 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests)
59 END_REGISTER_ANIMATED_PROPERTIES 51 END_REGISTER_ANIMATED_PROPERTIES
60 52
61 inline SVGPatternElement::SVGPatternElement(Document& document) 53 inline SVGPatternElement::SVGPatternElement(Document& document)
62 : SVGElement(SVGNames::patternTag, document) 54 : SVGElement(SVGNames::patternTag, document)
63 , m_x(LengthModeWidth) 55 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len gthModeWidth)))
64 , m_y(LengthModeHeight) 56 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len gthModeHeight)))
65 , m_width(LengthModeWidth) 57 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr eate(LengthModeWidth)))
66 , m_height(LengthModeHeight) 58 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength:: create(LengthModeHeight)))
67 , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) 59 , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
68 , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) 60 , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
69 { 61 {
70 ScriptWrappable::init(this); 62 ScriptWrappable::init(this);
63
64 addToPropertyMap(m_x);
65 addToPropertyMap(m_y);
66 addToPropertyMap(m_width);
67 addToPropertyMap(m_height);
71 registerAnimatedPropertiesForSVGPatternElement(); 68 registerAnimatedPropertiesForSVGPatternElement();
72 } 69 }
73 70
74 PassRefPtr<SVGPatternElement> SVGPatternElement::create(Document& document) 71 PassRefPtr<SVGPatternElement> SVGPatternElement::create(Document& document)
75 { 72 {
76 return adoptRef(new SVGPatternElement(document)); 73 return adoptRef(new SVGPatternElement(document));
77 } 74 }
78 75
79 bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName) 76 bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName)
80 { 77 {
(...skipping 29 matching lines...) Expand all
110 if (propertyValue > 0) 107 if (propertyValue > 0)
111 setPatternContentUnitsBaseValue(propertyValue); 108 setPatternContentUnitsBaseValue(propertyValue);
112 return; 109 return;
113 } else if (name == SVGNames::patternTransformAttr) { 110 } else if (name == SVGNames::patternTransformAttr) {
114 SVGTransformList newList; 111 SVGTransformList newList;
115 newList.parse(value); 112 newList.parse(value);
116 detachAnimatedPatternTransformListWrappers(newList.size()); 113 detachAnimatedPatternTransformListWrappers(newList.size());
117 setPatternTransformBaseValue(newList); 114 setPatternTransformBaseValue(newList);
118 return; 115 return;
119 } else if (name == SVGNames::xAttr) 116 } else if (name == SVGNames::xAttr)
120 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); 117 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError);
121 else if (name == SVGNames::yAttr) 118 else if (name == SVGNames::yAttr)
122 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ; 119 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError);
123 else if (name == SVGNames::widthAttr) 120 else if (name == SVGNames::widthAttr)
124 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r, ForbidNegativeLengths)); 121 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
125 else if (name == SVGNames::heightAttr) 122 else if (name == SVGNames::heightAttr)
126 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror, ForbidNegativeLengths)); 123 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError) ;
127 else if (SVGURIReference::parseAttribute(name, value) 124 else if (SVGURIReference::parseAttribute(name, value)
128 || SVGTests::parseAttribute(name, value) 125 || SVGTests::parseAttribute(name, value)
129 || SVGFitToViewBox::parseAttribute(this, name, value)) { 126 || SVGFitToViewBox::parseAttribute(this, name, value)) {
130 } else 127 } else
131 ASSERT_NOT_REACHED(); 128 ASSERT_NOT_REACHED();
132 129
133 reportAttributeParsingError(parseError, name, value); 130 reportAttributeParsingError(parseError, name, value);
134 } 131 }
135 132
136 void SVGPatternElement::svgAttributeChanged(const QualifiedName& attrName) 133 void SVGPatternElement::svgAttributeChanged(const QualifiedName& attrName)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return new RenderSVGResourcePattern(this); 166 return new RenderSVGResourcePattern(this);
170 } 167 }
171 168
172 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const 169 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const
173 { 170 {
174 HashSet<const SVGPatternElement*> processedPatterns; 171 HashSet<const SVGPatternElement*> processedPatterns;
175 172
176 const SVGPatternElement* current = this; 173 const SVGPatternElement* current = this;
177 while (current) { 174 while (current) {
178 if (!attributes.hasX() && current->hasAttribute(SVGNames::xAttr)) 175 if (!attributes.hasX() && current->hasAttribute(SVGNames::xAttr))
179 attributes.setX(current->xCurrentValue()); 176 attributes.setX(current->x()->currentValue());
180 177
181 if (!attributes.hasY() && current->hasAttribute(SVGNames::yAttr)) 178 if (!attributes.hasY() && current->hasAttribute(SVGNames::yAttr))
182 attributes.setY(current->yCurrentValue()); 179 attributes.setY(current->y()->currentValue());
183 180
184 if (!attributes.hasWidth() && current->hasAttribute(SVGNames::widthAttr) ) 181 if (!attributes.hasWidth() && current->hasAttribute(SVGNames::widthAttr) )
185 attributes.setWidth(current->widthCurrentValue()); 182 attributes.setWidth(current->width()->currentValue());
186 183
187 if (!attributes.hasHeight() && current->hasAttribute(SVGNames::heightAtt r)) 184 if (!attributes.hasHeight() && current->hasAttribute(SVGNames::heightAtt r))
188 attributes.setHeight(current->heightCurrentValue()); 185 attributes.setHeight(current->height()->currentValue());
189 186
190 if (!attributes.hasViewBox() && current->hasAttribute(SVGNames::viewBoxA ttr) && current->viewBoxCurrentValue().isValid()) 187 if (!attributes.hasViewBox() && current->hasAttribute(SVGNames::viewBoxA ttr) && current->viewBoxCurrentValue().isValid())
191 attributes.setViewBox(current->viewBoxCurrentValue()); 188 attributes.setViewBox(current->viewBoxCurrentValue());
192 189
193 if (!attributes.hasPreserveAspectRatio() && current->hasAttribute(SVGNam es::preserveAspectRatioAttr)) 190 if (!attributes.hasPreserveAspectRatio() && current->hasAttribute(SVGNam es::preserveAspectRatioAttr))
194 attributes.setPreserveAspectRatio(current->preserveAspectRatioCurren tValue()); 191 attributes.setPreserveAspectRatio(current->preserveAspectRatioCurren tValue());
195 192
196 if (!attributes.hasPatternUnits() && current->hasAttribute(SVGNames::pat ternUnitsAttr)) 193 if (!attributes.hasPatternUnits() && current->hasAttribute(SVGNames::pat ternUnitsAttr))
197 attributes.setPatternUnits(current->patternUnitsCurrentValue()); 194 attributes.setPatternUnits(current->patternUnitsCurrentValue());
198 195
(...skipping 28 matching lines...) Expand all
227 224
228 AffineTransform SVGPatternElement::localCoordinateSpaceTransform(SVGElement::CTM Scope) const 225 AffineTransform SVGPatternElement::localCoordinateSpaceTransform(SVGElement::CTM Scope) const
229 { 226 {
230 AffineTransform matrix; 227 AffineTransform matrix;
231 patternTransformCurrentValue().concatenate(matrix); 228 patternTransformCurrentValue().concatenate(matrix);
232 return matrix; 229 return matrix;
233 } 230 }
234 231
235 bool SVGPatternElement::selfHasRelativeLengths() const 232 bool SVGPatternElement::selfHasRelativeLengths() const
236 { 233 {
237 return xCurrentValue().isRelative() 234 return m_x->currentValue()->isRelative()
238 || yCurrentValue().isRelative() 235 || m_y->currentValue()->isRelative()
239 || widthCurrentValue().isRelative() 236 || m_width->currentValue()->isRelative()
240 || heightCurrentValue().isRelative(); 237 || m_height->currentValue()->isRelative();
241 } 238 }
242 239
243 } 240 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGPatternElement.h ('k') | Source/core/svg/SVGRadialGradientElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698