<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[284499] branches/safari-613.1.6-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/284499">284499</a></dd>
<dt>Author</dt> <dd>alancoon@apple.com</dd>
<dt>Date</dt> <dd>2021-10-19 14:46:07 -0700 (Tue, 19 Oct 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Cherry-pick <a href="http://trac.webkit.org/projects/webkit/changeset/284490">r284490</a>. rdar://problem/84434069

    Regression(<a href="http://trac.webkit.org/projects/webkit/changeset/284336">r284336</a>): [ iOS 15 ] system-preview/badge.html is image failing
    https://bugs.webkit.org/show_bug.cgi?id=231916

    Reviewed by Antti Koivisto.
    Source/WebCore:

    In <a href="http://trac.webkit.org/projects/webkit/changeset/284336">r284336</a> I made clip-path not apply to non-RenderBoxes, which disabled it on inlines,
    breaking the system-preview/badge.html test.

    The spec says it applies to all elements, so this behavior change was incorrect.

    Revert back to using calculateLayerBounds() as the fallback rect to use for inlines, and add
    tests for this. This rectangle is obviously incorrect (for example, it's affected by text
    shadow), but leave it for now until https://github.com/w3c/csswg-drafts/issues/6383 is
    resolved.

    I also failed to see that computeClipPath() was already computing the reference box
    internally, so clean up the code with some comments to make it more clear that the result of
    calculateLayerBounds() is used only as the fallback for inlines, as well as for the buffer
    bounds for the applyClippingToContext() code path.

    Tests: css3/masking/clip-path-on-inline.html
           css3/masking/clip-path-on-split-inline.html

    * rendering/RenderLayer.cpp:
    (WebCore::RenderLayer::computeClipPath const):
    (WebCore::RenderLayer::setupClipPath):
    * rendering/RenderLayer.h:
    * rendering/RenderLayerBacking.cpp:
    (WebCore::RenderLayerBacking::updateMaskingLayerGeometry):

    LayoutTests:

    Tests for clip-path on a single-box inline, and a split inline.

    * css3/masking/clip-path-on-inline-expected.html: Added.
    * css3/masking/clip-path-on-inline.html: Added.
    * css3/masking/clip-path-on-split-inline-expected.html: Added.
    * css3/masking/clip-path-on-split-inline.html: Added.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284490 268f45cc-cd09-0410-ab3c-d52691b4dbfc</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari61316branchLayoutTestsChangeLog">branches/safari-613.1.6-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari61316branchSourceWebCoreChangeLog">branches/safari-613.1.6-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari61316branchSourceWebCorerenderingRenderLayercpp">branches/safari-613.1.6-branch/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#branchessafari61316branchSourceWebCorerenderingRenderLayerh">branches/safari-613.1.6-branch/Source/WebCore/rendering/RenderLayer.h</a></li>
<li><a href="#branchessafari61316branchSourceWebCorerenderingRenderLayerBackingcpp">branches/safari-613.1.6-branch/Source/WebCore/rendering/RenderLayerBacking.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari61316branchLayoutTestscss3maskingclippathoninlineexpectedhtml">branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-inline-expected.html</a></li>
<li><a href="#branchessafari61316branchLayoutTestscss3maskingclippathoninlinehtml">branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-inline.html</a></li>
<li><a href="#branchessafari61316branchLayoutTestscss3maskingclippathonsplitinlineexpectedhtml">branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-split-inline-expected.html</a></li>
<li><a href="#branchessafari61316branchLayoutTestscss3maskingclippathonsplitinlinehtml">branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-split-inline.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari61316branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-613.1.6-branch/LayoutTests/ChangeLog (284498 => 284499)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.6-branch/LayoutTests/ChangeLog     2021-10-19 21:44:07 UTC (rev 284498)
+++ branches/safari-613.1.6-branch/LayoutTests/ChangeLog        2021-10-19 21:46:07 UTC (rev 284499)
</span><span class="lines">@@ -1,5 +1,65 @@
</span><span class="cx"> 2021-10-19  Alan Coon  <alancoon@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r284490. rdar://problem/84434069
+
+    Regression(r284336): [ iOS 15 ] system-preview/badge.html is image failing
+    https://bugs.webkit.org/show_bug.cgi?id=231916
+    
+    Reviewed by Antti Koivisto.
+    Source/WebCore:
+    
+    In r284336 I made clip-path not apply to non-RenderBoxes, which disabled it on inlines,
+    breaking the system-preview/badge.html test.
+    
+    The spec says it applies to all elements, so this behavior change was incorrect.
+    
+    Revert back to using calculateLayerBounds() as the fallback rect to use for inlines, and add
+    tests for this. This rectangle is obviously incorrect (for example, it's affected by text
+    shadow), but leave it for now until https://github.com/w3c/csswg-drafts/issues/6383 is
+    resolved.
+    
+    I also failed to see that computeClipPath() was already computing the reference box
+    internally, so clean up the code with some comments to make it more clear that the result of
+    calculateLayerBounds() is used only as the fallback for inlines, as well as for the buffer
+    bounds for the applyClippingToContext() code path.
+    
+    Tests: css3/masking/clip-path-on-inline.html
+           css3/masking/clip-path-on-split-inline.html
+    
+    * rendering/RenderLayer.cpp:
+    (WebCore::RenderLayer::computeClipPath const):
+    (WebCore::RenderLayer::setupClipPath):
+    * rendering/RenderLayer.h:
+    * rendering/RenderLayerBacking.cpp:
+    (WebCore::RenderLayerBacking::updateMaskingLayerGeometry):
+    
+    LayoutTests:
+    
+    Tests for clip-path on a single-box inline, and a split inline.
+    
+    * css3/masking/clip-path-on-inline-expected.html: Added.
+    * css3/masking/clip-path-on-inline.html: Added.
+    * css3/masking/clip-path-on-split-inline-expected.html: Added.
+    * css3/masking/clip-path-on-split-inline.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-19  Simon Fraser  <simon.fraser@apple.com>
+
+            Regression(r284336): [ iOS 15 ] system-preview/badge.html is image failing
+            https://bugs.webkit.org/show_bug.cgi?id=231916
+
+            Reviewed by Antti Koivisto.
+
+            Tests for clip-path on a single-box inline, and a split inline.
+
+            * css3/masking/clip-path-on-inline-expected.html: Added.
+            * css3/masking/clip-path-on-inline.html: Added.
+            * css3/masking/clip-path-on-split-inline-expected.html: Added.
+            * css3/masking/clip-path-on-split-inline.html: Added.
+
+2021-10-19  Alan Coon  <alancoon@apple.com>
+
</ins><span class="cx">         Cherry-pick r284483. rdar://problem/84428759
</span><span class="cx"> 
</span><span class="cx">     LayoutTests/imported/w3c:
</span></span></pre></div>
<a id="branchessafari61316branchLayoutTestscss3maskingclippathoninlineexpectedhtml"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-inline-expected.html (0 => 284499)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-inline-expected.html                                (rev 0)
+++ branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-inline-expected.html   2021-10-19 21:46:07 UTC (rev 284499)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    .container {
+        font-family: ahem;
+        font-size: 100px;
+        overflow: hidden;
+        height: calc(1em - 20px);
+    }
+    span {
+        color: transparent;
+        background-color: green;
+    }
+</style>
+</head>
+<body>
+    <div class="container">
+        <span>AAAA</span>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari61316branchLayoutTestscss3maskingclippathoninlinehtml"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-inline.html (0 => 284499)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-inline.html                         (rev 0)
+++ branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-inline.html    2021-10-19 21:46:07 UTC (rev 284499)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    .container {
+        font-family: ahem;
+        font-size: 100px;
+        overflow: hidden;
+        height: 1em;
+    }
+    span {
+        color: transparent;
+        background-color: green;
+        clip-path: inset(0 0 20px 0);
+    }
+</style>
+</head>
+<body>
+    <div class="container">
+        <span>AAAA</span>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari61316branchLayoutTestscss3maskingclippathonsplitinlineexpectedhtml"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-split-inline-expected.html (0 => 284499)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-split-inline-expected.html                          (rev 0)
+++ branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-split-inline-expected.html     2021-10-19 21:46:07 UTC (rev 284499)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    .container {
+        font-family: ahem;
+        font-size: 100px;
+        width: 400px;
+        overflow: hidden;
+        height: 160px;
+        margin-top: 28px;
+    }
+    span {
+        color: transparent;
+        background-color: green;
+    }
+</style>
+</head>
+<body>
+    <div class="container">
+        <span>AAAA<br>AAAA</span>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari61316branchLayoutTestscss3maskingclippathonsplitinlinehtml"></a>
<div class="addfile"><h4>Added: branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-split-inline.html (0 => 284499)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-split-inline.html                           (rev 0)
+++ branches/safari-613.1.6-branch/LayoutTests/css3/masking/clip-path-on-split-inline.html      2021-10-19 21:46:07 UTC (rev 284499)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<style>
+    .container {
+        font-family: ahem;
+        font-size: 100px;
+        width: 400px;
+        overflow: hidden;
+    }
+    span {
+        color: transparent;
+        background-color: green;
+        clip-path: inset(20px 0 20px 0);
+    }
+</style>
+</head>
+<body>
+    <div class="container">
+        <span>AAAA<br>AAAA</span>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari61316branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-613.1.6-branch/Source/WebCore/ChangeLog (284498 => 284499)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.6-branch/Source/WebCore/ChangeLog  2021-10-19 21:44:07 UTC (rev 284498)
+++ branches/safari-613.1.6-branch/Source/WebCore/ChangeLog     2021-10-19 21:46:07 UTC (rev 284499)
</span><span class="lines">@@ -1,5 +1,83 @@
</span><span class="cx"> 2021-10-19  Alan Coon  <alancoon@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r284490. rdar://problem/84434069
+
+    Regression(r284336): [ iOS 15 ] system-preview/badge.html is image failing
+    https://bugs.webkit.org/show_bug.cgi?id=231916
+    
+    Reviewed by Antti Koivisto.
+    Source/WebCore:
+    
+    In r284336 I made clip-path not apply to non-RenderBoxes, which disabled it on inlines,
+    breaking the system-preview/badge.html test.
+    
+    The spec says it applies to all elements, so this behavior change was incorrect.
+    
+    Revert back to using calculateLayerBounds() as the fallback rect to use for inlines, and add
+    tests for this. This rectangle is obviously incorrect (for example, it's affected by text
+    shadow), but leave it for now until https://github.com/w3c/csswg-drafts/issues/6383 is
+    resolved.
+    
+    I also failed to see that computeClipPath() was already computing the reference box
+    internally, so clean up the code with some comments to make it more clear that the result of
+    calculateLayerBounds() is used only as the fallback for inlines, as well as for the buffer
+    bounds for the applyClippingToContext() code path.
+    
+    Tests: css3/masking/clip-path-on-inline.html
+           css3/masking/clip-path-on-split-inline.html
+    
+    * rendering/RenderLayer.cpp:
+    (WebCore::RenderLayer::computeClipPath const):
+    (WebCore::RenderLayer::setupClipPath):
+    * rendering/RenderLayer.h:
+    * rendering/RenderLayerBacking.cpp:
+    (WebCore::RenderLayerBacking::updateMaskingLayerGeometry):
+    
+    LayoutTests:
+    
+    Tests for clip-path on a single-box inline, and a split inline.
+    
+    * css3/masking/clip-path-on-inline-expected.html: Added.
+    * css3/masking/clip-path-on-inline.html: Added.
+    * css3/masking/clip-path-on-split-inline-expected.html: Added.
+    * css3/masking/clip-path-on-split-inline.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-19  Simon Fraser  <simon.fraser@apple.com>
+
+            Regression(r284336): [ iOS 15 ] system-preview/badge.html is image failing
+            https://bugs.webkit.org/show_bug.cgi?id=231916
+
+            Reviewed by Antti Koivisto.
+
+            In r284336 I made clip-path not apply to non-RenderBoxes, which disabled it on inlines,
+            breaking the system-preview/badge.html test.
+
+            The spec says it applies to all elements, so this behavior change was incorrect.
+
+            Revert back to using calculateLayerBounds() as the fallback rect to use for inlines, and add
+            tests for this. This rectangle is obviously incorrect (for example, it's affected by text
+            shadow), but leave it for now until https://github.com/w3c/csswg-drafts/issues/6383 is
+            resolved.
+
+            I also failed to see that computeClipPath() was already computing the reference box
+            internally, so clean up the code with some comments to make it more clear that the result of
+            calculateLayerBounds() is used only as the fallback for inlines, as well as for the buffer
+            bounds for the applyClippingToContext() code path.
+
+            Tests: css3/masking/clip-path-on-inline.html
+                   css3/masking/clip-path-on-split-inline.html
+
+            * rendering/RenderLayer.cpp:
+            (WebCore::RenderLayer::computeClipPath const):
+            (WebCore::RenderLayer::setupClipPath):
+            * rendering/RenderLayer.h:
+            * rendering/RenderLayerBacking.cpp:
+            (WebCore::RenderLayerBacking::updateMaskingLayerGeometry):
+
+2021-10-19  Alan Coon  <alancoon@apple.com>
+
</ins><span class="cx">         Cherry-pick r284483. rdar://problem/84428759
</span><span class="cx"> 
</span><span class="cx">     LayoutTests/imported/w3c:
</span></span></pre></div>
<a id="branchessafari61316branchSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-613.1.6-branch/Source/WebCore/rendering/RenderLayer.cpp (284498 => 284499)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.6-branch/Source/WebCore/rendering/RenderLayer.cpp  2021-10-19 21:44:07 UTC (rev 284498)
+++ branches/safari-613.1.6-branch/Source/WebCore/rendering/RenderLayer.cpp     2021-10-19 21:46:07 UTC (rev 284499)
</span><span class="lines">@@ -3139,7 +3139,7 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Path RenderLayer::computeClipPath(const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, WindRule& windRule) const
</del><ins>+std::pair<Path, WindRule> RenderLayer::computeClipPath(const LayoutSize& offsetFromRoot, const LayoutRect& rootRelativeBoundsForNonBoxes) const
</ins><span class="cx"> {
</span><span class="cx">     const RenderStyle& style = renderer().style();
</span><span class="cx">     float deviceScaleFactor = renderer().document().deviceScaleFactor();
</span><span class="lines">@@ -3151,26 +3151,25 @@
</span><span class="cx">         if (is<RenderBox>(renderer())) {
</span><span class="cx">             referenceBox = downcast<RenderBox>(renderer()).referenceBox(clipPath.referenceBox());
</span><span class="cx">             referenceBox.move(offsetFromRoot);
</span><del>-        } else
-            referenceBox = rootRelativeBounds;
</del><ins>+        } else {
+            // Reference box for inlines is not well defined: https://github.com/w3c/csswg-drafts/issues/6383
+            referenceBox = rootRelativeBoundsForNonBoxes;
+        }
</ins><span class="cx"> 
</span><del>-        FloatRect snappedReferenceBox = snapRectToDevicePixels(referenceBox, deviceScaleFactor);
-
-        windRule = clipPath.windRule();
-        return clipPath.pathForReferenceRect(snappedReferenceBox);
</del><ins>+        auto snappedReferenceBox = snapRectToDevicePixels(referenceBox, deviceScaleFactor);
+        return { clipPath.pathForReferenceRect(snappedReferenceBox), clipPath.windRule() };
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (is<BoxClipPathOperation>(*style.clipPath()) && is<RenderBox>(renderer())) {
</span><span class="cx">         auto& clipPath = downcast<BoxClipPathOperation>(*style.clipPath());
</span><span class="cx"> 
</span><del>-        FloatRoundedRect shapeRect = computeRoundedRectForBoxShape(clipPath.referenceBox(), downcast<RenderBox>(renderer())).pixelSnappedRoundedRectForPainting(deviceScaleFactor);
</del><ins>+        auto shapeRect = computeRoundedRectForBoxShape(clipPath.referenceBox(), downcast<RenderBox>(renderer())).pixelSnappedRoundedRectForPainting(deviceScaleFactor);
</ins><span class="cx">         shapeRect.move(offsetFromRoot);
</span><span class="cx"> 
</span><del>-        windRule = WindRule::NonZero;
-        return clipPath.pathForReferenceRect(shapeRect);
</del><ins>+        return { clipPath.pathForReferenceRect(shapeRect), WindRule::NonZero };
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return Path();
</del><ins>+    return { Path(), WindRule::NonZero };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RenderLayer::setupClipPath(GraphicsContext& context, const LayerPaintingInfo& paintingInfo, const LayoutSize& offsetFromRoot)
</span><span class="lines">@@ -3182,19 +3181,14 @@
</span><span class="cx">     if (is<RenderSVGRoot>(renderer()))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    if (!is<RenderBox>(renderer()))
-        return false;
</del><ins>+    auto clippedContentBounds = calculateLayerBounds(paintingInfo.rootLayer, offsetFromRoot, { UseLocalClipRectIfPossible });
</ins><span class="cx"> 
</span><del>-    // It's not clear that this geometry is correct: https://github.com/w3c/csswg-drafts/issues/5786
-    auto clipPathObjectBoundingBox = computeReferenceRectFromBox(downcast<RenderBox>(renderer()), CSSBoxType::BorderBox, offsetFromRoot);
-
</del><span class="cx">     auto& style = renderer().style();
</span><span class="cx">     LayoutSize paintingOffsetFromRoot = LayoutSize(snapSizeToDevicePixel(offsetFromRoot + paintingInfo.subpixelOffset, LayoutPoint(), renderer().document().deviceScaleFactor()));
</span><span class="cx">     ASSERT(style.clipPath());
</span><span class="cx">     if (is<ShapeClipPathOperation>(*style.clipPath()) || (is<BoxClipPathOperation>(*style.clipPath()) && is<RenderBox>(renderer()))) {
</span><del>-        WindRule windRule;
-        // FIXME: Should probably pixel-snap clipPathObjectBoundingBox here.
-        Path path = computeClipPath(paintingOffsetFromRoot, clipPathObjectBoundingBox, windRule);
</del><ins>+        // clippedContentBounds is used as the reference box for inlines, which is also poorly specified: https://github.com/w3c/csswg-drafts/issues/6383.
+        auto [path, windRule] = computeClipPath(paintingOffsetFromRoot, clippedContentBounds);
</ins><span class="cx">         context.save();
</span><span class="cx">         context.clipPath(path, windRule);
</span><span class="cx">         return true;
</span><span class="lines">@@ -3203,16 +3197,19 @@
</span><span class="cx">     if (is<ReferenceClipPathOperation>(style.clipPath())) {
</span><span class="cx">         auto& referenceClipPathOperation = downcast<ReferenceClipPathOperation>(*style.clipPath());
</span><span class="cx">         if (auto* clipperRenderer = renderer().ensureReferencedSVGResources().referencedClipperRenderer(renderer().document(), referenceClipPathOperation)) {
</span><del>-            context.save();
-            auto referenceBox = snapRectToDevicePixels(clipPathObjectBoundingBox, renderer().document().deviceScaleFactor());
-            auto offset = referenceBox.location();
</del><ins>+            // Use the border box as the reference box, even though this is not clearly specified: https://github.com/w3c/csswg-drafts/issues/5786.
+            // clippedContentBounds is used as the reference box for inlines, which is also poorly specified: https://github.com/w3c/csswg-drafts/issues/6383.
+            auto referenceBox = computeReferenceBox(renderer(), CSSBoxType::BorderBox, offsetFromRoot, clippedContentBounds);
+            auto snappedReferenceBox = snapRectToDevicePixels(referenceBox, renderer().document().deviceScaleFactor());
+            auto offset = snappedReferenceBox.location();
</ins><span class="cx"> 
</span><del>-            auto clippedContentBounds = FloatRect(calculateLayerBounds(paintingInfo.rootLayer, offsetFromRoot, { UseLocalClipRectIfPossible }));
-            clippedContentBounds.moveBy(-offset);
</del><ins>+            auto snappedClippingBounds = snapRectToDevicePixels(clippedContentBounds, renderer().document().deviceScaleFactor());
+            snappedClippingBounds.moveBy(-offset);
</ins><span class="cx"> 
</span><ins>+            context.save();
</ins><span class="cx">             context.translate(offset);
</span><span class="cx">             FloatRect clipPathReferenceBox { { }, referenceBox.size() };
</span><del>-            clipperRenderer->applyClippingToContext(context, renderer(), clipPathReferenceBox, clippedContentBounds, renderer().style().effectiveZoom());
</del><ins>+            clipperRenderer->applyClippingToContext(context, renderer(), clipPathReferenceBox, snappedClippingBounds, renderer().style().effectiveZoom());
</ins><span class="cx">             context.translate(-offset);
</span><span class="cx">             return true;
</span><span class="cx">         }
</span></span></pre></div>
<a id="branchessafari61316branchSourceWebCorerenderingRenderLayerh"></a>
<div class="modfile"><h4>Modified: branches/safari-613.1.6-branch/Source/WebCore/rendering/RenderLayer.h (284498 => 284499)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.6-branch/Source/WebCore/rendering/RenderLayer.h    2021-10-19 21:44:07 UTC (rev 284498)
+++ branches/safari-613.1.6-branch/Source/WebCore/rendering/RenderLayer.h       2021-10-19 21:46:07 UTC (rev 284499)
</span><span class="lines">@@ -968,7 +968,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool setupFontSubpixelQuantization(GraphicsContext&, bool& didQuantizeFonts);
</span><span class="cx"> 
</span><del>-    Path computeClipPath(const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, WindRule&) const;
</del><ins>+    std::pair<Path, WindRule> computeClipPath(const LayoutSize& offsetFromRoot, const LayoutRect& rootRelativeBoundsForNonBoxes) const;
</ins><span class="cx"> 
</span><span class="cx">     bool setupClipPath(GraphicsContext&, const LayerPaintingInfo&, const LayoutSize& offsetFromRoot);
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari61316branchSourceWebCorerenderingRenderLayerBackingcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-613.1.6-branch/Source/WebCore/rendering/RenderLayerBacking.cpp (284498 => 284499)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-613.1.6-branch/Source/WebCore/rendering/RenderLayerBacking.cpp   2021-10-19 21:44:07 UTC (rev 284498)
+++ branches/safari-613.1.6-branch/Source/WebCore/rendering/RenderLayerBacking.cpp      2021-10-19 21:46:07 UTC (rev 284499)
</span><span class="lines">@@ -1617,12 +1617,11 @@
</span><span class="cx">         if (renderer().hasClipPath()) {
</span><span class="cx">             ASSERT(renderer().style().clipPath()->type() != ClipPathOperation::Reference);
</span><span class="cx"> 
</span><del>-            WindRule windRule;
-            // FIXME: Use correct reference box for inlines: https://bugs.webkit.org/show_bug.cgi?id=129047
</del><ins>+            // FIXME: Use correct reference box for inlines: https://bugs.webkit.org/show_bug.cgi?id=129047, https://github.com/w3c/csswg-drafts/issues/6383
</ins><span class="cx">             LayoutRect boundingBox = m_owningLayer.boundingBox(&m_owningLayer);
</span><span class="cx">             LayoutRect referenceBoxForClippedInline = LayoutRect(snapRectToDevicePixels(boundingBox, deviceScaleFactor()));
</span><span class="cx">             LayoutSize offset = LayoutSize(snapSizeToDevicePixel(-m_subpixelOffsetFromRenderer, LayoutPoint(), deviceScaleFactor()));
</span><del>-            Path clipPath = m_owningLayer.computeClipPath(offset, referenceBoxForClippedInline, windRule);
</del><ins>+            auto [clipPath, windRule] = m_owningLayer.computeClipPath(offset, referenceBoxForClippedInline);
</ins><span class="cx"> 
</span><span class="cx">             FloatSize pathOffset = m_maskLayer->offsetFromRenderer();
</span><span class="cx">             if (!pathOffset.isZero())
</span></span></pre>
</div>
</div>

</body>
</html>