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

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

Issue 1154853007: Move toClipPath to SVGGeometryElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Draft 12 Created 5 years, 6 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/SVGUseElement.cpp
diff --git a/Source/core/svg/SVGUseElement.cpp b/Source/core/svg/SVGUseElement.cpp
index e56f7c78d65ffa83f4748ca4b87916614e959905..ccd58d2b4e23fe0c4655482917cbad093eb0c5df 100644
--- a/Source/core/svg/SVGUseElement.cpp
+++ b/Source/core/svg/SVGUseElement.cpp
@@ -444,30 +444,41 @@ void SVGUseElement::toClipPath(Path& path)
{
ASSERT(path.isEmpty());
+ const SVGGraphicsElement* element = targetGraphicsElementForClipping();
+
+ if (!element)
+ return;
+
+ if (element->isSVGGeometryElement()) {
+ toSVGGeometryElement(*element).toClipPath(path);
+ // FIXME: Avoid manual resolution of x/y here. Its potentially harmful.
+ SVGLengthContext lengthContext(this);
+ path.translate(FloatSize(m_x->currentValue()->value(lengthContext), m_y->currentValue()->value(lengthContext)));
+ path.transform(calculateAnimatedLocalTransform());
+ }
+}
+
+SVGGraphicsElement* SVGUseElement::targetGraphicsElementForClipping() const
+{
Node* n = userAgentShadowRoot()->firstChild();
if (!n || !n->isSVGElement())
- return;
+ return nullptr;
+
SVGElement& element = toSVGElement(*n);
if (element.isSVGGraphicsElement()) {
fs 2015/06/22 10:57:44 Suggest you turn this into the negation to flatten
+ // Spec: "If a <use> element is a child of a clipPath element, it must directly
+ // reference <path>, <text> or basic shapes elements. Indirect references are an
+ // error and the clipPath element must be ignored."
+ // http://dev.w3.org/fxtf/css-masking-1/#the-clip-path
if (!isDirectReference(element)) {
+ if (isSVGClipPathElement(element))
fs 2015/06/22 10:57:44 There's nothing special with <clipPath> in this ca
+ return nullptr;
// Spec: Indirect references are an error (14.3.5)
document().accessSVGExtensions().reportError("Not allowed to use indirect reference in <clip-path>");
fs 2015/06/22 10:57:44 Add return after this (or the method will still re
- } else {
- toSVGGraphicsElement(element).toClipPath(path);
- // FIXME: Avoid manual resolution of x/y here. Its potentially harmful.
- SVGLengthContext lengthContext(this);
- path.translate(FloatSize(m_x->currentValue()->value(lengthContext), m_y->currentValue()->value(lengthContext)));
- path.transform(calculateAnimatedLocalTransform());
}
- }
-}
-LayoutObject* SVGUseElement::layoutObjectClipChild() const
-{
- if (Node* n = userAgentShadowRoot()->firstChild()) {
- if (n->isSVGElement() && isDirectReference(toSVGElement(*n)))
- return n->layoutObject();
+ return &toSVGGraphicsElement(element);
}
return nullptr;
« Source/core/layout/svg/LayoutSVGResourceClipper.cpp ('K') | « Source/core/svg/SVGUseElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698