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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 RenderObject* SVGLinearGradientElement::createRenderer(RenderStyle*) | 113 RenderObject* SVGLinearGradientElement::createRenderer(RenderStyle*) |
114 { | 114 { |
115 return new RenderSVGResourceLinearGradient(this); | 115 return new RenderSVGResourceLinearGradient(this); |
116 } | 116 } |
117 | 117 |
118 bool SVGLinearGradientElement::collectGradientAttributes(LinearGradientAttribute
s& attributes) | 118 bool SVGLinearGradientElement::collectGradientAttributes(LinearGradientAttribute
s& attributes) |
119 { | 119 { |
120 HashSet<SVGGradientElement*> processedGradients; | 120 HashSet<SVGGradientElement*> processedGradients; |
121 | 121 |
122 bool isLinear = true; | |
123 SVGGradientElement* current = this; | 122 SVGGradientElement* current = this; |
| 123 setAttributeAnimatedLength(current, attributes); |
124 | 124 |
125 while (current) { | 125 do { |
126 if (!current->renderer()) | 126 if (!current->renderer()) |
127 return false; | 127 return false; |
128 | 128 |
129 if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spr
eadMethodAttr)) | 129 if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spr
eadMethodAttr)) |
130 attributes.setSpreadMethod(current->spreadMethodCurrentValue()); | 130 attributes.setSpreadMethod(current->spreadMethodCurrentValue()); |
131 | 131 |
132 if (!attributes.hasGradientUnits() && current->hasAttribute(SVGNames::gr
adientUnitsAttr)) | 132 if (!attributes.hasGradientUnits() && current->hasAttribute(SVGNames::gr
adientUnitsAttr)) |
133 attributes.setGradientUnits(current->gradientUnitsCurrentValue()); | 133 attributes.setGradientUnits(current->gradientUnitsCurrentValue()); |
134 | 134 |
135 if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames
::gradientTransformAttr)) { | 135 if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames
::gradientTransformAttr)) { |
136 AffineTransform transform; | 136 AffineTransform transform; |
137 current->gradientTransformCurrentValue().concatenate(transform); | 137 current->gradientTransformCurrentValue().concatenate(transform); |
138 attributes.setGradientTransform(transform); | 138 attributes.setGradientTransform(transform); |
139 } | 139 } |
140 | 140 |
141 if (!attributes.hasStops()) { | 141 if (!attributes.hasStops()) { |
142 const Vector<Gradient::ColorStop>& stops(current->buildStops()); | 142 const Vector<Gradient::ColorStop>& stops(current->buildStops()); |
143 if (!stops.isEmpty()) | 143 if (!stops.isEmpty()) |
144 attributes.setStops(stops); | 144 attributes.setStops(stops); |
145 } | 145 } |
146 | 146 |
147 if (isLinear) { | |
148 SVGLinearGradientElement* linear = toSVGLinearGradientElement(curren
t); | |
149 | |
150 if (!attributes.hasX1() && current->hasAttribute(SVGNames::x1Attr)) | |
151 attributes.setX1(linear->x1()->currentValue()); | |
152 | |
153 if (!attributes.hasY1() && current->hasAttribute(SVGNames::y1Attr)) | |
154 attributes.setY1(linear->y1()->currentValue()); | |
155 | |
156 if (!attributes.hasX2() && current->hasAttribute(SVGNames::x2Attr)) | |
157 attributes.setX2(linear->x2()->currentValue()); | |
158 | |
159 if (!attributes.hasY2() && current->hasAttribute(SVGNames::y2Attr)) | |
160 attributes.setY2(linear->y2()->currentValue()); | |
161 } | |
162 | |
163 processedGradients.add(current); | 147 processedGradients.add(current); |
164 | 148 |
165 // Respect xlink:href, take attributes from referenced element | 149 // Respect xlink:href, take attributes from referenced element |
166 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre
fCurrentValue(), document()); | 150 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre
fCurrentValue(), document()); |
167 if (refNode && (refNode->hasTagName(SVGNames::linearGradientTag) || refN
ode->hasTagName(SVGNames::radialGradientTag))) { | 151 if (refNode && isSVGGradientElement(*refNode)) { |
168 current = toSVGGradientElement(refNode); | 152 current = toSVGGradientElement(refNode); |
169 | 153 |
170 // Cycle detection | 154 // Cycle detection |
171 if (processedGradients.contains(current)) { | 155 if (processedGradients.contains(current)) { |
172 current = 0; | 156 current = 0; |
173 break; | 157 break; |
174 } | 158 } |
175 | 159 |
176 isLinear = current->hasTagName(SVGNames::linearGradientTag); | 160 if (current->hasTagName(SVGNames::linearGradientTag)) |
177 } else | 161 setAttributeAnimatedLength(current, attributes); |
| 162 } else { |
178 current = 0; | 163 current = 0; |
179 } | 164 } |
| 165 } while (current); |
180 | 166 |
181 return true; | 167 return true; |
182 } | 168 } |
183 | 169 |
| 170 void SVGLinearGradientElement::setAttributeAnimatedLength(SVGGradientElement* el
ement, LinearGradientAttributes& attributes) |
| 171 { |
| 172 SVGLinearGradientElement* linear = toSVGLinearGradientElement(element); |
| 173 |
| 174 if (!attributes.hasX1() && element->hasAttribute(SVGNames::x1Attr)) |
| 175 attributes.setX1(linear->x1()->currentValue()); |
| 176 |
| 177 if (!attributes.hasY1() && element->hasAttribute(SVGNames::y1Attr)) |
| 178 attributes.setY1(linear->y1()->currentValue()); |
| 179 |
| 180 if (!attributes.hasX2() && element->hasAttribute(SVGNames::x2Attr)) |
| 181 attributes.setX2(linear->x2()->currentValue()); |
| 182 |
| 183 if (!attributes.hasY2() && element->hasAttribute(SVGNames::y2Attr)) |
| 184 attributes.setY2(linear->y2()->currentValue()); |
| 185 } |
| 186 |
184 bool SVGLinearGradientElement::selfHasRelativeLengths() const | 187 bool SVGLinearGradientElement::selfHasRelativeLengths() const |
185 { | 188 { |
186 return m_x1->currentValue()->isRelative() | 189 return m_x1->currentValue()->isRelative() |
187 || m_y1->currentValue()->isRelative() | 190 || m_y1->currentValue()->isRelative() |
188 || m_x2->currentValue()->isRelative() | 191 || m_x2->currentValue()->isRelative() |
189 || m_y2->currentValue()->isRelative(); | 192 || m_y2->currentValue()->isRelative(); |
190 } | 193 } |
191 | 194 |
192 } | 195 } |
OLD | NEW |