<!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>[203261] 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/203261">203261</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2016-07-14 18:46:25 -0700 (Thu, 14 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS WK2] When scrolling apple.com/music on iPad Pro in landscape, left-hand tiles appear first
https://bugs.webkit.org/show_bug.cgi?id=159798
rdar://problem/27362717

Reviewed by Tim Horton.
Source/WebCore:

In out-of-visible tiled layers, we always allocated the top-left tile, wasting
memory and causing ugliness when scrolling that layer into view. This happened
because getTileIndexRangeForRect() had no way to express the fact that no tiles
should be created.

Fix getTileIndexRangeForRect() to return a bool, and fix callers to respect the
return value.

Test: compositing/tiling/offscreen-tiled-layer.html

* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::dumpAdditionalProperties):
* platform/graphics/ca/TileGrid.cpp:
(WebCore::TileGrid::setNeedsDisplayInRect):
(WebCore::TileGrid::tilesWouldChangeForCoverageRect):
(WebCore::TileGrid::getTileIndexRangeForRect):
(WebCore::TileGrid::revalidateTiles):
(WebCore::TileGrid::ensureTilesForRect):
(WebCore::TileGrid::extent):
* platform/graphics/ca/TileGrid.h:

LayoutTests:

Test with an offscreen tiled layer.

* compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
* compositing/tiling/offscreen-tiled-layer.html: Added.
* platform/ios-simulator-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
* platform/ios-simulator-wk2/compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
* platform/mac-wk1/compositing/tiling/offscreen-tiled-layer-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="#trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAcpp">trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileGridcpp">trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileGridh">trunk/Source/WebCore/platform/graphics/ca/TileGrid.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscompositingtilingoffscreentiledlayerexpectedtxt">trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer-expected.txt</a></li>
<li><a href="#trunkLayoutTestscompositingtilingoffscreentiledlayerhtml">trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer.html</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk1compositingtilingoffscreentiledlayerexpectedtxt">trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk2compositingtilingoffscreentiledlayerexpectedtxt">trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/offscreen-tiled-layer-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk1compositingtilingoffscreentiledlayerexpectedtxt">trunk/LayoutTests/platform/mac-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (203260 => 203261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-07-15 00:52:15 UTC (rev 203260)
+++ trunk/LayoutTests/ChangeLog        2016-07-15 01:46:25 UTC (rev 203261)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-07-14  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        [iOS WK2] When scrolling apple.com/music on iPad Pro in landscape, left-hand tiles appear first
+        https://bugs.webkit.org/show_bug.cgi?id=159798
+        rdar://problem/27362717
+
+        Reviewed by Tim Horton.
+        
+        Test with an offscreen tiled layer.
+
+        * compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
+        * compositing/tiling/offscreen-tiled-layer.html: Added.
+        * platform/ios-simulator-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
+        * platform/ios-simulator-wk2/compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
+        * platform/mac-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt: Added.
+
</ins><span class="cx"> 2016-07-14  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Skipping editing/spelling/copy-paste-crash.html on ios-simulator.
</span></span></pre></div>
<a id="trunkLayoutTestscompositingtilingoffscreentiledlayerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer-expected.txt (0 => 203261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer-expected.txt                                (rev 0)
+++ trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer-expected.txt        2016-07-15 01:46:25 UTC (rev 203261)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 2208.00 2808.00)
+  (visible rect 0.00, 0.00 785.00 x 585.00)
+  (coverage rect 0.00, 0.00 785.00 x 585.00)
+  (intersects coverage rect 1)
+  (contentsScale 1.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 2208.00 2808.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 785.00 x 585.00)
+      (coverage rect 0.00, 0.00 785.00 x 585.00)
+      (intersects coverage rect 1)
+      (contentsScale 1.00)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 1800.00)
+          (bounds 2200.00 1000.00)
+          (usingTiledLayer 1)
+          (contentsOpaque 1)
+          (drawsContent 1)
+          (visible rect 0.00, 0.00 0.00 x 0.00)
+          (coverage rect -8.00, -1800.00 785.00 x 585.00)
+          (intersects coverage rect 0)
+          (contentsScale 1.00)
+          (tile cache coverage 0, 0 0 x 0)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 0 x 0)
+        )
+      )
+    )
+  )
+)
+Some text here.
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingtilingoffscreentiledlayerhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer.html (0 => 203261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer.html                                (rev 0)
+++ trunk/LayoutTests/compositing/tiling/offscreen-tiled-layer.html        2016-07-15 01:46:25 UTC (rev 203261)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .box {
+            margin-top: 1800px;
+            height: 1000px;
+            width: 2200px;
+            background-color: blue;
+        }
+        
+        .composited {
+            -webkit-transform: translateZ(0);
+        }
+    &lt;/style&gt;
+    &lt;script&gt;
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function doTest()
+        {
+            if (window.internals) {
+                document.getElementById('layers').innerText = internals.layerTreeAsText(document,
+                    internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+            }
+        }
+        
+        window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;pre id=&quot;layers&quot;&gt;&lt;/pre&gt;
+    &lt;div class=&quot;composited box&quot;&gt;
+        Some text here.
+    &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk1compositingtilingoffscreentiledlayerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt (0 => 203261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt        2016-07-15 01:46:25 UTC (rev 203261)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 2208.00 2808.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 2208.00 2808.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)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 1800.00)
+          (bounds 2200.00 1000.00)
+          (usingTiledLayer 1)
+          (contentsOpaque 1)
+          (drawsContent 1)
+          (visible rect 0.00, 0.00 0.00 x 0.00)
+          (coverage rect -8.00, -1800.00 800.00 x 600.00)
+          (intersects coverage rect 0)
+          (contentsScale 2.00)
+          (tile cache coverage 0, 0 0 x 0)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 0 x 0)
+        )
+      )
+    )
+  )
+)
+Some text here.
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk2compositingtilingoffscreentiledlayerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/offscreen-tiled-layer-expected.txt (0 => 203261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/offscreen-tiled-layer-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/compositing/tiling/offscreen-tiled-layer-expected.txt        2016-07-15 01:46:25 UTC (rev 203261)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 2208.00 2808.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 2208.00 2808.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 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 1800.00)
+          (bounds 2200.00 1000.00)
+          (usingTiledLayer 1)
+          (contentsOpaque 1)
+          (drawsContent 1)
+          (visible rect 0.00, 0.00 0.00 x 0.00)
+          (coverage rect -8.00, -1800.00 800.00 x 600.00)
+          (intersects coverage rect 0)
+          (contentsScale 2.00)
+          (tile cache coverage 0, 0 0 x 0)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 0 x 0)
+        )
+      )
+    )
+  )
+)
+Some text here.
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1compositingtilingoffscreentiledlayerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt (0 => 203261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/compositing/tiling/offscreen-tiled-layer-expected.txt        2016-07-15 01:46:25 UTC (rev 203261)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 2208.00 2808.00)
+  (visible rect 0.00, 0.00 785.00 x 585.00)
+  (coverage rect 0.00, 0.00 785.00 x 585.00)
+  (intersects coverage rect 1)
+  (contentsScale 1.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 2208.00 2808.00)
+      (contentsOpaque 1)
+      (visible rect 0.00, 0.00 785.00 x 585.00)
+      (coverage rect 0.00, 0.00 785.00 x 585.00)
+      (intersects coverage rect 1)
+      (contentsScale 1.00)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 1800.00)
+          (bounds 2200.00 1000.00)
+          (usingTiledLayer 1)
+          (contentsOpaque 1)
+          (drawsContent 1)
+          (visible rect 0.00, 0.00 0.00 x 0.00)
+          (coverage rect -8.00, -1800.00 785.00 x 585.00)
+          (intersects coverage rect 0)
+          (contentsScale 1.00)
+          (tile cache coverage 0, 0 0 x 0)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 0 x 0)
+        )
+      )
+    )
+  )
+)
+Some text here.
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (203260 => 203261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-07-15 00:52:15 UTC (rev 203260)
+++ trunk/Source/WebCore/ChangeLog        2016-07-15 01:46:25 UTC (rev 203261)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2016-07-14  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        [iOS WK2] When scrolling apple.com/music on iPad Pro in landscape, left-hand tiles appear first
+        https://bugs.webkit.org/show_bug.cgi?id=159798
+        rdar://problem/27362717
+
+        Reviewed by Tim Horton.
+
+        In out-of-visible tiled layers, we always allocated the top-left tile, wasting
+        memory and causing ugliness when scrolling that layer into view. This happened
+        because getTileIndexRangeForRect() had no way to express the fact that no tiles
+        should be created.
+
+        Fix getTileIndexRangeForRect() to return a bool, and fix callers to respect the
+        return value.
+
+        Test: compositing/tiling/offscreen-tiled-layer.html
+
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::dumpAdditionalProperties):
+        * platform/graphics/ca/TileGrid.cpp:
+        (WebCore::TileGrid::setNeedsDisplayInRect):
+        (WebCore::TileGrid::tilesWouldChangeForCoverageRect):
+        (WebCore::TileGrid::getTileIndexRangeForRect):
+        (WebCore::TileGrid::revalidateTiles):
+        (WebCore::TileGrid::ensureTilesForRect):
+        (WebCore::TileGrid::extent):
+        * platform/graphics/ca/TileGrid.h:
+
</ins><span class="cx"> 2016-07-14  John Wilander  &lt;wilander@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove credentials in URL when accessed through location.href
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaGraphicsLayerCAcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (203260 => 203261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp        2016-07-15 00:52:15 UTC (rev 203260)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp        2016-07-15 01:46:25 UTC (rev 203261)
</span><span class="lines">@@ -3496,7 +3496,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (behavior &amp; LayerTreeAsTextDebug) {
</span><span class="cx">         writeIndent(textStream, indent + 1);
</span><del>-        textStream &lt;&lt; &quot;(acceleratetes drawing &quot; &lt;&lt; m_acceleratesDrawing &lt;&lt; &quot;)\n&quot;;
</del><ins>+        textStream &lt;&lt; &quot;(accelerates drawing &quot; &lt;&lt; m_acceleratesDrawing &lt;&lt; &quot;)\n&quot;;
</ins><span class="cx">         writeIndent(textStream, indent + 1);
</span><span class="cx">         textStream &lt;&lt; &quot;(uses display-list drawing &quot; &lt;&lt; m_usesDisplayListDrawing &lt;&lt; &quot;)\n&quot;;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileGridcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp (203260 => 203261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp        2016-07-15 00:52:15 UTC (rev 203260)
+++ trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp        2016-07-15 01:46:25 UTC (rev 203261)
</span><span class="lines">@@ -112,15 +112,15 @@
</span><span class="cx">     if (repaintRectInTileCoords.height() &lt; 2 * tileSize.height() &amp;&amp; repaintRectInTileCoords.width() &lt; 2 * tileSize.width()) {
</span><span class="cx">         TileIndex topLeft;
</span><span class="cx">         TileIndex bottomRight;
</span><del>-        getTileIndexRangeForRect(repaintRectInTileCoords, topLeft, bottomRight);
-
-        for (int y = topLeft.y(); y &lt;= bottomRight.y(); ++y) {
-            for (int x = topLeft.x(); x &lt;= bottomRight.x(); ++x) {
-                TileIndex tileIndex(x, y);
-                
-                TileMap::iterator it = m_tiles.find(tileIndex);
-                if (it != m_tiles.end())
-                    setTileNeedsDisplayInRect(tileIndex, it-&gt;value, repaintRectInTileCoords, m_primaryTileCoverageRect);
</del><ins>+        if (getTileIndexRangeForRect(repaintRectInTileCoords, topLeft, bottomRight)) {
+            for (int y = topLeft.y(); y &lt;= bottomRight.y(); ++y) {
+                for (int x = topLeft.x(); x &lt;= bottomRight.x(); ++x) {
+                    TileIndex tileIndex(x, y);
+                    
+                    TileMap::iterator it = m_tiles.find(tileIndex);
+                    if (it != m_tiles.end())
+                        setTileNeedsDisplayInRect(tileIndex, it-&gt;value, repaintRectInTileCoords, m_primaryTileCoverageRect);
+                }
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">         return;
</span><span class="lines">@@ -199,12 +199,14 @@
</span><span class="cx">     scaledRect.scale(m_scale);
</span><span class="cx">     IntRect currentCoverageRectInTileCoords(enclosingIntRect(scaledRect));
</span><span class="cx"> 
</span><ins>+    IntRect tileCoverageRect;
</ins><span class="cx">     TileIndex topLeft;
</span><span class="cx">     TileIndex bottomRight;
</span><del>-    getTileIndexRangeForRect(currentCoverageRectInTileCoords, topLeft, bottomRight);
</del><ins>+    if (getTileIndexRangeForRect(currentCoverageRectInTileCoords, topLeft, bottomRight)) {
+        tileCoverageRect = rectForTileIndex(topLeft);
+        tileCoverageRect.unite(rectForTileIndex(bottomRight));
+    }
</ins><span class="cx"> 
</span><del>-    IntRect tileCoverageRect = rectForTileIndex(topLeft);
-    tileCoverageRect.unite(rectForTileIndex(bottomRight));
</del><span class="cx">     return tileCoverageRect != m_primaryTileCoverageRect;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -231,11 +233,14 @@
</span><span class="cx">     return rect;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TileGrid::getTileIndexRangeForRect(const IntRect&amp; rect, TileIndex&amp; topLeft, TileIndex&amp; bottomRight) const
</del><ins>+bool TileGrid::getTileIndexRangeForRect(const IntRect&amp; rect, TileIndex&amp; topLeft, TileIndex&amp; bottomRight) const
</ins><span class="cx"> {
</span><span class="cx">     IntRect clampedRect = m_controller.bounds();
</span><span class="cx">     clampedRect.scale(m_scale);
</span><span class="cx">     clampedRect.intersect(rect);
</span><ins>+    
+    if (clampedRect.isEmpty())
+        return false;
</ins><span class="cx"> 
</span><span class="cx">     auto tileSize = m_tileSize;
</span><span class="cx">     if (clampedRect.x() &gt;= 0)
</span><span class="lines">@@ -253,6 +258,8 @@
</span><span class="cx"> 
</span><span class="cx">     int bottomYRatio = ceil((float)clampedRect.maxY() / tileSize.height());
</span><span class="cx">     bottomRight.setY(std::max(bottomYRatio - 1, 0));
</span><ins>+    
+    return true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> unsigned TileGrid::blankPixelCount() const
</span><span class="lines">@@ -348,6 +355,7 @@
</span><span class="cx"> 
</span><span class="cx">         PlatformCALayer* tileLayer = tileInfo.layer.get();
</span><span class="cx">         IntRect tileRect = rectForTileIndex(tileIndex);
</span><ins>+
</ins><span class="cx">         if (tileRect.intersects(coverageRectInTileCoords)) {
</span><span class="cx">             tileInfo.cohort = VisibleTileCohort;
</span><span class="cx">             if (tileInfo.hasStaleContent) {
</span><span class="lines">@@ -444,14 +452,14 @@
</span><span class="cx"> 
</span><span class="cx">         TileIndex topLeftForBounds;
</span><span class="cx">         TileIndex bottomRightForBounds;
</span><del>-        getTileIndexRangeForRect(boundsInTileCoords, topLeftForBounds, bottomRightForBounds);
-
-        Vector&lt;TileIndex&gt; tilesToRemove;
-        for (auto&amp; index : m_tiles.keys()) {
-            if (index.y() &lt; topLeftForBounds.y() || index.y() &gt; bottomRightForBounds.y() || index.x() &lt; topLeftForBounds.x() || index.x() &gt; bottomRightForBounds.x())
-                tilesToRemove.append(index);
</del><ins>+        if (getTileIndexRangeForRect(boundsInTileCoords, topLeftForBounds, bottomRightForBounds)) {
+            Vector&lt;TileIndex&gt; tilesToRemove;
+            for (auto&amp; index : m_tiles.keys()) {
+                if (index.y() &lt; topLeftForBounds.y() || index.y() &gt; bottomRightForBounds.y() || index.x() &lt; topLeftForBounds.x() || index.x() &gt; bottomRightForBounds.x())
+                    tilesToRemove.append(index);
+            }
+            removeTiles(tilesToRemove);
</ins><span class="cx">         }
</span><del>-        removeTiles(tilesToRemove);
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_controller.didRevalidateTiles();
</span><span class="lines">@@ -526,7 +534,8 @@
</span><span class="cx"> 
</span><span class="cx">     TileIndex topLeft;
</span><span class="cx">     TileIndex bottomRight;
</span><del>-    getTileIndexRangeForRect(rectInTileCoords, topLeft, bottomRight);
</del><ins>+    if (!getTileIndexRangeForRect(rectInTileCoords, topLeft, bottomRight))
+        return IntRect();
</ins><span class="cx"> 
</span><span class="cx">     TileCohort currCohort = nextTileCohort();
</span><span class="cx">     unsigned tilesInCohort = 0;
</span><span class="lines">@@ -581,10 +590,12 @@
</span><span class="cx"> {
</span><span class="cx">     TileIndex topLeft;
</span><span class="cx">     TileIndex bottomRight;
</span><del>-    getTileIndexRangeForRect(m_primaryTileCoverageRect, topLeft, bottomRight);
</del><ins>+    if (getTileIndexRangeForRect(m_primaryTileCoverageRect, topLeft, bottomRight)) {
+        // Return index of top, left tile and the number of tiles across and down.
+        return IntRect(topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x() + 1, bottomRight.y() - topLeft.y() + 1);
+    }
</ins><span class="cx"> 
</span><del>-    // Return index of top, left tile and the number of tiles across and down.
-    return IntRect(topLeft.x(), topLeft.y(), bottomRight.x() - topLeft.x() + 1, bottomRight.y() - topLeft.y() + 1);
</del><ins>+    return IntRect();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> double TileGrid::retainedTileBackingStoreMemory() const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileGridh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/TileGrid.h (203260 => 203261)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileGrid.h        2016-07-15 00:52:15 UTC (rev 203260)
+++ trunk/Source/WebCore/platform/graphics/ca/TileGrid.h        2016-07-15 01:46:25 UTC (rev 203261)
</span><span class="lines">@@ -110,7 +110,7 @@
</span><span class="cx">     void setTileNeedsDisplayInRect(const TileIndex&amp;, TileInfo&amp;, const IntRect&amp; repaintRectInTileCoords, const IntRect&amp; coverageRectInTileCoords);
</span><span class="cx"> 
</span><span class="cx">     IntRect rectForTileIndex(const TileIndex&amp;) const;
</span><del>-    void getTileIndexRangeForRect(const IntRect&amp;, TileIndex&amp; topLeft, TileIndex&amp; bottomRight) const;
</del><ins>+    bool getTileIndexRangeForRect(const IntRect&amp;, TileIndex&amp; topLeft, TileIndex&amp; bottomRight) const;
</ins><span class="cx"> 
</span><span class="cx">     enum class CoverageType { PrimaryTiles, SecondaryTiles };
</span><span class="cx">     IntRect ensureTilesForRect(const FloatRect&amp;, CoverageType);
</span></span></pre>
</div>
</div>

</body>
</html>