summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/RenderSVGResource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/rendering/RenderSVGResource.cpp')
-rw-r--r--WebCore/rendering/RenderSVGResource.cpp111
1 files changed, 12 insertions, 99 deletions
diff --git a/WebCore/rendering/RenderSVGResource.cpp b/WebCore/rendering/RenderSVGResource.cpp
index b4f499e..9c89d3c 100644
--- a/WebCore/rendering/RenderSVGResource.cpp
+++ b/WebCore/rendering/RenderSVGResource.cpp
@@ -26,28 +26,13 @@
#if ENABLE(SVG)
#include "RenderSVGResource.h"
-#include "RenderSVGResourceClipper.h"
#include "RenderSVGResourceContainer.h"
-#include "RenderSVGResourceFilter.h"
-#include "RenderSVGResourceMarker.h"
-#include "RenderSVGResourceMasker.h"
#include "RenderSVGResourceSolidColor.h"
+#include "SVGResources.h"
#include "SVGURIReference.h"
namespace WebCore {
-static inline void registerPendingResource(const AtomicString& id, const SVGPaint::SVGPaintType& paintType, const RenderObject* object)
-{
- if (paintType != SVGPaint::SVG_PAINTTYPE_URI)
- return;
-
- SVGElement* svgElement = static_cast<SVGElement*>(object->node());
- ASSERT(svgElement);
- ASSERT(svgElement->isStyled());
-
- object->document()->accessSVGExtensions()->addPendingResource(id, static_cast<SVGStyledElement*>(svgElement));
-}
-
inline void RenderSVGResource::adjustColorForPseudoRules(const RenderStyle* style, bool useFillPaint, Color& color)
{
if (style->insideLink() != InsideVisitedLink)
@@ -69,7 +54,7 @@ inline void RenderSVGResource::adjustColorForPseudoRules(const RenderStyle* styl
}
// FIXME: This method and strokePaintingResource() should be refactored, to share even more code
-RenderSVGResource* RenderSVGResource::fillPaintingResource(const RenderObject* object, const RenderStyle* style)
+RenderSVGResource* RenderSVGResource::fillPaintingResource(RenderObject* object, const RenderStyle* style)
{
ASSERT(object);
ASSERT(style);
@@ -84,13 +69,9 @@ RenderSVGResource* RenderSVGResource::fillPaintingResource(const RenderObject* o
RenderSVGResource* fillPaintingResource = 0;
SVGPaint::SVGPaintType paintType = fillPaint->paintType();
- if (paintType == SVGPaint::SVG_PAINTTYPE_URI
- || paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR) {
- AtomicString id(SVGURIReference::getTarget(fillPaint->uri()));
- fillPaintingResource = getRenderSVGResourceContainerById(object->document(), id);
-
- if (!fillPaintingResource)
- registerPendingResource(id, paintType, object);
+ if (paintType == SVGPaint::SVG_PAINTTYPE_URI || paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR) {
+ if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object))
+ fillPaintingResource = resources->fill();
}
if (paintType != SVGPaint::SVG_PAINTTYPE_URI && !fillPaintingResource) {
@@ -122,7 +103,7 @@ RenderSVGResource* RenderSVGResource::fillPaintingResource(const RenderObject* o
return fillPaintingResource;
}
-RenderSVGResource* RenderSVGResource::strokePaintingResource(const RenderObject* object, const RenderStyle* style)
+RenderSVGResource* RenderSVGResource::strokePaintingResource(RenderObject* object, const RenderStyle* style)
{
ASSERT(object);
ASSERT(style);
@@ -138,13 +119,9 @@ RenderSVGResource* RenderSVGResource::strokePaintingResource(const RenderObject*
FloatRect objectBoundingBox = object->objectBoundingBox();
SVGPaint::SVGPaintType paintType = strokePaint->paintType();
- if (!objectBoundingBox.isEmpty()
- && (paintType == SVGPaint::SVG_PAINTTYPE_URI || paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR)) {
- AtomicString id(SVGURIReference::getTarget(strokePaint->uri()));
- strokePaintingResource = getRenderSVGResourceContainerById(object->document(), id);
-
- if (!strokePaintingResource)
- registerPendingResource(id, paintType, object);
+ if (!objectBoundingBox.isEmpty() && (paintType == SVGPaint::SVG_PAINTTYPE_URI || paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR)) {
+ if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object))
+ strokePaintingResource = resources->stroke();
}
if (paintType != SVGPaint::SVG_PAINTTYPE_URI && !strokePaintingResource) {
@@ -184,72 +161,6 @@ RenderSVGResourceSolidColor* RenderSVGResource::sharedSolidPaintingResource()
return s_sharedSolidPaintingResource;
}
-void RenderSVGResource::markForLayoutAndResourceInvalidation(RenderObject* object, bool needsBoundariesUpdate)
-{
- ASSERT(object);
- ASSERT(object->node());
- ASSERT(object->node()->isSVGElement());
-
- // Eventually mark the renderer needing a boundaries update
- if (needsBoundariesUpdate)
- object->setNeedsBoundariesUpdate();
-
- markForLayoutAndParentResourceInvalidation(object);
-}
-
-static inline void invalidatePaintingResource(SVGPaint* paint, RenderObject* object)
-{
- ASSERT(paint);
-
- SVGPaint::SVGPaintType paintType = paint->paintType();
- if (paintType != SVGPaint::SVG_PAINTTYPE_URI && paintType != SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR)
- return;
-
- AtomicString id(SVGURIReference::getTarget(paint->uri()));
- if (RenderSVGResourceContainer* paintingResource = getRenderSVGResourceContainerById(object->document(), id))
- paintingResource->invalidateClient(object);
-}
-
-void RenderSVGResource::invalidateAllResourcesOfRenderer(RenderObject* object)
-{
- ASSERT(object);
- ASSERT(object->style());
-
- Document* document = object->document();
- ASSERT(document);
-
- const SVGRenderStyle* svgStyle = object->style()->svgStyle();
- ASSERT(svgStyle);
-
- // Masker
- if (RenderSVGResourceMasker* masker = getRenderSVGResourceById<RenderSVGResourceMasker>(document, svgStyle->maskerResource()))
- masker->invalidateClient(object);
-
- // Clipper
- if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById<RenderSVGResourceClipper>(document, svgStyle->clipperResource()))
- clipper->invalidateClient(object);
-
- // Filter
-#if ENABLE(FILTERS)
- if (RenderSVGResourceFilter* filter = getRenderSVGResourceById<RenderSVGResourceFilter>(document, svgStyle->filterResource()))
- filter->invalidateClient(object);
-#endif
-
- // Markers
- if (RenderSVGResourceMarker* startMarker = getRenderSVGResourceById<RenderSVGResourceMarker>(document, svgStyle->markerStartResource()))
- startMarker->invalidateClient(object);
- if (RenderSVGResourceMarker* midMarker = getRenderSVGResourceById<RenderSVGResourceMarker>(document, svgStyle->markerMidResource()))
- midMarker->invalidateClient(object);
- if (RenderSVGResourceMarker* endMarker = getRenderSVGResourceById<RenderSVGResourceMarker>(document, svgStyle->markerEndResource()))
- endMarker->invalidateClient(object);
-
- // Gradients/Patterns
- if (svgStyle->hasFill())
- invalidatePaintingResource(svgStyle->fillPaint(), object);
- if (svgStyle->hasStroke())
- invalidatePaintingResource(svgStyle->strokePaint(), object);
-}
-
void RenderSVGResource::markForLayoutAndParentResourceInvalidation(RenderObject* object, bool needsLayout)
{
ASSERT(object);
@@ -259,8 +170,10 @@ void RenderSVGResource::markForLayoutAndParentResourceInvalidation(RenderObject*
// Invalidate resources in ancestor chain, if needed.
RenderObject* current = object->parent();
while (current) {
- if (current->isSVGResourceContainer())
+ if (current->isSVGResourceContainer()) {
current->toRenderSVGResourceContainer()->invalidateClients();
+ break;
+ }
current = current->parent();
}