Chromium Code Reviews| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | 136 |
| 137 bool isRadial = true; | |
| 138 SVGGradientElement* current = this; | 137 SVGGradientElement* current = this; |
| 138 setAttributeAnimatedLength(current, attributes); | |
| 139 | 139 |
| 140 while (current) { | 140 do { |
| 141 if (!current->renderer()) | 141 if (!current->renderer()) |
|
Stephen Chennney
2014/01/16 02:19:52
This "if" needs to be done for the initial "this"
gyuyoung-inactive
2014/01/16 02:34:01
Right.
| |
| 142 return false; | 142 return false; |
| 143 | 143 |
| 144 if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spr eadMethodAttr)) | 144 if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spr eadMethodAttr)) |
|
Stephen Chennney
2014/01/16 02:19:52
All of these attribute checks should also go into
gyuyoung-inactive
2014/01/16 02:34:01
Yes, it is fine to call them in new method. Howeve
| |
| 145 attributes.setSpreadMethod(current->spreadMethodCurrentValue()); | 145 attributes.setSpreadMethod(current->spreadMethodCurrentValue()); |
| 146 | 146 |
| 147 if (!attributes.hasGradientUnits() && current->hasAttribute(SVGNames::gr adientUnitsAttr)) | 147 if (!attributes.hasGradientUnits() && current->hasAttribute(SVGNames::gr adientUnitsAttr)) |
| 148 attributes.setGradientUnits(current->gradientUnitsCurrentValue()); | 148 attributes.setGradientUnits(current->gradientUnitsCurrentValue()); |
| 149 | 149 |
| 150 if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames ::gradientTransformAttr)) { | 150 if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames ::gradientTransformAttr)) { |
| 151 AffineTransform transform; | 151 AffineTransform transform; |
| 152 current->gradientTransformCurrentValue().concatenate(transform); | 152 current->gradientTransformCurrentValue().concatenate(transform); |
| 153 attributes.setGradientTransform(transform); | 153 attributes.setGradientTransform(transform); |
| 154 } | 154 } |
| 155 | 155 |
| 156 if (!attributes.hasStops()) { | 156 if (!attributes.hasStops()) { |
| 157 const Vector<Gradient::ColorStop>& stops(current->buildStops()); | 157 const Vector<Gradient::ColorStop>& stops(current->buildStops()); |
| 158 if (!stops.isEmpty()) | 158 if (!stops.isEmpty()) |
| 159 attributes.setStops(stops); | 159 attributes.setStops(stops); |
| 160 } | 160 } |
| 161 | 161 |
| 162 if (isRadial) { | |
| 163 SVGRadialGradientElement* radial = toSVGRadialGradientElement(curren t); | |
| 164 | |
| 165 if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr)) | |
| 166 attributes.setCx(radial->cx()->currentValue()); | |
| 167 | |
| 168 if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAttr)) | |
| 169 attributes.setCy(radial->cy()->currentValue()); | |
| 170 | |
| 171 if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr)) | |
| 172 attributes.setR(radial->r()->currentValue()); | |
| 173 | |
| 174 if (!attributes.hasFx() && current->hasAttribute(SVGNames::fxAttr)) | |
| 175 attributes.setFx(radial->fx()->currentValue()); | |
| 176 | |
| 177 if (!attributes.hasFy() && current->hasAttribute(SVGNames::fyAttr)) | |
| 178 attributes.setFy(radial->fy()->currentValue()); | |
| 179 | |
| 180 if (!attributes.hasFr() && current->hasAttribute(SVGNames::frAttr)) | |
| 181 attributes.setFr(radial->fr()->currentValue()); | |
| 182 } | |
| 183 | |
| 184 processedGradients.add(current); | 162 processedGradients.add(current); |
|
Stephen Chennney
2014/01/16 02:19:52
You'll need to do this for the initial "this" elem
gyuyoung-inactive
2014/01/16 02:34:01
Is *this* element added by first iteration ? I don
| |
| 185 | 163 |
| 186 // Respect xlink:href, take attributes from referenced element | 164 // Respect xlink:href, take attributes from referenced element |
| 187 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre fCurrentValue(), document()); | 165 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre fCurrentValue(), document()); |
| 188 if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refN ode->hasTagName(SVGNames::linearGradientTag))) { | 166 if (refNode && isSVGGradientElement(*refNode)) { |
| 189 current = toSVGGradientElement(refNode); | 167 current = toSVGGradientElement(refNode); |
| 190 | 168 |
| 191 // Cycle detection | 169 // Cycle detection |
| 192 if (processedGradients.contains(current)) { | 170 if (processedGradients.contains(current)) { |
| 193 current = 0; | 171 current = 0; |
| 194 break; | 172 break; |
| 195 } | 173 } |
| 196 | 174 |
| 197 isRadial = current->hasTagName(SVGNames::radialGradientTag); | 175 if (current->hasTagName(SVGNames::radialGradientTag)) |
| 198 } else | 176 setAttributeAnimatedLength(current, attributes); |
| 177 } else { | |
| 199 current = 0; | 178 current = 0; |
| 200 } | 179 } |
| 180 } while (current); | |
| 201 | 181 |
| 202 // Handle default values for fx/fy | 182 // Handle default values for fx/fy |
| 203 if (!attributes.hasFx()) | 183 if (!attributes.hasFx()) |
| 204 attributes.setFx(attributes.cx()); | 184 attributes.setFx(attributes.cx()); |
| 205 | 185 |
| 206 if (!attributes.hasFy()) | 186 if (!attributes.hasFy()) |
| 207 attributes.setFy(attributes.cy()); | 187 attributes.setFy(attributes.cy()); |
| 208 return true; | 188 return true; |
| 209 } | 189 } |
| 210 | 190 |
| 191 void SVGRadialGradientElement::setAttributeAnimatedLength(SVGGradientElement* el ement, RadialGradientAttributes& attributes) | |
| 192 { | |
| 193 SVGRadialGradientElement* radial = toSVGRadialGradientElement(element); | |
| 194 | |
| 195 if (!attributes.hasCx() && element->hasAttribute(SVGNames::cxAttr)) | |
| 196 attributes.setCx(radial->cx()->currentValue()); | |
| 197 | |
| 198 if (!attributes.hasCy() && element->hasAttribute(SVGNames::cyAttr)) | |
| 199 attributes.setCy(radial->cy()->currentValue()); | |
| 200 | |
| 201 if (!attributes.hasR() && element->hasAttribute(SVGNames::rAttr)) | |
| 202 attributes.setR(radial->r()->currentValue()); | |
| 203 | |
| 204 if (!attributes.hasFx() && element->hasAttribute(SVGNames::fxAttr)) | |
| 205 attributes.setFx(radial->fx()->currentValue()); | |
| 206 | |
| 207 if (!attributes.hasFy() && element->hasAttribute(SVGNames::fyAttr)) | |
| 208 attributes.setFy(radial->fy()->currentValue()); | |
| 209 | |
| 210 if (!attributes.hasFr() && element->hasAttribute(SVGNames::frAttr)) | |
| 211 attributes.setFr(radial->fr()->currentValue()); | |
| 212 } | |
| 213 | |
| 211 bool SVGRadialGradientElement::selfHasRelativeLengths() const | 214 bool SVGRadialGradientElement::selfHasRelativeLengths() const |
| 212 { | 215 { |
| 213 return m_cx->currentValue()->isRelative() | 216 return m_cx->currentValue()->isRelative() |
| 214 || m_cy->currentValue()->isRelative() | 217 || m_cy->currentValue()->isRelative() |
| 215 || m_r->currentValue()->isRelative() | 218 || m_r->currentValue()->isRelative() |
| 216 || m_fx->currentValue()->isRelative() | 219 || m_fx->currentValue()->isRelative() |
| 217 || m_fy->currentValue()->isRelative() | 220 || m_fy->currentValue()->isRelative() |
| 218 || m_fr->currentValue()->isRelative(); | 221 || m_fr->currentValue()->isRelative(); |
| 219 } | 222 } |
| 220 | 223 |
| 221 } | 224 } |
| OLD | NEW |