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

Unified Diff: third_party/WebKit/Source/core/svg/SVGGradientElement.cpp

Issue 2741993002: Move common gradient attribute collection to SVGGradientElement (Closed)
Patch Set: Rebase; fix semantics on find cycle Created 3 years, 9 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: third_party/WebKit/Source/core/svg/SVGGradientElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGGradientElement.cpp b/third_party/WebKit/Source/core/svg/SVGGradientElement.cpp
index 74edf376486425cb7fe6a240841fc0f06e34ab39..58ce0f1b20401f78560d3949320d9678bd6f2f82 100644
--- a/third_party/WebKit/Source/core/svg/SVGGradientElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGGradientElement.cpp
@@ -25,6 +25,7 @@
#include "core/dom/ElementTraversal.h"
#include "core/dom/StyleChangeReason.h"
#include "core/layout/svg/LayoutSVGResourceContainer.h"
+#include "core/svg/GradientAttributes.h"
#include "core/svg/SVGStopElement.h"
#include "core/svg/SVGTransformList.h"
@@ -119,7 +120,37 @@ void SVGGradientElement::childrenChanged(const ChildrenChange& change) {
LayoutInvalidationReason::ChildChanged);
}
-Vector<Gradient::ColorStop> SVGGradientElement::buildStops() {
+void SVGGradientElement::collectCommonAttributes(
+ GradientAttributes& attributes) const {
+ if (!attributes.hasSpreadMethod() && spreadMethod()->isSpecified())
+ attributes.setSpreadMethod(spreadMethod()->currentValue()->enumValue());
+
+ if (!attributes.hasGradientUnits() && gradientUnits()->isSpecified())
+ attributes.setGradientUnits(gradientUnits()->currentValue()->enumValue());
+
+ if (!attributes.hasGradientTransform() &&
+ hasTransform(SVGElement::ExcludeMotionTransform)) {
+ attributes.setGradientTransform(
+ calculateTransform(SVGElement::ExcludeMotionTransform));
+ }
+
+ if (!attributes.hasStops()) {
+ const Vector<Gradient::ColorStop>& stops(buildStops());
+ if (!stops.isEmpty())
+ attributes.setStops(stops);
+ }
+}
+
+const SVGGradientElement* SVGGradientElement::referencedElement() const {
+ // Respect xlink:href, take attributes from referenced element.
+ Element* referencedElement =
+ targetElementFromIRIString(hrefString(), treeScope());
+ if (!referencedElement || !isSVGGradientElement(*referencedElement))
+ return nullptr;
+ return toSVGGradientElement(referencedElement);
+}
+
+Vector<Gradient::ColorStop> SVGGradientElement::buildStops() const {
Vector<Gradient::ColorStop> stops;
float previousOffset = 0.0f;

Powered by Google App Engine
This is Rietveld 408576698