diff options
Diffstat (limited to 'WebCore/rendering/RenderSVGResource.h')
-rw-r--r-- | WebCore/rendering/RenderSVGResource.h | 101 |
1 files changed, 32 insertions, 69 deletions
diff --git a/WebCore/rendering/RenderSVGResource.h b/WebCore/rendering/RenderSVGResource.h index 1665404..f14fa4a 100644 --- a/WebCore/rendering/RenderSVGResource.h +++ b/WebCore/rendering/RenderSVGResource.h @@ -22,64 +22,47 @@ #define RenderSVGResource_h #if ENABLE(SVG) -#include "FloatRect.h" -#include "RenderSVGHiddenContainer.h" +#include "SVGDocumentExtensions.h" namespace WebCore { enum RenderSVGResourceType { MaskerResourceType, MarkerResourceType, + PatternResourceType, + LinearGradientResourceType, + RadialGradientResourceType, + SolidColorResourceType, FilterResourceType, ClipperResourceType }; -class RenderSVGResource : public RenderSVGHiddenContainer { -public: - RenderSVGResource(SVGStyledElement* node) - : RenderSVGHiddenContainer(node) - , m_id(node->getIDAttribute()) - { - ASSERT(node->document()); - node->document()->accessSVGExtensions()->addResource(m_id, this); - } - - virtual ~RenderSVGResource() - { - ASSERT(node()); - ASSERT(node()->document()); - node()->document()->accessSVGExtensions()->removeResource(m_id); - } - - void idChanged() - { - ASSERT(node()); - ASSERT(node()->document()); - SVGDocumentExtensions* extensions = node()->document()->accessSVGExtensions(); - - // Remove old id, that is guaranteed to be present in cache - extensions->removeResource(m_id); +enum RenderSVGResourceMode { + ApplyToDefaultMode = 1 << 0, // used for all resources except gradient/pattern + ApplyToFillMode = 1 << 1, + ApplyToStrokeMode = 1 << 2, + ApplyToTextMode = 1 << 3 // used in combination with ApplyTo{Fill|Stroke}Mode +}; - m_id = static_cast<Element*>(node())->getIDAttribute(); +class FloatRect; +class GraphicsContext; +class RenderObject; +class RenderStyle; +class RenderSVGResourceSolidColor; - // 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)) { - OwnPtr<HashSet<SVGStyledElement*> > clients(extensions->removePendingResource(m_id)); - if (clients->isEmpty()) - return; +class RenderSVGResource { +public: + RenderSVGResource() { } + virtual ~RenderSVGResource() { } - HashSet<SVGStyledElement*>::const_iterator it = clients->begin(); - const HashSet<SVGStyledElement*>::const_iterator end = clients->end(); + virtual void invalidateClients() = 0; + virtual void invalidateClient(RenderObject*) = 0; - for (; it != end; ++it) { - if (RenderObject* renderer = (*it)->renderer()) - renderer->setNeedsLayout(true); - } - } + virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode) = 0; + virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short) { } + virtual FloatRect resourceBoundingBox(const FloatRect&) const = 0; - // Recache us with the new id - extensions->addResource(m_id, this); - } + virtual RenderSVGResourceType resourceType() const = 0; template<class Renderer> Renderer* cast() @@ -90,35 +73,15 @@ public: return 0; } - virtual RenderSVGResource* toRenderSVGResource() { return this; } - virtual bool isSVGResource() const { return true; } - virtual bool drawsContents() { return false; } - - virtual void invalidateClients() = 0; - virtual void invalidateClient(RenderObject*) = 0; - - virtual bool applyResource(RenderObject*, GraphicsContext*&) = 0; - virtual void postApplyResource(RenderObject*, GraphicsContext*&) { } - virtual FloatRect resourceBoundingBox(const FloatRect&) const = 0; - - virtual RenderSVGResourceType resourceType() const = 0; + // Helper utilities used in the render tree to access resources used for painting shapes/text (gradients & patterns only) + static RenderSVGResource* fillPaintingResource(const RenderObject*, const RenderStyle*); + static RenderSVGResource* strokePaintingResource(const RenderObject*, const RenderStyle*); + static RenderSVGResourceSolidColor* sharedSolidPaintingResource(); -private: - AtomicString m_id; +protected: + void markForLayoutAndResourceInvalidation(RenderObject*); }; -template<typename Renderer> -Renderer* getRenderSVGResourceById(Document* document, const AtomicString& id) -{ - if (id.isEmpty()) - return 0; - - if (RenderSVGResource* renderResource = document->accessSVGExtensions()->resourceById(id)) - return renderResource->cast<Renderer>(); - - return 0; -} - } #endif |