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; |