Bug 242420

Summary: ☂️ avoid invalidating SVG resources when referencing element changes layout
Product: WebKit Reporter: Cameron McCormack (:heycam) <heycam>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: sabouhallawa, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 242778, 242421, 242423    
Bug Blocks:    

Description Cameron McCormack (:heycam) 2022-07-06 21:26:02 PDT
In SVG RenderObject layout methods, we call SVGResourcesCache::clientLayoutChanged if any layout was performed.  Sometimes this is unnecessary work, as the specific changes that were made during layout do not affect the data that the SVGResourceContainer has cached.  In the dependent bugs I'll file under here, I'll make all of the SVG resource types able to respond to changes on referencing element lazily, without needing to eagerly remove and recreate all resources.
Comment 1 Cameron McCormack (:heycam) 2022-07-06 21:29:04 PDT
The pattern I will use for all of the resource classes is to store the dependencies that came from the referencing RenderElement (such as its object bounding box) on the data object we store in the HashMap of the resource container object.  Then, under applyResource, we compute those dependencies and compare them against the cached values.  If they differ, we invalidate the cached values (such as the RefPtr<Gradient> of a gradient resource or the RefPtr<ImageBuffer> of a mask resource) and recompute them.
Comment 2 Radar WebKit Bug Importer 2022-07-13 21:26:15 PDT
<rdar://problem/96991415>