<!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>[260950] trunk</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/260950">260950</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2020-04-30 07:39:02 -0700 (Thu, 30 Apr 2020)</dd>
</dl>

<h3>Log Message</h3>
<pre>border-radius fails to clip iframe contents
https://bugs.webkit.org/show_bug.cgi?id=211199
Source/WebCore:

<rdar://problem/61945671>

Reviewed by Zalan Bujtas.

iframes need to use the same composited clipping strategy that we use for other
replaced elements with composited contents, like video and WebGL. To achieve this,
change GraphicsLayer to allow child GraphicsLayers to be parented in the contents
clipping layer, just like content layers are. (We don't want to do this unconditionally,
because it will change behavior for video with controls.)

Add GraphicsLayer::contentsRectClipsDescendants(), and used it to run code that
creates the contents clipping (and optional shape) layers even when no contents
layer is present. Fix up the sublayer list building to parent layers from
children in the contents clipping layer.

Tests: compositing/iframes/border-radius-composited-frame.html
       compositing/iframes/border-uneven-radius-composited-frame.html

* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::GraphicsLayer):
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::contentsRectClipsDescendants const):
(WebCore::GraphicsLayer::setContentsRectClipsDescendants):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::setContentsRectClipsDescendants):
(WebCore::GraphicsLayerCA::updateSublayerList):
(WebCore::GraphicsLayerCA::updateContentsRects):
(WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
* platform/graphics/ca/GraphicsLayerCA.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateConfiguration):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::isCompositedSubframeRenderer):
* rendering/RenderLayerCompositor.h:

LayoutTests:

Reviewed by Zalan Bujtas.

* compositing/iframes/border-radius-composited-frame-expected.html: Added.
* compositing/iframes/border-radius-composited-frame.html: Added.
* compositing/iframes/border-uneven-radius-composited-frame-expected.html: Added.
* compositing/iframes/border-uneven-radius-composited-frame.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1TestExpectations">trunk/LayoutTests/platform/mac-wk1/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsLayercpp">trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsLayerh">trunk/Source/WebCore/platform/graphics/GraphicsLayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAcpp">trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAh">trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerBackingcpp">trunk/Source/WebCore/rendering/RenderLayerBacking.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorcpp">trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorh">trunk/Source/WebCore/rendering/RenderLayerCompositor.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscompositingiframesborderradiuscompositedframeexpectedhtml">trunk/LayoutTests/compositing/iframes/border-radius-composited-frame-expected.html</a></li>
<li><a href="#trunkLayoutTestscompositingiframesborderradiuscompositedframehtml">trunk/LayoutTests/compositing/iframes/border-radius-composited-frame.html</a></li>
<li><a href="#trunkLayoutTestscompositingiframesborderunevenradiuscompositedframeexpectedhtml">trunk/LayoutTests/compositing/iframes/border-uneven-radius-composited-frame-expected.html</a></li>
<li><a href="#trunkLayoutTestscompositingiframesborderunevenradiuscompositedframehtml">trunk/LayoutTests/compositing/iframes/border-uneven-radius-composited-frame.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (260949 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2020-04-30 14:04:51 UTC (rev 260949)
+++ trunk/LayoutTests/ChangeLog 2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2020-04-30  Simon Fraser  <simon.fraser@apple.com>
+
+        border-radius fails to clip iframe contents
+        https://bugs.webkit.org/show_bug.cgi?id=211199
+
+        Reviewed by Zalan Bujtas.
+
+        * compositing/iframes/border-radius-composited-frame-expected.html: Added.
+        * compositing/iframes/border-radius-composited-frame.html: Added.
+        * compositing/iframes/border-uneven-radius-composited-frame-expected.html: Added.
+        * compositing/iframes/border-uneven-radius-composited-frame.html: Added.
+
</ins><span class="cx"> 2020-04-30  Philippe Normand  <pnormand@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [SOUP] http/tests/media/video-accept-encoding.html fails
</span></span></pre></div>
<a id="trunkLayoutTestscompositingiframesborderradiuscompositedframeexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/iframes/border-radius-composited-frame-expected.html (0 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/iframes/border-radius-composited-frame-expected.html                               (rev 0)
+++ trunk/LayoutTests/compositing/iframes/border-radius-composited-frame-expected.html  2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        .wrapper {
+            height: 400px;
+            width: 400px;
+            border: 10px solid black;
+            box-sizing: border-box;
+            border-radius: 50%;
+            overflow: hidden;
+            transform: translateZ(0);
+        }
+        
+        .composited {
+            transform: translateZ(0);
+        }
+        
+        .box {
+            width: 100%;
+            height: 100%;
+            background-color: silver;
+        }
+    </style>
+</head>
+<body>
+    <div class="wrapper">
+        <div class="composited box">asd
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingiframesborderradiuscompositedframehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/iframes/border-radius-composited-frame.html (0 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/iframes/border-radius-composited-frame.html                                (rev 0)
+++ trunk/LayoutTests/compositing/iframes/border-radius-composited-frame.html   2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        iframe {
+            height: 400px;
+            width: 400px;
+            border: 10px solid black;
+            box-sizing: border-box;
+            border-radius: 50%;
+        }
+    </style>
+</head>
+<body>
+    <iframe srcdoc="
+       <style>
+        body {
+            background-color: silver;
+            margin: 0;
+                   transform: translateZ(0);
+        }
+       </style>
+    "></iframe>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingiframesborderunevenradiuscompositedframeexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/iframes/border-uneven-radius-composited-frame-expected.html (0 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/iframes/border-uneven-radius-composited-frame-expected.html                                (rev 0)
+++ trunk/LayoutTests/compositing/iframes/border-uneven-radius-composited-frame-expected.html   2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        .wrapper {
+            height: 400px;
+            width: 400px;
+            border: 10px solid black;
+            box-sizing: border-box;
+            border-top-left-radius: 30%;
+            overflow: hidden;
+            transform: translateZ(0);
+        }
+        
+        .composited {
+            transform: translateZ(0);
+        }
+        
+        .box {
+            width: 100%;
+            height: 100%;
+            background-color: silver;
+        }
+    </style>
+</head>
+<body>
+    <div class="wrapper">
+        <div class="composited box">asd
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingiframesborderunevenradiuscompositedframehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/iframes/border-uneven-radius-composited-frame.html (0 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/iframes/border-uneven-radius-composited-frame.html                         (rev 0)
+++ trunk/LayoutTests/compositing/iframes/border-uneven-radius-composited-frame.html    2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        iframe {
+            height: 400px;
+            width: 400px;
+            border: 10px solid black;
+            box-sizing: border-box;
+            border-top-left-radius: 30%;
+        }
+    </style>
+</head>
+<body>
+    <iframe srcdoc="
+       <style>
+        body {
+            background-color: silver;
+            margin: 0;
+                   transform: translateZ(0);
+        }
+       </style>
+    "></iframe>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (260949 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/TestExpectations      2020-04-30 14:04:51 UTC (rev 260949)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations 2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -389,6 +389,7 @@
</span><span class="cx"> fast/scrolling/overflow-scrollable-after-back.html [ Skip ]
</span><span class="cx"> 
</span><span class="cx"> compositing/rtl/rtl-fixed-overflow-scrolled.html [ Failure ]
</span><ins>+compositing/iframes/border-uneven-radius-composited-frame.html [ ImageOnlyFailure ]
</ins><span class="cx"> compositing/iframes/overlapped-nested-iframes.html [ Pass Failure ]
</span><span class="cx"> compositing/clipping/border-radius-async-overflow-non-stacking.html [ ImageOnlyFailure ]
</span><span class="cx"> compositing/visibility/visibility-change-in-subframe.html [ Failure ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (260949 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2020-04-30 14:04:51 UTC (rev 260949)
+++ trunk/Source/WebCore/ChangeLog      2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2020-04-30  Simon Fraser  <simon.fraser@apple.com>
+
+        border-radius fails to clip iframe contents
+        https://bugs.webkit.org/show_bug.cgi?id=211199
+        <rdar://problem/61945671>
+
+        Reviewed by Zalan Bujtas.
+
+        iframes need to use the same composited clipping strategy that we use for other
+        replaced elements with composited contents, like video and WebGL. To achieve this,
+        change GraphicsLayer to allow child GraphicsLayers to be parented in the contents
+        clipping layer, just like content layers are. (We don't want to do this unconditionally,
+        because it will change behavior for video with controls.)
+
+        Add GraphicsLayer::contentsRectClipsDescendants(), and used it to run code that
+        creates the contents clipping (and optional shape) layers even when no contents
+        layer is present. Fix up the sublayer list building to parent layers from
+        children in the contents clipping layer.
+
+        Tests: compositing/iframes/border-radius-composited-frame.html
+               compositing/iframes/border-uneven-radius-composited-frame.html
+
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::GraphicsLayer):
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::contentsRectClipsDescendants const):
+        (WebCore::GraphicsLayer::setContentsRectClipsDescendants):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::setContentsRectClipsDescendants):
+        (WebCore::GraphicsLayerCA::updateSublayerList):
+        (WebCore::GraphicsLayerCA::updateContentsRects):
+        (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateConfiguration):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::isCompositedSubframeRenderer):
+        * rendering/RenderLayerCompositor.h:
+
</ins><span class="cx"> 2020-04-30  Zalan Bujtas  <zalan@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [LFC][TFC] Adjust the available vertical space with the row span for cell layout
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (260949 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp 2020-04-30 14:04:51 UTC (rev 260949)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp    2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -135,6 +135,7 @@
</span><span class="cx">     , m_masksToBounds(false)
</span><span class="cx">     , m_drawsContent(false)
</span><span class="cx">     , m_contentsVisible(true)
</span><ins>+    , m_contentsRectClipsDescendants(false)
</ins><span class="cx">     , m_acceleratesDrawing(false)
</span><span class="cx">     , m_usesDisplayListDrawing(false)
</span><span class="cx">     , m_appliesPageScale(false)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (260949 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h   2020-04-30 14:04:51 UTC (rev 260949)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h      2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -451,6 +451,10 @@
</span><span class="cx">     // Set a rounded rect that will be used to clip the layer contents.
</span><span class="cx">     FloatRoundedRect contentsClippingRect() const { return m_contentsClippingRect; }
</span><span class="cx">     virtual void setContentsClippingRect(const FloatRoundedRect& roundedRect) { m_contentsClippingRect = roundedRect; }
</span><ins>+    
+    // If true, contentsClippingRect is used to clip child GraphicsLayers.
+    bool contentsRectClipsDescendants() const { return m_contentsRectClipsDescendants; }
+    virtual void setContentsRectClipsDescendants(bool b) { m_contentsRectClipsDescendants = b; }
</ins><span class="cx"> 
</span><span class="cx">     // Set a rounded rect that is used to clip this layer and its descendants (implies setting masksToBounds).
</span><span class="cx">     // Returns false if the platform can't support this rounded clip, and we should fall back to painting a mask.
</span><span class="lines">@@ -711,6 +715,7 @@
</span><span class="cx">     bool m_masksToBounds : 1;
</span><span class="cx">     bool m_drawsContent : 1;
</span><span class="cx">     bool m_contentsVisible : 1;
</span><ins>+    bool m_contentsRectClipsDescendants : 1;
</ins><span class="cx">     bool m_acceleratesDrawing : 1;
</span><span class="cx">     bool m_usesDisplayListDrawing : 1;
</span><span class="cx">     bool m_appliesPageScale : 1; // Set for the layer which has the page scale applied to it.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (260949 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp    2020-04-30 14:04:51 UTC (rev 260949)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp       2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -967,6 +967,15 @@
</span><span class="cx">     noteLayerPropertyChanged(ContentsRectsChanged);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GraphicsLayerCA::setContentsRectClipsDescendants(bool contentsRectClipsDescendants)
+{
+    if (contentsRectClipsDescendants == m_contentsRectClipsDescendants)
+        return;
+
+    GraphicsLayer::setContentsRectClipsDescendants(contentsRectClipsDescendants);
+    noteLayerPropertyChanged(ChildrenChanged | ContentsRectsChanged);
+}
+
</ins><span class="cx"> bool GraphicsLayerCA::setMasksToBoundsRect(const FloatRoundedRect& roundedRect)
</span><span class="cx"> {
</span><span class="cx">     if (roundedRect == m_masksToBoundsRect)
</span><span class="lines">@@ -2019,19 +2028,31 @@
</span><span class="cx"> #endif
</span><span class="cx">     };
</span><span class="cx"> 
</span><ins>+    auto buildChildLayerList = [&](PlatformCALayerList& list) {
+        appendLayersFromChildren(list);
+        appendDebugLayers(list);
+    };
+
</ins><span class="cx">     PlatformCALayerList primaryLayerChildren;
</span><span class="cx">     appendCustomAndClippingLayers(primaryLayerChildren);
</span><span class="cx"> 
</span><ins>+    bool clippingLayerHostsChildren = m_contentsRectClipsDescendants && m_contentsClippingLayer;
+    if (clippingLayerHostsChildren) {
+        PlatformCALayerList clippingChildren;
+        buildChildLayerList(clippingChildren);
+        m_contentsClippingLayer->setSublayers(clippingChildren);
+    }
+
</ins><span class="cx">     if (m_structuralLayer) {
</span><span class="cx">         PlatformCALayerList layerList;
</span><span class="cx">         appendStructuralLayerChildren(layerList);
</span><del>-        appendLayersFromChildren(layerList);
-        appendDebugLayers(layerList);
</del><ins>+
+        if (!clippingLayerHostsChildren)
+            buildChildLayerList(layerList);
+
</ins><span class="cx">         m_structuralLayer->setSublayers(layerList);
</span><del>-    } else {
-        appendLayersFromChildren(primaryLayerChildren);
-        appendDebugLayers(primaryLayerChildren);
-    }
</del><ins>+    } else if (!clippingLayerHostsChildren)
+        buildChildLayerList(primaryLayerChildren);
</ins><span class="cx"> 
</span><span class="cx">     m_layer->setSublayers(primaryLayerChildren);
</span><span class="cx"> }
</span><span class="lines">@@ -2677,7 +2698,7 @@
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerCA::updateContentsRects()
</span><span class="cx"> {
</span><del>-    if (!m_contentsLayer)
</del><ins>+    if (!m_contentsLayer && !m_contentsRectClipsDescendants)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     auto contentBounds = FloatRect { { }, m_contentsRect.size() };
</span><span class="lines">@@ -2700,13 +2721,14 @@
</span><span class="cx">         
</span><span class="cx">         updateClippingStrategy(*m_contentsClippingLayer, m_contentsShapeMaskLayer, m_contentsClippingRect);
</span><span class="cx"> 
</span><del>-        if (gainedOrLostClippingLayer) {
</del><ins>+        if (m_contentsLayer && gainedOrLostClippingLayer) {
</ins><span class="cx">             m_contentsLayer->removeFromSuperlayer();
</span><span class="cx">             m_contentsClippingLayer->appendSublayer(*m_contentsLayer);
</span><span class="cx">         }
</span><span class="cx">     } else {
</span><span class="cx">         if (m_contentsClippingLayer) {
</span><del>-            m_contentsLayer->removeFromSuperlayer();
</del><ins>+            if (m_contentsLayer)
+                m_contentsLayer->removeFromSuperlayer();
</ins><span class="cx"> 
</span><span class="cx">             m_contentsClippingLayer->removeFromSuperlayer();
</span><span class="cx">             m_contentsClippingLayer->setOwner(nullptr);
</span><span class="lines">@@ -2724,8 +2746,10 @@
</span><span class="cx">     if (gainedOrLostClippingLayer)
</span><span class="cx">         noteSublayersChanged(DontScheduleFlush);
</span><span class="cx"> 
</span><del>-    m_contentsLayer->setPosition(m_contentsRect.location());
-    m_contentsLayer->setBounds(contentBounds);
</del><ins>+    if (m_contentsLayer) {
+        m_contentsLayer->setPosition(m_contentsRect.location());
+        m_contentsLayer->setBounds(contentBounds);
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (m_layerClones) {
</span><span class="cx">         for (auto& layer : m_layerClones->contentsLayerClones.values()) {
</span><span class="lines">@@ -3615,7 +3639,13 @@
</span><span class="cx"> 
</span><span class="cx"> PlatformCALayer* GraphicsLayerCA::hostLayerForSublayers() const
</span><span class="cx"> {
</span><del>-    return m_structuralLayer.get() ? m_structuralLayer.get() : m_layer.get(); 
</del><ins>+    if (contentsRectClipsDescendants() && m_contentsClippingLayer)
+        return m_contentsClippingLayer.get();
+
+    if (m_structuralLayer)
+        return m_structuralLayer.get();
+
+    return m_layer.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PlatformCALayer* GraphicsLayerCA::layerForSuperlayer() const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (260949 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h      2020-04-30 14:04:51 UTC (rev 260949)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -120,6 +120,7 @@
</span><span class="cx">     
</span><span class="cx">     WEBCORE_EXPORT void setContentsRect(const FloatRect&) override;
</span><span class="cx">     WEBCORE_EXPORT void setContentsClippingRect(const FloatRoundedRect&) override;
</span><ins>+    WEBCORE_EXPORT void setContentsRectClipsDescendants(bool) override;
</ins><span class="cx">     WEBCORE_EXPORT bool setMasksToBoundsRect(const FloatRoundedRect&) override;
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void setShapeLayerPath(const Path&) override;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerBackingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (260949 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp    2020-04-30 14:04:51 UTC (rev 260949)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp       2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -967,6 +967,11 @@
</span><span class="cx">         layerConfigChanged = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if (RenderLayerCompositor::isCompositedSubframeRenderer(renderer())) {
+        m_graphicsLayer->setContentsRectClipsDescendants(true);
+        updateContentsRects();
+    }
+
</ins><span class="cx">     if (is<RenderImage>(renderer()) && downcast<RenderImage>(renderer()).isEditableImage()) {
</span><span class="cx">         auto element = renderer().element();
</span><span class="cx">         if (is<HTMLImageElement>(element)) {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (260949 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2020-04-30 14:04:51 UTC (rev 260949)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp    2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -2823,6 +2823,14 @@
</span><span class="cx">     return containerScrollingNodeID;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool RenderLayerCompositor::isCompositedSubframeRenderer(const RenderObject& renderer)
+{
+    if (!is<RenderWidget>(renderer))
+        return false;
+
+    return downcast<RenderWidget>(renderer).requiresAcceleratedCompositing();
+}
+
</ins><span class="cx"> // Return true if the given layer is a stacking context and has compositing child
</span><span class="cx"> // layers that it needs to clip. In this case we insert a clipping GraphicsLayer
</span><span class="cx"> // into the hierarchy between this layer and its children in the z-order hierarchy.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.h (260949 => 260950)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.h   2020-04-30 14:04:51 UTC (rev 260949)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.h      2020-04-30 14:39:02 UTC (rev 260950)
</span><span class="lines">@@ -295,6 +295,7 @@
</span><span class="cx">     // to know if there is non-affine content, e.g. for drawing into an image.
</span><span class="cx">     bool has3DContent() const;
</span><span class="cx">     
</span><ins>+    static bool isCompositedSubframeRenderer(const RenderObject&);
</ins><span class="cx">     static RenderLayerCompositor* frameContentsCompositor(RenderWidget&);
</span><span class="cx">     // Return true if the layers changed.
</span><span class="cx">     bool parentFrameContentLayers(RenderWidget&);
</span></span></pre>
</div>
</div>

</body>
</html>