Skip to content

Commit

Permalink
Invalidate SVG filter results in SVGResourcesCache::clientLayoutChang…
Browse files Browse the repository at this point in the history
…ed()

https://bugs.webkit.org/show_bug.cgi?id=271449

Reviewed by Simon Fraser.

This patch is to align WebKit with Gecko / Firefox and Blink / Chromium.

Merge: https://chromium.googlesource.com/chromium/blink/+/25d72ebd50bec9a4caa426e735e5ee7292c4da69

^ Also import `skipped` test from Blink / Chromium upstream.

This patch effectively fix regression introduced by 91851@main.

For the SVG tree, filter result invalidation is handled by LegacyRenderSVGResource::markForLayoutAndParentResourceInvalidation.
But non-SVG content (such as a <foreignObject> HTML subtree) does not call markForLayoutAndParentResourceInvalidation
and instead uses the regular setNeedsLayout() invalidation path.

Hence, changes in the HTML subtree do not invalidate cached results for filters applied on
ancestor SVG elements. In order to cover this case, clientLayoutChanged() needs to
invalidate filter results even if the SVG element itself does not need a re-layout. Note
that prior to 91851@main the method used to do exactly that, but the branch was removed on
the assumption that markForLayoutAndParentResourceInvalidation() is already taking care of
it. Obviously, the assumption doesn't hold for non-SVG content.

* Source/WebCore/rendering/svg/SVGResourcesCache.cpp:
(SVGResourcesCache::clientLayoutChanged():
* LayoutTests/svg/foreignObject/filter-repaint.svg: Add Test Case
* LayoutTests/svg/foreignObject/filter-repaint-expected.svg: Add Test Case Expectation

Canonical link: https://commits.webkit.org/276808@main
  • Loading branch information
Ahmad Saleem committed Mar 28, 2024
1 parent 3ee555d commit 34cb73b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
11 changes: 11 additions & 0 deletions LayoutTests/svg/foreignObject/filter-repaint-expected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions LayoutTests/svg/foreignObject/filter-repaint.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/svg/SVGResourcesCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void SVGResourcesCache::clientLayoutChanged(RenderElement& renderer)

// Invalidate the resources if either the RenderElement itself changed,
// or we have filter resources, which could depend on the layout of children.
if (renderer.selfNeedsLayout() && hasResourcesRequiringRemovalOnClientLayoutChange(*resources))
if ((renderer.selfNeedsLayout() || resources->filter()) && hasResourcesRequiringRemovalOnClientLayoutChange(*resources))
resources->removeClientFromCache(renderer, false);
}

Expand Down

0 comments on commit 34cb73b

Please sign in to comment.