Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c52f78ad2c4d402d423f696158ae8413d0bfef5f
      
https://github.com/WebKit/WebKit/commit/c52f78ad2c4d402d423f696158ae8413d0bfef5f
  Author: Taher Ali <[email protected]>
  Date:   2026-07-07 (Tue, 07 Jul 2026)

  Changed paths:
    A 
LayoutTests/svg/custom/non-scaling-stroke-nested-scaling-ancestor-expected.svg
    A LayoutTests/svg/custom/non-scaling-stroke-nested-scaling-ancestor.svg
    M Source/WebCore/rendering/svg/SVGRenderSupport.cpp
    M Source/WebCore/rendering/svg/SVGRenderSupport.h
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGContainer.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGModelObject.h
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGShape.cpp

  Log Message:
  -----------
  Avoid full subtree walk for non-scaling-stroke when no scaling exists in the 
SVG tree
https://bugs.webkit.org/show_bug.cgi?id=316857
rdar://179288836

Reviewed by Simon Fraser.

In legacy SVG, repaintRectInLocalCoordinates() bypasses its cache for
non-scaling-stroke (NSS) subtrees. For trees with thousands of NSS
shapes that bypass is a hot loop: every repaint walks the entire subtree
and each leaf climbs the DOM to compute its CTM.

But NSS only changes the bounding box when the CTM has a scale, skew, or
rotate component. If a renderer's ancestor chain and its own transform
are all identity-or-translation, NSS is a no-op and the cached repaint
bounding box is already correct.

This fixes a real-world perf issue. On content with thousands of nested
NSS paths and no scaling, computeContainerBoundingBoxes was the single
hottest function at ~8.5% of total time; with the cache hit it drops to
~0.3%

* 
LayoutTests/svg/custom/non-scaling-stroke-nested-scaling-ancestor-expected.svg: 
Added.
* LayoutTests/svg/custom/non-scaling-stroke-nested-scaling-ancestor.svg: Added.

* Source/WebCore/rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::updateAncestorScalingTransformCounts):
(WebCore::SVGRenderSupport::elementWillBeRemovedFromTree):
* Source/WebCore/rendering/svg/SVGRenderSupport.h:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGContainer.cpp:
(WebCore::LegacyRenderSVGContainer::repaintRectInLocalCoordinates const):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGContainer.h:
(WebCore::LegacyRenderSVGContainer::hasScalingTransformDescendant const):
(WebCore::LegacyRenderSVGContainer::adjustScalingTransformDescendantCount):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGModelObject.h:
(WebCore::LegacyRenderSVGModelObject::isCountedAsScalingTransformDescendant 
const):
(WebCore::LegacyRenderSVGModelObject::setIsCountedAsScalingTransformDescendant):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.cpp:
(WebCore::LegacyRenderSVGRoot::repaintRectInLocalCoordinates const):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRoot.h:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGShape.cpp:
(WebCore::LegacyRenderSVGShape::layout):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGTransformableContainer.cpp:
(WebCore::LegacyRenderSVGTransformableContainer::calculateLocalTransform):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGViewportContainer.cpp:
(WebCore::LegacyRenderSVGViewportContainer::calculateLocalTransform):

Canonical link: https://commits.webkit.org/316651@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to