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

Side by Side Diff: Source/core/svg/SVGRectElement.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/SVGRectElement.h ('k') | Source/core/svg/SVGSVGElement.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, 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/SVGRectElement.h" 23 #include "core/svg/SVGRectElement.h"
24 24
25 #include "core/rendering/svg/RenderSVGRect.h" 25 #include "core/rendering/svg/RenderSVGRect.h"
26 #include "core/rendering/svg/RenderSVGResource.h" 26 #include "core/rendering/svg/RenderSVGResource.h"
27 #include "core/svg/SVGElementInstance.h" 27 #include "core/svg/SVGElementInstance.h"
28 #include "core/svg/SVGLength.h" 28 #include "core/svg/SVGLength.h"
29 29
30 namespace WebCore { 30 namespace WebCore {
31 31
32 // Animated property definitions 32 // Animated property definitions
33 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::xAttr, X, x)
34 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::yAttr, Y, y)
35 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::widthAttr, Width, width)
36 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::heightAttr, Height, height)
37 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::rxAttr, Rx, rx)
38 DEFINE_ANIMATED_LENGTH(SVGRectElement, SVGNames::ryAttr, Ry, ry)
39
40 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGRectElement) 33 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGRectElement)
41 REGISTER_LOCAL_ANIMATED_PROPERTY(x)
42 REGISTER_LOCAL_ANIMATED_PROPERTY(y)
43 REGISTER_LOCAL_ANIMATED_PROPERTY(width)
44 REGISTER_LOCAL_ANIMATED_PROPERTY(height)
45 REGISTER_LOCAL_ANIMATED_PROPERTY(rx)
46 REGISTER_LOCAL_ANIMATED_PROPERTY(ry)
47 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) 34 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
48 END_REGISTER_ANIMATED_PROPERTIES 35 END_REGISTER_ANIMATED_PROPERTIES
49 36
50 inline SVGRectElement::SVGRectElement(Document& document) 37 inline SVGRectElement::SVGRectElement(Document& document)
51 : SVGGeometryElement(SVGNames::rectTag, document) 38 : SVGGeometryElement(SVGNames::rectTag, document)
52 , m_x(LengthModeWidth) 39 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len gthModeWidth)))
53 , m_y(LengthModeHeight) 40 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len gthModeHeight)))
54 , m_width(LengthModeWidth) 41 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr eate(LengthModeWidth)))
55 , m_height(LengthModeHeight) 42 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength:: create(LengthModeHeight)))
56 , m_rx(LengthModeWidth) 43 , m_rx(SVGAnimatedLength::create(this, SVGNames::rxAttr, SVGLength::create(L engthModeWidth)))
57 , m_ry(LengthModeHeight) 44 , m_ry(SVGAnimatedLength::create(this, SVGNames::ryAttr, SVGLength::create(L engthModeHeight)))
58 { 45 {
59 ScriptWrappable::init(this); 46 ScriptWrappable::init(this);
47
48 addToPropertyMap(m_x);
49 addToPropertyMap(m_y);
50 addToPropertyMap(m_width);
51 addToPropertyMap(m_height);
52 addToPropertyMap(m_rx);
53 addToPropertyMap(m_ry);
54
60 registerAnimatedPropertiesForSVGRectElement(); 55 registerAnimatedPropertiesForSVGRectElement();
61 } 56 }
62 57
63 PassRefPtr<SVGRectElement> SVGRectElement::create(Document& document) 58 PassRefPtr<SVGRectElement> SVGRectElement::create(Document& document)
64 { 59 {
65 return adoptRef(new SVGRectElement(document)); 60 return adoptRef(new SVGRectElement(document));
66 } 61 }
67 62
68 bool SVGRectElement::isSupportedAttribute(const QualifiedName& attrName) 63 bool SVGRectElement::isSupportedAttribute(const QualifiedName& attrName)
69 { 64 {
70 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 65 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
71 if (supportedAttributes.isEmpty()) { 66 if (supportedAttributes.isEmpty()) {
72 supportedAttributes.add(SVGNames::xAttr); 67 supportedAttributes.add(SVGNames::xAttr);
73 supportedAttributes.add(SVGNames::yAttr); 68 supportedAttributes.add(SVGNames::yAttr);
74 supportedAttributes.add(SVGNames::widthAttr); 69 supportedAttributes.add(SVGNames::widthAttr);
75 supportedAttributes.add(SVGNames::heightAttr); 70 supportedAttributes.add(SVGNames::heightAttr);
76 supportedAttributes.add(SVGNames::rxAttr); 71 supportedAttributes.add(SVGNames::rxAttr);
77 supportedAttributes.add(SVGNames::ryAttr); 72 supportedAttributes.add(SVGNames::ryAttr);
78 } 73 }
79 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 74 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
80 } 75 }
81 76
82 void SVGRectElement::parseAttribute(const QualifiedName& name, const AtomicStrin g& value) 77 void SVGRectElement::parseAttribute(const QualifiedName& name, const AtomicStrin g& value)
83 { 78 {
84 SVGParsingError parseError = NoError; 79 SVGParsingError parseError = NoError;
85 80
86 if (!isSupportedAttribute(name)) 81 if (!isSupportedAttribute(name))
87 SVGGeometryElement::parseAttribute(name, value); 82 SVGGeometryElement::parseAttribute(name, value);
88 else if (name == SVGNames::xAttr) 83 else if (name == SVGNames::xAttr)
89 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); 84 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError);
90 else if (name == SVGNames::yAttr) 85 else if (name == SVGNames::yAttr)
91 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError)) ; 86 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError);
92 else if (name == SVGNames::rxAttr) 87 else if (name == SVGNames::rxAttr)
93 setRxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths)); 88 m_rx->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
94 else if (name == SVGNames::ryAttr) 89 else if (name == SVGNames::ryAttr)
95 setRyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths)); 90 m_ry->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
96 else if (name == SVGNames::widthAttr) 91 else if (name == SVGNames::widthAttr)
97 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro r, ForbidNegativeLengths)); 92 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError);
98 else if (name == SVGNames::heightAttr) 93 else if (name == SVGNames::heightAttr)
99 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr ror, ForbidNegativeLengths)); 94 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError) ;
100 else 95 else
101 ASSERT_NOT_REACHED(); 96 ASSERT_NOT_REACHED();
102 97
103 reportAttributeParsingError(parseError, name, value); 98 reportAttributeParsingError(parseError, name, value);
104 } 99 }
105 100
106 void SVGRectElement::svgAttributeChanged(const QualifiedName& attrName) 101 void SVGRectElement::svgAttributeChanged(const QualifiedName& attrName)
107 { 102 {
108 if (!isSupportedAttribute(attrName)) { 103 if (!isSupportedAttribute(attrName)) {
109 SVGGeometryElement::svgAttributeChanged(attrName); 104 SVGGeometryElement::svgAttributeChanged(attrName);
(...skipping 20 matching lines...) Expand all
130 renderer->setNeedsShapeUpdate(); 125 renderer->setNeedsShapeUpdate();
131 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); 126 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
132 return; 127 return;
133 } 128 }
134 129
135 ASSERT_NOT_REACHED(); 130 ASSERT_NOT_REACHED();
136 } 131 }
137 132
138 bool SVGRectElement::selfHasRelativeLengths() const 133 bool SVGRectElement::selfHasRelativeLengths() const
139 { 134 {
140 return xCurrentValue().isRelative() 135 return m_x->currentValue()->isRelative()
141 || yCurrentValue().isRelative() 136 || m_y->currentValue()->isRelative()
142 || widthCurrentValue().isRelative() 137 || m_width->currentValue()->isRelative()
143 || heightCurrentValue().isRelative() 138 || m_height->currentValue()->isRelative()
144 || rxCurrentValue().isRelative() 139 || m_rx->currentValue()->isRelative()
145 || ryCurrentValue().isRelative(); 140 || m_ry->currentValue()->isRelative();
146 } 141 }
147 142
148 RenderObject* SVGRectElement::createRenderer(RenderStyle*) 143 RenderObject* SVGRectElement::createRenderer(RenderStyle*)
149 { 144 {
150 return new RenderSVGRect(this); 145 return new RenderSVGRect(this);
151 } 146 }
152 147
153 } 148 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGRectElement.h ('k') | Source/core/svg/SVGSVGElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698