RenderObject* SVGUseElement::rendererClipChild() const { Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : 0; if (!n) return 0; if (n->isSVGElement() && isDirectReference(n)) return static_cast<SVGElement*>(n)->renderer(); return 0; }
RenderElement* SVGUseElement::rendererClipChild() const { if (!m_targetElementInstance) return nullptr; auto* element = m_targetElementInstance->shadowTreeElement(); if (!element) return nullptr; if (!isDirectReference(*element)) return nullptr; return element->renderer(); }
Path SVGUseElement::toClipPath() const { if (!m_shadowTreeRootElement) const_cast<SVGUseElement*>(this)->buildPendingResource(); Node* n = m_shadowTreeRootElement->firstChild(); if (n->isSVGElement() && static_cast<SVGElement*>(n)->isStyledTransformable()) { if (!isDirectReference(n)) // Spec: Indirect references are an error (14.3.5) document()->accessSVGExtensions()->reportError("Not allowed to use indirect reference in <clip-path>"); else return static_cast<SVGStyledTransformableElement*>(n)->toClipPath(); } return Path(); }
void SVGUseElement::toClipPath(Path& path) const { ASSERT(path.isEmpty()); Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : 0; if (!n) return; if (n->isSVGElement() && static_cast<SVGElement*>(n)->isStyledTransformable()) { if (!isDirectReference(n)) // Spec: Indirect references are an error (14.3.5) document()->accessSVGExtensions()->reportError("Not allowed to use indirect reference in <clip-path>"); else { static_cast<SVGStyledTransformableElement*>(n)->toClipPath(path); path.translate(FloatSize(x().value(this), y().value(this))); path.transform(animatedLocalTransform()); } } }
void SVGUseElement::toClipPath(Path& path) { ASSERT(path.isEmpty()); Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : 0; if (!n) return; if (n->isSVGElement() && toSVGElement(*n).isSVGGraphicsElement()) { if (!isDirectReference(toSVGElement(*n))) { // Spec: Indirect references are an error (14.3.5) document().accessSVGExtensions()->reportError("Not allowed to use indirect reference in <clip-path>"); } else { toSVGGraphicsElement(*n).toClipPath(path); // FIXME: Avoid manual resolution of x/y here. Its potentially harmful. SVGLengthContext lengthContext(this); path.translate(FloatSize(x().value(lengthContext), y().value(lengthContext))); path.transform(animatedLocalTransform()); } } }
SVGGraphicsElement* SVGUseElement::targetGraphicsElementForClipping() const { Node* n = userAgentShadowRoot()->firstChild(); if (!n || !n->isSVGElement()) return nullptr; SVGElement& element = toSVGElement(*n); if (!element.isSVGGraphicsElement()) return nullptr; // 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)) { // Spec: Indirect references are an error (14.3.5) document().accessSVGExtensions().reportError("Not allowed to use indirect reference in <clip-path>"); return nullptr; } return &toSVGGraphicsElement(element); }