Bug 87573 - Avoid updateFromElement() usage in SVG
Summary: Avoid updateFromElement() usage in SVG
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nikolas Zimmermann
URL:
Keywords:
Depends on:
Blocks: 87572
  Show dependency treegraph
 
Reported: 2012-05-25 23:03 PDT by Nikolas Zimmermann
Modified: 2012-05-26 02:44 PDT (History)
3 users (show)

See Also:


Attachments
Patch (17.46 KB, patch)
2012-05-25 23:09 PDT, Nikolas Zimmermann
no flags Details | Formatted Diff | Diff
Patch v2 (17.85 KB, patch)
2012-05-26 01:09 PDT, Nikolas Zimmermann
rniwa: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>