<!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>[245490] 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/245490">245490</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2019-05-17 18:32:03 -0700 (Fri, 17 May 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/245170">r245170</a>): gmail.com inbox table header flickers
https://bugs.webkit.org/show_bug.cgi?id=198005
<rdar://problem/50907718>

Reviewed by Antti Koivisto.

Source/WebCore:

When a layer started as painting into shared backing, but then became independently
composited (e.g. by having to clip composited children), it wouldn't have the "overlap"
indirect compositing reason. This allowed requiresOwnBackingStore() to say that it
could paint into some ancestor, but this breaks overlap. So in this code path,
put IndirectCompositingReason::Overlap back on the layer which restores the previous
behavior.

Make some logging changes to help diagnose things like this.

Test: compositing/shared-backing/overlap-after-end-sharing.html

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects const):
(WebCore::outputPaintOrderTreeLegend):
(WebCore::outputPaintOrderTreeRecursive):
* rendering/RenderLayer.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::updateBacking):
(WebCore::RenderLayerCompositor::requiresOwnBackingStore const):
(WebCore::RenderLayerCompositor::reasonsForCompositing const):
(WebCore::RenderLayerCompositor::requiresCompositingForIndirectReason const):
* rendering/RenderLayerCompositor.h:

LayoutTests:

* compositing/shared-backing/overlap-after-end-sharing-expected.html: Added.
* compositing/shared-backing/overlap-after-end-sharing.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayercpp">trunk/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerh">trunk/Source/WebCore/rendering/RenderLayer.h</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="#trunkLayoutTestscompositingsharedbackingoverlapafterendsharingexpectedhtml">trunk/LayoutTests/compositing/shared-backing/overlap-after-end-sharing-expected.html</a></li>
<li><a href="#trunkLayoutTestscompositingsharedbackingoverlapafterendsharinghtml">trunk/LayoutTests/compositing/shared-backing/overlap-after-end-sharing.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (245489 => 245490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-05-17 23:45:38 UTC (rev 245489)
+++ trunk/LayoutTests/ChangeLog 2019-05-18 01:32:03 UTC (rev 245490)
</span><span class="lines">@@ -35,6 +35,17 @@
</span><span class="cx"> 
</span><span class="cx"> 2019-05-17  Simon Fraser  <simon.fraser@apple.com>
</span><span class="cx"> 
</span><ins>+        REGRESSION (r245170): gmail.com inbox table header flickers
+        https://bugs.webkit.org/show_bug.cgi?id=198005
+        <rdar://problem/50907718>
+
+        Reviewed by Antti Koivisto.
+
+        * compositing/shared-backing/overlap-after-end-sharing-expected.html: Added.
+        * compositing/shared-backing/overlap-after-end-sharing.html: Added.
+
+2019-05-17  Simon Fraser  <simon.fraser@apple.com>
+
</ins><span class="cx">         REGRESSION (r245170): gmail.com header flickers when hovering over the animating buttons
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=197975
</span><span class="cx">         <rdar://problem/50865946>
</span></span></pre></div>
<a id="trunkLayoutTestscompositingsharedbackingoverlapafterendsharingexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/shared-backing/overlap-after-end-sharing-expected.html (0 => 245490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/shared-backing/overlap-after-end-sharing-expected.html                             (rev 0)
+++ trunk/LayoutTests/compositing/shared-backing/overlap-after-end-sharing-expected.html        2019-05-18 01:32:03 UTC (rev 245490)
</span><span class="lines">@@ -0,0 +1,67 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+       <style>
+               body {
+                       margin: 0;
+               }
+               .backdrop {
+                       position: fixed;
+                       top: 10px;
+                       left: 10px;
+                       width: 500px;
+                       height: 300px;
+                       background-color: silver;
+               }
+               
+               .container {
+                       position: relative;
+                       top: 20px;
+                       left: 20px;
+                       width: 480px;
+                       height: 280px;
+                       border: 1px solid black;
+                       padding: 10px;
+                       box-sizing: border-box;
+               }
+               
+               .header {
+                       position: relative;
+                       z-index: 1;
+                       overflow: hidden;
+                       width: 460px;
+                       height: 260px;
+                       background-color: lightblue;
+               }
+
+               .target {
+                       position: relative;
+                       top: 10px;
+                       left: 10px;
+                       width: 200px;
+                       height: 100px;
+                       background-color: green;
+               }
+               
+               .animating {
+                       position: relative;
+                       background-color: orange;
+                       opacity: 0.6;
+                       top: 20px;
+                       left: 250px;
+                       width: 180px;
+                       height: 100px;
+                       padding: 10px;
+               }
+       </style>
+</head>
+<body>
+       <div class="backdrop"></div>
+       <div class="container">
+               <div class="header">
+                       <div class="target"></div>
+                       <div class="animating"></div>
+               </div>
+       </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingsharedbackingoverlapafterendsharinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/shared-backing/overlap-after-end-sharing.html (0 => 245490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/shared-backing/overlap-after-end-sharing.html                              (rev 0)
+++ trunk/LayoutTests/compositing/shared-backing/overlap-after-end-sharing.html 2019-05-18 01:32:03 UTC (rev 245490)
</span><span class="lines">@@ -0,0 +1,85 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+       <style>
+               body {
+                       margin: 0;
+               }
+               .backdrop {
+                       position: fixed;
+                       top: 10px;
+                       left: 10px;
+                       width: 500px;
+                       height: 300px;
+                       background-color: silver;
+               }
+               
+               .container {
+                       position: relative;
+                       top: 20px;
+                       left: 20px;
+                       width: 480px;
+                       height: 280px;
+                       border: 1px solid black;
+                       padding: 10px;
+                       box-sizing: border-box;
+               }
+               
+               .header {
+                       position: relative;
+                       z-index: 1;
+                       overflow: hidden;
+                       width: 460px;
+                       height: 260px;
+                       background-color: lightblue;
+               }
+
+               .target {
+                       position: relative;
+                       top: 10px;
+                       left: 10px;
+                       width: 200px;
+                       height: 100px;
+                       background-color: green;
+               }
+               
+               .animating {
+                       position: relative;
+                       background-color: orange;
+                       top: auto;
+                       left: 250px;
+                       width: 180px;
+                       height: 100px;
+                       opacity: 0.6;
+                       transition: opacity 500s;
+                       padding: 10px;
+               }
+               
+               .animating.changed {
+                       opacity: 1;
+                       top: 20px;
+               }
+       </style>
+    <script>
+               if (window.testRunner)
+                       testRunner.waitUntilDone();
+
+               window.addEventListener('load', () => {
+                       setTimeout(() => {
+                               document.querySelector('.animating').classList.add('changed');
+                               if (window.testRunner)
+                                       testRunner.notifyDone();
+                       }, 0);
+               }, false);
+    </script>
+</head>
+<body>
+       <div class="backdrop"></div>
+       <div class="container">
+               <div class="header">
+                       <div class="target"></div>
+                       <div class="animating"></div>
+               </div>
+       </div>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (245489 => 245490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-05-17 23:45:38 UTC (rev 245489)
+++ trunk/Source/WebCore/ChangeLog      2019-05-18 01:32:03 UTC (rev 245490)
</span><span class="lines">@@ -149,6 +149,38 @@
</span><span class="cx"> 
</span><span class="cx"> 2019-05-17  Simon Fraser  <simon.fraser@apple.com>
</span><span class="cx"> 
</span><ins>+        REGRESSION (r245170): gmail.com inbox table header flickers
+        https://bugs.webkit.org/show_bug.cgi?id=198005
+        <rdar://problem/50907718>
+
+        Reviewed by Antti Koivisto.
+
+        When a layer started as painting into shared backing, but then became independently
+        composited (e.g. by having to clip composited children), it wouldn't have the "overlap"
+        indirect compositing reason. This allowed requiresOwnBackingStore() to say that it
+        could paint into some ancestor, but this breaks overlap. So in this code path,
+        put IndirectCompositingReason::Overlap back on the layer which restores the previous
+        behavior.
+
+        Make some logging changes to help diagnose things like this.
+
+        Test: compositing/shared-backing/overlap-after-end-sharing.html
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::calculateClipRects const):
+        (WebCore::outputPaintOrderTreeLegend):
+        (WebCore::outputPaintOrderTreeRecursive):
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::computeCompositingRequirements):
+        (WebCore::RenderLayerCompositor::updateBacking):
+        (WebCore::RenderLayerCompositor::requiresOwnBackingStore const):
+        (WebCore::RenderLayerCompositor::reasonsForCompositing const):
+        (WebCore::RenderLayerCompositor::requiresCompositingForIndirectReason const):
+        * rendering/RenderLayerCompositor.h:
+
+2019-05-17  Simon Fraser  <simon.fraser@apple.com>
+
</ins><span class="cx">         REGRESSION (r245170): gmail.com header flickers when hovering over the animating buttons
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=197975
</span><span class="cx">         <rdar://problem/50865946>
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (245489 => 245490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp   2019-05-17 23:45:38 UTC (rev 245489)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp      2019-05-18 01:32:03 UTC (rev 245490)
</span><span class="lines">@@ -6887,6 +6887,22 @@
</span><span class="cx">     return ts;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TextStream& operator<<(TextStream& ts, IndirectCompositingReason reason)
+{
+    switch (reason) {
+    case IndirectCompositingReason::None: ts << "none"; break;
+    case IndirectCompositingReason::Stacking: ts << "stacking"; break;
+    case IndirectCompositingReason::OverflowScrollPositioning: ts << "overflow positioning"; break;
+    case IndirectCompositingReason::Overlap: ts << "overlap"; break;
+    case IndirectCompositingReason::BackgroundLayer: ts << "background layer"; break;
+    case IndirectCompositingReason::GraphicalEffect: ts << "graphical effect"; break;
+    case IndirectCompositingReason::Perspective: ts << "perspective"; break;
+    case IndirectCompositingReason::Preserve3D: ts << "preserve-3d"; break;
+    }
+
+    return ts;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(TREE_DEBUGGING)
</span><span class="lines">@@ -6921,7 +6937,7 @@
</span><span class="cx"> static void outputPaintOrderTreeLegend(TextStream& stream)
</span><span class="cx"> {
</span><span class="cx">     stream.nextLine();
</span><del>-    stream << "(S)tacking Context/(F)orced SC/O(P)portunistic SC, (N)ormal flow only, (O)verflow clip, (A)lpha (opacity or mask), has (B)lend mode, (I)solates blending, (T)ransform-ish, (F)ilter, Fi(X)ed position, (C)omposited, (P)rovides backing/uses (p)rovided backing, (c)omposited descendant, (s)scrolling ancestor\n"
</del><ins>+    stream << "(S)tacking Context/(F)orced SC/O(P)portunistic SC, (N)ormal flow only, (O)verflow clip, (A)lpha (opacity or mask), has (B)lend mode, (I)solates blending, (T)ransform-ish, (F)ilter, Fi(X)ed position, (C)omposited, (P)rovides backing/uses (p)rovided backing/paints to (a)ncestor, (c)omposited descendant, (s)scrolling ancestor\n"
</ins><span class="cx">         "Dirty (z)-lists, Dirty (n)ormal flow lists\n"
</span><span class="cx">         "Traversal needs: requirements (t)raversal on descendants, (b)acking or hierarchy traversal on descendants, (r)equirements traversal on all descendants, requirements traversal on all (s)ubsequent layers, (h)ierarchy traversal on all descendants, update of paint (o)rder children\n"
</span><span class="cx">         "Update needs:    post-(l)ayout requirements, (g)eometry, (k)ids geometry, (c)onfig, layer conne(x)ion, (s)crolling tree\n";
</span><span class="lines">@@ -6947,7 +6963,24 @@
</span><span class="cx">     stream << (layer.hasFilter() ? "F" : "-");
</span><span class="cx">     stream << (layer.renderer().isFixedPositioned() ? "X" : "-");
</span><span class="cx">     stream << (layer.isComposited() ? "C" : "-");
</span><del>-    stream << ((layer.isComposited() && layer.backing()->hasBackingSharingLayers()) ? "P" : (layer.paintsIntoProvidedBacking() ? "p" : "-"));
</del><ins>+    
+    auto compositedPaintingDestinationString = [&layer]() {
+        if (layer.paintsIntoProvidedBacking())
+            return "p";
+
+        if (!layer.isComposited())
+            return "-";
+
+        if (layer.backing()->hasBackingSharingLayers())
+            return "P";
+        
+        if (layer.backing()->paintsIntoCompositedAncestor())
+            return "a";
+
+        return "-";
+    };
+
+    stream << compositedPaintingDestinationString();
</ins><span class="cx">     stream << (layer.hasCompositingDescendant() ? "c" : "-");
</span><span class="cx">     stream << (layer.hasCompositedScrollingAncestor() ? "s" : "-");
</span><span class="cx"> 
</span><span class="lines">@@ -6986,6 +7019,9 @@
</span><span class="cx">     if (layer.isComposited()) {
</span><span class="cx">         auto& backing = *layer.backing();
</span><span class="cx">         stream << " (layerID " << backing.graphicsLayer()->primaryLayerID() << ")";
</span><ins>+        
+        if (layer.indirectCompositingReason() != WebCore::IndirectCompositingReason::None)
+            stream << " " << layer.indirectCompositingReason();
</ins><span class="cx"> 
</span><span class="cx">         auto scrollingNodeID = backing.scrollingNodeIDForRole(WebCore::ScrollCoordinationRole::Scrolling);
</span><span class="cx">         auto frameHostingNodeID = backing.scrollingNodeIDForRole(WebCore::ScrollCoordinationRole::FrameHosting);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.h (245489 => 245490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.h     2019-05-17 23:45:38 UTC (rev 245489)
+++ trunk/Source/WebCore/rendering/RenderLayer.h        2019-05-18 01:32:03 UTC (rev 245490)
</span><span class="lines">@@ -117,6 +117,17 @@
</span><span class="cx">     Undetermined
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+enum class IndirectCompositingReason {
+    None,
+    Stacking,
+    OverflowScrollPositioning,
+    Overlap,
+    BackgroundLayer,
+    GraphicalEffect, // opacity, mask, filter, transform etc.
+    Perspective,
+    Preserve3D
+};
+
</ins><span class="cx"> struct ScrollRectToVisibleOptions {
</span><span class="cx">     SelectionRevealMode revealMode { SelectionRevealMode::Reveal };
</span><span class="cx">     const ScrollAlignment& alignX { ScrollAlignment::alignCenterIfNeeded };
</span><span class="lines">@@ -870,7 +881,9 @@
</span><span class="cx"> 
</span><span class="cx">     void setViewportConstrainedNotCompositedReason(ViewportConstrainedNotCompositedReason reason) { m_viewportConstrainedNotCompositedReason = reason; }
</span><span class="cx">     ViewportConstrainedNotCompositedReason viewportConstrainedNotCompositedReason() const { return static_cast<ViewportConstrainedNotCompositedReason>(m_viewportConstrainedNotCompositedReason); }
</span><del>-    
</del><ins>+
+    IndirectCompositingReason indirectCompositingReason() const { return static_cast<IndirectCompositingReason>(m_indirectCompositingReason); }
+
</ins><span class="cx">     bool isRenderFragmentedFlow() const { return renderer().isRenderFragmentedFlow(); }
</span><span class="cx">     bool isOutOfFlowRenderFragmentedFlow() const { return renderer().isOutOfFlowRenderFragmentedFlow(); }
</span><span class="cx">     bool isInsideFragmentedFlow() const { return renderer().fragmentedFlowState() != RenderObject::NotInsideFragmentedFlow; }
</span><span class="lines">@@ -1157,19 +1170,7 @@
</span><span class="cx"> 
</span><span class="cx">     void setHasCompositingDescendant(bool b)  { m_hasCompositingDescendant = b; }
</span><span class="cx">     
</span><del>-    enum class IndirectCompositingReason {
-        None,
-        Stacking,
-        OverflowScrollPositioning,
-        Overlap,
-        BackgroundLayer,
-        GraphicalEffect, // opacity, mask, filter, transform etc.
-        Perspective,
-        Preserve3D
-    };
-    
</del><span class="cx">     void setIndirectCompositingReason(IndirectCompositingReason reason) { m_indirectCompositingReason = static_cast<unsigned>(reason); }
</span><del>-    IndirectCompositingReason indirectCompositingReason() const { return static_cast<IndirectCompositingReason>(m_indirectCompositingReason); }
</del><span class="cx">     bool mustCompositeForIndirectReasons() const { return m_indirectCompositingReason; }
</span><span class="cx"> 
</span><span class="cx">     friend class RenderLayerBacking;
</span><span class="lines">@@ -1387,6 +1388,7 @@
</span><span class="cx"> WTF::TextStream& operator<<(WTF::TextStream&, ClipRectsType);
</span><span class="cx"> WTF::TextStream& operator<<(WTF::TextStream&, const RenderLayer&);
</span><span class="cx"> WTF::TextStream& operator<<(WTF::TextStream&, const RenderLayer::ClipRectsContext&);
</span><ins>+WTF::TextStream& operator<<(WTF::TextStream&, IndirectCompositingReason);
</ins><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (245489 => 245490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2019-05-17 23:45:38 UTC (rev 245489)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp    2019-05-18 01:32:03 UTC (rev 245490)
</span><span class="lines">@@ -862,7 +862,7 @@
</span><span class="cx">     bool becameCompositedAfterDescendantTraversal = false;
</span><span class="cx"> 
</span><span class="cx">     if (layer.needsPostLayoutCompositingUpdate() || compositingState.fullPaintOrderTraversalRequired || compositingState.descendantsRequireCompositingUpdate) {
</span><del>-        layer.setIndirectCompositingReason(RenderLayer::IndirectCompositingReason::None);
</del><ins>+        layer.setIndirectCompositingReason(IndirectCompositingReason::None);
</ins><span class="cx">         willBeComposited = needsToBeComposited(layer, queryData);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -877,7 +877,7 @@
</span><span class="cx">     bool respectTransforms = !layerExtent.hasTransformAnimation;
</span><span class="cx">     overlapMap.geometryMap().pushMappingsToAncestor(&layer, ancestorLayer, respectTransforms);
</span><span class="cx"> 
</span><del>-    RenderLayer::IndirectCompositingReason compositingReason = compositingState.subtreeIsCompositing ? RenderLayer::IndirectCompositingReason::Stacking : RenderLayer::IndirectCompositingReason::None;
</del><ins>+    IndirectCompositingReason compositingReason = compositingState.subtreeIsCompositing ? IndirectCompositingReason::Stacking : IndirectCompositingReason::None;
</ins><span class="cx">     bool layerPaintsIntoProvidedBacking = false;
</span><span class="cx"> 
</span><span class="cx">     // If we know for sure the layer is going to be composited, don't bother looking it up in the overlap map
</span><span class="lines">@@ -889,12 +889,12 @@
</span><span class="cx">             if (backingSharingState.backingProviderCandidate() && canBeComposited(layer) && backingProviderLayerCanIncludeLayer(*backingSharingState.backingProviderCandidate(), layer)) {
</span><span class="cx">                 backingSharingState.appendSharingLayer(layer);
</span><span class="cx">                 LOG(Compositing, " layer %p can share with %p", &layer, backingSharingState.backingProviderCandidate());
</span><del>-                compositingReason = RenderLayer::IndirectCompositingReason::None;
</del><ins>+                compositingReason = IndirectCompositingReason::None;
</ins><span class="cx">                 layerPaintsIntoProvidedBacking = true;
</span><span class="cx">             } else
</span><del>-                compositingReason = RenderLayer::IndirectCompositingReason::Overlap;
</del><ins>+                compositingReason = IndirectCompositingReason::Overlap;
</ins><span class="cx">         } else
</span><del>-            compositingReason = RenderLayer::IndirectCompositingReason::None;
</del><ins>+            compositingReason = IndirectCompositingReason::None;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO)
</span><span class="lines">@@ -903,14 +903,15 @@
</span><span class="cx">     // into. These children (the controls) always need to be promoted into their
</span><span class="cx">     // own layers to draw on top of the accelerated video.
</span><span class="cx">     if (compositingState.compositingAncestor && compositingState.compositingAncestor->renderer().isVideo())
</span><del>-        compositingReason = RenderLayer::IndirectCompositingReason::Overlap;
</del><ins>+        compositingReason = IndirectCompositingReason::Overlap;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (compositingReason != RenderLayer::IndirectCompositingReason::None)
</del><ins>+    if (compositingReason != IndirectCompositingReason::None)
</ins><span class="cx">         layer.setIndirectCompositingReason(compositingReason);
</span><span class="cx"> 
</span><span class="cx">     // Check if the computed indirect reason will force the layer to become composited.
</span><span class="cx">     if (!willBeComposited && layer.mustCompositeForIndirectReasons() && canBeComposited(layer)) {
</span><ins>+        LOG_WITH_STREAM(Compositing, stream << "layer " << &layer << " compositing for indirect reason " << layer.indirectCompositingReason() << " (was sharing: " << layerPaintsIntoProvidedBacking << ")");
</ins><span class="cx">         willBeComposited = true;
</span><span class="cx">         layerPaintsIntoProvidedBacking = false;
</span><span class="cx">     }
</span><span class="lines">@@ -927,13 +928,18 @@
</span><span class="cx">         // This layer now acts as the ancestor for kids.
</span><span class="cx">         currentState.compositingAncestor = &layer;
</span><span class="cx">         
</span><del>-        if (!layerPaintsIntoProvidedBacking) {
</del><ins>+        if (layerPaintsIntoProvidedBacking) {
+            layerPaintsIntoProvidedBacking = false;
+            // layerPaintsIntoProvidedBacking was only true for layers that would otherwise composite because of overlap. If we can
+            // no longer share, put this this indirect reason back on the layer so that requiresOwnBackingStore() sees it.
+            layer.setIndirectCompositingReason(IndirectCompositingReason::Overlap);
+            LOG_WITH_STREAM(CompositingOverlap, stream << "layer " << &layer << " was sharing now will composite");
+        } else {
</ins><span class="cx">             overlapMap.pushCompositingContainer();
</span><span class="cx">             LOG_WITH_STREAM(CompositingOverlap, stream << "layer " << &layer << " will composite, pushed container " << overlapMap);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         willBeComposited = true;
</span><del>-        layerPaintsIntoProvidedBacking = false;
</del><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     auto layerWillCompositePostDescendants = [&] {
</span><span class="lines">@@ -971,7 +977,7 @@
</span><span class="cx">         // (since we need to ensure that the -ve z-order child renders underneath our contents).
</span><span class="cx">         if (!willBeComposited && currentState.subtreeIsCompositing) {
</span><span class="cx">             // make layer compositing
</span><del>-            layer.setIndirectCompositingReason(RenderLayer::IndirectCompositingReason::BackgroundLayer);
</del><ins>+            layer.setIndirectCompositingReason(IndirectCompositingReason::BackgroundLayer);
</ins><span class="cx">             layerWillComposite();
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -999,7 +1005,7 @@
</span><span class="cx">     ASSERT(!layer.hasNotIsolatedCompositedBlendingDescendants() || layer.hasNotIsolatedBlendingDescendants());
</span><span class="cx"> #endif
</span><span class="cx">     // Now check for reasons to become composited that depend on the state of descendant layers.
</span><del>-    RenderLayer::IndirectCompositingReason indirectCompositingReason;
</del><ins>+    IndirectCompositingReason indirectCompositingReason;
</ins><span class="cx">     if (!willBeComposited && canBeComposited(layer)
</span><span class="cx">         && requiresCompositingForIndirectReason(layer, compositingState.compositingAncestor, currentState.subtreeIsCompositing, anyDescendantHas3DTransform, layerPaintsIntoProvidedBacking, indirectCompositingReason)) {
</span><span class="cx">         layer.setIndirectCompositingReason(indirectCompositingReason);
</span><span class="lines">@@ -1008,7 +1014,7 @@
</span><span class="cx">     
</span><span class="cx">     if (layer.reflectionLayer()) {
</span><span class="cx">         // FIXME: Shouldn't we call computeCompositingRequirements to handle a reflection overlapping with another renderer?
</span><del>-        layer.reflectionLayer()->setIndirectCompositingReason(willBeComposited ? RenderLayer::IndirectCompositingReason::Stacking : RenderLayer::IndirectCompositingReason::None);
</del><ins>+        layer.reflectionLayer()->setIndirectCompositingReason(willBeComposited ? IndirectCompositingReason::Stacking : IndirectCompositingReason::None);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Set the flag to say that this layer has compositing children.
</span><span class="lines">@@ -1583,7 +1589,7 @@
</span><span class="cx">         if (!layer.backing()) {
</span><span class="cx">             // If we need to repaint, do so before making backing
</span><span class="cx">             if (shouldRepaint == CompositingChangeRepaintNow)
</span><del>-                repaintOnCompositingChange(layer);
</del><ins>+                repaintOnCompositingChange(layer); // wrong backing
</ins><span class="cx"> 
</span><span class="cx">             layer.ensureBacking();
</span><span class="cx"> 
</span><span class="lines">@@ -2282,13 +2288,13 @@
</span><span class="cx">         return true;
</span><span class="cx"> 
</span><span class="cx">     if (layer.mustCompositeForIndirectReasons()) {
</span><del>-        RenderLayer::IndirectCompositingReason reason = layer.indirectCompositingReason();
-        return reason == RenderLayer::IndirectCompositingReason::Overlap
-            || reason == RenderLayer::IndirectCompositingReason::OverflowScrollPositioning
-            || reason == RenderLayer::IndirectCompositingReason::Stacking
-            || reason == RenderLayer::IndirectCompositingReason::BackgroundLayer
-            || reason == RenderLayer::IndirectCompositingReason::GraphicalEffect
-            || reason == RenderLayer::IndirectCompositingReason::Preserve3D; // preserve-3d has to create backing store to ensure that 3d-transformed elements intersect.
</del><ins>+        IndirectCompositingReason reason = layer.indirectCompositingReason();
+        return reason == IndirectCompositingReason::Overlap
+            || reason == IndirectCompositingReason::OverflowScrollPositioning
+            || reason == IndirectCompositingReason::Stacking
+            || reason == IndirectCompositingReason::BackgroundLayer
+            || reason == IndirectCompositingReason::GraphicalEffect
+            || reason == IndirectCompositingReason::Preserve3D; // preserve-3d has to create backing store to ensure that 3d-transformed elements intersect.
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!ancestorCompositedBounds.contains(layerCompositedBoundsInAncestor))
</span><span class="lines">@@ -2347,21 +2353,21 @@
</span><span class="cx">         reasons.add(CompositingReason::OverflowScrolling);
</span><span class="cx"> 
</span><span class="cx">     switch (renderer.layer()->indirectCompositingReason()) {
</span><del>-    case RenderLayer::IndirectCompositingReason::None:
</del><ins>+    case IndirectCompositingReason::None:
</ins><span class="cx">         break;
</span><del>-    case RenderLayer::IndirectCompositingReason::Stacking:
</del><ins>+    case IndirectCompositingReason::Stacking:
</ins><span class="cx">         reasons.add(CompositingReason::Stacking);
</span><span class="cx">         break;
</span><del>-    case RenderLayer::IndirectCompositingReason::OverflowScrollPositioning:
</del><ins>+    case IndirectCompositingReason::OverflowScrollPositioning:
</ins><span class="cx">         reasons.add(CompositingReason::OverflowScrollPositioning);
</span><span class="cx">         break;
</span><del>-    case RenderLayer::IndirectCompositingReason::Overlap:
</del><ins>+    case IndirectCompositingReason::Overlap:
</ins><span class="cx">         reasons.add(CompositingReason::Overlap);
</span><span class="cx">         break;
</span><del>-    case RenderLayer::IndirectCompositingReason::BackgroundLayer:
</del><ins>+    case IndirectCompositingReason::BackgroundLayer:
</ins><span class="cx">         reasons.add(CompositingReason::NegativeZIndexChildren);
</span><span class="cx">         break;
</span><del>-    case RenderLayer::IndirectCompositingReason::GraphicalEffect:
</del><ins>+    case IndirectCompositingReason::GraphicalEffect:
</ins><span class="cx">         if (renderer.hasTransform())
</span><span class="cx">             reasons.add(CompositingReason::TransformWithCompositedDescendants);
</span><span class="cx"> 
</span><span class="lines">@@ -2385,10 +2391,10 @@
</span><span class="cx">             reasons.add(CompositingReason::BlendingWithCompositedDescendants);
</span><span class="cx"> #endif
</span><span class="cx">         break;
</span><del>-    case RenderLayer::IndirectCompositingReason::Perspective:
</del><ins>+    case IndirectCompositingReason::Perspective:
</ins><span class="cx">         reasons.add(CompositingReason::Perspective);
</span><span class="cx">         break;
</span><del>-    case RenderLayer::IndirectCompositingReason::Preserve3D:
</del><ins>+    case IndirectCompositingReason::Preserve3D:
</ins><span class="cx">         reasons.add(CompositingReason::Preserve3D);
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="lines">@@ -2829,13 +2835,13 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // FIXME: why doesn't this handle the clipping cases?
</span><del>-bool RenderLayerCompositor::requiresCompositingForIndirectReason(const RenderLayer& layer, const RenderLayer* compositingAncestor, bool hasCompositedDescendants, bool has3DTransformedDescendants, bool paintsIntoProvidedBacking, RenderLayer::IndirectCompositingReason& reason) const
</del><ins>+bool RenderLayerCompositor::requiresCompositingForIndirectReason(const RenderLayer& layer, const RenderLayer* compositingAncestor, bool hasCompositedDescendants, bool has3DTransformedDescendants, bool paintsIntoProvidedBacking, IndirectCompositingReason& reason) const
</ins><span class="cx"> {
</span><span class="cx">     // When a layer has composited descendants, some effects, like 2d transforms, filters, masks etc must be implemented
</span><span class="cx">     // via compositing so that they also apply to those composited descendants.
</span><span class="cx">     auto& renderer = layer.renderer();
</span><span class="cx">     if (hasCompositedDescendants && (layer.isolatesCompositedBlending() || layer.transform() || renderer.createsGroup() || renderer.hasReflection())) {
</span><del>-        reason = RenderLayer::IndirectCompositingReason::GraphicalEffect;
</del><ins>+        reason = IndirectCompositingReason::GraphicalEffect;
</ins><span class="cx">         return true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -2843,12 +2849,12 @@
</span><span class="cx">     // will be affected by the preserve-3d or perspective.
</span><span class="cx">     if (has3DTransformedDescendants) {
</span><span class="cx">         if (renderer.style().transformStyle3D() == TransformStyle3D::Preserve3D) {
</span><del>-            reason = RenderLayer::IndirectCompositingReason::Preserve3D;
</del><ins>+            reason = IndirectCompositingReason::Preserve3D;
</ins><span class="cx">             return true;
</span><span class="cx">         }
</span><span class="cx">     
</span><span class="cx">         if (renderer.style().hasPerspective()) {
</span><del>-            reason = RenderLayer::IndirectCompositingReason::Perspective;
</del><ins>+            reason = IndirectCompositingReason::Perspective;
</ins><span class="cx">             return true;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -2855,12 +2861,12 @@
</span><span class="cx"> 
</span><span class="cx">     if (!paintsIntoProvidedBacking && renderer.isAbsolutelyPositioned() && compositingAncestor && layer.hasCompositedScrollingAncestor()) {
</span><span class="cx">         if (layerContainingBlockCrossesCoordinatedScrollingBoundary(layer, *compositingAncestor)) {
</span><del>-            reason = RenderLayer::IndirectCompositingReason::OverflowScrollPositioning;
</del><ins>+            reason = IndirectCompositingReason::OverflowScrollPositioning;
</ins><span class="cx">             return true;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    reason = RenderLayer::IndirectCompositingReason::None;
</del><ins>+    reason = IndirectCompositingReason::None;
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.h (245489 => 245490)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.h   2019-05-17 23:45:38 UTC (rev 245489)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.h      2019-05-18 01:32:03 UTC (rev 245490)
</span><span class="lines">@@ -478,7 +478,7 @@
</span><span class="cx">     bool requiresCompositingForPosition(RenderLayerModelObject&, const RenderLayer&, RequiresCompositingData&) const;
</span><span class="cx">     bool requiresCompositingForOverflowScrolling(const RenderLayer&, RequiresCompositingData&) const;
</span><span class="cx">     bool requiresCompositingForEditableImage(RenderLayerModelObject&) const;
</span><del>-    bool requiresCompositingForIndirectReason(const RenderLayer&, const RenderLayer* compositingAncestor, bool hasCompositedDescendants, bool has3DTransformedDescendants, bool paintsIntoProvidedBacking, RenderLayer::IndirectCompositingReason&) const;
</del><ins>+    bool requiresCompositingForIndirectReason(const RenderLayer&, const RenderLayer* compositingAncestor, bool hasCompositedDescendants, bool has3DTransformedDescendants, bool paintsIntoProvidedBacking, IndirectCompositingReason&) const;
</ins><span class="cx"> 
</span><span class="cx">     static bool layerContainingBlockCrossesCoordinatedScrollingBoundary(const RenderLayer&, const RenderLayer& compositedAncestor);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>