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

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

Issue 148173018: [SVG] SVGAnimatedString{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove debug print 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
« no previous file with comments | « Source/core/svg/SVGPatternElement.h ('k') | Source/core/svg/SVGRadialGradientElement.cpp » ('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 17 matching lines...) Expand all
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_ENUMERATION(SVGPatternElement, SVGNames::patternUnitsAttr, Patte rnUnits, patternUnits, SVGUnitTypes::SVGUnitType) 35 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternUnitsAttr, Patte rnUnits, patternUnits, SVGUnitTypes::SVGUnitType)
36 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternContentUnitsAttr , PatternContentUnits, patternContentUnits, SVGUnitTypes::SVGUnitType) 36 DEFINE_ANIMATED_ENUMERATION(SVGPatternElement, SVGNames::patternContentUnitsAttr , PatternContentUnits, patternContentUnits, SVGUnitTypes::SVGUnitType)
37 DEFINE_ANIMATED_TRANSFORM_LIST(SVGPatternElement, SVGNames::patternTransformAttr , PatternTransform, patternTransform) 37 DEFINE_ANIMATED_TRANSFORM_LIST(SVGPatternElement, SVGNames::patternTransformAttr , PatternTransform, patternTransform)
38 DEFINE_ANIMATED_STRING(SVGPatternElement, XLinkNames::hrefAttr, Href, href)
39 38
40 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPatternElement) 39 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPatternElement)
41 REGISTER_LOCAL_ANIMATED_PROPERTY(patternUnits) 40 REGISTER_LOCAL_ANIMATED_PROPERTY(patternUnits)
42 REGISTER_LOCAL_ANIMATED_PROPERTY(patternContentUnits) 41 REGISTER_LOCAL_ANIMATED_PROPERTY(patternContentUnits)
43 REGISTER_LOCAL_ANIMATED_PROPERTY(patternTransform) 42 REGISTER_LOCAL_ANIMATED_PROPERTY(patternTransform)
44 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
45 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) 43 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement)
46 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGTests)
47 END_REGISTER_ANIMATED_PROPERTIES 44 END_REGISTER_ANIMATED_PROPERTIES
48 45
49 inline SVGPatternElement::SVGPatternElement(Document& document) 46 inline SVGPatternElement::SVGPatternElement(Document& document)
50 : SVGElement(SVGNames::patternTag, document) 47 : SVGElement(SVGNames::patternTag, document)
48 , SVGTests(this)
51 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len gthModeWidth))) 49 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len gthModeWidth)))
52 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len gthModeHeight))) 50 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len gthModeHeight)))
53 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr eate(LengthModeWidth))) 51 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr eate(LengthModeWidth)))
54 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength:: create(LengthModeHeight))) 52 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength:: create(LengthModeHeight)))
55 , m_viewBox(SVGAnimatedRect::create(this, SVGNames::viewBoxAttr)) 53 , m_viewBox(SVGAnimatedRect::create(this, SVGNames::viewBoxAttr))
56 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) 54 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create()))
55 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr eate()))
57 , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) 56 , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
58 , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) 57 , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
59 { 58 {
60 ScriptWrappable::init(this); 59 ScriptWrappable::init(this);
61 60
62 addToPropertyMap(m_x); 61 addToPropertyMap(m_x);
63 addToPropertyMap(m_y); 62 addToPropertyMap(m_y);
64 addToPropertyMap(m_width); 63 addToPropertyMap(m_width);
65 addToPropertyMap(m_height); 64 addToPropertyMap(m_height);
66 addToPropertyMap(m_viewBox); 65 addToPropertyMap(m_viewBox);
67 addToPropertyMap(m_preserveAspectRatio); 66 addToPropertyMap(m_preserveAspectRatio);
67 addToPropertyMap(m_href);
68 registerAnimatedPropertiesForSVGPatternElement(); 68 registerAnimatedPropertiesForSVGPatternElement();
69 } 69 }
70 70
71 PassRefPtr<SVGPatternElement> SVGPatternElement::create(Document& document) 71 PassRefPtr<SVGPatternElement> SVGPatternElement::create(Document& document)
72 { 72 {
73 return adoptRef(new SVGPatternElement(document)); 73 return adoptRef(new SVGPatternElement(document));
74 } 74 }
75 75
76 bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName) 76 bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName)
77 { 77 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 setPatternTransformBaseValue(newList); 114 setPatternTransformBaseValue(newList);
115 return; 115 return;
116 } else if (name == SVGNames::xAttr) 116 } else if (name == SVGNames::xAttr)
117 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); 117 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError);
118 else if (name == SVGNames::yAttr) 118 else if (name == SVGNames::yAttr)
119 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); 119 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError);
120 else if (name == SVGNames::widthAttr) 120 else if (name == SVGNames::widthAttr)
121 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); 121 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
122 else if (name == SVGNames::heightAttr) 122 else if (name == SVGNames::heightAttr)
123 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError) ; 123 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError) ;
124 else if (SVGURIReference::parseAttribute(name, value) 124 else if (name.matches(XLinkNames::hrefAttr))
125 || SVGTests::parseAttribute(name, value) 125 m_href->setBaseValueAsString(value, parseError);
126 else if (SVGTests::parseAttribute(name, value)
126 || SVGFitToViewBox::parseAttribute(this, name, value)) { 127 || SVGFitToViewBox::parseAttribute(this, name, value)) {
127 } else 128 } else
128 ASSERT_NOT_REACHED(); 129 ASSERT_NOT_REACHED();
129 130
130 reportAttributeParsingError(parseError, name, value); 131 reportAttributeParsingError(parseError, name, value);
131 } 132 }
132 133
133 void SVGPatternElement::svgAttributeChanged(const QualifiedName& attrName) 134 void SVGPatternElement::svgAttributeChanged(const QualifiedName& attrName)
134 { 135 {
135 if (!isSupportedAttribute(attrName)) { 136 if (!isSupportedAttribute(attrName)) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const 206 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const
206 { 207 {
207 HashSet<const SVGPatternElement*> processedPatterns; 208 HashSet<const SVGPatternElement*> processedPatterns;
208 const SVGPatternElement* current = this; 209 const SVGPatternElement* current = this;
209 210
210 while (true) { 211 while (true) {
211 setPatternAttributes(current, attributes); 212 setPatternAttributes(current, attributes);
212 processedPatterns.add(current); 213 processedPatterns.add(current);
213 214
214 // Respect xlink:href, take attributes from referenced element 215 // Respect xlink:href, take attributes from referenced element
215 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre fCurrentValue(), document()); 216 Node* refNode = SVGURIReference::targetElementFromIRIString(current->m_h ref->currentValue()->value(), document());
216 if (refNode && refNode->hasTagName(SVGNames::patternTag)) { 217 if (refNode && refNode->hasTagName(SVGNames::patternTag)) {
217 current = toSVGPatternElement(const_cast<const Node*>(refNode)); 218 current = toSVGPatternElement(const_cast<const Node*>(refNode));
218 219
219 // Cycle detection 220 // Cycle detection
220 if (processedPatterns.contains(current)) 221 if (processedPatterns.contains(current))
221 return; 222 return;
222 } else { 223 } else {
223 return; 224 return;
224 } 225 }
225 } 226 }
(...skipping 10 matching lines...) Expand all
236 237
237 bool SVGPatternElement::selfHasRelativeLengths() const 238 bool SVGPatternElement::selfHasRelativeLengths() const
238 { 239 {
239 return m_x->currentValue()->isRelative() 240 return m_x->currentValue()->isRelative()
240 || m_y->currentValue()->isRelative() 241 || m_y->currentValue()->isRelative()
241 || m_width->currentValue()->isRelative() 242 || m_width->currentValue()->isRelative()
242 || m_height->currentValue()->isRelative(); 243 || m_height->currentValue()->isRelative();
243 } 244 }
244 245
245 } 246 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGPatternElement.h ('k') | Source/core/svg/SVGRadialGradientElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698