Index: Source/core/svg/SVGUseElement.cpp |
diff --git a/Source/core/svg/SVGUseElement.cpp b/Source/core/svg/SVGUseElement.cpp |
index e7cc3c9764d4a14e751ec64036114680d44ae057..70cb02bab3a97d8b85f864076e6aafe3e7efde83 100644 |
--- a/Source/core/svg/SVGUseElement.cpp |
+++ b/Source/core/svg/SVGUseElement.cpp |
@@ -444,33 +444,46 @@ void SVGUseElement::toClipPath(Path& path) |
{ |
ASSERT(path.isEmpty()); |
+ const SVGGraphicsElement* element = targetGraphicsElementForClipping(); |
+ |
+ if (!element) |
+ return; |
+ |
+ if (!isDirectReference(*element)) { |
+ // Spec: Indirect references are an error (14.3.5) |
+ document().accessSVGExtensions().reportError("Not allowed to use indirect reference in <clip-path>"); |
+ } else 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; |
- SVGElement& element = toSVGElement(*n); |
+ return nullptr; |
+ SVGElement& element = toSVGElement(*n); |
if (element.isSVGGraphicsElement()) { |
- if (!isDirectReference(element)) { |
- // Spec: Indirect references are an error (14.3.5) |
- document().accessSVGExtensions().reportError("Not allowed to use indirect reference in <clip-path>"); |
- } 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()); |
- } |
+ if (isSVGTextElement(element) || isSVGTSpanElement(element) || element.isSVGGeometryElement()) |
pdr.
2015/06/17 04:42:13
Lets add a link to the spec here.
// Spec: "If a <
|
+ return &toSVGGraphicsElement(element); |
} |
+ |
+ return nullptr; |
} |
LayoutObject* SVGUseElement::layoutObjectClipChild() const |
pdr.
2015/06/17 04:42:13
This function is pretty simple now, can you move t
|
{ |
- if (Node* n = userAgentShadowRoot()->firstChild()) { |
- if (n->isSVGElement() && isDirectReference(toSVGElement(*n))) |
- return n->layoutObject(); |
- } |
+ const SVGGraphicsElement* element = targetGraphicsElementForClipping(); |
- return nullptr; |
+ if (!element) |
+ return nullptr; |
+ |
+ return element->layoutObject(); |
} |
bool SVGUseElement::buildShadowTree(SVGElement* target, SVGElement* targetInstance, bool foundUse) |