Bug 87573

Summary: Avoid updateFromElement() usage in SVG
Product: WebKit Reporter: Nikolas Zimmermann <zimmermann>
Component: SVGAssignee: Nikolas Zimmermann <zimmermann>
Status: RESOLVED FIXED    
Severity: Normal CC: eric, webkit.review.bot, zimmermann
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 87572    
Attachments:
Description Flags
Patch
none
Patch v2 rniwa: review+

Description Nikolas Zimmermann 2012-05-25 23:03:00 PDT
Avoid updateFromElement() usage in SVG.
Comment 1 Nikolas Zimmermann 2012-05-25 23:09:45 PDT
Created attachment 144195 [details]
Patch
Comment 2 Ryosuke Niwa 2012-05-25 23:49:09 PDT
Comment on attachment 144195 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=144195&action=review

> Source/WebCore/rendering/svg/RenderSVGModelObject.cpp:-119
> -void RenderSVGModelObject::updateFromElement()
> -{
> -    RenderObject::updateFromElement();
> -    SVGResourcesCache::clientUpdatedFromElement(this, style());
> -}
> -

Don't we need to add calls to clientWasAddedToTree and clientWillBeRemovedFromTree here?
RenderSVGShape, RenderSVGImage, etc... directly inherit from RenderSVGModelObject.
Comment 3 Nikolas Zimmermann 2012-05-26 01:09:38 PDT
Created attachment 144197 [details]
Patch v2
Comment 4 Nikolas Zimmermann 2012-05-26 01:10:14 PDT
(In reply to comment #2)
> Don't we need to add calls to clientWasAddedToTree and clientWillBeRemovedFromTree here?
> RenderSVGShape, RenderSVGImage, etc... directly inherit from RenderSVGModelObject.
As discussed on IRC, RenderSVGModelObject doesn't have children, so it doesn't need this logic.
Comment 5 Ryosuke Niwa 2012-05-26 02:06:23 PDT
Comment on attachment 144195 [details]
Patch

I think this refactoring is done right (had a lengthy discussion with WildFox on IRC)., and new approach makes the removal and addition of SVG resource much more apparent when constructing or destructing the render tree.
Comment 6 Ryosuke Niwa 2012-05-26 02:06:40 PDT
Comment on attachment 144197 [details]
Patch v2

View in context: https://bugs.webkit.org/attachment.cgi?id=144197&action=review

> Source/WebCore/rendering/svg/SVGResourcesCache.cpp:140
> -    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);
> +    SVGResourcesCache* cache = resourcesCacheFromRenderObject(renderer);
> +    cache->removeResourcesFromRenderObject(renderer);
> +    cache->addResourcesFromRenderObject(renderer, newStyle);

I think this function deserves a little clarifying why we would want to remove/add the resource here.
Comment 7 Nikolas Zimmermann 2012-05-26 02:08:12 PDT
(In reply to comment #5)
> (From update of attachment 144195 [details])
> I think this refactoring is done right (had a lengthy discussion with WildFox on IRC)., and new approach makes the removal and addition of SVG resource much more apparent when constructing or destructing the render tree.

Thanks! The discussion was very helpful. I left a new comment there:
    // 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.
Comment 8 Nikolas Zimmermann 2012-05-26 02:08:39 PDT
Committed r118608: <http://trac.webkit.org/changeset/118608>