| Index: Source/core/svg/SVGRadialGradientElement.cpp
|
| diff --git a/Source/core/svg/SVGRadialGradientElement.cpp b/Source/core/svg/SVGRadialGradientElement.cpp
|
| index d8fe2a87533664771aa6a0172e1ccf679ad55592..1a65657773714ad9404494e9800ecd69e667da15 100644
|
| --- a/Source/core/svg/SVGRadialGradientElement.cpp
|
| +++ b/Source/core/svg/SVGRadialGradientElement.cpp
|
| @@ -130,73 +130,78 @@ RenderObject* SVGRadialGradientElement::createRenderer(RenderStyle*)
|
| return new RenderSVGResourceRadialGradient(this);
|
| }
|
|
|
| -bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttributes& attributes)
|
| +static void setGradientAttributes(SVGGradientElement* element, RadialGradientAttributes& attributes, bool isRadial = true)
|
| {
|
| - HashSet<SVGGradientElement*> processedGradients;
|
| + if (!attributes.hasSpreadMethod() && element->hasAttribute(SVGNames::spreadMethodAttr))
|
| + attributes.setSpreadMethod(element->spreadMethodCurrentValue());
|
|
|
| - bool isRadial = true;
|
| - SVGGradientElement* current = this;
|
| + if (!attributes.hasGradientUnits() && element->hasAttribute(SVGNames::gradientUnitsAttr))
|
| + attributes.setGradientUnits(element->gradientUnitsCurrentValue());
|
|
|
| - while (current) {
|
| - if (!current->renderer())
|
| - return false;
|
| -
|
| - if (!attributes.hasSpreadMethod() && current->hasAttribute(SVGNames::spreadMethodAttr))
|
| - attributes.setSpreadMethod(current->spreadMethodCurrentValue());
|
| + if (!attributes.hasGradientTransform() && element->hasAttribute(SVGNames::gradientTransformAttr)) {
|
| + AffineTransform transform;
|
| + element->gradientTransformCurrentValue().concatenate(transform);
|
| + attributes.setGradientTransform(transform);
|
| + }
|
|
|
| - if (!attributes.hasGradientUnits() && current->hasAttribute(SVGNames::gradientUnitsAttr))
|
| - attributes.setGradientUnits(current->gradientUnitsCurrentValue());
|
| + if (!attributes.hasStops()) {
|
| + const Vector<Gradient::ColorStop>& stops(element->buildStops());
|
| + if (!stops.isEmpty())
|
| + attributes.setStops(stops);
|
| + }
|
|
|
| - if (!attributes.hasGradientTransform() && current->hasAttribute(SVGNames::gradientTransformAttr)) {
|
| - AffineTransform transform;
|
| - current->gradientTransformCurrentValue().concatenate(transform);
|
| - attributes.setGradientTransform(transform);
|
| - }
|
| + if (isRadial) {
|
| + SVGRadialGradientElement* radial = toSVGRadialGradientElement(element);
|
|
|
| - if (!attributes.hasStops()) {
|
| - const Vector<Gradient::ColorStop>& stops(current->buildStops());
|
| - if (!stops.isEmpty())
|
| - attributes.setStops(stops);
|
| - }
|
| + if (!attributes.hasCx() && element->hasAttribute(SVGNames::cxAttr))
|
| + attributes.setCx(radial->cx()->currentValue());
|
|
|
| - if (isRadial) {
|
| - SVGRadialGradientElement* radial = toSVGRadialGradientElement(current);
|
| + if (!attributes.hasCy() && element->hasAttribute(SVGNames::cyAttr))
|
| + attributes.setCy(radial->cy()->currentValue());
|
|
|
| - if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr))
|
| - attributes.setCx(radial->cx()->currentValue());
|
| + if (!attributes.hasR() && element->hasAttribute(SVGNames::rAttr))
|
| + attributes.setR(radial->r()->currentValue());
|
|
|
| - if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAttr))
|
| - attributes.setCy(radial->cy()->currentValue());
|
| + if (!attributes.hasFx() && element->hasAttribute(SVGNames::fxAttr))
|
| + attributes.setFx(radial->fx()->currentValue());
|
|
|
| - if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr))
|
| - attributes.setR(radial->r()->currentValue());
|
| + if (!attributes.hasFy() && element->hasAttribute(SVGNames::fyAttr))
|
| + attributes.setFy(radial->fy()->currentValue());
|
|
|
| - if (!attributes.hasFx() && current->hasAttribute(SVGNames::fxAttr))
|
| - attributes.setFx(radial->fx()->currentValue());
|
| + if (!attributes.hasFr() && element->hasAttribute(SVGNames::frAttr))
|
| + attributes.setFr(radial->fr()->currentValue());
|
| + }
|
| +}
|
|
|
| - if (!attributes.hasFy() && current->hasAttribute(SVGNames::fyAttr))
|
| - attributes.setFy(radial->fy()->currentValue());
|
| +bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttributes& attributes)
|
| +{
|
| + if (!renderer())
|
| + return false;
|
|
|
| - if (!attributes.hasFr() && current->hasAttribute(SVGNames::frAttr))
|
| - attributes.setFr(radial->fr()->currentValue());
|
| - }
|
| + HashSet<SVGGradientElement*> processedGradients;
|
| + SVGGradientElement* current = this;
|
|
|
| - processedGradients.add(current);
|
| + setGradientAttributes(current, attributes);
|
| + processedGradients.add(current);
|
|
|
| + while (true) {
|
| // Respect xlink:href, take attributes from referenced element
|
| Node* refNode = SVGURIReference::targetElementFromIRIString(current->hrefCurrentValue(), document());
|
| - if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refNode->hasTagName(SVGNames::linearGradientTag))) {
|
| + if (refNode && isSVGGradientElement(*refNode)) {
|
| current = toSVGGradientElement(refNode);
|
|
|
| // Cycle detection
|
| - if (processedGradients.contains(current)) {
|
| - current = 0;
|
| + if (processedGradients.contains(current))
|
| break;
|
| - }
|
|
|
| - isRadial = current->hasTagName(SVGNames::radialGradientTag);
|
| - } else
|
| - current = 0;
|
| + if (!current->renderer())
|
| + return false;
|
| +
|
| + setGradientAttributes(current, attributes, current->hasTagName(SVGNames::radialGradientTag));
|
| + processedGradients.add(current);
|
| + } else {
|
| + break;
|
| + }
|
| }
|
|
|
| // Handle default values for fx/fy
|
| @@ -205,6 +210,7 @@ bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttribute
|
|
|
| if (!attributes.hasFy())
|
| attributes.setFy(attributes.cy());
|
| +
|
| return true;
|
| }
|
|
|
|
|