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; |
124 | 123 |
125 while (current) { | 124 do { |
126 if (!current->renderer()) | 125 if (!current->renderer()) |
127 return false; | 126 return false; |
128 | 127 |
129 if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spr eadMethodAttr)) | 128 if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spr eadMethodAttr)) |
130 attributes.setSpreadMethod(current->spreadMethodCurrentValue()); | 129 attributes.setSpreadMethod(current->spreadMethodCurrentValue()); |
131 | 130 |
132 if (!attributes.hasGradientUnits() && current->hasAttribute(SVGNames::gr adientUnitsAttr)) | 131 if (!attributes.hasGradientUnits() && current->hasAttribute(SVGNames::gr adientUnitsAttr)) |
133 attributes.setGradientUnits(current->gradientUnitsCurrentValue()); | 132 attributes.setGradientUnits(current->gradientUnitsCurrentValue()); |
134 | 133 |
135 if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames ::gradientTransformAttr)) { | 134 if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames ::gradientTransformAttr)) { |
136 AffineTransform transform; | 135 AffineTransform transform; |
137 current->gradientTransformCurrentValue().concatenate(transform); | 136 current->gradientTransformCurrentValue().concatenate(transform); |
138 attributes.setGradientTransform(transform); | 137 attributes.setGradientTransform(transform); |
139 } | 138 } |
140 | 139 |
141 if (!attributes.hasStops()) { | 140 if (!attributes.hasStops()) { |
142 const Vector<Gradient::ColorStop>& stops(current->buildStops()); | 141 const Vector<Gradient::ColorStop>& stops(current->buildStops()); |
143 if (!stops.isEmpty()) | 142 if (!stops.isEmpty()) |
144 attributes.setStops(stops); | 143 attributes.setStops(stops); |
145 } | 144 } |
146 | 145 |
147 if (isLinear) { | 146 if (current->hasTagName(SVGNames::linearGradientTag)) { |
148 SVGLinearGradientElement* linear = toSVGLinearGradientElement(curren t); | 147 SVGLinearGradientElement* linear = toSVGLinearGradientElement(curren t); |
149 | 148 |
150 if (!attributes.hasX1() && current->hasAttribute(SVGNames::x1Attr)) | 149 if (!attributes.hasX1() && current->hasAttribute(SVGNames::x1Attr)) |
151 attributes.setX1(linear->x1()->currentValue()); | 150 attributes.setX1(linear->x1()->currentValue()); |
152 | 151 |
153 if (!attributes.hasY1() && current->hasAttribute(SVGNames::y1Attr)) | 152 if (!attributes.hasY1() && current->hasAttribute(SVGNames::y1Attr)) |
154 attributes.setY1(linear->y1()->currentValue()); | 153 attributes.setY1(linear->y1()->currentValue()); |
155 | 154 |
156 if (!attributes.hasX2() && current->hasAttribute(SVGNames::x2Attr)) | 155 if (!attributes.hasX2() && current->hasAttribute(SVGNames::x2Attr)) |
157 attributes.setX2(linear->x2()->currentValue()); | 156 attributes.setX2(linear->x2()->currentValue()); |
158 | 157 |
159 if (!attributes.hasY2() && current->hasAttribute(SVGNames::y2Attr)) | 158 if (!attributes.hasY2() && current->hasAttribute(SVGNames::y2Attr)) |
160 attributes.setY2(linear->y2()->currentValue()); | 159 attributes.setY2(linear->y2()->currentValue()); |
161 } | 160 } |
162 | 161 |
163 processedGradients.add(current); | 162 processedGradients.add(current); |
164 | 163 |
165 // Respect xlink:href, take attributes from referenced element | 164 // Respect xlink:href, take attributes from referenced element |
166 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre fCurrentValue(), document()); | 165 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre fCurrentValue(), document()); |
167 if (refNode && (refNode->hasTagName(SVGNames::linearGradientTag) || refN ode->hasTagName(SVGNames::radialGradientTag))) { | 166 if (refNode && (refNode->hasTagName(SVGNames::linearGradientTag) || refN ode->hasTagName(SVGNames::radialGradientTag))) { |
168 current = toSVGGradientElement(refNode); | 167 current = toSVGGradientElement(refNode); |
169 | 168 |
170 // Cycle detection | 169 // Cycle detection |
171 if (processedGradients.contains(current)) { | 170 if (processedGradients.contains(current)) { |
172 current = 0; | 171 current = 0; |
173 break; | 172 break; |
174 } | 173 } |
175 | |
176 isLinear = current->hasTagName(SVGNames::linearGradientTag); | |
177 } else | 174 } else |
178 current = 0; | 175 current = 0; |
Stephen Chennney
2014/01/14 13:44:16
Need braces here.
| |
179 } | 176 } while (current); |
180 | 177 |
181 return true; | 178 return true; |
182 } | 179 } |
183 | 180 |
184 bool SVGLinearGradientElement::selfHasRelativeLengths() const | 181 bool SVGLinearGradientElement::selfHasRelativeLengths() const |
185 { | 182 { |
186 return m_x1->currentValue()->isRelative() | 183 return m_x1->currentValue()->isRelative() |
187 || m_y1->currentValue()->isRelative() | 184 || m_y1->currentValue()->isRelative() |
188 || m_x2->currentValue()->isRelative() | 185 || m_x2->currentValue()->isRelative() |
189 || m_y2->currentValue()->isRelative(); | 186 || m_y2->currentValue()->isRelative(); |
190 } | 187 } |
191 | 188 |
192 } | 189 } |
OLD | NEW |