Index: Source/WebCore/rendering/svg/SVGResourcesCache.cpp |
=================================================================== |
--- Source/WebCore/rendering/svg/SVGResourcesCache.cpp (revision 119626) |
+++ Source/WebCore/rendering/svg/SVGResourcesCache.cpp (working copy) |
@@ -128,25 +128,45 @@ |
void SVGResourcesCache::clientStyleChanged(RenderObject* renderer, StyleDifference diff, const RenderStyle* newStyle) |
{ |
ASSERT(renderer); |
- if (diff == StyleDifferenceEqual) |
+ if (diff == StyleDifferenceEqual || !renderer->parent()) |
return; |
// In this case the proper SVGFE*Element will decide whether the modified CSS properties require a relayout or repaint. |
if (renderer->isSVGResourceFilterPrimitive() && diff == StyleDifferenceRepaint) |
return; |
- clientUpdatedFromElement(renderer, newStyle); |
+ // Dynamic changes of CSS properties like 'clip-path' may require us to recompute the associated resources for a renderer. |
+ // FIXME: Avoid passing in a useless StyleDifference, but instead compare oldStyle/newStyle to see which resources changed |
+ // to be able to selectively rebuild individual resources, instead of all of them. |
+ SVGResourcesCache* cache = resourcesCacheFromRenderObject(renderer); |
+ cache->removeResourcesFromRenderObject(renderer); |
+ cache->addResourcesFromRenderObject(renderer, newStyle); |
+ |
+ RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer, false); |
} |
-void SVGResourcesCache::clientUpdatedFromElement(RenderObject* renderer, const RenderStyle* newStyle) |
+static inline bool rendererCanHaveResources(RenderObject* renderer) |
{ |
ASSERT(renderer); |
ASSERT(renderer->parent()); |
+ return renderer->node() && !renderer->isSVGInlineText(); |
+} |
+void SVGResourcesCache::clientWasAddedToTree(RenderObject* renderer, const RenderStyle* newStyle) |
+{ |
+ if (!rendererCanHaveResources(renderer)) |
+ return; |
SVGResourcesCache* cache = resourcesCacheFromRenderObject(renderer); |
- cache->removeResourcesFromRenderObject(renderer); |
cache->addResourcesFromRenderObject(renderer, newStyle); |
+} |
+void SVGResourcesCache::clientWillBeRemovedFromTree(RenderObject* renderer) |
+{ |
+ if (!rendererCanHaveResources(renderer)) |
+ return; |
+ SVGResourcesCache* cache = resourcesCacheFromRenderObject(renderer); |
+ cache->removeResourcesFromRenderObject(renderer); |
+ |
RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer, false); |
} |