From 0bd4123974c84dfb807360523c27aa73a4afb92f Mon Sep 17 00:00:00 2001 From: Said Abou-Hallawa Date: Tue, 16 Sep 2025 10:15:47 -0700 Subject: [PATCH] [Filters] Applying CoreGraphics filters on different tiles may result in white borders around the tiles https://bugs.webkit.org/show_bug.cgi?id=298453 rdar://159951868 Reviewed by Simon Fraser. The transparency layer of the CoreGraphics filter should be clipped to the layer backgroundClipRect without intersecting it with the paintDirtyRect. CoreGraphics expects the context is set to the coordinates of the target filtered renderer not only the dirty rectangle only. Test: css3/filters/effect-graphics-context-blur-tile-boundaries.html * LayoutTests/css3/filters/effect-graphics-context-blur-tile-boundaries-expected.html: Added. * LayoutTests/css3/filters/effect-graphics-context-blur-tile-boundaries.html: Added. * Source/WebCore/rendering/LayerFragment.h: (WebCore::LayerFragment::Rects::backgroundRect const): (WebCore::LayerFragment::backgroundRect const): * Source/WebCore/rendering/RenderLayer.cpp: (WebCore::RenderLayer::paintLayerContents): Canonical link: https://commits.webkit.org/300038@main --- ...context-blur-tile-boundaries-expected.html | 14 ++++++++++++++ ...graphics-context-blur-tile-boundaries.html | 19 +++++++++++++++++++ Source/WebCore/rendering/LayerFragment.h | 2 ++ Source/WebCore/rendering/RenderLayer.cpp | 2 +- 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 LayoutTests/css3/filters/effect-graphics-context-blur-tile-boundaries-expected.html create mode 100644 LayoutTests/css3/filters/effect-graphics-context-blur-tile-boundaries.html diff --git a/LayoutTests/css3/filters/effect-graphics-context-blur-tile-boundaries-expected.html b/LayoutTests/css3/filters/effect-graphics-context-blur-tile-boundaries-expected.html new file mode 100644 index 0000000000000..aaacd071aaccf --- /dev/null +++ b/LayoutTests/css3/filters/effect-graphics-context-blur-tile-boundaries-expected.html @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/LayoutTests/css3/filters/effect-graphics-context-blur-tile-boundaries.html b/LayoutTests/css3/filters/effect-graphics-context-blur-tile-boundaries.html new file mode 100644 index 0000000000000..fc6d084b78bd0 --- /dev/null +++ b/LayoutTests/css3/filters/effect-graphics-context-blur-tile-boundaries.html @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/Source/WebCore/rendering/LayerFragment.h b/Source/WebCore/rendering/LayerFragment.h index 39e9ee6f4896d..bd03c7dda3610 100644 --- a/Source/WebCore/rendering/LayerFragment.h +++ b/Source/WebCore/rendering/LayerFragment.h @@ -51,6 +51,7 @@ class LayerFragment { LayoutRect layerBounds() const { return m_layerBounds; } + ClipRect backgroundRect() const { return m_backgroundRect; } ClipRect dirtyBackgroundRect() const { return intersection(m_paintDirtyRect, m_backgroundRect); } ClipRect dirtyForegroundRect() const { return intersection(m_paintDirtyRect, m_foregroundRect); } @@ -93,6 +94,7 @@ class LayerFragment { LayoutRect layerBounds() const { return rects.layerBounds(); } + ClipRect backgroundRect() const { return rects.backgroundRect(); } ClipRect dirtyBackgroundRect() const { return rects.dirtyBackgroundRect(); } ClipRect dirtyForegroundRect() const { return rects.dirtyForegroundRect(); } diff --git a/Source/WebCore/rendering/RenderLayer.cpp b/Source/WebCore/rendering/RenderLayer.cpp index d2dc0893f9223..9237016f279e7 100644 --- a/Source/WebCore/rendering/RenderLayer.cpp +++ b/Source/WebCore/rendering/RenderLayer.cpp @@ -3879,7 +3879,7 @@ void RenderLayer::paintLayerContents(GraphicsContext& context, const LayerPainti updatePaintingInfoForFragments(layerFragments, paintingInfo, localPaintFlags, shouldPaintContent, offsetFromRoot); // FIXME: Handle more than one fragment. - backgroundRect = layerFragments.isEmpty() ? ClipRect() : layerFragments[0].dirtyBackgroundRect(); + backgroundRect = layerFragments.isEmpty() ? ClipRect() : layerFragments[0].backgroundRect(); if (haveTransparency) { // If we have a filter and transparency, we have to eagerly start a transparency layer here, rather than risk a child layer lazily starts one with the wrong context.