diff options
author | Ben Murdoch <benm@google.com> | 2010-07-22 15:37:06 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-07-27 10:20:25 +0100 |
commit | 967717af5423377c967781471ee106e2bb4e11c8 (patch) | |
tree | 1e701dc0a12f7f07cce1df4a7681717de77a211b /WebCore/rendering/RenderSVGResourceContainer.h | |
parent | dcc30a9fca45f634b1d3a12b276d3a0ccce99fc3 (diff) | |
download | external_webkit-967717af5423377c967781471ee106e2bb4e11c8.zip external_webkit-967717af5423377c967781471ee106e2bb4e11c8.tar.gz external_webkit-967717af5423377c967781471ee106e2bb4e11c8.tar.bz2 |
Merge WebKit at r63859 : Initial merge by git.
Change-Id: Ie8096c63ec7c991c9a9cba8bdd9c3b74a3b8ed62
Diffstat (limited to 'WebCore/rendering/RenderSVGResourceContainer.h')
-rw-r--r-- | WebCore/rendering/RenderSVGResourceContainer.h | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/WebCore/rendering/RenderSVGResourceContainer.h b/WebCore/rendering/RenderSVGResourceContainer.h index 54617bb..5f1c828 100644 --- a/WebCore/rendering/RenderSVGResourceContainer.h +++ b/WebCore/rendering/RenderSVGResourceContainer.h @@ -26,6 +26,7 @@ #include "SVGStyledTransformableElement.h" #include "RenderSVGResource.h" +#include "RenderSVGShadowTreeRootContainer.h" namespace WebCore { @@ -35,8 +36,7 @@ public: RenderSVGResourceContainer(SVGStyledElement* node) : RenderSVGHiddenContainer(node) , RenderSVGResource() - // FIXME: Should probably be using getIdAttribute rather than idForStyleResolution. - , m_id(node->hasID() ? node->idForStyleResolution() : nullAtom) + , m_id(node->hasID() ? node->getIdAttribute() : nullAtom) { ASSERT(node->document()); node->document()->accessSVGExtensions()->addResource(m_id, this); @@ -57,9 +57,7 @@ public: // Remove old id, that is guaranteed to be present in cache extensions->removeResource(m_id); - - // FIXME: Should probably be using getIdAttribute rather than idForStyleResolution. - m_id = node()->hasID() ? static_cast<Element*>(node())->idForStyleResolution() : nullAtom; + m_id = static_cast<Element*>(node())->getIdAttribute(); // It's possible that an element is referencing us with the new id, and has to be notified that we're existing now if (extensions->isPendingResource(m_id)) { @@ -84,7 +82,8 @@ public: virtual bool drawsContents() { return false; } virtual RenderSVGResourceContainer* toRenderSVGResourceContainer() { return this; } - + virtual bool childElementReferencesResource(const SVGRenderStyle*, const String&) const { return false; } + static AffineTransform transformOnNonScalingStroke(RenderObject* object, const AffineTransform resourceTransform) { if (!object->isRenderPath()) @@ -96,6 +95,48 @@ public: return transform; } + bool containsCyclicReference(const Node* startNode) const + { + ASSERT(startNode->document()); + + for (Node* node = startNode->firstChild(); node; node = node->nextSibling()) { + if (!node->isSVGElement()) + continue; + + RenderObject* renderer = node->renderer(); + if (!renderer) + continue; + + RenderStyle* style = renderer->style(); + if (!style) + continue; + + const SVGRenderStyle* svgStyle = style->svgStyle(); + ASSERT(svgStyle); + + // Let the class inheriting from us decide whether the child element references ourselves. + if (childElementReferencesResource(svgStyle, m_id)) + return true; + + // Dive into shadow tree to check for cycles there. + if (node->hasTagName(SVGNames::useTag)) { + ASSERT(renderer->isSVGShadowTreeRootContainer()); + if (Node* shadowRoot = static_cast<RenderSVGShadowTreeRootContainer*>(renderer)->rootElement()) { + if (containsCyclicReference(shadowRoot)) + return true; + } + + } + + if (node->hasChildNodes()) { + if (containsCyclicReference(node)) + return true; + } + } + + return false; + } + private: AtomicString m_id; }; |