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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 126 } |
127 | 127 |
128 RenderObject* SVGRadialGradientElement::createRenderer(RenderStyle*) | 128 RenderObject* SVGRadialGradientElement::createRenderer(RenderStyle*) |
129 { | 129 { |
130 return new RenderSVGResourceRadialGradient(this); | 130 return new RenderSVGResourceRadialGradient(this); |
131 } | 131 } |
132 | 132 |
133 bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttribute
s& attributes) | 133 bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttribute
s& attributes) |
134 { | 134 { |
135 HashSet<SVGGradientElement*> processedGradients; | 135 HashSet<SVGGradientElement*> processedGradients; |
136 | |
137 bool isRadial = true; | |
138 SVGGradientElement* current = this; | 136 SVGGradientElement* current = this; |
139 | 137 |
140 while (current) { | 138 do { |
141 if (!current->renderer()) | 139 if (!current->renderer()) |
142 return false; | 140 return false; |
143 | 141 |
144 if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spr
eadMethodAttr)) | 142 if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spr
eadMethodAttr)) |
145 attributes.setSpreadMethod(current->spreadMethodCurrentValue()); | 143 attributes.setSpreadMethod(current->spreadMethodCurrentValue()); |
146 | 144 |
147 if (!attributes.hasGradientUnits() && current->hasAttribute(SVGNames::gr
adientUnitsAttr)) | 145 if (!attributes.hasGradientUnits() && current->hasAttribute(SVGNames::gr
adientUnitsAttr)) |
148 attributes.setGradientUnits(current->gradientUnitsCurrentValue()); | 146 attributes.setGradientUnits(current->gradientUnitsCurrentValue()); |
149 | 147 |
150 if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames
::gradientTransformAttr)) { | 148 if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames
::gradientTransformAttr)) { |
151 AffineTransform transform; | 149 AffineTransform transform; |
152 current->gradientTransformCurrentValue().concatenate(transform); | 150 current->gradientTransformCurrentValue().concatenate(transform); |
153 attributes.setGradientTransform(transform); | 151 attributes.setGradientTransform(transform); |
154 } | 152 } |
155 | 153 |
156 if (!attributes.hasStops()) { | 154 if (!attributes.hasStops()) { |
157 const Vector<Gradient::ColorStop>& stops(current->buildStops()); | 155 const Vector<Gradient::ColorStop>& stops(current->buildStops()); |
158 if (!stops.isEmpty()) | 156 if (!stops.isEmpty()) |
159 attributes.setStops(stops); | 157 attributes.setStops(stops); |
160 } | 158 } |
161 | 159 |
162 if (isRadial) { | 160 if (current->hasTagName(SVGNames::radialGradientTag)) { |
163 SVGRadialGradientElement* radial = toSVGRadialGradientElement(curren
t); | 161 SVGRadialGradientElement* radial = toSVGRadialGradientElement(curren
t); |
164 | 162 |
165 if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr)) | 163 if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr)) |
166 attributes.setCx(radial->cx()->currentValue()); | 164 attributes.setCx(radial->cx()->currentValue()); |
167 | 165 |
168 if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAttr)) | 166 if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAttr)) |
169 attributes.setCy(radial->cy()->currentValue()); | 167 attributes.setCy(radial->cy()->currentValue()); |
170 | 168 |
171 if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr)) | 169 if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr)) |
172 attributes.setR(radial->r()->currentValue()); | 170 attributes.setR(radial->r()->currentValue()); |
(...skipping 13 matching lines...) Expand all Loading... |
186 // Respect xlink:href, take attributes from referenced element | 184 // Respect xlink:href, take attributes from referenced element |
187 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre
fCurrentValue(), document()); | 185 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre
fCurrentValue(), document()); |
188 if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refN
ode->hasTagName(SVGNames::linearGradientTag))) { | 186 if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refN
ode->hasTagName(SVGNames::linearGradientTag))) { |
189 current = toSVGGradientElement(refNode); | 187 current = toSVGGradientElement(refNode); |
190 | 188 |
191 // Cycle detection | 189 // Cycle detection |
192 if (processedGradients.contains(current)) { | 190 if (processedGradients.contains(current)) { |
193 current = 0; | 191 current = 0; |
194 break; | 192 break; |
195 } | 193 } |
196 | |
197 isRadial = current->hasTagName(SVGNames::radialGradientTag); | |
198 } else | 194 } else |
199 current = 0; | 195 current = 0; |
200 } | 196 } while (current); |
201 | 197 |
202 // Handle default values for fx/fy | 198 // Handle default values for fx/fy |
203 if (!attributes.hasFx()) | 199 if (!attributes.hasFx()) |
204 attributes.setFx(attributes.cx()); | 200 attributes.setFx(attributes.cx()); |
205 | 201 |
206 if (!attributes.hasFy()) | 202 if (!attributes.hasFy()) |
207 attributes.setFy(attributes.cy()); | 203 attributes.setFy(attributes.cy()); |
208 return true; | 204 return true; |
209 } | 205 } |
210 | 206 |
211 bool SVGRadialGradientElement::selfHasRelativeLengths() const | 207 bool SVGRadialGradientElement::selfHasRelativeLengths() const |
212 { | 208 { |
213 return m_cx->currentValue()->isRelative() | 209 return m_cx->currentValue()->isRelative() |
214 || m_cy->currentValue()->isRelative() | 210 || m_cy->currentValue()->isRelative() |
215 || m_r->currentValue()->isRelative() | 211 || m_r->currentValue()->isRelative() |
216 || m_fx->currentValue()->isRelative() | 212 || m_fx->currentValue()->isRelative() |
217 || m_fy->currentValue()->isRelative() | 213 || m_fy->currentValue()->isRelative() |
218 || m_fr->currentValue()->isRelative(); | 214 || m_fr->currentValue()->isRelative(); |
219 } | 215 } |
220 | 216 |
221 } | 217 } |
OLD | NEW |