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

Unified Diff: Source/core/svg/SVGRadialGradientElement.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
« no previous file with comments | « Source/core/svg/SVGRadialGradientElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGRadialGradientElement.cpp
diff --git a/Source/core/svg/SVGRadialGradientElement.cpp b/Source/core/svg/SVGRadialGradientElement.cpp
index d8fe2a87533664771aa6a0172e1ccf679ad55592..147547ef57361766f69ee3131e5abe3da9f60097 100644
--- a/Source/core/svg/SVGRadialGradientElement.cpp
+++ b/Source/core/svg/SVGRadialGradientElement.cpp
@@ -134,10 +134,10 @@ bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttribute
{
HashSet<SVGGradientElement*> processedGradients;
- bool isRadial = true;
SVGGradientElement* current = this;
+ setAttributeAnimatedLength(current, attributes);
- while (current) {
+ do {
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.
return false;
@@ -159,33 +159,11 @@ bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttribute
attributes.setStops(stops);
}
- if (isRadial) {
- SVGRadialGradientElement* radial = toSVGRadialGradientElement(current);
-
- if (!attributes.hasCx() && current->hasAttribute(SVGNames::cxAttr))
- attributes.setCx(radial->cx()->currentValue());
-
- if (!attributes.hasCy() && current->hasAttribute(SVGNames::cyAttr))
- attributes.setCy(radial->cy()->currentValue());
-
- if (!attributes.hasR() && current->hasAttribute(SVGNames::rAttr))
- attributes.setR(radial->r()->currentValue());
-
- if (!attributes.hasFx() && current->hasAttribute(SVGNames::fxAttr))
- attributes.setFx(radial->fx()->currentValue());
-
- if (!attributes.hasFy() && current->hasAttribute(SVGNames::fyAttr))
- attributes.setFy(radial->fy()->currentValue());
-
- if (!attributes.hasFr() && current->hasAttribute(SVGNames::frAttr))
- attributes.setFr(radial->fr()->currentValue());
- }
-
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
// 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
@@ -194,10 +172,12 @@ bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttribute
break;
}
- isRadial = current->hasTagName(SVGNames::radialGradientTag);
- } else
+ if (current->hasTagName(SVGNames::radialGradientTag))
+ setAttributeAnimatedLength(current, attributes);
+ } else {
current = 0;
- }
+ }
+ } while (current);
// Handle default values for fx/fy
if (!attributes.hasFx())
@@ -208,6 +188,29 @@ bool SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttribute
return true;
}
+void SVGRadialGradientElement::setAttributeAnimatedLength(SVGGradientElement* element, RadialGradientAttributes& attributes)
+{
+ SVGRadialGradientElement* radial = toSVGRadialGradientElement(element);
+
+ if (!attributes.hasCx() && element->hasAttribute(SVGNames::cxAttr))
+ attributes.setCx(radial->cx()->currentValue());
+
+ if (!attributes.hasCy() && element->hasAttribute(SVGNames::cyAttr))
+ attributes.setCy(radial->cy()->currentValue());
+
+ if (!attributes.hasR() && element->hasAttribute(SVGNames::rAttr))
+ attributes.setR(radial->r()->currentValue());
+
+ if (!attributes.hasFx() && element->hasAttribute(SVGNames::fxAttr))
+ attributes.setFx(radial->fx()->currentValue());
+
+ if (!attributes.hasFy() && element->hasAttribute(SVGNames::fyAttr))
+ attributes.setFy(radial->fy()->currentValue());
+
+ if (!attributes.hasFr() && element->hasAttribute(SVGNames::frAttr))
+ attributes.setFr(radial->fr()->currentValue());
+}
+
bool SVGRadialGradientElement::selfHasRelativeLengths() const
{
return m_cx->currentValue()->isRelative()
« no previous file with comments | « Source/core/svg/SVGRadialGradientElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698