<!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>[245630] branches/safari-608.1.24.20-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/245630">245630</a></dd>
<dt>Author</dt> <dd>kocsen_chung@apple.com</dd>
<dt>Date</dt> <dd>2019-05-22 10:49:43 -0700 (Wed, 22 May 2019)</dd>
</dl>

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

    Backing-sharing layers with transforms render incorrectly
    https://bugs.webkit.org/show_bug.cgi?id=197692
    <rdar://problem/50652127>

    Reviewed by Antti Koivisto.
    Source/WebCore:

    Layers that paint into shared backing need to enter the RenderLayer painting code
    in a way that paints the filters, transforms, opacity and blending.

    RenderLayerBacking::paintIntoLayer() normally enters at paintLayerContents(), because
    the effects are rendered via the GraphicsLayer, but shared layers will paint effects.
    Note that if the backing-provider has effects, it will be the stacking context
    for the shared layers, so it's correct that sharing layers are impacted by effects
    on the backing-provider.

    In addition, we have to ensure that we don't over-eagerly make layers shared.
    Consider:

    <div class="clipping">
        <div class="sharing">
            <div class="inner">
            </div>
        </div>
    </div>

    Here "clipping" is the provider layer, "sharing" paints into shared backing, but
    we don't want to also mark "inner" as sharing, since "sharing" will just paint it.
    This is akin to avoiding unnecessary compositing of z-order descendants when they can just
    paint.

    To do this we need to ensure that sharing layers are treated like compositing layers
    in the overlap map, i.e. when a layer is sharing, we call overlapMap.pushCompositingContainer(),
    and later overlapMap.popCompositingContainer().

    Tests: compositing/shared-backing/nested-shared-layers-with-opacity.html
           compositing/shared-backing/shared-layer-has-blending.html
           compositing/shared-backing/shared-layer-has-filter.html
           compositing/shared-backing/shared-layer-has-opacity.html
           compositing/shared-backing/shared-layer-has-reflection.html
           compositing/shared-backing/shared-layer-has-transform.html
           compositing/shared-backing/shared-layer-isolates-blending.html
           compositing/shared-backing/shared-transformed-layer-bounds.html
           compositing/shared-backing/sharing-layer-becomes-non-scrollable.html
           compositing/shared-backing/sharing-layer-has-effect.html

    * rendering/RenderLayer.cpp:
    (WebCore::RenderLayer::paintLayer):
    (WebCore::RenderLayer::paintLayerWithEffects):
    * rendering/RenderLayer.h:
    * rendering/RenderLayerBacking.cpp:
    (WebCore::RenderLayerBacking::paintIntoLayer):
    * rendering/RenderLayerCompositor.cpp:
    (WebCore::RenderLayerCompositor::CompositingState::stateForPaintOrderChildren const):
    (WebCore::backingProviderLayerCanIncludeLayer):
    (WebCore::RenderLayerCompositor::computeCompositingRequirements):
    (WebCore::RenderLayerCompositor::traverseUnchangedSubtree):

    LayoutTests:

    Ref tests for effects on sharing layers. The references make "clipping" be stacking context via z-index,
    which eliminates sharing.

    * compositing/shared-backing/nested-shared-layers-with-opacity-expected.html: Added.
    * compositing/shared-backing/nested-shared-layers-with-opacity.html: Added.
    * compositing/shared-backing/shared-layer-has-blending-expected.html: Added.
    * compositing/shared-backing/shared-layer-has-blending.html: Added.
    * compositing/shared-backing/shared-layer-has-filter-expected.html: Added.
    * compositing/shared-backing/shared-layer-has-filter.html: Added.
    * compositing/shared-backing/shared-layer-has-opacity-expected.html: Added.
    * compositing/shared-backing/shared-layer-has-opacity.html: Added.
    * compositing/shared-backing/shared-layer-has-reflection-expected.html: Added.
    * compositing/shared-backing/shared-layer-has-reflection.html: Added.
    * compositing/shared-backing/shared-layer-has-transform-expected.html: Added.
    * compositing/shared-backing/shared-layer-has-transform.html: Added.
    * compositing/shared-backing/shared-layer-isolates-blending-expected.html: Added.
    * compositing/shared-backing/shared-layer-isolates-blending.html: Added.

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

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari60812420branchLayoutTestsChangeLog">branches/safari-608.1.24.20-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari60812420branchSourceWebCoreChangeLog">branches/safari-608.1.24.20-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari60812420branchSourceWebCorerenderingRenderLayercpp">branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#branchessafari60812420branchSourceWebCorerenderingRenderLayerh">branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayer.h</a></li>
<li><a href="#branchessafari60812420branchSourceWebCorerenderingRenderLayerBackingcpp">branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayerBacking.cpp</a></li>
<li><a href="#branchessafari60812420branchSourceWebCorerenderingRenderLayerCompositorcpp">branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingnestedsharedlayerswithopacityexpectedhtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/nested-shared-layers-with-opacity-expected.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingnestedsharedlayerswithopacityhtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/nested-shared-layers-with-opacity.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasblendingexpectedhtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-blending-expected.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasblendinghtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-blending.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasfilterexpectedhtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-filter-expected.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasfilterhtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-filter.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasopacityexpectedhtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-opacity-expected.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasopacityhtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-opacity.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasreflectionexpectedhtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-reflection-expected.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasreflectionhtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-reflection.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhastransformexpectedhtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-transform-expected.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhastransformhtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-transform.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerisolatesblendingexpectedhtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-isolates-blending-expected.html</a></li>
<li><a href="#branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerisolatesblendinghtml">branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-isolates-blending.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari60812420branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/LayoutTests/ChangeLog (245629 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/ChangeLog 2019-05-22 17:49:37 UTC (rev 245629)
+++ branches/safari-608.1.24.20-branch/LayoutTests/ChangeLog    2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -1,5 +1,116 @@
</span><span class="cx"> 2019-05-22  Kocsen Chung  <kocsen_chung@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r245205. rdar://problem/50652127
+
+    Backing-sharing layers with transforms render incorrectly
+    https://bugs.webkit.org/show_bug.cgi?id=197692
+    <rdar://problem/50652127>
+    
+    Reviewed by Antti Koivisto.
+    Source/WebCore:
+    
+    Layers that paint into shared backing need to enter the RenderLayer painting code
+    in a way that paints the filters, transforms, opacity and blending.
+    
+    RenderLayerBacking::paintIntoLayer() normally enters at paintLayerContents(), because
+    the effects are rendered via the GraphicsLayer, but shared layers will paint effects.
+    Note that if the backing-provider has effects, it will be the stacking context
+    for the shared layers, so it's correct that sharing layers are impacted by effects
+    on the backing-provider.
+    
+    In addition, we have to ensure that we don't over-eagerly make layers shared.
+    Consider:
+    
+    <div class="clipping">
+        <div class="sharing">
+            <div class="inner">
+            </div>
+        </div>
+    </div>
+    
+    Here "clipping" is the provider layer, "sharing" paints into shared backing, but
+    we don't want to also mark "inner" as sharing, since "sharing" will just paint it.
+    This is akin to avoiding unnecessary compositing of z-order descendants when they can just
+    paint.
+    
+    To do this we need to ensure that sharing layers are treated like compositing layers
+    in the overlap map, i.e. when a layer is sharing, we call overlapMap.pushCompositingContainer(),
+    and later overlapMap.popCompositingContainer().
+    
+    Tests: compositing/shared-backing/nested-shared-layers-with-opacity.html
+           compositing/shared-backing/shared-layer-has-blending.html
+           compositing/shared-backing/shared-layer-has-filter.html
+           compositing/shared-backing/shared-layer-has-opacity.html
+           compositing/shared-backing/shared-layer-has-reflection.html
+           compositing/shared-backing/shared-layer-has-transform.html
+           compositing/shared-backing/shared-layer-isolates-blending.html
+           compositing/shared-backing/shared-transformed-layer-bounds.html
+           compositing/shared-backing/sharing-layer-becomes-non-scrollable.html
+           compositing/shared-backing/sharing-layer-has-effect.html
+    
+    * rendering/RenderLayer.cpp:
+    (WebCore::RenderLayer::paintLayer):
+    (WebCore::RenderLayer::paintLayerWithEffects):
+    * rendering/RenderLayer.h:
+    * rendering/RenderLayerBacking.cpp:
+    (WebCore::RenderLayerBacking::paintIntoLayer):
+    * rendering/RenderLayerCompositor.cpp:
+    (WebCore::RenderLayerCompositor::CompositingState::stateForPaintOrderChildren const):
+    (WebCore::backingProviderLayerCanIncludeLayer):
+    (WebCore::RenderLayerCompositor::computeCompositingRequirements):
+    (WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
+    
+    LayoutTests:
+    
+    Ref tests for effects on sharing layers. The references make "clipping" be stacking context via z-index,
+    which eliminates sharing.
+    
+    * compositing/shared-backing/nested-shared-layers-with-opacity-expected.html: Added.
+    * compositing/shared-backing/nested-shared-layers-with-opacity.html: Added.
+    * compositing/shared-backing/shared-layer-has-blending-expected.html: Added.
+    * compositing/shared-backing/shared-layer-has-blending.html: Added.
+    * compositing/shared-backing/shared-layer-has-filter-expected.html: Added.
+    * compositing/shared-backing/shared-layer-has-filter.html: Added.
+    * compositing/shared-backing/shared-layer-has-opacity-expected.html: Added.
+    * compositing/shared-backing/shared-layer-has-opacity.html: Added.
+    * compositing/shared-backing/shared-layer-has-reflection-expected.html: Added.
+    * compositing/shared-backing/shared-layer-has-reflection.html: Added.
+    * compositing/shared-backing/shared-layer-has-transform-expected.html: Added.
+    * compositing/shared-backing/shared-layer-has-transform.html: Added.
+    * compositing/shared-backing/shared-layer-isolates-blending-expected.html: Added.
+    * compositing/shared-backing/shared-layer-isolates-blending.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245205 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-05-11  Simon Fraser  <simon.fraser@apple.com>
+
+            Backing-sharing layers with transforms render incorrectly
+            https://bugs.webkit.org/show_bug.cgi?id=197692
+            <rdar://problem/50652127>
+
+            Reviewed by Antti Koivisto.
+
+            Ref tests for effects on sharing layers. The references make "clipping" be stacking context via z-index,
+            which eliminates sharing.
+
+            * compositing/shared-backing/nested-shared-layers-with-opacity-expected.html: Added.
+            * compositing/shared-backing/nested-shared-layers-with-opacity.html: Added.
+            * compositing/shared-backing/shared-layer-has-blending-expected.html: Added.
+            * compositing/shared-backing/shared-layer-has-blending.html: Added.
+            * compositing/shared-backing/shared-layer-has-filter-expected.html: Added.
+            * compositing/shared-backing/shared-layer-has-filter.html: Added.
+            * compositing/shared-backing/shared-layer-has-opacity-expected.html: Added.
+            * compositing/shared-backing/shared-layer-has-opacity.html: Added.
+            * compositing/shared-backing/shared-layer-has-reflection-expected.html: Added.
+            * compositing/shared-backing/shared-layer-has-reflection.html: Added.
+            * compositing/shared-backing/shared-layer-has-transform-expected.html: Added.
+            * compositing/shared-backing/shared-layer-has-transform.html: Added.
+            * compositing/shared-backing/shared-layer-isolates-blending-expected.html: Added.
+            * compositing/shared-backing/shared-layer-isolates-blending.html: Added.
+
+2019-05-22  Kocsen Chung  <kocsen_chung@apple.com>
+
</ins><span class="cx">         Cherry-pick r245181. rdar://problem/50670806
</span><span class="cx"> 
</span><span class="cx">     ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant()) on nytimes.com after r245170
</span></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingnestedsharedlayerswithopacityexpectedhtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/nested-shared-layers-with-opacity-expected.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/nested-shared-layers-with-opacity-expected.html                                (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/nested-shared-layers-with-opacity-expected.html   2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,51 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <title>Tests painting of a layer with opacity into shared backing</title>
+    <style>
+        .clipping {
+            position: absolute;
+            z-index: 0;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+
+               .box {
+                       position: relative;
+                       top: 50px;
+                       left: 50px;
+            width: 180px;
+            height: 180px;
+            background-color: green;
+               }
+               
+               .opacity {
+            opacity: 0.5;
+               }
+    
+        .composited {
+            transform: translateZ(0);
+        }
+        
+        .trigger {
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+        
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing opacity box">
+                       <div class="opacity box"></div>
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingnestedsharedlayerswithopacityhtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/nested-shared-layers-with-opacity.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/nested-shared-layers-with-opacity.html                         (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/nested-shared-layers-with-opacity.html    2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <title>Tests painting of a layer with opacity into shared backing</title>
+    <style>
+        .clipping {
+            position: absolute;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+
+               .box {
+                       position: relative;
+                       top: 50px;
+                       left: 50px;
+            width: 180px;
+            height: 180px;
+            background-color: green;
+               }
+               
+               .opacity {
+            opacity: 0.5;
+               }
+    
+        .composited {
+            transform: translateZ(0);
+        }
+        
+        .trigger {
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+        
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing opacity box">
+                       <div class="opacity box"></div>
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasblendingexpectedhtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-blending-expected.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-blending-expected.html                                (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-blending-expected.html   2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        .clipping {
+            position: absolute;
+            z-index: 0;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+        
+        .sharing {
+                       position: relative;
+                       top: 50px;
+                       left: 50px;
+            width: 180px;
+            height: 180px;
+            background-color: green;
+        }
+        
+        .blending {
+            mix-blend-mode: difference;
+        }
+
+        .trigger {
+            transform: translateZ(0);
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+        
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing blending box">
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasblendinghtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-blending.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-blending.html                         (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-blending.html    2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <title>Tests painting of a layer with mix-blend-mode into shared backing</title>
+    <style>
+        .clipping {
+            position: absolute;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+        
+        .sharing {
+                       position: relative;
+                       top: 50px;
+                       left: 50px;
+            width: 180px;
+            height: 180px;
+            background-color: green;
+        }
+        
+        .blending {
+            mix-blend-mode: difference;
+        }
+
+        .trigger {
+            transform: translateZ(0);
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+        
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing blending box">
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasfilterexpectedhtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-filter-expected.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-filter-expected.html                          (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-filter-expected.html     2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        .clipping {
+            position: absolute;
+            z-index: 0;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+        
+        .sharing {
+                       position: relative;
+                       top: 50px;
+                       left: 50px;
+            width: 180px;
+            height: 180px;
+            background-color: green;
+        }
+        
+        .filtered {
+            filter: saturate(0);
+        }
+
+        .trigger {
+            transform: translateZ(0);
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+        
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing filtered box">
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasfilterhtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-filter.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-filter.html                           (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-filter.html      2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <title>Tests painting of a layer with a filter into shared backing</title>
+    <style>
+        .clipping {
+            position: absolute;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+        
+        .sharing {
+                       position: relative;
+                       top: 50px;
+                       left: 50px;
+            width: 180px;
+            height: 180px;
+            background-color: green;
+        }
+        
+        .filtered {
+            filter: saturate(0);
+        }
+
+        .trigger {
+            transform: translateZ(0);
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+        
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing filtered box">
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasopacityexpectedhtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-opacity-expected.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-opacity-expected.html                         (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-opacity-expected.html    2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <title>Tests painting of a layer with opacity into shared backing</title>
+    <style>
+        .clipping {
+            position: absolute;
+            z-index: 0;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+        
+        .sharing {
+                       position: relative;
+                       top: 50px;
+                       left: 50px;
+            width: 180px;
+            height: 180px;
+            background-color: green;
+        }
+        
+        .opacity {
+            opacity: 0.5;
+        }
+
+        .trigger {
+            transform: translateZ(0);
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+        
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing opacity box">
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasopacityhtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-opacity.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-opacity.html                          (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-opacity.html     2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <title>Tests painting of a layer with opacity into shared backing</title>
+    <style>
+        .clipping {
+            position: absolute;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+        
+        .sharing {
+                       position: relative;
+                       top: 50px;
+                       left: 50px;
+            width: 180px;
+            height: 180px;
+            background-color: green;
+        }
+        
+        .opacity {
+            opacity: 0.5;
+        }
+
+        .trigger {
+            transform: translateZ(0);
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+        
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing opacity box">
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasreflectionexpectedhtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-reflection-expected.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-reflection-expected.html                              (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-reflection-expected.html 2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        .clipping {
+            position: absolute;
+            z-index: 0;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+        
+        .sharing {
+                       position: relative;
+                       top: 50px;
+                       left: 50px;
+            width: 180px;
+            height: 160px;
+            background-color: green;
+            border-bottom: 20px solid orange;
+        }
+        
+        .reflected {
+            -webkit-box-reflect: below 10px;
+        }
+
+        .trigger {
+            transform: translateZ(0);
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+        
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing reflected box">
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhasreflectionhtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-reflection.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-reflection.html                               (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-reflection.html  2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <title>Tests painting of a layer with a reflection into shared backing</title>
+    <style>
+        .clipping {
+            position: absolute;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+        
+        .sharing {
+                       position: relative;
+                       top: 50px;
+                       left: 50px;
+            width: 180px;
+            height: 160px;
+            background-color: green;
+            border-bottom: 20px solid orange;
+        }
+        
+        .reflected {
+            -webkit-box-reflect: below 10px;
+        }
+
+        .trigger {
+            transform: translateZ(0);
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+        
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing reflected box">
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhastransformexpectedhtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-transform-expected.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-transform-expected.html                               (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-transform-expected.html  2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        .clipping {
+            position: absolute;
+            z-index: 0;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+        
+        .sharing {
+                       position: relative;
+                       top: 50px;
+                       left: 50px;
+            width: 180px;
+            height: 180px;
+            background-color: green;
+        }
+        
+        .transformed {
+            transform: rotate(45deg);
+        }
+
+        .trigger {
+            transform: translateZ(0);
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+        
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing transformed box">
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerhastransformhtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-transform.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-transform.html                                (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-has-transform.html   2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <title>Tests painting of a layer with a transform into shared backing</title>
+    <style>
+        .clipping {
+            position: absolute;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+        
+        .sharing {
+                       position: relative;
+                       top: 50px;
+                       left: 50px;
+            width: 180px;
+            height: 180px;
+            background-color: green;
+        }
+        
+        .transformed {
+            transform: rotate(45deg);
+        }
+
+        .trigger {
+            transform: translateZ(0);
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+        
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing transformed box">
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerisolatesblendingexpectedhtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-isolates-blending-expected.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-isolates-blending-expected.html                           (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-isolates-blending-expected.html      2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        .clipping {
+            position: absolute;
+            z-index: 0;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+        
+        .sharing {
+                       position: relative;
+                       top: 30px;
+                       left: 30px;
+            width: 180px;
+            height: 180px;
+            background-color: green;
+        }
+        
+        .isolation {
+            isolation: isolate;
+        }
+        
+        .blending {
+            position: relative;
+            top: 50px;
+            left: 50px;
+            width: 180px;
+            height: 180px;
+            mix-blend-mode: multiply;
+            background-color: green;
+        }
+
+        .trigger {
+            transform: translateZ(0);
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing isolation box">
+            <div class="blending"></div>
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchLayoutTestscompositingsharedbackingsharedlayerisolatesblendinghtml"></a>
<div class="addfile"><h4>Added: branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-isolates-blending.html (0 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-isolates-blending.html                            (rev 0)
+++ branches/safari-608.1.24.20-branch/LayoutTests/compositing/shared-backing/shared-layer-isolates-blending.html       2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+    <title>Tests painting of a layer which isolates blending into shared backing</title>
+    <style>
+        .clipping {
+            position: absolute;
+            top: 20px;
+            left: 20px;
+            overflow: hidden;
+            height: 300px;
+            width: 300px;
+            margin: 10px;
+            border: 1px solid black;
+        }
+        
+        .sharing {
+                       position: relative;
+                       top: 30px;
+                       left: 30px;
+            width: 180px;
+            height: 180px;
+            background-color: green;
+        }
+        
+        .isolation {
+            isolation: isolate;
+        }
+        
+        .blending {
+            position: relative;
+            top: 50px;
+            left: 50px;
+            width: 180px;
+            height: 180px;
+            mix-blend-mode: multiply;
+            background-color: green;
+        }
+
+        .trigger {
+            transform: translateZ(0);
+            width: 50px;
+            height: 50px;
+            background-color: silver;
+        }
+    </style>
+</head>
+<body>
+    <div class="composited trigger"></div>
+    <div class="clipping">
+        <div class="sharing isolation box">
+            <div class="blending"></div>
+        </div>
+    </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari60812420branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/ChangeLog (245629 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/ChangeLog      2019-05-22 17:49:37 UTC (rev 245629)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/ChangeLog 2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -1,5 +1,149 @@
</span><span class="cx"> 2019-05-22  Kocsen Chung  <kocsen_chung@apple.com>
</span><span class="cx"> 
</span><ins>+        Cherry-pick r245205. rdar://problem/50652127
+
+    Backing-sharing layers with transforms render incorrectly
+    https://bugs.webkit.org/show_bug.cgi?id=197692
+    <rdar://problem/50652127>
+    
+    Reviewed by Antti Koivisto.
+    Source/WebCore:
+    
+    Layers that paint into shared backing need to enter the RenderLayer painting code
+    in a way that paints the filters, transforms, opacity and blending.
+    
+    RenderLayerBacking::paintIntoLayer() normally enters at paintLayerContents(), because
+    the effects are rendered via the GraphicsLayer, but shared layers will paint effects.
+    Note that if the backing-provider has effects, it will be the stacking context
+    for the shared layers, so it's correct that sharing layers are impacted by effects
+    on the backing-provider.
+    
+    In addition, we have to ensure that we don't over-eagerly make layers shared.
+    Consider:
+    
+    <div class="clipping">
+        <div class="sharing">
+            <div class="inner">
+            </div>
+        </div>
+    </div>
+    
+    Here "clipping" is the provider layer, "sharing" paints into shared backing, but
+    we don't want to also mark "inner" as sharing, since "sharing" will just paint it.
+    This is akin to avoiding unnecessary compositing of z-order descendants when they can just
+    paint.
+    
+    To do this we need to ensure that sharing layers are treated like compositing layers
+    in the overlap map, i.e. when a layer is sharing, we call overlapMap.pushCompositingContainer(),
+    and later overlapMap.popCompositingContainer().
+    
+    Tests: compositing/shared-backing/nested-shared-layers-with-opacity.html
+           compositing/shared-backing/shared-layer-has-blending.html
+           compositing/shared-backing/shared-layer-has-filter.html
+           compositing/shared-backing/shared-layer-has-opacity.html
+           compositing/shared-backing/shared-layer-has-reflection.html
+           compositing/shared-backing/shared-layer-has-transform.html
+           compositing/shared-backing/shared-layer-isolates-blending.html
+           compositing/shared-backing/shared-transformed-layer-bounds.html
+           compositing/shared-backing/sharing-layer-becomes-non-scrollable.html
+           compositing/shared-backing/sharing-layer-has-effect.html
+    
+    * rendering/RenderLayer.cpp:
+    (WebCore::RenderLayer::paintLayer):
+    (WebCore::RenderLayer::paintLayerWithEffects):
+    * rendering/RenderLayer.h:
+    * rendering/RenderLayerBacking.cpp:
+    (WebCore::RenderLayerBacking::paintIntoLayer):
+    * rendering/RenderLayerCompositor.cpp:
+    (WebCore::RenderLayerCompositor::CompositingState::stateForPaintOrderChildren const):
+    (WebCore::backingProviderLayerCanIncludeLayer):
+    (WebCore::RenderLayerCompositor::computeCompositingRequirements):
+    (WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
+    
+    LayoutTests:
+    
+    Ref tests for effects on sharing layers. The references make "clipping" be stacking context via z-index,
+    which eliminates sharing.
+    
+    * compositing/shared-backing/nested-shared-layers-with-opacity-expected.html: Added.
+    * compositing/shared-backing/nested-shared-layers-with-opacity.html: Added.
+    * compositing/shared-backing/shared-layer-has-blending-expected.html: Added.
+    * compositing/shared-backing/shared-layer-has-blending.html: Added.
+    * compositing/shared-backing/shared-layer-has-filter-expected.html: Added.
+    * compositing/shared-backing/shared-layer-has-filter.html: Added.
+    * compositing/shared-backing/shared-layer-has-opacity-expected.html: Added.
+    * compositing/shared-backing/shared-layer-has-opacity.html: Added.
+    * compositing/shared-backing/shared-layer-has-reflection-expected.html: Added.
+    * compositing/shared-backing/shared-layer-has-reflection.html: Added.
+    * compositing/shared-backing/shared-layer-has-transform-expected.html: Added.
+    * compositing/shared-backing/shared-layer-has-transform.html: Added.
+    * compositing/shared-backing/shared-layer-isolates-blending-expected.html: Added.
+    * compositing/shared-backing/shared-layer-isolates-blending.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245205 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-05-11  Simon Fraser  <simon.fraser@apple.com>
+
+            Backing-sharing layers with transforms render incorrectly
+            https://bugs.webkit.org/show_bug.cgi?id=197692
+            <rdar://problem/50652127>
+
+            Reviewed by Antti Koivisto.
+
+            Layers that paint into shared backing need to enter the RenderLayer painting code
+            in a way that paints the filters, transforms, opacity and blending.
+
+            RenderLayerBacking::paintIntoLayer() normally enters at paintLayerContents(), because
+            the effects are rendered via the GraphicsLayer, but shared layers will paint effects.
+            Note that if the backing-provider has effects, it will be the stacking context
+            for the shared layers, so it's correct that sharing layers are impacted by effects
+            on the backing-provider.
+
+            In addition, we have to ensure that we don't over-eagerly make layers shared.
+            Consider:
+
+            <div class="clipping">
+                <div class="sharing">
+                    <div class="inner">
+                    </div>
+                </div>
+            </div>
+
+            Here "clipping" is the provider layer, "sharing" paints into shared backing, but
+            we don't want to also mark "inner" as sharing, since "sharing" will just paint it.
+            This is akin to avoiding unnecessary compositing of z-order descendants when they can just
+            paint.
+
+            To do this we need to ensure that sharing layers are treated like compositing layers
+            in the overlap map, i.e. when a layer is sharing, we call overlapMap.pushCompositingContainer(),
+            and later overlapMap.popCompositingContainer().
+
+            Tests: compositing/shared-backing/nested-shared-layers-with-opacity.html
+                   compositing/shared-backing/shared-layer-has-blending.html
+                   compositing/shared-backing/shared-layer-has-filter.html
+                   compositing/shared-backing/shared-layer-has-opacity.html
+                   compositing/shared-backing/shared-layer-has-reflection.html
+                   compositing/shared-backing/shared-layer-has-transform.html
+                   compositing/shared-backing/shared-layer-isolates-blending.html
+                   compositing/shared-backing/shared-transformed-layer-bounds.html
+                   compositing/shared-backing/sharing-layer-becomes-non-scrollable.html
+                   compositing/shared-backing/sharing-layer-has-effect.html
+
+            * rendering/RenderLayer.cpp:
+            (WebCore::RenderLayer::paintLayer):
+            (WebCore::RenderLayer::paintLayerWithEffects):
+            * rendering/RenderLayer.h:
+            * rendering/RenderLayerBacking.cpp:
+            (WebCore::RenderLayerBacking::paintIntoLayer):
+            * rendering/RenderLayerCompositor.cpp:
+            (WebCore::RenderLayerCompositor::CompositingState::stateForPaintOrderChildren const):
+            (WebCore::backingProviderLayerCanIncludeLayer):
+            (WebCore::RenderLayerCompositor::computeCompositingRequirements):
+            (WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
+
+2019-05-22  Kocsen Chung  <kocsen_chung@apple.com>
+
</ins><span class="cx">         Cherry-pick r245181. rdar://problem/50670806
</span><span class="cx"> 
</span><span class="cx">     ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant()) on nytimes.com after r245170
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayer.cpp (245629 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayer.cpp      2019-05-22 17:49:37 UTC (rev 245629)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayer.cpp 2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -4100,6 +4100,11 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    paintLayerWithEffects(context, paintingInfo, paintFlags);
+}
+
+void RenderLayer::paintLayerWithEffects(GraphicsContext& context, const LayerPaintingInfo& paintingInfo, OptionSet<PaintLayerFlag> paintFlags)
+{
</ins><span class="cx">     // Non self-painting leaf layers don't need to be painted as their renderer() should properly paint itself.
</span><span class="cx">     if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant())
</span><span class="cx">         return;
</span><span class="lines">@@ -4106,7 +4111,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (shouldSuppressPaintingLayer(this))
</span><span class="cx">         return;
</span><del>-    
</del><ins>+
</ins><span class="cx">     // If this layer is totally invisible then there is nothing to paint.
</span><span class="cx">     if (!renderer().opacity())
</span><span class="cx">         return;
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCorerenderingRenderLayerh"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayer.h (245629 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayer.h        2019-05-22 17:49:37 UTC (rev 245629)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayer.h   2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -1003,6 +1003,8 @@
</span><span class="cx">     void applyFilters(GraphicsContext& originalContext, const LayerPaintingInfo&, const LayerFragments&);
</span><span class="cx"> 
</span><span class="cx">     void paintLayer(GraphicsContext&, const LayerPaintingInfo&, OptionSet<PaintLayerFlag>);
</span><ins>+    void paintLayerWithEffects(GraphicsContext&, const LayerPaintingInfo&, OptionSet<PaintLayerFlag>);
+
</ins><span class="cx">     void paintLayerContentsAndReflection(GraphicsContext&, const LayerPaintingInfo&, OptionSet<PaintLayerFlag>);
</span><span class="cx">     void paintLayerByApplyingTransform(GraphicsContext&, const LayerPaintingInfo&, OptionSet<PaintLayerFlag>, const LayoutSize& translationOffset = LayoutSize());
</span><span class="cx">     void paintLayerContents(GraphicsContext&, const LayerPaintingInfo&, OptionSet<PaintLayerFlag>);
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCorerenderingRenderLayerBackingcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayerBacking.cpp (245629 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayerBacking.cpp       2019-05-22 17:49:37 UTC (rev 245629)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayerBacking.cpp  2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -2668,10 +2668,13 @@
</span><span class="cx"> 
</span><span class="cx">         RenderLayer::LayerPaintingInfo paintingInfo(&m_owningLayer, paintDirtyRect, paintBehavior, -m_subpixelOffsetFromRenderer);
</span><span class="cx"> 
</span><del>-        layer.paintLayerContents(context, paintingInfo, paintFlags);
</del><ins>+        if (&layer == &m_owningLayer) {
+            layer.paintLayerContents(context, paintingInfo, paintFlags);
</ins><span class="cx"> 
</span><del>-        if (layer.containsDirtyOverlayScrollbars())
-            layer.paintLayerContents(context, paintingInfo, paintFlags | RenderLayer::PaintLayerPaintingOverlayScrollbars);
</del><ins>+            if (layer.containsDirtyOverlayScrollbars())
+                layer.paintLayerContents(context, paintingInfo, paintFlags | RenderLayer::PaintLayerPaintingOverlayScrollbars);
+        } else
+            layer.paintLayerWithEffects(context, paintingInfo, paintFlags);
</ins><span class="cx"> 
</span><span class="cx">         if (layer.isRenderViewLayer())
</span><span class="cx">             renderer().view().frameView().didPaintContents(context, paintDirtyRect, paintingState);
</span></span></pre></div>
<a id="branchessafari60812420branchSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp (245629 => 245630)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp    2019-05-22 17:49:37 UTC (rev 245629)
+++ branches/safari-608.1.24.20-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp       2019-05-22 17:49:43 UTC (rev 245630)
</span><span class="lines">@@ -241,6 +241,7 @@
</span><span class="cx">         else
</span><span class="cx">             childState.stackingContextAncestor = stackingContextAncestor;
</span><span class="cx"> 
</span><ins>+        childState.backingSharingAncestor = backingSharingAncestor;
</ins><span class="cx">         childState.subtreeIsCompositing = false;
</span><span class="cx">         childState.testingOverlap = testingOverlap;
</span><span class="cx">         childState.fullPaintOrderTraversalRequired = fullPaintOrderTraversalRequired;
</span><span class="lines">@@ -268,6 +269,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     RenderLayer* compositingAncestor;
</span><ins>+    RenderLayer* backingSharingAncestor { nullptr };
</ins><span class="cx">     RenderLayer* stackingContextAncestor { nullptr };
</span><span class="cx">     bool subtreeIsCompositing { false };
</span><span class="cx">     bool testingOverlap { true };
</span><span class="lines">@@ -860,6 +862,10 @@
</span><span class="cx"> 
</span><span class="cx"> static bool backingProviderLayerCanIncludeLayer(const RenderLayer& sharedLayer, const RenderLayer& layer)
</span><span class="cx"> {
</span><ins>+    // Disable sharing when painting shared layers doesn't work correctly.
+    if (layer.hasReflection())
+        return false;
+
</ins><span class="cx">     return layer.ancestorLayerIsInContainingBlockChain(sharedLayer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -981,6 +987,9 @@
</span><span class="cx">         // Compositing for any reason disables backing sharing.
</span><span class="cx">         LOG_WITH_STREAM(Compositing, stream << &layer << " is compositing - flushing sharing to " << backingSharingState.backingProviderCandidate << " with " << backingSharingState.backingSharingLayers.size() << " sharing layers");
</span><span class="cx">         backingSharingState.resetBackingProviderCandidate();
</span><ins>+    } else if (layerPaintsIntoProvidedBacking) {
+        childState.backingSharingAncestor = &layer;
+        overlapMap.pushCompositingContainer();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> #if !ASSERT_DISABLED
</span><span class="lines">@@ -1064,7 +1073,7 @@
</span><span class="cx">         compositingState.hasNotIsolatedCompositedBlendingDescendants = true;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (childState.compositingAncestor == &layer && !layer.isRenderViewLayer())
</del><ins>+    if ((childState.compositingAncestor == &layer && !layer.isRenderViewLayer()) || childState.backingSharingAncestor == &layer)
</ins><span class="cx">         overlapMap.popCompositingContainer();
</span><span class="cx"> 
</span><span class="cx">     // If we're back at the root, and no other layers need to be composited, and the root layer itself doesn't need
</span><span class="lines">@@ -1228,7 +1237,7 @@
</span><span class="cx">         compositingState.hasNotIsolatedCompositedBlendingDescendants = true;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (childState.compositingAncestor == &layer && !layer.isRenderViewLayer())
</del><ins>+    if ((childState.compositingAncestor == &layer && !layer.isRenderViewLayer()) || childState.backingSharingAncestor == &layer)
</ins><span class="cx">         overlapMap.popCompositingContainer();
</span><span class="cx"> 
</span><span class="cx">     if (layer.isComposited())
</span></span></pre>
</div>
</div>

</body>
</html>