OLD | NEW |
---|---|
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 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 5 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 15 matching lines...) Expand all Loading... | |
26 #include "core/svg/SVGRadialGradientElement.h" | 26 #include "core/svg/SVGRadialGradientElement.h" |
27 | 27 |
28 #include "core/rendering/svg/RenderSVGResourceRadialGradient.h" | 28 #include "core/rendering/svg/RenderSVGResourceRadialGradient.h" |
29 #include "core/svg/RadialGradientAttributes.h" | 29 #include "core/svg/RadialGradientAttributes.h" |
30 #include "core/svg/SVGElementInstance.h" | 30 #include "core/svg/SVGElementInstance.h" |
31 #include "core/svg/SVGTransformList.h" | 31 #include "core/svg/SVGTransformList.h" |
32 | 32 |
33 namespace WebCore { | 33 namespace WebCore { |
34 | 34 |
35 // Animated property definitions | 35 // Animated property definitions |
36 DEFINE_ANIMATED_LENGTH(SVGRadialGradientElement, SVGNames::cxAttr, Cx, cx) | |
37 DEFINE_ANIMATED_LENGTH(SVGRadialGradientElement, SVGNames::cyAttr, Cy, cy) | |
38 DEFINE_ANIMATED_LENGTH(SVGRadialGradientElement, SVGNames::rAttr, R, r) | |
39 DEFINE_ANIMATED_LENGTH(SVGRadialGradientElement, SVGNames::fxAttr, Fx, fx) | |
40 DEFINE_ANIMATED_LENGTH(SVGRadialGradientElement, SVGNames::fyAttr, Fy, fy) | |
41 DEFINE_ANIMATED_LENGTH(SVGRadialGradientElement, SVGNames::frAttr, Fr, fr) | |
42 | 36 |
43 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGRadialGradientElement) | 37 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGRadialGradientElement) |
44 REGISTER_LOCAL_ANIMATED_PROPERTY(cx) | |
45 REGISTER_LOCAL_ANIMATED_PROPERTY(cy) | |
46 REGISTER_LOCAL_ANIMATED_PROPERTY(r) | |
47 REGISTER_LOCAL_ANIMATED_PROPERTY(fx) | |
48 REGISTER_LOCAL_ANIMATED_PROPERTY(fy) | |
49 REGISTER_LOCAL_ANIMATED_PROPERTY(fr) | |
50 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGradientElement) | 38 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGradientElement) |
51 END_REGISTER_ANIMATED_PROPERTIES | 39 END_REGISTER_ANIMATED_PROPERTIES |
52 | 40 |
53 inline SVGRadialGradientElement::SVGRadialGradientElement(Document& document) | 41 inline SVGRadialGradientElement::SVGRadialGradientElement(Document& document) |
54 : SVGGradientElement(SVGNames::radialGradientTag, document) | 42 : SVGGradientElement(SVGNames::radialGradientTag, document) |
55 , m_cx(LengthModeWidth, "50%") | 43 , m_cx(SVGAnimatedLength::create(this, SVGNames::cxAttr, SVGLength::create(L engthModeWidth))) |
56 , m_cy(LengthModeHeight, "50%") | 44 , m_cy(SVGAnimatedLength::create(this, SVGNames::cyAttr, SVGLength::create(L engthModeHeight))) |
57 , m_r(LengthModeOther, "50%") | 45 , m_r(SVGAnimatedLength::create(this, SVGNames::rAttr, SVGLength::create(Len gthModeOther))) |
58 , m_fx(LengthModeWidth) | 46 , m_fx(SVGAnimatedLength::create(this, SVGNames::fxAttr, SVGLength::create(L engthModeWidth))) |
59 , m_fy(LengthModeHeight) | 47 , m_fy(SVGAnimatedLength::create(this, SVGNames::fyAttr, SVGLength::create(L engthModeHeight))) |
60 , m_fr(LengthModeOther, "0%") | 48 , m_fr(SVGAnimatedLength::create(this, SVGNames::frAttr, SVGLength::create(L engthModeOther))) |
61 { | 49 { |
62 // Spec: If the cx/cy/r/fr attribute is not specified, the effect is as if a value of "50%" were specified. | |
63 ScriptWrappable::init(this); | 50 ScriptWrappable::init(this); |
51 | |
52 // Spec: If the cx/cy/r attribute is not specified, the effect is as if a va lue of "50%" were specified. | |
53 m_cx->setDefaultValueAsString("50%"); | |
54 m_cy->setDefaultValueAsString("50%"); | |
55 m_r->setDefaultValueAsString("50%"); | |
56 | |
57 // FIXME: "fr" attribute is not mentioned anywhere in the spec. | |
pdr.
2014/01/07 06:42:53
This fixme is incorrect. The fr attribute was rece
kouhei (in TOK)
2014/01/08 08:12:07
Done.
| |
58 m_fr->setDefaultValueAsString("0%"); | |
59 | |
60 addToPropertyMap(m_cx); | |
61 addToPropertyMap(m_cy); | |
62 addToPropertyMap(m_r); | |
63 addToPropertyMap(m_fx); | |
64 addToPropertyMap(m_fy); | |
65 addToPropertyMap(m_fr); | |
64 registerAnimatedPropertiesForSVGRadialGradientElement(); | 66 registerAnimatedPropertiesForSVGRadialGradientElement(); |
65 } | 67 } |
66 | 68 |
67 PassRefPtr<SVGRadialGradientElement> SVGRadialGradientElement::create(Document& document) | 69 PassRefPtr<SVGRadialGradientElement> SVGRadialGradientElement::create(Document& document) |
68 { | 70 { |
69 return adoptRef(new SVGRadialGradientElement(document)); | 71 return adoptRef(new SVGRadialGradientElement(document)); |
70 } | 72 } |
71 | 73 |
72 bool SVGRadialGradientElement::isSupportedAttribute(const QualifiedName& attrNam e) | 74 bool SVGRadialGradientElement::isSupportedAttribute(const QualifiedName& attrNam e) |
73 { | 75 { |
74 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 76 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
75 if (supportedAttributes.isEmpty()) { | 77 if (supportedAttributes.isEmpty()) { |
76 supportedAttributes.add(SVGNames::cxAttr); | 78 supportedAttributes.add(SVGNames::cxAttr); |
77 supportedAttributes.add(SVGNames::cyAttr); | 79 supportedAttributes.add(SVGNames::cyAttr); |
78 supportedAttributes.add(SVGNames::fxAttr); | 80 supportedAttributes.add(SVGNames::fxAttr); |
79 supportedAttributes.add(SVGNames::fyAttr); | 81 supportedAttributes.add(SVGNames::fyAttr); |
80 supportedAttributes.add(SVGNames::rAttr); | 82 supportedAttributes.add(SVGNames::rAttr); |
81 supportedAttributes.add(SVGNames::frAttr); | 83 supportedAttributes.add(SVGNames::frAttr); |
82 } | 84 } |
83 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 85 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
84 } | 86 } |
85 | 87 |
86 void SVGRadialGradientElement::parseAttribute(const QualifiedName& name, const A tomicString& value) | 88 void SVGRadialGradientElement::parseAttribute(const QualifiedName& name, const A tomicString& value) |
87 { | 89 { |
88 SVGParsingError parseError = NoError; | 90 SVGParsingError parseError = NoError; |
89 | 91 |
90 if (!isSupportedAttribute(name)) | 92 if (!isSupportedAttribute(name)) |
91 SVGGradientElement::parseAttribute(name, value); | 93 SVGGradientElement::parseAttribute(name, value); |
92 else if (name == SVGNames::cxAttr) | 94 else if (name == SVGNames::cxAttr) |
93 setCxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)) ; | 95 m_cx->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
94 else if (name == SVGNames::cyAttr) | 96 else if (name == SVGNames::cyAttr) |
95 setCyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError) ); | 97 m_cy->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
96 else if (name == SVGNames::rAttr) | 98 else if (name == SVGNames::rAttr) |
97 setRBaseValue(SVGLength::construct(LengthModeOther, value, parseError, F orbidNegativeLengths)); | 99 m_r->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
98 else if (name == SVGNames::fxAttr) | 100 else if (name == SVGNames::fxAttr) |
99 setFxBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)) ; | 101 m_fx->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
100 else if (name == SVGNames::fyAttr) | 102 else if (name == SVGNames::fyAttr) |
101 setFyBaseValue(SVGLength::construct(LengthModeHeight, value, parseError) ); | 103 m_fy->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
102 else if (name == SVGNames::frAttr) | 104 else if (name == SVGNames::frAttr) |
103 setFrBaseValue(SVGLength::construct(LengthModeOther, value, parseError, ForbidNegativeLengths)); | 105 m_fr->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
104 else | 106 else |
105 ASSERT_NOT_REACHED(); | 107 ASSERT_NOT_REACHED(); |
106 | 108 |
107 reportAttributeParsingError(parseError, name, value); | 109 reportAttributeParsingError(parseError, name, value); |
108 } | 110 } |
109 | 111 |
110 void SVGRadialGradientElement::svgAttributeChanged(const QualifiedName& attrName ) | 112 void SVGRadialGradientElement::svgAttributeChanged(const QualifiedName& attrName ) |
111 { | 113 { |
112 if (!isSupportedAttribute(attrName)) { | 114 if (!isSupportedAttribute(attrName)) { |
113 SVGGradientElement::svgAttributeChanged(attrName); | 115 SVGGradientElement::svgAttributeChanged(attrName); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 if (!attributes.hasStops()) { | 156 if (!attributes.hasStops()) { |
155 const Vector<Gradient::ColorStop>& stops(current->buildStops()); | 157 const Vector<Gradient::ColorStop>& stops(current->buildStops()); |
156 if (!stops.isEmpty()) | 158 if (!stops.isEmpty()) |
157 attributes.setStops(stops); | 159 attributes.setStops(stops); |
158 } | 160 } |
159 | 161 |
160 if (isRadial) { | 162 if (isRadial) { |
161 SVGRadialGradientElement* radial = toSVGRadialGradientElement(curren t); | 163 SVGRadialGradientElement* radial = toSVGRadialGradientElement(curren t); |
162 | 164 |
163 if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr)) | 165 if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr)) |
164 attributes.setCx(radial->cxCurrentValue()); | 166 attributes.setCx(radial->cx()->currentValue()); |
165 | 167 |
166 if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAttr)) | 168 if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAttr)) |
167 attributes.setCy(radial->cyCurrentValue()); | 169 attributes.setCy(radial->cy()->currentValue()); |
168 | 170 |
169 if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr)) | 171 if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr)) |
170 attributes.setR(radial->rCurrentValue()); | 172 attributes.setR(radial->r()->currentValue()); |
171 | 173 |
172 if (!attributes.hasFx() && current->hasAttribute(SVGNames::fxAttr)) | 174 if (!attributes.hasFx() && current->hasAttribute(SVGNames::fxAttr)) |
173 attributes.setFx(radial->fxCurrentValue()); | 175 attributes.setFx(radial->fx()->currentValue()); |
174 | 176 |
175 if (!attributes.hasFy() && current->hasAttribute(SVGNames::fyAttr)) | 177 if (!attributes.hasFy() && current->hasAttribute(SVGNames::fyAttr)) |
176 attributes.setFy(radial->fyCurrentValue()); | 178 attributes.setFy(radial->fy()->currentValue()); |
177 | 179 |
178 if (!attributes.hasFr() && current->hasAttribute(SVGNames::frAttr)) | 180 if (!attributes.hasFr() && current->hasAttribute(SVGNames::frAttr)) |
179 attributes.setFr(radial->frCurrentValue()); | 181 attributes.setFr(radial->fr()->currentValue()); |
180 } | 182 } |
181 | 183 |
182 processedGradients.add(current); | 184 processedGradients.add(current); |
183 | 185 |
184 // Respect xlink:href, take attributes from referenced element | 186 // Respect xlink:href, take attributes from referenced element |
185 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre fCurrentValue(), document()); | 187 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre fCurrentValue(), document()); |
186 if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refN ode->hasTagName(SVGNames::linearGradientTag))) { | 188 if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refN ode->hasTagName(SVGNames::linearGradientTag))) { |
187 current = toSVGGradientElement(refNode); | 189 current = toSVGGradientElement(refNode); |
188 | 190 |
189 // Cycle detection | 191 // Cycle detection |
(...skipping 11 matching lines...) Expand all Loading... | |
201 if (!attributes.hasFx()) | 203 if (!attributes.hasFx()) |
202 attributes.setFx(attributes.cx()); | 204 attributes.setFx(attributes.cx()); |
203 | 205 |
204 if (!attributes.hasFy()) | 206 if (!attributes.hasFy()) |
205 attributes.setFy(attributes.cy()); | 207 attributes.setFy(attributes.cy()); |
206 return true; | 208 return true; |
207 } | 209 } |
208 | 210 |
209 bool SVGRadialGradientElement::selfHasRelativeLengths() const | 211 bool SVGRadialGradientElement::selfHasRelativeLengths() const |
210 { | 212 { |
211 return cxCurrentValue().isRelative() | 213 return m_cx->currentValue()->isRelative() |
212 || cyCurrentValue().isRelative() | 214 || m_cy->currentValue()->isRelative() |
213 || rCurrentValue().isRelative() | 215 || m_r->currentValue()->isRelative() |
214 || fxCurrentValue().isRelative() | 216 || m_fx->currentValue()->isRelative() |
215 || fyCurrentValue().isRelative() | 217 || m_fy->currentValue()->isRelative() |
216 || frCurrentValue().isRelative(); | 218 || m_fr->currentValue()->isRelative(); |
217 } | 219 } |
218 | 220 |
219 } | 221 } |
OLD | NEW |