<!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>[187116] 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/187116">187116</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-07-21 12:56:24 -0700 (Tue, 21 Jul 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/172417">r172417</a>, <a href="http://trac.webkit.org/projects/webkit/changeset/184065">r184065</a>): Multiple rendering issues with fixed attached background-image
https://bugs.webkit.org/show_bug.cgi?id=147049
&lt;rdar://problem/21110936&gt;

Patch by Said Abou-Hallawa &lt;sabouhallawa@apple.com&gt; on 2015-07-21
Reviewed by Simon Fraser.
Source/WebCore:

The fixed-attached background-image rendering is special. In general, to
display it, the destinationSize should be set to visibleContentSize. The
destinationLocation should be set such that the background-image does
not move with scrolling. The topContentInset should be subtracted from
the destinationLocation such that background-image can be rendered blurred
in the topContentArea. However there are cases in which these rules have to
be changed.

-- destinationSize: In the case of fixed layout size, the fixedLayoutSize
is bigger than the visibleContentSize. In this case, if the background-image
belongs to the root element, the destinationSize has to be set to fixedLayoutSize.
Otherwise it has to be set to the borderBoxSize unless the overflow is
hidden.

-- destinationLocation: If the background-image belongs to the root element, no
scroll offset to added to destinationLocation. For non-root element case,
FrameView::documentScrollOffsetRelativeToViewOrigin() should be used if no page
scaling is applied. Otherwise FrameView::scrollOffsetForFixedPosition() should be
used instead.

Tests: platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover.html
       platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local.html

* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry): Ensure
the geometry for the fixed-attached background-image is calculated correctly.

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateGeometry): Ensure the background layer
gets the correct size for the fixedLayoutSize mode.

LayoutTests:

fixedLayoutSize background-image rendering for root and non-root elements.

* platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover-expected.html: Added.
* platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover.html: Added.
* platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local-expected.html: Added.
* platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerBackingcpp">trunk/Source/WebCore/rendering/RenderLayerBacking.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsplatformmacwk2tileddrawingfixedlayoutsizefixedattachmentcoverexpectedhtml">trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover-expected.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2tileddrawingfixedlayoutsizefixedattachmentcoverhtml">trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2tileddrawingfixedlayoutsizefixedattachmentlocalexpectedhtml">trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local-expected.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2tileddrawingfixedlayoutsizefixedattachmentlocalhtml">trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (187115 => 187116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-07-21 19:54:23 UTC (rev 187115)
+++ trunk/LayoutTests/ChangeLog        2015-07-21 19:56:24 UTC (rev 187116)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-07-21  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        REGRESSION (r172417, r184065): Multiple rendering issues with fixed attached background-image
+        https://bugs.webkit.org/show_bug.cgi?id=147049
+        &lt;rdar://problem/21110936&gt;
+
+        Reviewed by Simon Fraser.
+        
+        fixedLayoutSize background-image rendering for root and non-root elements.
+
+        * platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover-expected.html: Added.
+        * platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover.html: Added.
+        * platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local-expected.html: Added.
+        * platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local.html: Added.
+
</ins><span class="cx"> 2015-07-21  Sungmann Cho  &lt;sungmann.cho@navercorp.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make PluginProxy::handleMouseEvent() asynchronous.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2tileddrawingfixedlayoutsizefixedattachmentcoverexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover-expected.html (0 => 187116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover-expected.html                                (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover-expected.html        2015-07-21 19:56:24 UTC (rev 187116)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+  body {
+    margin: 0;
+  }
+  .container {
+    height: 2000px;
+    overflow: hidden;
+    width: 50%;
+    height: 50%;
+    background-image: url('resources/green-blue.png');
+    background-attachment: fixed;
+    background-repeat: no-repeat;
+    background-size: 300px;
+  }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;div class=&quot;container&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2tileddrawingfixedlayoutsizefixedattachmentcoverhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover.html (0 => 187116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover.html                                (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover.html        2015-07-21 19:56:24 UTC (rev 187116)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+  body {
+    margin: 0;
+    height: 2000px;
+    overflow: hidden;
+    background: url('resources/green-blue.png') white;
+    background-attachment: fixed;
+    background-size: contain;
+    background-repeat: no-repeat;
+  }
+&lt;/style&gt;
+&lt;script&gt;
+  function runTest() {
+    if (window.internals) {
+      window.internals.setFixedLayoutSize(800, 600);
+      window.internals.setPageScaleFactor(0.5, 0, 0);
+      window.internals.setUseFixedLayout(true);
+    }
+  }
+  window.addEventListener('load', runTest, false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2tileddrawingfixedlayoutsizefixedattachmentlocalexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local-expected.html (0 => 187116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local-expected.html                                (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local-expected.html        2015-07-21 19:56:24 UTC (rev 187116)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;style&gt;
+  body {
+    margin: 0;
+  }
+  .container {
+    height: 2000px;
+    overflow: hidden;
+    width: 50%;
+    height: 50%;
+    background-image: url('resources/green-blue.png');
+    background-attachment: fixed;
+    background-repeat: no-repeat;
+    background-size: 300px;
+  }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+  &lt;div class=&quot;container&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2tileddrawingfixedlayoutsizefixedattachmentlocalhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local.html (0 => 187116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local.html                                (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local.html        2015-07-21 19:56:24 UTC (rev 187116)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+  &lt;style&gt;
+    html {
+      background: white;
+    }
+    body {
+      margin: 0;
+      height: 2000px;
+      overflow: hidden;
+      background: url(resources/green-blue.png);
+      background-attachment: fixed;
+      background-size: contain;
+      background-repeat: no-repeat;
+    }
+  &lt;/style&gt;
+  &lt;script&gt;
+  function runTest() {
+    if (window.internals) {
+      window.internals.setFixedLayoutSize(800, 600);
+      window.internals.setPageScaleFactor(0.5, 0, 0);
+      window.internals.setUseFixedLayout(true);
+    }
+  }
+  window.addEventListener('load', runTest, false);
+  &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (187115 => 187116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-07-21 19:54:23 UTC (rev 187115)
+++ trunk/Source/WebCore/ChangeLog        2015-07-21 19:56:24 UTC (rev 187116)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2015-07-21  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        REGRESSION (r172417, r184065): Multiple rendering issues with fixed attached background-image
+        https://bugs.webkit.org/show_bug.cgi?id=147049
+        &lt;rdar://problem/21110936&gt;
+
+        Reviewed by Simon Fraser.
+
+        The fixed-attached background-image rendering is special. In general, to
+        display it, the destinationSize should be set to visibleContentSize. The
+        destinationLocation should be set such that the background-image does
+        not move with scrolling. The topContentInset should be subtracted from
+        the destinationLocation such that background-image can be rendered blurred
+        in the topContentArea. However there are cases in which these rules have to
+        be changed.
+        
+        -- destinationSize: In the case of fixed layout size, the fixedLayoutSize
+        is bigger than the visibleContentSize. In this case, if the background-image
+        belongs to the root element, the destinationSize has to be set to fixedLayoutSize.
+        Otherwise it has to be set to the borderBoxSize unless the overflow is
+        hidden.
+        
+        -- destinationLocation: If the background-image belongs to the root element, no
+        scroll offset to added to destinationLocation. For non-root element case,
+        FrameView::documentScrollOffsetRelativeToViewOrigin() should be used if no page
+        scaling is applied. Otherwise FrameView::scrollOffsetForFixedPosition() should be
+        used instead.
+        
+        Tests: platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-cover.html
+               platform/mac-wk2/tiled-drawing/fixed-layout-size-fixed-attachment-local.html
+
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry): Ensure
+        the geometry for the fixed-attached background-image is calculated correctly.
+        
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateGeometry): Ensure the background layer
+        gets the correct size for the fixedLayoutSize mode.
+
</ins><span class="cx"> 2015-07-21  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix the !ENABLE(DETAILS_ELEMENT) build after r186598
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (187115 => 187116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2015-07-21 19:54:23 UTC (rev 187115)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2015-07-21 19:56:24 UTC (rev 187116)
</span><span class="lines">@@ -1115,13 +1115,32 @@
</span><span class="cx">             viewportRect = view().unscaledDocumentRect();
</span><span class="cx">         else {
</span><span class="cx">             FrameView&amp; frameView = view().frameView();
</span><del>-            viewportRect.setSize(frameView.unscaledVisibleContentSizeIncludingObscuredArea());
-            topContentInset = frameView.topContentInset(ScrollView::TopContentInsetType::WebCoreOrPlatformContentInset);
</del><ins>+            bool useFixedLayout = frameView.useFixedLayout() &amp;&amp; !frameView.fixedLayoutSize().isEmpty();
</ins><span class="cx"> 
</span><del>-            if (fixedBackgroundPaintsInLocalCoordinates())
-                viewportRect.setLocation(LayoutPoint(0, -topContentInset));
-            else
</del><ins>+            if (useFixedLayout) {
+                // Use the fixedLayoutSize() when useFixedLayout() because the rendering will scale
+                // down the frameView to to fit in the current viewport.
+                viewportRect.setSize(frameView.fixedLayoutSize());
+            } else
+                viewportRect.setSize(frameView.unscaledVisibleContentSizeIncludingObscuredArea());
+
+            if (fixedBackgroundPaintsInLocalCoordinates()) {
+                if (!useFixedLayout) {
+                    // Shifting location up by topContentInset is needed for layout tests which expect
+                    // layout to be shifted down when calling window.internals.setTopContentInset().
+                    topContentInset = frameView.topContentInset(ScrollView::TopContentInsetType::WebCoreOrPlatformContentInset);
+                    viewportRect.setLocation(LayoutPoint(0, -topContentInset));
+                }
+            } else if (useFixedLayout || frameView.frameScaleFactor() != 1) {
+                // scrollOffsetForFixedPosition() is adjusted for page scale and it does not include
+                // topContentInset so do not add it to the calculation below.
+                viewportRect.setLocation(toLayoutPoint(frameView.scrollOffsetForFixedPosition()));
+            } else {
+                // documentScrollOffsetRelativeToViewOrigin() includes -topContentInset in its height
+                // so we need to account for that in calculating the phase size
+                topContentInset = frameView.topContentInset(ScrollView::TopContentInsetType::WebCoreOrPlatformContentInset);
</ins><span class="cx">                 viewportRect.setLocation(toLayoutPoint(frameView.documentScrollOffsetRelativeToViewOrigin()));
</span><ins>+            }
</ins><span class="cx"> 
</span><span class="cx">             top += topContentInset;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerBackingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (187115 => 187116)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp        2015-07-21 19:54:23 UTC (rev 187115)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp        2015-07-21 19:56:24 UTC (rev 187116)
</span><span class="lines">@@ -925,7 +925,7 @@
</span><span class="cx">         if (backgroundLayerPaintsFixedRootBackground()) {
</span><span class="cx">             const FrameView&amp; frameView = renderer().view().frameView();
</span><span class="cx">             backgroundPosition = toLayoutPoint(frameView.scrollOffsetForFixedPosition());
</span><del>-            backgroundSize = frameView.visibleContentRect().size();
</del><ins>+            backgroundSize = frameView.layoutSize();
</ins><span class="cx">         }
</span><span class="cx">         m_backgroundLayer-&gt;setPosition(backgroundPosition);
</span><span class="cx">         m_backgroundLayer-&gt;setSize(backgroundSize);
</span></span></pre>
</div>
</div>

</body>
</html>