<!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>[207087] releases/WebKitGTK/webkit-2.14</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/207087">207087</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-10-11 04:09:55 -0700 (Tue, 11 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/206188">r206188</a> - REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/204552">r204552</a>): Athlete search on Strava gives bad rendering.
https://bugs.webkit.org/show_bug.cgi?id=162250

Reviewed by Simon Fraser.

Source/WebCore:

Test: fast/layers/blank-content-when-child-layer-is-at-negative-big-number.html

* platform/graphics/LayoutRect.cpp:
(WebCore::LayoutRect::checkedUnite):
* platform/graphics/LayoutRect.h:
(WebCore::LayoutRect::isMaxXMaxYRepresentable):
(WebCore::LayoutRect::maxXMaxYCorner): Deleted.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects):

LayoutTests:

While computing the size of a particular layer, we unite the content size and the descendant layers' size.
If a descendant layer is positioned far off, the computed rectangle might not fully cover the original rectangles.
This happens when the 2 rectangles' distance is close to the maximum LayoutUnit value.
It's fairly common technic to put some content offscreen (top: -99999999px;). In order to keep the main content
visible, we need to ensure that the parent layer never gets cut off, while uniting it with the descendant layers.

* fast/layers/blank-content-when-child-layer-is-at-negative-big-number-expected.html: Added.
* fast/layers/blank-content-when-child-layer-is-at-negative-big-number.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit214LayoutTestsChangeLog">releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceWebCoreplatformgraphicsLayoutRectcpp">releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/LayoutRect.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceWebCoreplatformgraphicsLayoutRecth">releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/LayoutRect.h</a></li>
<li><a href="#releasesWebKitGTKwebkit214SourceWebCorerenderingRenderLayercpp">releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderLayer.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit214LayoutTestsfastlayersblankcontentwhenchildlayerisatnegativebignumberexpectedhtml">releases/WebKitGTK/webkit-2.14/LayoutTests/fast/layers/blank-content-when-child-layer-is-at-negative-big-number-expected.html</a></li>
<li><a href="#releasesWebKitGTKwebkit214LayoutTestsfastlayersblankcontentwhenchildlayerisatnegativebignumberhtml">releases/WebKitGTK/webkit-2.14/LayoutTests/fast/layers/blank-content-when-child-layer-is-at-negative-big-number.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit214LayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog (207086 => 207087)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog        2016-10-11 10:53:22 UTC (rev 207086)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/ChangeLog        2016-10-11 11:09:55 UTC (rev 207087)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-09-20  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        REGRESSION (r204552): Athlete search on Strava gives bad rendering.
+        https://bugs.webkit.org/show_bug.cgi?id=162250
+
+        Reviewed by Simon Fraser.
+
+        While computing the size of a particular layer, we unite the content size and the descendant layers' size.
+        If a descendant layer is positioned far off, the computed rectangle might not fully cover the original rectangles.
+        This happens when the 2 rectangles' distance is close to the maximum LayoutUnit value.
+        It's fairly common technic to put some content offscreen (top: -99999999px;). In order to keep the main content
+        visible, we need to ensure that the parent layer never gets cut off, while uniting it with the descendant layers.
+
+        * fast/layers/blank-content-when-child-layer-is-at-negative-big-number-expected.html: Added.
+        * fast/layers/blank-content-when-child-layer-is-at-negative-big-number.html: Added.
+
</ins><span class="cx"> 2016-09-19  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         ASSERTION FAILED: clipRectsContext.rootLayer == m_clipRectsCache-&gt;m_clipRectsRoot[clipRectsType] while loading guardian.co.uk
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214LayoutTestsfastlayersblankcontentwhenchildlayerisatnegativebignumberexpectedhtml"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.14/LayoutTests/fast/layers/blank-content-when-child-layer-is-at-negative-big-number-expected.html (0 => 207087)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/LayoutTests/fast/layers/blank-content-when-child-layer-is-at-negative-big-number-expected.html                                (rev 0)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/fast/layers/blank-content-when-child-layer-is-at-negative-big-number-expected.html        2016-10-11 11:09:55 UTC (rev 207087)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that we paint the parent layer properly even when the child layer is positioned far off.&lt;/title&gt;
+&lt;style&gt;
+div {
+    height: 100px;
+    width: 100px;
+    background-color: green;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit214LayoutTestsfastlayersblankcontentwhenchildlayerisatnegativebignumberhtml"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.14/LayoutTests/fast/layers/blank-content-when-child-layer-is-at-negative-big-number.html (0 => 207087)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/LayoutTests/fast/layers/blank-content-when-child-layer-is-at-negative-big-number.html                                (rev 0)
+++ releases/WebKitGTK/webkit-2.14/LayoutTests/fast/layers/blank-content-when-child-layer-is-at-negative-big-number.html        2016-10-11 11:09:55 UTC (rev 207087)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that we paint the parent layer properly even when the child layer is positioned far off.&lt;/title&gt;
+&lt;style&gt;
+.container {
+    transform: translateZ(0);
+    height: 100px;
+    width: 100px;
+    background-color: green;
+}
+
+.offscreen {
+    position: absolute;
+    top: -99999999px;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div class=&quot;container&quot;&gt;&lt;div class=&quot;offscreen&quot;&gt;foobar&lt;/div&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog (207086 => 207087)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog        2016-10-11 10:53:22 UTC (rev 207086)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/ChangeLog        2016-10-11 11:09:55 UTC (rev 207087)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-09-20  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        REGRESSION (r204552): Athlete search on Strava gives bad rendering.
+        https://bugs.webkit.org/show_bug.cgi?id=162250
+
+        Reviewed by Simon Fraser.
+
+        Test: fast/layers/blank-content-when-child-layer-is-at-negative-big-number.html
+
+        * platform/graphics/LayoutRect.cpp:
+        (WebCore::LayoutRect::checkedUnite):
+        * platform/graphics/LayoutRect.h:
+        (WebCore::LayoutRect::isMaxXMaxYRepresentable):
+        (WebCore::LayoutRect::maxXMaxYCorner): Deleted.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::calculateClipRects):
+
</ins><span class="cx"> 2016-09-19  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Cleanup: Remove an extraneous copy of SecurityOrigin
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceWebCoreplatformgraphicsLayoutRectcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/LayoutRect.cpp (207086 => 207087)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/LayoutRect.cpp        2016-10-11 10:53:22 UTC (rev 207086)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/LayoutRect.cpp        2016-10-11 11:09:55 UTC (rev 207087)
</span><span class="lines">@@ -88,6 +88,27 @@
</span><span class="cx">     m_size = newMaxPoint - newLocation;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool LayoutRect::checkedUnite(const LayoutRect&amp; other)
+{
+    if (other.isEmpty())
+        return true;
+    if (isEmpty()) {
+        *this = other;
+        return true;
+    }
+    if (!isMaxXMaxYRepresentable() || !other.isMaxXMaxYRepresentable())
+        return false;
+    FloatPoint topLeft = FloatPoint(std::min&lt;float&gt;(x(), other.x()), std::min&lt;float&gt;(y(), other.y()));
+    FloatPoint bottomRight = FloatPoint(std::max&lt;float&gt;(maxX(), other.maxX()), std::max&lt;float&gt;(maxY(), other.maxY()));
+    FloatSize size = bottomRight - topLeft;
+    
+    if (size.width() &gt;= LayoutUnit::nearlyMax() || size.height() &gt;= LayoutUnit::nearlyMax())
+        return false;
+    m_location = LayoutPoint(topLeft);
+    m_size = LayoutSize(size);
+    return true;
+}
+
</ins><span class="cx"> void LayoutRect::uniteIfNonZero(const LayoutRect&amp; other)
</span><span class="cx"> {
</span><span class="cx">     // Handle empty special cases first.
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceWebCoreplatformgraphicsLayoutRecth"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/LayoutRect.h (207086 => 207087)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/LayoutRect.h        2016-10-11 10:53:22 UTC (rev 207086)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/platform/graphics/LayoutRect.h        2016-10-11 11:09:55 UTC (rev 207087)
</span><span class="lines">@@ -126,6 +126,13 @@
</span><span class="cx">     LayoutPoint maxXMinYCorner() const { return LayoutPoint(m_location.x() + m_size.width(), m_location.y()); } // typically topRight
</span><span class="cx">     LayoutPoint minXMaxYCorner() const { return LayoutPoint(m_location.x(), m_location.y() + m_size.height()); } // typically bottomLeft
</span><span class="cx">     LayoutPoint maxXMaxYCorner() const { return LayoutPoint(m_location.x() + m_size.width(), m_location.y() + m_size.height()); } // typically bottomRight
</span><ins>+    bool isMaxXMaxYRepresentable() const
+    {
+        FloatRect rect = *this;
+        float maxX = rect.maxX();
+        float maxY = rect.maxY();
+        return maxX &gt; LayoutUnit::nearlyMin() &amp;&amp; maxX &lt; LayoutUnit::nearlyMax() &amp;&amp; maxY &gt; LayoutUnit::nearlyMin() &amp;&amp; maxY &lt; LayoutUnit::nearlyMax();
+    }
</ins><span class="cx">     
</span><span class="cx">     bool intersects(const LayoutRect&amp;) const;
</span><span class="cx">     WEBCORE_EXPORT bool contains(const LayoutRect&amp;) const;
</span><span class="lines">@@ -139,6 +146,7 @@
</span><span class="cx">     void intersect(const LayoutRect&amp;);
</span><span class="cx">     WEBCORE_EXPORT void unite(const LayoutRect&amp;);
</span><span class="cx">     void uniteIfNonZero(const LayoutRect&amp;);
</span><ins>+    bool checkedUnite(const LayoutRect&amp;);
</ins><span class="cx"> 
</span><span class="cx">     void inflateX(LayoutUnit dx)
</span><span class="cx">     {
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit214SourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderLayer.cpp (207086 => 207087)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderLayer.cpp        2016-10-11 10:53:22 UTC (rev 207086)
+++ releases/WebKitGTK/webkit-2.14/Source/WebCore/rendering/RenderLayer.cpp        2016-10-11 11:09:55 UTC (rev 207087)
</span><span class="lines">@@ -6003,34 +6003,35 @@
</span><span class="cx">     LayerListMutationDetector mutationChecker(const_cast&lt;RenderLayer*&gt;(this));
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    auto computeLayersUnion = [this, &amp;unionBounds, flags, descendantFlags] (const RenderLayer&amp; childLayer) {
+        if (!(flags &amp; IncludeCompositedDescendants) &amp;&amp; childLayer.isComposited())
+            return;
+        LayoutRect childBounds = childLayer.calculateLayerBounds(this, childLayer.offsetFromAncestor(this), descendantFlags);
+        // Ignore child layer (and behave as if we had overflow: hidden) when it is positioned off the parent layer so much
+        // that we hit the max LayoutUnit value.
+        unionBounds.checkedUnite(childBounds);
+    };
+
</ins><span class="cx">     if (Vector&lt;RenderLayer*&gt;* negZOrderList = this-&gt;negZOrderList()) {
</span><del>-        for (auto* curLayer : *negZOrderList) {
-            if (flags &amp; IncludeCompositedDescendants || !curLayer-&gt;isComposited()) {
-                LayoutRect childUnionBounds = curLayer-&gt;calculateLayerBounds(this, curLayer-&gt;offsetFromAncestor(this), descendantFlags);
-                unionBounds.unite(childUnionBounds);
-            }
-        }
</del><ins>+        for (auto* childLayer : *negZOrderList)
+            computeLayersUnion(*childLayer);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (Vector&lt;RenderLayer*&gt;* posZOrderList = this-&gt;posZOrderList()) {
</span><del>-        for (auto* curLayer : *posZOrderList) {
</del><ins>+        for (auto* childLayer : *posZOrderList) {
</ins><span class="cx">             // The RenderNamedFlowThread is ignored when we calculate the bounds of the RenderView.
</span><del>-            if ((flags &amp; IncludeCompositedDescendants || !curLayer-&gt;isComposited()) &amp;&amp; !curLayer-&gt;isFlowThreadCollectingGraphicsLayersUnderRegions()) {
-                LayoutRect childUnionBounds = curLayer-&gt;calculateLayerBounds(this, curLayer-&gt;offsetFromAncestor(this), descendantFlags);
-                unionBounds.unite(childUnionBounds);
-            }
</del><ins>+            if (childLayer-&gt;isFlowThreadCollectingGraphicsLayersUnderRegions())
+                continue;
+            computeLayersUnion(*childLayer);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (Vector&lt;RenderLayer*&gt;* normalFlowList = this-&gt;normalFlowList()) {
</span><del>-        for (auto* curLayer : *normalFlowList) {
</del><ins>+        for (auto* childLayer : *normalFlowList) {
</ins><span class="cx">             // RenderView will always return the size of the document, before reaching this point,
</span><span class="cx">             // so there's no way we could hit a RenderNamedFlowThread here.
</span><del>-            ASSERT(!curLayer-&gt;isFlowThreadCollectingGraphicsLayersUnderRegions());
-            if (flags &amp; IncludeCompositedDescendants || !curLayer-&gt;isComposited()) {
-                LayoutRect curAbsBounds = curLayer-&gt;calculateLayerBounds(this, curLayer-&gt;offsetFromAncestor(this), descendantFlags);
-                unionBounds.unite(curAbsBounds);
-            }
</del><ins>+            ASSERT(!childLayer-&gt;isFlowThreadCollectingGraphicsLayersUnderRegions());
+            computeLayersUnion(*childLayer);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>