Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: a36097add8b01a89a6cac53320fb09eec72f24ff
https://github.com/WebKit/WebKit/commit/a36097add8b01a89a6cac53320fb09eec72f24ff
Author: Nikolas Zimmermann <[email protected]>
Date: 2026-07-02 (Thu, 02 Jul 2026)
Changed paths:
M Source/WebCore/rendering/ReferencedSVGResources.cpp
M Source/WebCore/rendering/ReferencedSVGResources.h
M Source/WebCore/rendering/RenderElement.cpp
M Source/WebCore/rendering/RenderElement.h
M Source/WebCore/rendering/RenderLayerModelObject.cpp
M Source/WebCore/rendering/RenderLayerModelObject.h
M Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp
M Source/WebCore/svg/SVGElement.cpp
Log Message:
-----------
[LBSE] Cache the resolved SVG fill and stroke paint server
https://bugs.webkit.org/show_bug.cgi?id=318363
Reviewed by Rob Buis.
Resolving the url(#id) fill or stroke paint server from style on every paint
re-parses the URL string and looks the element up by id, which is not cheap.
Cache the resolved RenderSVGResourcePaintServer on ReferencedSVGResources, the
SVG-only object in rare data that already tracks a renderer's fill and stroke
references. It exists whenever a paint server is referenced and the weak pointer
clears itself if the paint server is destroyed. Only the renderer's own style
is cached. A foreign style passed by the text selection or decoration painters
points at a different paint server, so it resolves fresh and never reads or
writes the cache.
Drop the cache whenever it can go stale. styleDidChange clears it when fill or
stroke changes. resourceChanged clears it when the referenced gradient or
pattern changes. To make that work under the layer-based engine, dispatch
idChanged to RenderSVGResourceContainer, which was previously only wired up
for the legacy containers, and have it notify existing clients so a renamed
resource repaints properly.
Covered by existing tests.
* Source/WebCore/rendering/ReferencedSVGResources.cpp:
(WebCore::CSSSVGResourceElementClient::resourceChanged):
(WebCore::ReferencedSVGResources::cachedFillPaintServer const):
(WebCore::ReferencedSVGResources::cachedStrokePaintServer const):
(WebCore::ReferencedSVGResources::setCachedPaintServer):
* Source/WebCore/rendering/ReferencedSVGResources.h:
(WebCore::ReferencedSVGResources::invalidatePaintServerCache):
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::referencedSVGResources const):
* Source/WebCore/rendering/RenderElement.h:
* Source/WebCore/rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::styleDidChange):
(WebCore::RenderLayerModelObject::svgPaintServerResourceFromStyle const):
(WebCore::RenderLayerModelObject::svgFillPaintServerResourceFromStyle const):
(WebCore::RenderLayerModelObject::svgStrokePaintServerResourceFromStyle const):
(WebCore::RenderLayerModelObject::invalidateSVGPaintServerCache const):
* Source/WebCore/rendering/RenderLayerModelObject.h:
* Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp:
(WebCore::RenderSVGResourceContainer::idChanged):
* Source/WebCore/svg/SVGElement.cpp:
(WebCore::SVGElement::svgAttributeChanged):
Canonical link: https://commits.webkit.org/316428@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications