| Index: Source/core/svg/SVGLinearGradientElement.cpp
|
| diff --git a/Source/core/svg/SVGLinearGradientElement.cpp b/Source/core/svg/SVGLinearGradientElement.cpp
|
| index 19df4d50b46b7eedc0f0ac5a5057ca7f93c6c38b..8a596e44944328a425c13512bd5d2d1486448084 100644
|
| --- a/Source/core/svg/SVGLinearGradientElement.cpp
|
| +++ b/Source/core/svg/SVGLinearGradientElement.cpp
|
| @@ -115,70 +115,76 @@ RenderObject* SVGLinearGradientElement::createRenderer(RenderStyle*)
|
| return new RenderSVGResourceLinearGradient(this);
|
| }
|
|
|
| -bool SVGLinearGradientElement::collectGradientAttributes(LinearGradientAttributes& attributes)
|
| +static void setGradientAttributes(SVGGradientElement* element, LinearGradientAttributes& attributes, bool isLinear = true)
|
| {
|
| - HashSet<SVGGradientElement*> processedGradients;
|
| + if (!attributes.hasSpreadMethod() && element->hasAttribute(SVGNames::spreadMethodAttr))
|
| + attributes.setSpreadMethod(element->spreadMethodCurrentValue());
|
|
|
| - bool isLinear = 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 (isLinear) {
|
| + SVGLinearGradientElement* linear = toSVGLinearGradientElement(element);
|
|
|
| - if (!attributes.hasStops()) {
|
| - const Vector<Gradient::ColorStop>& stops(current->buildStops());
|
| - if (!stops.isEmpty())
|
| - attributes.setStops(stops);
|
| - }
|
| + if (!attributes.hasX1() && element->hasAttribute(SVGNames::x1Attr))
|
| + attributes.setX1(linear->x1()->currentValue());
|
|
|
| - if (isLinear) {
|
| - SVGLinearGradientElement* linear = toSVGLinearGradientElement(current);
|
| + if (!attributes.hasY1() && element->hasAttribute(SVGNames::y1Attr))
|
| + attributes.setY1(linear->y1()->currentValue());
|
|
|
| - if (!attributes.hasX1() && current->hasAttribute(SVGNames::x1Attr))
|
| - attributes.setX1(linear->x1()->currentValue());
|
| + if (!attributes.hasX2() && element->hasAttribute(SVGNames::x2Attr))
|
| + attributes.setX2(linear->x2()->currentValue());
|
|
|
| - if (!attributes.hasY1() && current->hasAttribute(SVGNames::y1Attr))
|
| - attributes.setY1(linear->y1()->currentValue());
|
| + if (!attributes.hasY2() && element->hasAttribute(SVGNames::y2Attr))
|
| + attributes.setY2(linear->y2()->currentValue());
|
| + }
|
| +}
|
|
|
| - if (!attributes.hasX2() && current->hasAttribute(SVGNames::x2Attr))
|
| - attributes.setX2(linear->x2()->currentValue());
|
| +bool SVGLinearGradientElement::collectGradientAttributes(LinearGradientAttributes& attributes)
|
| +{
|
| + if (!renderer())
|
| + return false;
|
|
|
| - if (!attributes.hasY2() && current->hasAttribute(SVGNames::y2Attr))
|
| - attributes.setY2(linear->y2()->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::linearGradientTag) || refNode->hasTagName(SVGNames::radialGradientTag))) {
|
| + if (refNode && isSVGGradientElement(*refNode)) {
|
| current = toSVGGradientElement(refNode);
|
|
|
| // Cycle detection
|
| - if (processedGradients.contains(current)) {
|
| - current = 0;
|
| - break;
|
| - }
|
| -
|
| - isLinear = current->hasTagName(SVGNames::linearGradientTag);
|
| - } else
|
| - current = 0;
|
| + if (processedGradients.contains(current))
|
| + return true;
|
| +
|
| + if (!current->renderer())
|
| + return false;
|
| +
|
| + setGradientAttributes(current, attributes, current->hasTagName(SVGNames::linearGradientTag));
|
| + processedGradients.add(current);
|
| + } else {
|
| + return true;
|
| + }
|
| }
|
|
|
| - return true;
|
| + ASSERT_NOT_REACHED();
|
| + return false;
|
| }
|
|
|
| bool SVGLinearGradientElement::selfHasRelativeLengths() const
|
|
|