Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(689)

Unified Diff: Source/core/svg/SVGLinearGradientElement.cpp

Issue 135913002: Do refactor in collectGradientAttributes() and renderStyleForLengthResolve() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/svg/SVGLinearGradientElement.cpp
diff --git a/Source/core/svg/SVGLinearGradientElement.cpp b/Source/core/svg/SVGLinearGradientElement.cpp
index 19df4d50b46b7eedc0f0ac5a5057ca7f93c6c38b..15c80bd4cd8c78fdd7938a9e1cb1a0ddfefb89b3 100644
--- a/Source/core/svg/SVGLinearGradientElement.cpp
+++ b/Source/core/svg/SVGLinearGradientElement.cpp
@@ -119,10 +119,10 @@ bool SVGLinearGradientElement::collectGradientAttributes(LinearGradientAttribute
{
HashSet<SVGGradientElement*> processedGradients;
- bool isLinear = true;
SVGGradientElement* current = this;
+ setAttributeAnimatedLength(current, attributes);
- while (current) {
+ do {
if (!current->renderer())
return false;
@@ -144,27 +144,11 @@ bool SVGLinearGradientElement::collectGradientAttributes(LinearGradientAttribute
attributes.setStops(stops);
}
- if (isLinear) {
- SVGLinearGradientElement* linear = toSVGLinearGradientElement(current);
-
- if (!attributes.hasX1() && current->hasAttribute(SVGNames::x1Attr))
- attributes.setX1(linear->x1()->currentValue());
-
- if (!attributes.hasY1() && current->hasAttribute(SVGNames::y1Attr))
- attributes.setY1(linear->y1()->currentValue());
-
- if (!attributes.hasX2() && current->hasAttribute(SVGNames::x2Attr))
- attributes.setX2(linear->x2()->currentValue());
-
- if (!attributes.hasY2() && current->hasAttribute(SVGNames::y2Attr))
- attributes.setY2(linear->y2()->currentValue());
- }
-
processedGradients.add(current);
// 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
@@ -173,14 +157,33 @@ bool SVGLinearGradientElement::collectGradientAttributes(LinearGradientAttribute
break;
}
- isLinear = current->hasTagName(SVGNames::linearGradientTag);
- } else
+ if (current->hasTagName(SVGNames::linearGradientTag))
+ setAttributeAnimatedLength(current, attributes);
+ } else {
current = 0;
- }
+ }
+ } while (current);
return true;
}
+void SVGLinearGradientElement::setAttributeAnimatedLength(SVGGradientElement* element, LinearGradientAttributes& attributes)
+{
+ SVGLinearGradientElement* linear = toSVGLinearGradientElement(element);
+
+ if (!attributes.hasX1() && element->hasAttribute(SVGNames::x1Attr))
+ attributes.setX1(linear->x1()->currentValue());
+
+ if (!attributes.hasY1() && element->hasAttribute(SVGNames::y1Attr))
+ attributes.setY1(linear->y1()->currentValue());
+
+ if (!attributes.hasX2() && element->hasAttribute(SVGNames::x2Attr))
+ attributes.setX2(linear->x2()->currentValue());
+
+ if (!attributes.hasY2() && element->hasAttribute(SVGNames::y2Attr))
+ attributes.setY2(linear->y2()->currentValue());
+}
+
bool SVGLinearGradientElement::selfHasRelativeLengths() const
{
return m_x1->currentValue()->isRelative()

Powered by Google App Engine
This is Rietveld 408576698