Skip to content

Commit

Permalink
Cherry-pick 274757@main (8411b7a). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=268278

    backdrop filters should be applied to the border area of the element with border-radius
    https://bugs.webkit.org/show_bug.cgi?id=268278

    Reviewed by Matt Woodrow.

    Backdrop filters should be applied to the inside of border edge of the
    element, not to the padding edge.

    * LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/backdrop-filter-clip-rect-2-expected.html: Added.
    * LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/backdrop-filter-clip-rect-2.html: Added.
    * LayoutTests/imported/w3c/web-platform-tests/css/filter-effects/backdrop-filter-clip-rect.html: Added fuzzy meta tag.
    * Source/WebCore/rendering/RenderLayerBacking.cpp:
    (WebCore::RenderLayerBacking::updateBackdropFiltersGeometry):
    Use borderRoundedRect of renderBox instead of roundedBorderBoxRect.

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

Canonical link: https://commits.webkit.org/274313.36@webkitglib/2.44
  • Loading branch information
fujii authored and aperezdc committed Mar 8, 2024
1 parent 3ca1c75 commit 919c7d5
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" href="mailto:Hironori.Fujii@sony.com">
<style>
.box {
display: inline-block;
box-sizing: border-box;
width: 100px;
height: 100px;
border-radius: 10px 20px 30px 40px;
border-width: 10px;
}
.no-bf > .box {
background: black;
}
</style>
<div>
<p>Expected: Same size rounded black boxes.</p>
</div>

<div class="no-bf">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
<div class="no-bf">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>backdrop-filter: Clip the filter at border box of element</title>
<link rel="author" href="mailto:Hironori.Fujii@sony.com">
<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
<link rel="match" href="reference/backdrop-filter-clip-rect-2-ref.html">
<meta name="fuzzy" content="maxDifference=0-80; totalPixels=0-1000" />
<style>
.box {
display: inline-block;
box-sizing: border-box;
width: 100px;
height: 100px;
border-radius: 10px 20px 30px 40px;
border-width: 10px;
}
.no-bf > .box {
background: black;
}
.bf > .box {
border-color: transparent;
backdrop-filter: invert(1);
}
</style>
<div>
<p>Expected: Same size rounded black boxes.</p>
</div>

<div class="no-bf">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
<div class="bf">
<div class="box" style="border-style:none"></div>
<div class="box" style="border-style:solid"></div>
<div class="box" style="border-style:dotted"></div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<link rel="author" href="mailto:masonf@chromium.org">
<link rel="help" href="https://drafts.fxtf.org/filter-effects-2/#BackdropFilterProperty">
<link rel="match" href="backdrop-filter-clip-rect-ref.html">
<meta name="fuzzy" content="maxDifference=0-1; totalPixels=0-1" />

<div>
<p>Expected: A green box, color-inverted inside the short, wide box with a<br>
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderLayerBacking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ void RenderLayerBacking::updateBackdropFiltersGeometry()

FloatRoundedRect backdropFiltersRect;
if (renderBox->style().hasBorderRadius() && !renderBox->hasClip()) {
auto roundedBoxRect = renderBox->roundedBorderBoxRect();
auto roundedBoxRect = renderBox->borderRoundedRect();
roundedBoxRect.move(contentOffsetInCompositingLayer());
backdropFiltersRect = roundedBoxRect.pixelSnappedRoundedRectForPainting(deviceScaleFactor());
} else {
Expand Down

0 comments on commit 919c7d5

Please sign in to comment.