<!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>[212125] branches/safari-603-branch</title>
</head>
<body>

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

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/211910">r211910</a>. rdar://problem/30358835</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari603branchLayoutTestsChangeLog">branches/safari-603-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari603branchSourceWebCoreChangeLog">branches/safari-603-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari603branchSourceWebCorepageFrameViewcpp">branches/safari-603-branch/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebCorepageFrameViewh">branches/safari-603-branch/Source/WebCore/page/FrameView.h</a></li>
<li><a href="#branchessafari603branchSourceWebCorepagePagecpp">branches/safari-603-branch/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebCorepagePageh">branches/safari-603-branch/Source/WebCore/page/Page.h</a></li>
<li><a href="#branchessafari603branchSourceWebCoreplatformgraphicsTiledBackingh">branches/safari-603-branch/Source/WebCore/platform/graphics/TiledBacking.h</a></li>
<li><a href="#branchessafari603branchSourceWebCoreplatformgraphicscaTileControllercpp">branches/safari-603-branch/Source/WebCore/platform/graphics/ca/TileController.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebCoreplatformgraphicscaTileControllerh">branches/safari-603-branch/Source/WebCore/platform/graphics/ca/TileController.h</a></li>
<li><a href="#branchessafari603branchSourceWebCoretestingInternalscpp">branches/safari-603-branch/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebCoretestingInternalsh">branches/safari-603-branch/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#branchessafari603branchSourceWebCoretestingInternalsidl">branches/safari-603-branch/Source/WebCore/testing/Internals.idl</a></li>
<li><a href="#branchessafari603branchToolsChangeLog">branches/safari-603-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari603branchToolsWebKitTestRunnermacPlatformWebViewMacmm">branches/safari-603-branch/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari603branchLayoutTestscompositingtilingnonactivewindowtilessizeexpectedtxt">branches/safari-603-branch/LayoutTests/compositing/tiling/non-active-window-tiles-size-expected.txt</a></li>
<li><a href="#branchessafari603branchLayoutTestscompositingtilingnonactivewindowtilessizehtml">branches/safari-603-branch/LayoutTests/compositing/tiling/non-active-window-tiles-size.html</a></li>
<li><a href="#branchessafari603branchLayoutTestsplatformiossimulatorwk2compositingtilingnonactivewindowtilessizeexpectedtxt">branches/safari-603-branch/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/non-active-window-tiles-size-expected.txt</a></li>
<li><a href="#branchessafari603branchLayoutTestsplatformmacwk1compositingtilingnonactivewindowtilessizeexpectedtxt">branches/safari-603-branch/LayoutTests/platform/mac-wk1/compositing/tiling/non-active-window-tiles-size-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari603branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/LayoutTests/ChangeLog (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/ChangeLog        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/LayoutTests/ChangeLog        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -1,5 +1,24 @@
</span><span class="cx"> 2017-02-10  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r211910. rdar://problem/30358835
+
+    2017-02-08  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+            Use smaller tiles in windows that are not active to facilitate App Napping
+            https://bugs.webkit.org/show_bug.cgi?id=167997
+            &lt;rdar://problem/30358835&gt;
+
+            Reviewed by Simon Fraser.
+
+            Add layout test coverage.
+
+            * compositing/tiling/non-active-window-tiles-size-expected.txt: Added.
+            * compositing/tiling/non-active-window-tiles-size.html: Added.
+            * platform/ios-simulator-wk2/compositing/tiling/non-active-window-tiles-size-expected.txt: Added.
+            * platform/mac-wk1/compositing/tiling/non-active-window-tiles-size-expected.txt: Added.
+
+2017-02-10  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Rollout r212118. rdar://problem/30096323
</span><span class="cx"> 
</span><span class="cx"> 2017-02-10  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari603branchLayoutTestscompositingtilingnonactivewindowtilessizeexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/compositing/tiling/non-active-window-tiles-size-expected.txt (0 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/compositing/tiling/non-active-window-tiles-size-expected.txt                                (rev 0)
+++ branches/safari-603-branch/LayoutTests/compositing/tiling/non-active-window-tiles-size-expected.txt        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+Tiles when window is active:
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (coverage rect 0.00, 0.00 800.00 x 600.00)
+  (intersects coverage rect 1)
+  (contentsScale 1.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (coverage rect 0.00, 0.00 800.00 x 600.00)
+      (intersects coverage rect 1)
+      (contentsScale 1.00)
+      (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)
+    )
+  )
+)
+Tiles when window is not active:
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (coverage rect 0.00, 0.00 800.00 x 600.00)
+  (intersects coverage rect 1)
+  (contentsScale 1.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (coverage rect 0.00, 0.00 800.00 x 600.00)
+      (intersects coverage rect 1)
+      (contentsScale 1.00)
+      (tile cache coverage 0, 0 800 x 600)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="branchessafari603branchLayoutTestscompositingtilingnonactivewindowtilessizehtml"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/compositing/tiling/non-active-window-tiles-size.html (0 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/compositing/tiling/non-active-window-tiles-size.html                                (rev 0)
+++ branches/safari-603-branch/LayoutTests/compositing/tiling/non-active-window-tiles-size.html        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;p&gt;Tiles when window is active:&lt;/p&gt;
+&lt;pre id=&quot;activeResult&quot;&gt;&lt;/pre&gt;
+&lt;p&gt;Tiles when window is not active:&lt;/p&gt;
+&lt;pre id=&quot;nonActiveResult&quot;&gt;&lt;/pre&gt;
+&lt;script&gt;
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+if (window.internals)
+    internals.disableTileSizeUpdateDelay();
+
+onload = function() {
+    document.getElementById(&quot;activeResult&quot;).innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+    if (window.testRunner)
+        testRunner.setWindowIsKey(false);
+    
+    setTimeout(function() {
+        document.getElementById(&quot;nonActiveResult&quot;).innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }, 0);
+}
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari603branchLayoutTestsplatformiossimulatorwk2compositingtilingnonactivewindowtilessizeexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/non-active-window-tiles-size-expected.txt (0 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/non-active-window-tiles-size-expected.txt                                (rev 0)
+++ branches/safari-603-branch/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/non-active-window-tiles-size-expected.txt        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+Tiles when window is active:
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (coverage rect 0.00, 0.00 800.00 x 600.00)
+  (intersects coverage rect 1)
+  (contentsScale 2.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (coverage rect 0.00, 0.00 800.00 x 600.00)
+      (intersects coverage rect 1)
+      (contentsScale 2.00)
+      (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)
+    )
+  )
+)
+Tiles when window is not active:
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (visible rect 0.00, 0.00 800.00 x 600.00)
+  (coverage rect 0.00, 0.00 800.00 x 600.00)
+  (intersects coverage rect 1)
+  (contentsScale 2.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 800.00 x 600.00)
+      (coverage rect 0.00, 0.00 800.00 x 600.00)
+      (intersects coverage rect 1)
+      (contentsScale 2.00)
+      (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)
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="branchessafari603branchLayoutTestsplatformmacwk1compositingtilingnonactivewindowtilessizeexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/platform/mac-wk1/compositing/tiling/non-active-window-tiles-size-expected.txt (0 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/platform/mac-wk1/compositing/tiling/non-active-window-tiles-size-expected.txt                                (rev 0)
+++ branches/safari-603-branch/LayoutTests/platform/mac-wk1/compositing/tiling/non-active-window-tiles-size-expected.txt        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+Tiles when window is active:
+
+Tiles when window is not active:
+
+
</ins></span></pre></div>
<a id="branchessafari603branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/ChangeLog        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2017-02-10  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+        Merge r211910. rdar://problem/30358835
+
+    2017-02-08  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+            Use smaller tiles in windows that are not active to facilitate App Napping
+            https://bugs.webkit.org/show_bug.cgi?id=167997
+            &lt;rdar://problem/30358835&gt;
+
+            Reviewed by Simon Fraser.
+
+            Use smaller / non-adaptative tiles in windows that are not active to facilitate
+            App Napping after &lt;https://trac.webkit.org/r197594&gt;.
+
+            Test: compositing/tiling/non-active-window-tiles-size.html
+
+            * page/FrameView.cpp:
+            (WebCore::FrameView::contentsResized):
+            (WebCore::FrameView::addedOrRemovedScrollbar):
+            (WebCore::FrameView::computeScrollability):
+            (WebCore::FrameView::updateTiledBackingAdaptiveSizing):
+            (WebCore::FrameView::unobscuredContentSizeChanged):
+            (WebCore::FrameView::setViewExposedRect):
+            * page/FrameView.h:
+            * page/Page.cpp:
+            (WebCore::Page::setActivityState):
+            (WebCore::Page::isWindowActive):
+            * page/Page.h:
+            * platform/graphics/TiledBacking.h:
+            * platform/graphics/ca/TileController.cpp:
+            (WebCore::TileController::setTileSizeUpdateDelayDisabledForTesting):
+            (WebCore::TileController::notePendingTileSizeChange):
+            * platform/graphics/ca/TileController.h:
+            * testing/Internals.cpp:
+            (WebCore::Internals::resetToConsistentState):
+            (WebCore::Internals::disableTileSizeUpdateDelay):
+            * testing/Internals.h:
+            * testing/Internals.idl:
+
</ins><span class="cx"> 2017-02-10  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge r212026. rdar://problem/30096323
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/page/FrameView.cpp (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/page/FrameView.cpp        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Source/WebCore/page/FrameView.cpp        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -2414,9 +2414,9 @@
</span><span class="cx"> 
</span><span class="cx"> void FrameView::contentsResized()
</span><span class="cx"> {
</span><del>-    // For non-delegated scrolling, adjustTiledBackingScrollability() is called via addedOrRemovedScrollbar() which occurs less often.
</del><ins>+    // For non-delegated scrolling, updateTiledBackingAdaptiveSizing() is called via addedOrRemovedScrollbar() which occurs less often.
</ins><span class="cx">     if (delegatesScrolling())
</span><del>-        adjustTiledBackingScrollability();
</del><ins>+        updateTiledBackingAdaptiveSizing();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FrameView::delegatesScrollingDidChange()
</span><span class="lines">@@ -2758,21 +2758,23 @@
</span><span class="cx">             renderView-&gt;compositor().frameViewDidAddOrRemoveScrollbars();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    adjustTiledBackingScrollability();
</del><ins>+    updateTiledBackingAdaptiveSizing();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FrameView::adjustTiledBackingScrollability()
</del><ins>+TiledBacking::Scrollability FrameView::computeScrollability() const
</ins><span class="cx"> {
</span><del>-    auto* tiledBacking = this-&gt;tiledBacking();
-    if (!tiledBacking)
-        return;
-    
</del><ins>+    auto* page = frame().page();
+
+    // Use smaller square tiles if the Window is not active to facilitate app napping.
+    if (!page || !page-&gt;isWindowActive())
+        return TiledBacking::HorizontallyScrollable | TiledBacking::VerticallyScrollable;
+
</ins><span class="cx">     bool horizontallyScrollable;
</span><span class="cx">     bool verticallyScrollable;
</span><span class="cx">     bool clippedByAncestorView = static_cast&lt;bool&gt;(m_viewExposedRect);
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-    if (Page* page = frame().page())
</del><ins>+    if (page)
</ins><span class="cx">         clippedByAncestorView |= page-&gt;enclosedInScrollableAncestorView();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -2779,7 +2781,7 @@
</span><span class="cx">     if (delegatesScrolling()) {
</span><span class="cx">         IntSize documentSize = contentsSize();
</span><span class="cx">         IntSize visibleSize = this-&gt;visibleSize();
</span><del>-        
</del><ins>+
</ins><span class="cx">         horizontallyScrollable = clippedByAncestorView || documentSize.width() &gt; visibleSize.width();
</span><span class="cx">         verticallyScrollable = clippedByAncestorView || documentSize.height() &gt; visibleSize.height();
</span><span class="cx">     } else {
</span><span class="lines">@@ -2794,13 +2796,22 @@
</span><span class="cx">     if (verticallyScrollable)
</span><span class="cx">         scrollability |= TiledBacking::VerticallyScrollable;
</span><span class="cx"> 
</span><del>-    tiledBacking-&gt;setScrollability(scrollability);
</del><ins>+    return scrollability;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FrameView::updateTiledBackingAdaptiveSizing()
+{
+    auto* tiledBacking = this-&gt;tiledBacking();
+    if (!tiledBacking)
+        return;
+
+    tiledBacking-&gt;setScrollability(computeScrollability());
+}
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> void FrameView::unobscuredContentSizeChanged()
</span><span class="cx"> {
</span><del>-    adjustTiledBackingScrollability();
</del><ins>+    updateTiledBackingAdaptiveSizing();
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -5226,7 +5237,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (TiledBacking* tiledBacking = this-&gt;tiledBacking()) {
</span><span class="cx">         if (hasRectChanged)
</span><del>-            adjustTiledBackingScrollability();
</del><ins>+            updateTiledBackingAdaptiveSizing();
</ins><span class="cx">         adjustTiledBackingCoverage();
</span><span class="cx">         tiledBacking-&gt;setTiledScrollingIndicatorPosition(m_viewExposedRect ? m_viewExposedRect.value().location() : FloatPoint());
</span><span class="cx">     }
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorepageFrameViewh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/page/FrameView.h (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/page/FrameView.h        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Source/WebCore/page/FrameView.h        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;PaintPhase.h&quot;
</span><span class="cx"> #include &quot;RenderPtr.h&quot;
</span><span class="cx"> #include &quot;ScrollView.h&quot;
</span><ins>+#include &quot;TiledBacking.h&quot;
</ins><span class="cx"> #include &lt;memory&gt;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/Function.h&gt;
</span><span class="lines">@@ -538,7 +539,8 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void availableContentSizeChanged(AvailableSizeChangeReason) override;
</span><span class="cx"> 
</span><del>-    void adjustTiledBackingScrollability();
</del><ins>+    void updateTiledBackingAdaptiveSizing();
+    TiledBacking::Scrollability computeScrollability() const;
</ins><span class="cx"> 
</span><span class="cx">     void addPaintPendingMilestones(LayoutMilestones);
</span><span class="cx">     void firePaintRelatedMilestonesIfNeeded();
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/page/Page.cpp (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/page/Page.cpp        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Source/WebCore/page/Page.cpp        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -1504,6 +1504,10 @@
</span><span class="cx">         setIsInWindowInternal(activityState &amp; ActivityState::IsInWindow);
</span><span class="cx">     if (changed &amp; ActivityState::IsVisuallyIdle)
</span><span class="cx">         setIsVisuallyIdleInternal(activityState &amp; ActivityState::IsVisuallyIdle);
</span><ins>+    if (changed &amp; ActivityState::WindowIsActive) {
+        if (auto* view = m_mainFrame-&gt;view())
+            view-&gt;updateTiledBackingAdaptiveSizing();
+    }
</ins><span class="cx"> 
</span><span class="cx">     if (changed &amp; (ActivityState::IsVisible | ActivityState::IsVisuallyIdle | ActivityState::IsAudible | ActivityState::IsLoading))
</span><span class="cx">         updateTimerThrottlingState();
</span><span class="lines">@@ -1523,6 +1527,11 @@
</span><span class="cx">     return (m_activityState &amp; ActivityState::IsVisible) &amp;&amp; (m_activityState &amp; ActivityState::WindowIsActive);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool Page::isWindowActive() const
+{
+    return m_activityState &amp; ActivityState::WindowIsActive;
+}
+
</ins><span class="cx"> void Page::setIsVisible(bool isVisible)
</span><span class="cx"> {
</span><span class="cx">     if (isVisible)
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/page/Page.h (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/page/Page.h        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Source/WebCore/page/Page.h        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -362,6 +362,7 @@
</span><span class="cx">     WEBCORE_EXPORT void setActivityState(ActivityState::Flags);
</span><span class="cx">     ActivityState::Flags activityState() const { return m_activityState; }
</span><span class="cx"> 
</span><ins>+    bool isWindowActive() const;
</ins><span class="cx">     bool isVisibleAndActive() const;
</span><span class="cx">     WEBCORE_EXPORT void setIsVisible(bool);
</span><span class="cx">     WEBCORE_EXPORT void setIsPrerender();
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCoreplatformgraphicsTiledBackingh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/platform/graphics/TiledBacking.h (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/platform/graphics/TiledBacking.h        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Source/WebCore/platform/graphics/TiledBacking.h        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -85,6 +85,8 @@
</span><span class="cx">     virtual void setTopContentInset(float) = 0;
</span><span class="cx"> 
</span><span class="cx">     virtual void setVelocity(const VelocityData&amp;) = 0;
</span><ins>+
+    virtual void setTileSizeUpdateDelayDisabledForTesting(bool) = 0;
</ins><span class="cx">     
</span><span class="cx">     enum {
</span><span class="cx">         NotScrollable           = 0,
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCoreplatformgraphicscaTileControllercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/platform/graphics/ca/TileController.cpp (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/platform/graphics/ca/TileController.cpp        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Source/WebCore/platform/graphics/ca/TileController.cpp        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -309,6 +309,11 @@
</span><span class="cx">     tileGrid().updateTileLayerProperties();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TileController::setTileSizeUpdateDelayDisabledForTesting(bool value)
+{
+    m_isTileSizeUpdateDelayDisabledForTesting = value;
+}
+
</ins><span class="cx"> IntRect TileController::boundsForSize(const FloatSize&amp; size) const
</span><span class="cx"> {
</span><span class="cx">     IntPoint boundsOriginIncludingMargin(-leftMarginWidth(), -topMarginHeight());
</span><span class="lines">@@ -487,7 +492,10 @@
</span><span class="cx"> 
</span><span class="cx"> void TileController::notePendingTileSizeChange()
</span><span class="cx"> {
</span><del>-    m_tileSizeChangeTimer.restart();
</del><ins>+    if (m_isTileSizeUpdateDelayDisabledForTesting)
+        tileSizeChangeTimerFired();
+    else
+        m_tileSizeChangeTimer.restart();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TileController::tileSizeChangeTimerFired()
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCoreplatformgraphicscaTileControllerh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/platform/graphics/ca/TileController.h (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/platform/graphics/ca/TileController.h        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Source/WebCore/platform/graphics/ca/TileController.h        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -84,6 +84,8 @@
</span><span class="cx">     FloatRect coverageRect() const override { return m_coverageRect; }
</span><span class="cx">     std::optional&lt;FloatRect&gt; layoutViewportRect() const { return m_layoutViewportRect; }
</span><span class="cx"> 
</span><ins>+    void setTileSizeUpdateDelayDisabledForTesting(bool) final;
+
</ins><span class="cx">     unsigned blankPixelCount() const;
</span><span class="cx">     static unsigned blankPixelCountForTiles(const PlatformLayerList&amp;, const FloatRect&amp;, const IntPoint&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -222,6 +224,7 @@
</span><span class="cx">     bool m_hasTilesWithTemporaryScaleFactor { false }; // Used to make low-res tiles when zooming.
</span><span class="cx">     bool m_inLiveResize { false };
</span><span class="cx">     mutable bool m_tileSizeLocked { false };
</span><ins>+    bool m_isTileSizeUpdateDelayDisabledForTesting { false };
</ins><span class="cx"> 
</span><span class="cx">     Color m_tileDebugBorderColor;
</span><span class="cx">     float m_tileDebugBorderWidth { 0 };
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/testing/Internals.cpp (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/testing/Internals.cpp        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Source/WebCore/testing/Internals.cpp        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -387,6 +387,8 @@
</span><span class="cx"> #if USE(COORDINATED_GRAPHICS)
</span><span class="cx">         mainFrameView-&gt;setFixedVisibleContentRect(IntRect());
</span><span class="cx"> #endif
</span><ins>+        if (auto* backing = mainFrameView-&gt;tiledBacking())
+            backing-&gt;setTileSizeUpdateDelayDisabledForTesting(false);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     WebCore::clearDefaultPortForProtocolMapForTesting();
</span><span class="lines">@@ -698,6 +700,20 @@
</span><span class="cx">     return PageCache::singleton().pageCount();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Internals::disableTileSizeUpdateDelay()
+{
+    Document* document = contextDocument();
+    if (!document || !document-&gt;frame())
+        return;
+
+    auto* view = document-&gt;frame()-&gt;view();
+    if (!view)
+        return;
+
+    if (auto* backing = view-&gt;tiledBacking())
+        backing-&gt;setTileSizeUpdateDelayDisabledForTesting(true);
+}
+
</ins><span class="cx"> Node* Internals::treeScopeRootNode(Node&amp; node)
</span><span class="cx"> {
</span><span class="cx">     return &amp;node.treeScope().rootNode();
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/testing/Internals.h (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/testing/Internals.h        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Source/WebCore/testing/Internals.h        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -112,6 +112,7 @@
</span><span class="cx">     unsigned pageCacheSize() const;
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;CSSComputedStyleDeclaration&gt; computedStyleIncludingVisitedInfo(Element&amp;) const;
</span><ins>+    void disableTileSizeUpdateDelay();
</ins><span class="cx"> 
</span><span class="cx">     Node* ensureUserAgentShadowRoot(Element&amp; host);
</span><span class="cx">     Node* shadowRoot(Element&amp; host);
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/testing/Internals.idl (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/testing/Internals.idl        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Source/WebCore/testing/Internals.idl        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -506,4 +506,6 @@
</span><span class="cx">     sequence&lt;DOMString&gt; accessKeyModifiers();
</span><span class="cx"> 
</span><span class="cx">     [CallWith=Document] void setAsRunningUserScripts();
</span><ins>+
+    void disableTileSizeUpdateDelay();
</ins><span class="cx"> };
</span></span></pre></div>
<a id="branchessafari603branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Tools/ChangeLog (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Tools/ChangeLog        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Tools/ChangeLog        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2017-02-10  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
+        Merge r211910. rdar://problem/30358835
+
+    2017-02-08  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+            Use smaller tiles in windows that are not active to facilitate App Napping
+            https://bugs.webkit.org/show_bug.cgi?id=167997
+            &lt;rdar://problem/30358835&gt;
+
+            Reviewed by Simon Fraser.
+
+            * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+            (WTR::PlatformWebView::setWindowIsKey):
+            Actually update windowIsKey state of NSWindow so the WebView
+            properly updates its activity state.
+
</ins><span class="cx"> 2017-02-09  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge r211763. rdar://problem/30380075
</span></span></pre></div>
<a id="branchessafari603branchToolsWebKitTestRunnermacPlatformWebViewMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm (212124 => 212125)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm        2017-02-10 18:21:16 UTC (rev 212124)
+++ branches/safari-603-branch/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm        2017-02-10 18:56:07 UTC (rev 212125)
</span><span class="lines">@@ -162,6 +162,10 @@
</span><span class="cx"> void PlatformWebView::setWindowIsKey(bool isKey)
</span><span class="cx"> {
</span><span class="cx">     m_windowIsKey = isKey;
</span><ins>+    if (m_windowIsKey)
+        [m_window makeKeyWindow];
+    else
+        [m_window resignKeyWindow];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PlatformWebView::resizeTo(unsigned width, unsigned height, WebViewSizingMode sizingMode)
</span></span></pre>
</div>
</div>

</body>
</html>