Skip to content

[LBSE] Paint <feImage> referenced elements through the layer tree - #71547

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
nikolaszimmermann:eng/LBSE-Paint-feImage-referenced-elements-through-the-layer-tree
Aug 18, 2026
Merged

[LBSE] Paint <feImage> referenced elements through the layer tree#71547
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
nikolaszimmermann:eng/LBSE-Paint-feImage-referenced-elements-through-the-layer-tree

Conversation

@nikolaszimmermann

@nikolaszimmermann nikolaszimmermann commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

6b3f8e7

[LBSE] Paint <feImage> referenced elements through the layer tree
https://bugs.webkit.org/show_bug.cgi?id=321677

Reviewed by Rob Buis.

SVGFEImageElement::imageBufferForEffect() draws the referenced element with
SVGRenderingContext::renderSubtreeToContext(). That helper belongs to the legacy
SVG engine and LBSE must not use it: it calls RenderElement::paint() directly,
which skips every child that owns a RenderLayer, so any opacity, mask, filter or
3D transform below the referenced element was lost. Furthermore it uses
calculateTransformationToOutermostCoordinateSystem(), which does not see the
transforms kept on RenderLayers, most noticeable it misses the viewBox
transform of the outermost <svg> element.

Draw the element with RenderLayer::paintResourceLayerForSVG() instead, like
<mask>, <clipPath>, <pattern> and <marker> content, and ask
SVGTransformComputation for the buffer scale, fixing the problems.

The feImage-referenced element needs a layer for that, so
requiresLayerForSVGIntrinsicReasons() now assignes one to every element an
<feImage> points to.

Fixes several feImage-* tests under LBSE. Also add a new test that verifies
layered descendants properly function under a feImage reference.

* LayoutTests/platform/mac-tahoe-wk2-lbse-text/TestExpectations:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/W3C-SVG-1.1/filters-composite-02-b-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-filterUnits-objectBoundingBox-primitiveUnits-objectBoundingBox-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-filterUnits-objectBoundingBox-primitiveUnits-userSpaceOnUse-expected.png:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-filterUnits-objectBoundingBox-primitiveUnits-userSpaceOnUse-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-filterUnits-userSpaceOnUse-primitiveUnits-objectBoundingBox-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-filterUnits-userSpaceOnUse-primitiveUnits-userSpaceOnUse-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-late-indirect-update-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-multiple-targets-id-change-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-position-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-reference-invalidation-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-reference-svg-primitive-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-subregions-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-subregions-preseveAspectRatio-none-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-subregions-preseveAspectRatio-none-with-viewBox-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-add-to-document-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-attribute-change-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-changes-id-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-id-change-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-inline-style-change-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-property-change-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-reappend-to-document-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-remove-from-document-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-style-change-expected.txt:
* LayoutTests/svg/filters/feImage-target-with-layered-descendants-expected.svg: Added.
* LayoutTests/svg/filters/feImage-target-with-layered-descendants.svg: Added.
* Source/WebCore/rendering/RenderLayer.h:
* Source/WebCore/rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::requiresLayerForSVGIntrinsicReasons const):
* Source/WebCore/rendering/RenderLayerSVGAdditions.cpp:
(WebCore::RenderLayer::paintChildrenInDOMOrderForSVG):
* Source/WebCore/svg/SVGElement.cpp:
(WebCore::SVGElement::addReferencingElement):
(WebCore::SVGElement::removeReferencingElement):
(WebCore::SVGElement::invalidateLayerRequirementForFEImageReference):
(WebCore::SVGElement::isReferencedByFEImage const):
* Source/WebCore/svg/SVGElement.h:
* Source/WebCore/svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::notifyFinished):
(WebCore::SVGFEImageElement::imageBufferForEffect const):

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

f6c217c

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ❌ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 api-mac-debug
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk3-gcc
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-AS-debug-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-wk2-stress ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-intel-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 unsafe-merge ✅ 🧪 vision-wk2 ✅ 🛠 mac-safer-cpp ✅ 🛠 playstation
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@nikolaszimmermann nikolaszimmermann self-assigned this Aug 13, 2026
@nikolaszimmermann nikolaszimmermann added the SVG For bugs in the SVG implementation. label Aug 13, 2026

@rwlbuis rwlbuis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! LGTM.

@nikolaszimmermann nikolaszimmermann added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Aug 18, 2026
https://bugs.webkit.org/show_bug.cgi?id=321677

Reviewed by Rob Buis.

SVGFEImageElement::imageBufferForEffect() draws the referenced element with
SVGRenderingContext::renderSubtreeToContext(). That helper belongs to the legacy
SVG engine and LBSE must not use it: it calls RenderElement::paint() directly,
which skips every child that owns a RenderLayer, so any opacity, mask, filter or
3D transform below the referenced element was lost. Furthermore it uses
calculateTransformationToOutermostCoordinateSystem(), which does not see the
transforms kept on RenderLayers, most noticeable it misses the viewBox
transform of the outermost <svg> element.

Draw the element with RenderLayer::paintResourceLayerForSVG() instead, like
<mask>, <clipPath>, <pattern> and <marker> content, and ask
SVGTransformComputation for the buffer scale, fixing the problems.

The feImage-referenced element needs a layer for that, so
requiresLayerForSVGIntrinsicReasons() now assignes one to every element an
<feImage> points to.

Fixes several feImage-* tests under LBSE. Also add a new test that verifies
layered descendants properly function under a feImage reference.

* LayoutTests/platform/mac-tahoe-wk2-lbse-text/TestExpectations:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/W3C-SVG-1.1/filters-composite-02-b-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-filterUnits-objectBoundingBox-primitiveUnits-objectBoundingBox-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-filterUnits-objectBoundingBox-primitiveUnits-userSpaceOnUse-expected.png:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-filterUnits-objectBoundingBox-primitiveUnits-userSpaceOnUse-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-filterUnits-userSpaceOnUse-primitiveUnits-objectBoundingBox-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-filterUnits-userSpaceOnUse-primitiveUnits-userSpaceOnUse-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-late-indirect-update-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-multiple-targets-id-change-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-position-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-reference-invalidation-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-reference-svg-primitive-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-subregions-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-subregions-preseveAspectRatio-none-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-subregions-preseveAspectRatio-none-with-viewBox-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-add-to-document-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-attribute-change-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-changes-id-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-id-change-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-inline-style-change-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-property-change-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-reappend-to-document-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-remove-from-document-expected.txt:
* LayoutTests/platform/mac-tahoe-wk2-lbse-text/svg/filters/feImage-target-style-change-expected.txt:
* LayoutTests/svg/filters/feImage-target-with-layered-descendants-expected.svg: Added.
* LayoutTests/svg/filters/feImage-target-with-layered-descendants.svg: Added.
* Source/WebCore/rendering/RenderLayer.h:
* Source/WebCore/rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::requiresLayerForSVGIntrinsicReasons const):
* Source/WebCore/rendering/RenderLayerSVGAdditions.cpp:
(WebCore::RenderLayer::paintChildrenInDOMOrderForSVG):
* Source/WebCore/svg/SVGElement.cpp:
(WebCore::SVGElement::addReferencingElement):
(WebCore::SVGElement::removeReferencingElement):
(WebCore::SVGElement::invalidateLayerRequirementForFEImageReference):
(WebCore::SVGElement::isReferencedByFEImage const):
* Source/WebCore/svg/SVGElement.h:
* Source/WebCore/svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::notifyFinished):
(WebCore::SVGFEImageElement::imageBufferForEffect const):

Canonical link: https://commits.webkit.org/319388@main
@webkit-commit-queue
webkit-commit-queue force-pushed the eng/LBSE-Paint-feImage-referenced-elements-through-the-layer-tree branch from f6c217c to 6b3f8e7 Compare August 18, 2026 17:48
@webkit-commit-queue

Copy link
Copy Markdown
Collaborator

Committed 319388@main (6b3f8e7): https://commits.webkit.org/319388@main

Reviewed commits have been landed. Closing PR #71547 and removing active labels.

@webkit-commit-queue
webkit-commit-queue merged commit 6b3f8e7 into WebKit:main Aug 18, 2026
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Aug 18, 2026
@nikolaszimmermann
nikolaszimmermann deleted the eng/LBSE-Paint-feImage-referenced-elements-through-the-layer-tree branch August 18, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SVG For bugs in the SVG implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants