<!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>[212153] 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/212153">212153</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2017-02-10 15:02:36 -0800 (Fri, 10 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make sure the &quot;inwindow&quot; flag propagates to TiledBackings for masks and reflections
https://bugs.webkit.org/show_bug.cgi?id=168127
rdar://problem/30467120

Reviewed by Tim Horton.
Source/WebCore:

Replace the special-case, but wrong, GraphicsLayer traversal in setIsInWindowIncludingDescendants()
which forgot to hit masks and replica layers with a generic traverse() function, which
is then used for setting 'inWindow' as well as resetting tracked repaints.

Tests: compositing/tiling/tiled-mask-inwindow.html
       compositing/tiling/tiled-reflection-inwindow.html

* page/PageOverlayController.cpp:
(WebCore::PageOverlayController::layerWithDocumentOverlays):
(WebCore::PageOverlayController::layerWithViewOverlays):
* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::setIsInWindow):
(WebCore::GraphicsLayer::setReplicatedByLayer):
(WebCore::GraphicsLayer::traverse):
(WebCore::GraphicsLayer::setIsInWindowIncludingDescendants): Deleted.
* platform/graphics/GraphicsLayer.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::setIsInWindow):
(WebCore::RenderLayerCompositor::resetTrackedRepaintRects):
(WebCore::resetTrackedRepaintRectsRecursive): Deleted.

Tools:

Reparent the web view before we try to fetch it via:
    [[[window contentView] subviews] objectAtIndex:0];
which would throw an exception if the test unparented it.

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebViewToConsistentStateBeforeTesting):
(runTest):

LayoutTests:

* compositing/tiling/tiled-mask-inwindow-expected.txt: Added.
* compositing/tiling/tiled-mask-inwindow.html: Added.
* compositing/tiling/tiled-reflection-inwindow-expected.txt: Added.
* compositing/tiling/tiled-reflection-inwindow.html: Added.
* platform/ios-simulator-wk1/compositing/tiling/tiled-mask-inwindow-expected.txt: Added.
* platform/ios-simulator-wk1/compositing/tiling/tiled-reflection-inwindow-expected.txt: Added.
* platform/ios-simulator-wk2/compositing/tiling/tiled-mask-inwindow-expected.txt: Added.
* platform/ios-simulator-wk2/compositing/tiling/tiled-reflection-inwindow-expected.txt: Added.
* platform/mac-wk1/compositing/tiling/tiled-mask-inwindow-expected.txt: Added.
* platform/mac-wk1/compositing/tiling/tiled-reflection-inwindow-expected.txt: 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="#trunkSourceWebCorepagePageOverlayControllercpp">trunk/Source/WebCore/page/PageOverlayController.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsLayercpp">trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsLayerh">trunk/Source/WebCore/platform/graphics/GraphicsLayer.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorcpp">trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreemacDumpRenderTreemm">trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscompositingtilingtiledmaskinwindowexpectedtxt">trunk/LayoutTests/compositing/tiling/tiled-mask-inwindow-expected.txt</a></li>
<li><a href="#trunkLayoutTestscompositingtilingtiledmaskinwindowhtml">trunk/LayoutTests/compositing/tiling/tiled-mask-inwindow.html</a></li>
<li><a href="#trunkLayoutTestscompositingtilingtiledreflectioninwindowexpectedtxt">trunk/LayoutTests/compositing/tiling/tiled-reflection-inwindow-expected.txt</a></li>
<li><a href="#trunkLayoutTestscompositingtilingtiledreflectioninwindowhtml">trunk/LayoutTests/compositing/tiling/tiled-reflection-inwindow.html</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk1compositingtilingtiledmaskinwindowexpectedtxt">trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/tiled-mask-inwindow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk1compositingtilingtiledreflectioninwindowexpectedtxt">trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/tiled-reflection-inwindow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk2compositingtilingtiledmaskinwindowexpectedtxt">trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/tiled-mask-inwindow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk2compositingtilingtiledreflectioninwindowexpectedtxt">trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/tiled-reflection-inwindow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1compositingtilingtiledmaskinwindowexpectedtxt">trunk/LayoutTests/platform/mac-wk1/compositing/tiling/tiled-mask-inwindow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1compositingtilingtiledreflectioninwindowexpectedtxt">trunk/LayoutTests/platform/mac-wk1/compositing/tiling/tiled-reflection-inwindow-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (212152 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-02-10 22:40:18 UTC (rev 212152)
+++ trunk/LayoutTests/ChangeLog        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2017-02-10  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Make sure the &quot;inwindow&quot; flag propagates to TiledBackings for masks and reflections
+        https://bugs.webkit.org/show_bug.cgi?id=168127
+        rdar://problem/30467120
+
+        Reviewed by Tim Horton.
+
+        * compositing/tiling/tiled-mask-inwindow-expected.txt: Added.
+        * compositing/tiling/tiled-mask-inwindow.html: Added.
+        * compositing/tiling/tiled-reflection-inwindow-expected.txt: Added.
+        * compositing/tiling/tiled-reflection-inwindow.html: Added.
+        * platform/ios-simulator-wk1/compositing/tiling/tiled-mask-inwindow-expected.txt: Added.
+        * platform/ios-simulator-wk1/compositing/tiling/tiled-reflection-inwindow-expected.txt: Added.
+        * platform/ios-simulator-wk2/compositing/tiling/tiled-mask-inwindow-expected.txt: Added.
+        * platform/ios-simulator-wk2/compositing/tiling/tiled-reflection-inwindow-expected.txt: Added.
+        * platform/mac-wk1/compositing/tiling/tiled-mask-inwindow-expected.txt: Added.
+        * platform/mac-wk1/compositing/tiling/tiled-reflection-inwindow-expected.txt: Added.
+
</ins><span class="cx"> 2017-02-09  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Tiled layers are sometimes left with some tiles when outside the viewport
</span></span></pre></div>
<a id="trunkLayoutTestscompositingtilingtiledmaskinwindowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/tiling/tiled-mask-inwindow-expected.txt (0 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/tiling/tiled-mask-inwindow-expected.txt                                (rev 0)
+++ trunk/LayoutTests/compositing/tiling/tiled-mask-inwindow-expected.txt        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -0,0 +1,99 @@
</span><ins>+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 800 x 600)
+      (tile size 800 x 600)
+      (top left tile 0, 0 tiles grid 1 x 1)
+      (in window 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 1)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 785.00 1101.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 785.00 1101.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 785 x 600)
+      (tile size 800 x 600)
+      (top left tile 0, 0 tiles grid 1 x 1)
+      (in window 0)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 0)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 0)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingtilingtiledmaskinwindowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/tiling/tiled-mask-inwindow.html (0 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/tiling/tiled-mask-inwindow.html                                (rev 0)
+++ trunk/LayoutTests/compositing/tiling/tiled-mask-inwindow.html        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .container {
+            height: 300px;
+            width: 400px;
+            border: 2px solid black;
+            overflow: hidden;
+        }
+
+        .box {
+            height: 300px;
+            width: 2800px;
+            border: 1px solid black;
+            background-color: gray;
+        }
+
+        .composited {
+            transform: translateZ(0);
+        }
+
+        .masked {
+            -webkit-mask-image: url(../resources/alpha-gradient.png);
+            -webkit-mask-repeat: repeat-x;
+        }
+    &lt;/style&gt;
+    &lt;script&gt;
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+        
+        function getUIScript()
+        {
+            return `
+            (function() {
+                uiController.removeViewFromWindow(function() {
+                    uiController.uiScriptComplete('');
+                });
+            })();`
+        }
+
+        function dumpTiles(outputId)
+        {
+            if (window.internals)
+                document.getElementById(outputId).innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+        }
+        function doTest()
+        {
+            if (!testRunner.runUIScript)
+                return;
+
+            dumpTiles('before-layers');
+
+            testRunner.runUIScript(getUIScript(), function(result) {
+                dumpTiles('after-layers');
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            });
+        }
+        window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div class=&quot;composited container&quot;&gt;
+        &lt;div class=&quot;composited masked box&quot;&gt;&lt;/div&gt; 
+    &lt;/div&gt;
+
+&lt;pre id=&quot;before-layers&quot;&gt;Layer tree goes here&lt;/pre&gt;
+&lt;pre id=&quot;after-layers&quot;&gt;Layer tree goes here&lt;/pre&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingtilingtiledreflectioninwindowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/tiling/tiled-reflection-inwindow-expected.txt (0 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/tiling/tiled-reflection-inwindow-expected.txt                                (rev 0)
+++ trunk/LayoutTests/compositing/tiling/tiled-reflection-inwindow-expected.txt        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -0,0 +1,113 @@
</span><ins>+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 800 x 600)
+      (tile size 800 x 600)
+      (top left tile 0, 0 tiles grid 1 x 1)
+      (in window 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (replica layer)
+            (GraphicsLayer
+              (position -2.00 -2.00)
+              (bounds 404.00 304.00)
+              (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 314.00 0.00 1.00])
+              (replicated layer)
+            )
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 1)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 913.00 1206.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 913.00 1206.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 800 x 600)
+      (tile size 800 x 600)
+      (top left tile 0, 0 tiles grid 1 x 1)
+      (in window 0)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (replica layer)
+            (GraphicsLayer
+              (position -2.00 -2.00)
+              (bounds 404.00 304.00)
+              (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 314.00 0.00 1.00])
+              (replicated layer)
+            )
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 0)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 0)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingtilingtiledreflectioninwindowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/tiling/tiled-reflection-inwindow.html (0 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/tiling/tiled-reflection-inwindow.html                                (rev 0)
+++ trunk/LayoutTests/compositing/tiling/tiled-reflection-inwindow.html        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -0,0 +1,75 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .container {
+            height: 300px;
+            width: 400px;
+            border: 2px solid black;
+            overflow: hidden;
+            -webkit-box-reflect: below 10px;
+        }
+
+        .box {
+            height: 300px;
+            width: 2800px;
+            border: 1px solid black;
+            background-color: gray;
+        }
+
+        .composited {
+            transform: translateZ(0);
+        }
+
+        .masked {
+            -webkit-mask-image: url(../resources/alpha-gradient.png);
+            -webkit-mask-repeat: repeat-x;
+        }
+    &lt;/style&gt;
+    &lt;script&gt;
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+        
+        function getUIScript()
+        {
+            return `
+            (function() {
+                uiController.removeViewFromWindow(function() {
+                    uiController.uiScriptComplete('');
+                });
+            })();`
+        }
+
+        function dumpTiles(outputId)
+        {
+            if (window.internals)
+                document.getElementById(outputId).innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+        }
+        function doTest()
+        {
+            if (!testRunner.runUIScript)
+                return;
+
+            dumpTiles('before-layers');
+
+            testRunner.runUIScript(getUIScript(), function(result) {
+                dumpTiles('after-layers');
+                if (window.testRunner)
+                    testRunner.notifyDone();
+            });
+        }
+        window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div class=&quot;composited container&quot;&gt;
+        &lt;div class=&quot;composited masked box&quot;&gt;&lt;/div&gt; 
+    &lt;/div&gt;
+
+&lt;pre id=&quot;before-layers&quot;&gt;Layer tree goes here&lt;/pre&gt;
+&lt;pre id=&quot;after-layers&quot;&gt;Layer tree goes here&lt;/pre&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk1compositingtilingtiledmaskinwindowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/tiled-mask-inwindow-expected.txt (0 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/tiled-mask-inwindow-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/tiled-mask-inwindow-expected.txt        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -0,0 +1,91 @@
</span><ins>+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 1)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 995.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 995.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 1)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk1compositingtilingtiledreflectioninwindowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/tiled-reflection-inwindow-expected.txt (0 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/tiled-reflection-inwindow-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/tiled-reflection-inwindow-expected.txt        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -0,0 +1,105 @@
</span><ins>+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (replica layer)
+            (GraphicsLayer
+              (position -2.00 -2.00)
+              (bounds 404.00 304.00)
+              (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 314.00 0.00 1.00])
+              (replicated layer)
+            )
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 1)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 913.00 1093.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 913.00 1093.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (replica layer)
+            (GraphicsLayer
+              (position -2.00 -2.00)
+              (bounds 404.00 304.00)
+              (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 314.00 0.00 1.00])
+              (replicated layer)
+            )
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 1)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk2compositingtilingtiledmaskinwindowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/tiled-mask-inwindow-expected.txt (0 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/tiled-mask-inwindow-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/tiled-mask-inwindow-expected.txt        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -0,0 +1,99 @@
</span><ins>+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 800 x 600)
+      (tile size 800 x 600)
+      (top left tile 0, 0 tiles grid 1 x 1)
+      (in window 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 1)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 1051.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 1051.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 800 x 600)
+      (tile size 800 x 600)
+      (top left tile 0, 0 tiles grid 1 x 1)
+      (in window 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 1)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk2compositingtilingtiledreflectioninwindowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/tiled-reflection-inwindow-expected.txt (0 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/tiled-reflection-inwindow-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/tiled-reflection-inwindow-expected.txt        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -0,0 +1,113 @@
</span><ins>+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 800 x 600)
+      (tile size 800 x 600)
+      (top left tile 0, 0 tiles grid 1 x 1)
+      (in window 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (replica layer)
+            (GraphicsLayer
+              (position -2.00 -2.00)
+              (bounds 404.00 304.00)
+              (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 314.00 0.00 1.00])
+              (replicated layer)
+            )
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 1)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 913.00 1149.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 913.00 1149.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 800 x 600)
+      (tile size 800 x 600)
+      (top left tile 0, 0 tiles grid 1 x 1)
+      (in window 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (replica layer)
+            (GraphicsLayer
+              (position -2.00 -2.00)
+              (bounds 404.00 304.00)
+              (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 314.00 0.00 1.00])
+              (replicated layer)
+            )
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 1)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1compositingtilingtiledmaskinwindowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-wk1/compositing/tiling/tiled-mask-inwindow-expected.txt (0 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/compositing/tiling/tiled-mask-inwindow-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/compositing/tiling/tiled-mask-inwindow-expected.txt        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -0,0 +1,91 @@
</span><ins>+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 1)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 785.00 1041.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 785.00 1041.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 0)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 0)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1compositingtilingtiledreflectioninwindowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-wk1/compositing/tiling/tiled-reflection-inwindow-expected.txt (0 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/compositing/tiling/tiled-reflection-inwindow-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/compositing/tiling/tiled-reflection-inwindow-expected.txt        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -0,0 +1,105 @@
</span><ins>+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (replica layer)
+            (GraphicsLayer
+              (position -2.00 -2.00)
+              (bounds 404.00 304.00)
+              (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 314.00 0.00 1.00])
+              (replicated layer)
+            )
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 1)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 1)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 913.00 1146.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 913.00 1146.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 404.00 304.00)
+          (drawsContent 1)
+          (replica layer)
+            (GraphicsLayer
+              (position -2.00 -2.00)
+              (bounds 404.00 304.00)
+              (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 314.00 0.00 1.00])
+              (replicated layer)
+            )
+          (children 1
+            (GraphicsLayer
+              (position 2.00 2.00)
+              (bounds 400.00 300.00)
+              (children 1
+                (GraphicsLayer
+                  (bounds 2802.00 302.00)
+                  (usingTiledLayer 1)
+                  (contentsOpaque 1)
+                  (drawsContent 1)
+                  (mask layer)
+                    (GraphicsLayer
+                      (bounds 2802.00 302.00)
+                      (usingTiledLayer 1)
+                      (drawsContent 1)
+                      (tile cache coverage 0, 0 512 x 302)
+                      (tile size 512 x 512)
+                      (top left tile 0, 0 tiles grid 1 x 1)
+                      (in window 0)
+                    )
+                  (tile cache coverage 0, 0 512 x 302)
+                  (tile size 512 x 512)
+                  (top left tile 0, 0 tiles grid 1 x 1)
+                  (in window 0)
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (212152 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-10 22:40:18 UTC (rev 212152)
+++ trunk/Source/WebCore/ChangeLog        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2017-02-10  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Make sure the &quot;inwindow&quot; flag propagates to TiledBackings for masks and reflections
+        https://bugs.webkit.org/show_bug.cgi?id=168127
+        rdar://problem/30467120
+
+        Reviewed by Tim Horton.
+        
+        Replace the special-case, but wrong, GraphicsLayer traversal in setIsInWindowIncludingDescendants()
+        which forgot to hit masks and replica layers with a generic traverse() function, which
+        is then used for setting 'inWindow' as well as resetting tracked repaints.
+
+        Tests: compositing/tiling/tiled-mask-inwindow.html
+               compositing/tiling/tiled-reflection-inwindow.html
+
+        * page/PageOverlayController.cpp:
+        (WebCore::PageOverlayController::layerWithDocumentOverlays):
+        (WebCore::PageOverlayController::layerWithViewOverlays):
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::setIsInWindow):
+        (WebCore::GraphicsLayer::setReplicatedByLayer):
+        (WebCore::GraphicsLayer::traverse):
+        (WebCore::GraphicsLayer::setIsInWindowIncludingDescendants): Deleted.
+        * platform/graphics/GraphicsLayer.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::setIsInWindow):
+        (WebCore::RenderLayerCompositor::resetTrackedRepaintRects):
+        (WebCore::resetTrackedRepaintRectsRecursive): Deleted.
+
</ins><span class="cx"> 2017-02-09  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Tiled layers are sometimes left with some tiles when outside the viewport
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageOverlayControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageOverlayController.cpp (212152 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageOverlayController.cpp        2017-02-10 22:40:18 UTC (rev 212152)
+++ trunk/Source/WebCore/page/PageOverlayController.cpp        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -103,7 +103,9 @@
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="cx">         GraphicsLayer&amp; layer = *overlayAndLayer.value;
</span><del>-        layer.setIsInWindowIncludingDescendants(inWindow);
</del><ins>+        GraphicsLayer::traverse(layer, [inWindow](GraphicsLayer&amp; layer) {
+            layer.setIsInWindow(inWindow);
+        });
</ins><span class="cx">         updateOverlayGeometry(overlay, layer);
</span><span class="cx">         
</span><span class="cx">         if (!layer.parent())
</span><span class="lines">@@ -125,7 +127,9 @@
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="cx">         GraphicsLayer&amp; layer = *overlayAndLayer.value;
</span><del>-        layer.setIsInWindowIncludingDescendants(inWindow);
</del><ins>+        GraphicsLayer::traverse(layer, [inWindow](GraphicsLayer&amp; layer) {
+            layer.setIsInWindow(inWindow);
+        });
</ins><span class="cx">         updateOverlayGeometry(overlay, layer);
</span><span class="cx">         
</span><span class="cx">         if (!layer.parent())
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (212152 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp        2017-02-10 22:40:18 UTC (rev 212152)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -363,13 +363,10 @@
</span><span class="cx">         childLayers[i]-&gt;noteDeviceOrPageScaleFactorChangedIncludingDescendants();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayer::setIsInWindowIncludingDescendants(bool inWindow)
</del><ins>+void GraphicsLayer::setIsInWindow(bool inWindow)
</ins><span class="cx"> {
</span><span class="cx">     if (TiledBacking* tiledBacking = this-&gt;tiledBacking())
</span><span class="cx">         tiledBacking-&gt;setIsInWindow(inWindow);
</span><del>-
-    for (auto* childLayer : children())
-        childLayer-&gt;setIsInWindowIncludingDescendants(inWindow);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayer::setReplicatedByLayer(GraphicsLayer* layer)
</span><span class="lines">@@ -378,7 +375,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (m_replicaLayer)
</span><del>-        m_replicaLayer-&gt;setReplicatedLayer(0);
</del><ins>+        m_replicaLayer-&gt;setReplicatedLayer(nullptr);
</ins><span class="cx"> 
</span><span class="cx">     if (layer)
</span><span class="cx">         layer-&gt;setReplicatedLayer(this);
</span><span class="lines">@@ -668,6 +665,20 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GraphicsLayer::traverse(GraphicsLayer&amp; layer, std::function&lt;void (GraphicsLayer&amp;)&gt; traversalFunc)
+{
+    traversalFunc(layer);
+
+    for (auto* childLayer : layer.children())
+        traverse(*childLayer, traversalFunc);
+
+    if (auto* replicaLayer = layer.replicaLayer())
+        traverse(*replicaLayer, traversalFunc);
+
+    if (auto* maskLayer = layer.maskLayer())
+        traverse(*maskLayer, traversalFunc);
+}
+
</ins><span class="cx"> void GraphicsLayer::dumpLayer(TextStream&amp; ts, int indent, LayerTreeAsTextBehavior behavior) const
</span><span class="cx"> {
</span><span class="cx">     writeIndent(ts, indent);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (212152 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h        2017-02-10 22:40:18 UTC (rev 212152)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -517,7 +517,7 @@
</span><span class="cx">     virtual void deviceOrPageScaleFactorChanged() { }
</span><span class="cx">     WEBCORE_EXPORT void noteDeviceOrPageScaleFactorChangedIncludingDescendants();
</span><span class="cx"> 
</span><del>-    void setIsInWindowIncludingDescendants(bool);
</del><ins>+    void setIsInWindow(bool);
</ins><span class="cx"> 
</span><span class="cx">     // Some compositing systems may do internal batching to synchronize compositing updates
</span><span class="cx">     // with updates drawn into the window. These methods flush internal batched state on this layer
</span><span class="lines">@@ -561,6 +561,8 @@
</span><span class="cx">     virtual bool isGraphicsLayerTextureMapper() const { return false; }
</span><span class="cx">     virtual bool isCoordinatedGraphicsLayer() const { return false; }
</span><span class="cx"> 
</span><ins>+    static void traverse(GraphicsLayer&amp;, std::function&lt;void (GraphicsLayer&amp;)&gt;);
+
</ins><span class="cx"> protected:
</span><span class="cx">     WEBCORE_EXPORT explicit GraphicsLayer(Type, GraphicsLayerClient&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (212152 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2017-02-10 22:40:18 UTC (rev 212152)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -2034,8 +2034,11 @@
</span><span class="cx">     if (!inCompositingMode())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (GraphicsLayer* rootLayer = rootGraphicsLayer())
-        rootLayer-&gt;setIsInWindowIncludingDescendants(isInWindow);
</del><ins>+    if (GraphicsLayer* rootLayer = rootGraphicsLayer()) {
+        GraphicsLayer::traverse(*rootLayer, [isInWindow](GraphicsLayer&amp; layer) {
+            layer.setIsInWindow(isInWindow);
+        });
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (isInWindow) {
</span><span class="cx">         if (m_rootLayerAttachment != RootLayerUnattached)
</span><span class="lines">@@ -2862,24 +2865,13 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void resetTrackedRepaintRectsRecursive(GraphicsLayer&amp; graphicsLayer)
-{
-    graphicsLayer.resetTrackedRepaints();
-
-    for (auto* childLayer : graphicsLayer.children())
-        resetTrackedRepaintRectsRecursive(*childLayer);
-
-    if (GraphicsLayer* replicaLayer = graphicsLayer.replicaLayer())
-        resetTrackedRepaintRectsRecursive(*replicaLayer);
-
-    if (GraphicsLayer* maskLayer = graphicsLayer.maskLayer())
-        resetTrackedRepaintRectsRecursive(*maskLayer);
-}
-
</del><span class="cx"> void RenderLayerCompositor::resetTrackedRepaintRects()
</span><span class="cx"> {
</span><del>-    if (GraphicsLayer* rootLayer = rootGraphicsLayer())
-        resetTrackedRepaintRectsRecursive(*rootLayer);
</del><ins>+    if (GraphicsLayer* rootLayer = rootGraphicsLayer()) {
+        GraphicsLayer::traverse(*rootLayer, [](GraphicsLayer&amp; layer) {
+            layer.resetTrackedRepaints();
+        });
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderLayerCompositor::setTracksRepaints(bool tracksRepaints)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (212152 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-02-10 22:40:18 UTC (rev 212152)
+++ trunk/Tools/ChangeLog        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2017-02-10  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Make sure the &quot;inwindow&quot; flag propagates to TiledBackings for masks and reflections
+        https://bugs.webkit.org/show_bug.cgi?id=168127
+        rdar://problem/30467120
+
+        Reviewed by Tim Horton.
+
+        Reparent the web view before we try to fetch it via:
+            [[[window contentView] subviews] objectAtIndex:0];
+        which would throw an exception if the test unparented it.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetWebViewToConsistentStateBeforeTesting):
+        (runTest):
+
</ins><span class="cx"> 2017-02-10  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Resource Timing] Enable Resource Timing by default in Tests
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreemacDumpRenderTreemm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (212152 => 212153)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm        2017-02-10 22:40:18 UTC (rev 212152)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm        2017-02-10 23:02:36 UTC (rev 212153)
</span><span class="lines">@@ -1848,11 +1848,6 @@
</span><span class="cx"> {
</span><span class="cx">     WebView *webView = [mainFrame webView];
</span><span class="cx"> 
</span><del>-#if PLATFORM(MAC)
-    if (![webView superview])
-        [[mainWindow contentView] addSubview:webView];
-#endif
-
</del><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     adjustWebDocumentForStandardViewport(gWebBrowserView, gWebScrollView);
</span><span class="cx">     [webView _setAllowsMessaging:YES];
</span><span class="lines">@@ -2111,6 +2106,13 @@
</span><span class="cx">         gTestRunner-&gt;setDeveloperExtrasEnabled(false);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC)
+    // Make sure the WebView is parented, since the test may have unparented it.
+    WebView *webView = [mainFrame webView];
+    if (![webView superview])
+        [[mainWindow contentView] addSubview:webView];
+#endif
+
</ins><span class="cx">     if (gTestRunner-&gt;closeRemainingWindowsWhenComplete()) {
</span><span class="cx">         NSArray* array = [DumpRenderTreeWindow openWindows];
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>