<!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>[210342] 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/210342">210342</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2017-01-05 09:09:02 -0800 (Thu, 05 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/210059">r210059</a>. rdar://problem/29727145</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari603branchLayoutTestsChangeLog">branches/safari-603-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari603branchLayoutTeststileddrawingscrollingfixedfourbarswithheaderandfooterexpectedtxt">branches/safari-603-branch/LayoutTests/tiled-drawing/scrolling/fixed/four-bars-with-header-and-footer-expected.txt</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="#branchessafari603branchSourceWebCorepagescrollingScrollingTreeFrameScrollingNodecpp">branches/safari-603-branch/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebCorepagescrollingmacScrollingTreeFrameScrollingNodeMacmm">branches/safari-603-branch/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari603branchLayoutTestsfastvisualviewportzoomedfixedheaderandfooterexpectedtxt">branches/safari-603-branch/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt</a></li>
<li><a href="#branchessafari603branchLayoutTestsfastvisualviewportzoomedfixedheaderandfooterhtml">branches/safari-603-branch/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer.html</a></li>
<li><a href="#branchessafari603branchLayoutTestsplatformiossimulatorfastvisualviewportzoomedfixedheaderandfooterexpectedtxt">branches/safari-603-branch/LayoutTests/platform/ios-simulator/fast/visual-viewport/zoomed-fixed-header-and-footer-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 (210341 => 210342)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/ChangeLog        2017-01-05 17:08:58 UTC (rev 210341)
+++ branches/safari-603-branch/LayoutTests/ChangeLog        2017-01-05 17:09:02 UTC (rev 210342)
</span><span class="lines">@@ -1,5 +1,22 @@
</span><span class="cx"> 2017-01-05  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r210059. rdar://problem/29727145
+
+    2016-12-21  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+            Fixed bars are positioned incorrectly when there are header and footer banners
+            https://bugs.webkit.org/show_bug.cgi?id=166302
+            rdar://problem/29727145
+
+            Reviewed by Tim Horton.
+
+            * fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt: Added.
+            * fast/visual-viewport/zoomed-fixed-header-and-footer.html: Added.
+            * platform/ios-simulator/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt: Added.
+            * tiled-drawing/scrolling/fixed/four-bars-with-header-and-footer-expected.txt:
+
+2017-01-05  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r210035. rdar://problem/29704862
</span><span class="cx"> 
</span><span class="cx">     2016-12-20  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari603branchLayoutTestsfastvisualviewportzoomedfixedheaderandfooterexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt (0 => 210342)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt                                (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt        2017-01-05 17:09:02 UTC (rev 210342)
</span><span class="lines">@@ -0,0 +1,55 @@
</span><ins>+This test zooms and scrolls the page and checks the positions of fixed-position objects.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+JSON.stringify(internals.layoutViewportRect()) is {&quot;top&quot;:0,&quot;right&quot;:785,&quot;bottom&quot;:585,&quot;left&quot;:0,&quot;width&quot;:785,&quot;height&quot;:585}
+JSON.stringify(internals.visualViewportRect()) is {&quot;top&quot;:0,&quot;right&quot;:392.5,&quot;bottom&quot;:271,&quot;left&quot;:0,&quot;width&quot;:392.5,&quot;height&quot;:271}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:0,&quot;right&quot;:785,&quot;bottom&quot;:100,&quot;left&quot;:0,&quot;width&quot;:785,&quot;height&quot;:100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:485,&quot;right&quot;:785,&quot;bottom&quot;:585,&quot;left&quot;:0,&quot;width&quot;:785,&quot;height&quot;:100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:0,&quot;right&quot;:100,&quot;bottom&quot;:585,&quot;left&quot;:0,&quot;width&quot;:100,&quot;height&quot;:585}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:0,&quot;right&quot;:785,&quot;bottom&quot;:585,&quot;left&quot;:685,&quot;width&quot;:100,&quot;height&quot;:585}
+
+Scrolled to 475, 525
+JSON.stringify(internals.layoutViewportRect()) is {&quot;top&quot;:211,&quot;right&quot;:867.5,&quot;bottom&quot;:796,&quot;left&quot;:82.5,&quot;width&quot;:785,&quot;height&quot;:585}
+JSON.stringify(internals.visualViewportRect()) is {&quot;top&quot;:503.5,&quot;right&quot;:867.5,&quot;bottom&quot;:796,&quot;left&quot;:475,&quot;width&quot;:392.5,&quot;height&quot;:292.5}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-314,&quot;right&quot;:392.5,&quot;bottom&quot;:-214,&quot;left&quot;:-392.5,&quot;width&quot;:785,&quot;height&quot;:100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:171,&quot;right&quot;:392.5,&quot;bottom&quot;:271,&quot;left&quot;:-392.5,&quot;width&quot;:785,&quot;height&quot;:100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-314,&quot;right&quot;:-292.5,&quot;bottom&quot;:271,&quot;left&quot;:-392.5,&quot;width&quot;:100,&quot;height&quot;:585}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-314,&quot;right&quot;:392.5,&quot;bottom&quot;:271,&quot;left&quot;:292.5,&quot;width&quot;:100,&quot;height&quot;:585}
+
+Scrolled to 100, 776
+JSON.stringify(internals.layoutViewportRect()) is {&quot;top&quot;:462,&quot;right&quot;:867.5,&quot;bottom&quot;:1047,&quot;left&quot;:82.5,&quot;width&quot;:785,&quot;height&quot;:585}
+JSON.stringify(internals.visualViewportRect()) is {&quot;top&quot;:754.5,&quot;right&quot;:492.5,&quot;bottom&quot;:1047,&quot;left&quot;:100,&quot;width&quot;:392.5,&quot;height&quot;:292.5}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-314,&quot;right&quot;:767.5,&quot;bottom&quot;:-214,&quot;left&quot;:-17.5,&quot;width&quot;:785,&quot;height&quot;:100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:171,&quot;right&quot;:767.5,&quot;bottom&quot;:271,&quot;left&quot;:-17.5,&quot;width&quot;:785,&quot;height&quot;:100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-314,&quot;right&quot;:82.5,&quot;bottom&quot;:271,&quot;left&quot;:-17.5,&quot;width&quot;:100,&quot;height&quot;:585}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-314,&quot;right&quot;:767.5,&quot;bottom&quot;:271,&quot;left&quot;:667.5,&quot;width&quot;:100,&quot;height&quot;:585}
+
+Scrolled to 50, 300
+JSON.stringify(internals.layoutViewportRect()) is {&quot;top&quot;:278.5,&quot;right&quot;:835,&quot;bottom&quot;:863.5,&quot;left&quot;:50,&quot;width&quot;:785,&quot;height&quot;:585}
+JSON.stringify(internals.visualViewportRect()) is {&quot;top&quot;:278.5,&quot;right&quot;:442.5,&quot;bottom&quot;:571,&quot;left&quot;:50,&quot;width&quot;:392.5,&quot;height&quot;:292.5}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-21.5,&quot;right&quot;:785,&quot;bottom&quot;:78.5,&quot;left&quot;:0,&quot;width&quot;:785,&quot;height&quot;:100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:463.5,&quot;right&quot;:785,&quot;bottom&quot;:563.5,&quot;left&quot;:0,&quot;width&quot;:785,&quot;height&quot;:100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-21.5,&quot;right&quot;:100,&quot;bottom&quot;:563.5,&quot;left&quot;:0,&quot;width&quot;:100,&quot;height&quot;:585}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-21.5,&quot;right&quot;:785,&quot;bottom&quot;:563.5,&quot;left&quot;:685,&quot;width&quot;:100,&quot;height&quot;:585}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="branchessafari603branchLayoutTestsfastvisualviewportzoomedfixedheaderandfooterhtml"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer.html (0 => 210342)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer.html                                (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/visual-viewport/zoomed-fixed-header-and-footer.html        2017-01-05 17:09:02 UTC (rev 210342)
</span><span class="lines">@@ -0,0 +1,137 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        body {
+            height: 2000px;
+            width: 2000px;
+        }
+        
+        .fixed {
+            position: fixed;
+            background-color: gray;
+        }
+        
+        #top, #bottom {
+            width: 100%;
+            left: 0;
+            height: 100px;
+        }
+
+        #left, #right {
+            width: 100px;
+            top: 0;
+            height: 100%;
+        }
+
+        #top { top: 0; }
+        #bottom { bottom: 0; }
+
+        #left { left: 0; }
+        #right { right: 0; }
+    &lt;/style&gt;
+    &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        description(&quot;This test zooms and scrolls the page and checks the positions of fixed-position objects.&quot;);
+
+        if (window.internals) {
+            internals.setHeaderHeight(43);
+            internals.setFooterHeight(56);
+            internals.settings.setVisualViewportEnabled(true);
+        }
+
+        window.jsTestIsAsync = true;
+
+        var fixedElement;
+        function logFixedObject(objectID)
+        {
+            debug('client rect of ' + objectID + ':');
+            fixedElement = document.getElementById(objectID);
+            evalAndLogResult(&quot;JSON.stringify(fixedElement.getBoundingClientRect())&quot;);
+        }
+        
+        function doAfterZooming()
+        {
+            // Zooming may scroll the view away from the origin.
+            window.scrollTo(0, 0);
+
+            evalAndLogResult(&quot;JSON.stringify(internals.layoutViewportRect())&quot;);
+            evalAndLogResult(&quot;JSON.stringify(internals.visualViewportRect())&quot;);
+
+            logFixedObject('top');
+            logFixedObject('bottom');
+            logFixedObject('left');
+            logFixedObject('right');
+
+            debug('');
+            window.scrollTo(475, 525);
+            debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
+
+            evalAndLogResult(&quot;JSON.stringify(internals.layoutViewportRect())&quot;);
+            evalAndLogResult(&quot;JSON.stringify(internals.visualViewportRect())&quot;);
+
+            logFixedObject('top');
+            logFixedObject('bottom');
+            logFixedObject('left');
+            logFixedObject('right');
+
+            debug('');
+            window.scrollTo(100, 776);
+            debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
+
+            evalAndLogResult(&quot;JSON.stringify(internals.layoutViewportRect())&quot;);
+            evalAndLogResult(&quot;JSON.stringify(internals.visualViewportRect())&quot;);
+
+            logFixedObject('top');
+            logFixedObject('bottom');
+            logFixedObject('left');
+            logFixedObject('right');
+
+            debug('');
+            window.scrollTo(50, 300);
+            debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
+
+            evalAndLogResult(&quot;JSON.stringify(internals.layoutViewportRect())&quot;);
+            evalAndLogResult(&quot;JSON.stringify(internals.visualViewportRect())&quot;);
+
+            logFixedObject('top');
+            logFixedObject('bottom');
+            logFixedObject('left');
+            logFixedObject('right');
+
+            window.scrollTo(0, 0);
+
+            finishJSTest();
+        }
+
+        function getUIScript()
+        {
+            return `(function() {
+                uiController.zoomToScale(2, function() {
+                    uiController.uiScriptComplete(uiController.zoomScale);
+                });
+            })();`;
+        }
+
+        function doTest()
+        {
+            if (!window.testRunner)
+                return;
+
+            testRunner.runUIScript(getUIScript(), function(zoomScale) {
+                doAfterZooming();
+            });
+        }
+        
+        window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div id=&quot;top&quot; class=&quot;fixed&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;bottom&quot; class=&quot;fixed&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;left&quot; class=&quot;fixed&quot;&gt;&lt;/div&gt;
+    &lt;div id=&quot;right&quot; class=&quot;fixed&quot;&gt;&lt;/div&gt;
+    &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari603branchLayoutTestsplatformiossimulatorfastvisualviewportzoomedfixedheaderandfooterexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/platform/ios-simulator/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt (0 => 210342)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/platform/ios-simulator/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt                                (rev 0)
+++ branches/safari-603-branch/LayoutTests/platform/ios-simulator/fast/visual-viewport/zoomed-fixed-header-and-footer-expected.txt        2017-01-05 17:09:02 UTC (rev 210342)
</span><span class="lines">@@ -0,0 +1,55 @@
</span><ins>+This test zooms and scrolls the page and checks the positions of fixed-position objects.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+JSON.stringify(internals.layoutViewportRect()) is {&quot;top&quot;:0,&quot;right&quot;:800,&quot;bottom&quot;:600,&quot;left&quot;:0,&quot;width&quot;:800,&quot;height&quot;:600}
+JSON.stringify(internals.visualViewportRect()) is {&quot;top&quot;:0,&quot;right&quot;:400,&quot;bottom&quot;:257,&quot;left&quot;:0,&quot;width&quot;:400,&quot;height&quot;:257}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:0,&quot;right&quot;:800,&quot;bottom&quot;:100,&quot;left&quot;:0,&quot;width&quot;:800,&quot;height&quot;:100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:500,&quot;right&quot;:800,&quot;bottom&quot;:600,&quot;left&quot;:0,&quot;width&quot;:800,&quot;height&quot;:100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:0,&quot;right&quot;:100,&quot;bottom&quot;:600,&quot;left&quot;:0,&quot;width&quot;:100,&quot;height&quot;:600}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:0,&quot;right&quot;:800,&quot;bottom&quot;:600,&quot;left&quot;:700,&quot;width&quot;:100,&quot;height&quot;:600}
+
+Scrolled to 475, 525
+JSON.stringify(internals.layoutViewportRect()) is {&quot;top&quot;:0,&quot;right&quot;:800,&quot;bottom&quot;:600,&quot;left&quot;:0,&quot;width&quot;:800,&quot;height&quot;:600}
+JSON.stringify(internals.visualViewportRect()) is {&quot;top&quot;:482,&quot;right&quot;:875,&quot;bottom&quot;:782,&quot;left&quot;:475,&quot;width&quot;:400,&quot;height&quot;:300}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-525,&quot;right&quot;:325,&quot;bottom&quot;:-425,&quot;left&quot;:-475,&quot;width&quot;:800,&quot;height&quot;:100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-25,&quot;right&quot;:325,&quot;bottom&quot;:75,&quot;left&quot;:-475,&quot;width&quot;:800,&quot;height&quot;:100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-525,&quot;right&quot;:-375,&quot;bottom&quot;:75,&quot;left&quot;:-475,&quot;width&quot;:100,&quot;height&quot;:600}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-525,&quot;right&quot;:325,&quot;bottom&quot;:75,&quot;left&quot;:225,&quot;width&quot;:100,&quot;height&quot;:600}
+
+Scrolled to 100, 776
+JSON.stringify(internals.layoutViewportRect()) is {&quot;top&quot;:0,&quot;right&quot;:800,&quot;bottom&quot;:600,&quot;left&quot;:0,&quot;width&quot;:800,&quot;height&quot;:600}
+JSON.stringify(internals.visualViewportRect()) is {&quot;top&quot;:733,&quot;right&quot;:500,&quot;bottom&quot;:1033,&quot;left&quot;:100,&quot;width&quot;:400,&quot;height&quot;:300}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-776,&quot;right&quot;:700,&quot;bottom&quot;:-676,&quot;left&quot;:-100,&quot;width&quot;:800,&quot;height&quot;:100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-276,&quot;right&quot;:700,&quot;bottom&quot;:-176,&quot;left&quot;:-100,&quot;width&quot;:800,&quot;height&quot;:100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-776,&quot;right&quot;:0,&quot;bottom&quot;:-176,&quot;left&quot;:-100,&quot;width&quot;:100,&quot;height&quot;:600}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-776,&quot;right&quot;:700,&quot;bottom&quot;:-176,&quot;left&quot;:600,&quot;width&quot;:100,&quot;height&quot;:600}
+
+Scrolled to 50, 300
+JSON.stringify(internals.layoutViewportRect()) is {&quot;top&quot;:0,&quot;right&quot;:800,&quot;bottom&quot;:600,&quot;left&quot;:0,&quot;width&quot;:800,&quot;height&quot;:600}
+JSON.stringify(internals.visualViewportRect()) is {&quot;top&quot;:257,&quot;right&quot;:450,&quot;bottom&quot;:557,&quot;left&quot;:50,&quot;width&quot;:400,&quot;height&quot;:300}
+client rect of top:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-300,&quot;right&quot;:750,&quot;bottom&quot;:-200,&quot;left&quot;:-50,&quot;width&quot;:800,&quot;height&quot;:100}
+client rect of bottom:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:200,&quot;right&quot;:750,&quot;bottom&quot;:300,&quot;left&quot;:-50,&quot;width&quot;:800,&quot;height&quot;:100}
+client rect of left:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-300,&quot;right&quot;:50,&quot;bottom&quot;:300,&quot;left&quot;:-50,&quot;width&quot;:100,&quot;height&quot;:600}
+client rect of right:
+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-300,&quot;right&quot;:750,&quot;bottom&quot;:300,&quot;left&quot;:650,&quot;width&quot;:100,&quot;height&quot;:600}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="branchessafari603branchLayoutTeststileddrawingscrollingfixedfourbarswithheaderandfooterexpectedtxt"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/LayoutTests/tiled-drawing/scrolling/fixed/four-bars-with-header-and-footer-expected.txt (210341 => 210342)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/tiled-drawing/scrolling/fixed/four-bars-with-header-and-footer-expected.txt        2017-01-05 17:08:58 UTC (rev 210341)
+++ branches/safari-603-branch/LayoutTests/tiled-drawing/scrolling/fixed/four-bars-with-header-and-footer-expected.txt        2017-01-05 17:09:02 UTC (rev 210342)
</span><span class="lines">@@ -2,29 +2,29 @@
</span><span class="cx">   (scrollable area size 785 600)
</span><span class="cx">   (contents size 785 2421)
</span><span class="cx">   (requested scroll position 0 200)
</span><del>-  (layout viewport at (0,200) size 785x600)
</del><ins>+  (layout viewport at (0,100) size 785x600)
</ins><span class="cx">   (min layout viewport origin (0,0))
</span><del>-  (max layout viewport origin (0,1821))
</del><ins>+  (max layout viewport origin (0,1621))
</ins><span class="cx">   (children 4
</span><span class="cx">     (Fixed node
</span><span class="cx">       (anchor edges: AnchorEdgeLeft AnchorEdgeTop)
</span><del>-      (viewport rect at last layout: 0.00 200.00 785.00 600.00)
-      (layer position at last layout 0.00 200.00)
</del><ins>+      (viewport rect at last layout: 0.00 100.00 785.00 600.00)
+      (layer position at last layout 0.00 100.00)
</ins><span class="cx">     )
</span><span class="cx">     (Fixed node
</span><span class="cx">       (anchor edges: AnchorEdgeLeft AnchorEdgeTop)
</span><del>-      (viewport rect at last layout: 0.00 200.00 785.00 600.00)
-      (layer position at last layout 6.00 396.00)
</del><ins>+      (viewport rect at last layout: 0.00 100.00 785.00 600.00)
+      (layer position at last layout 6.00 296.00)
</ins><span class="cx">     )
</span><span class="cx">     (Fixed node
</span><span class="cx">       (anchor edges: AnchorEdgeRight AnchorEdgeTop)
</span><del>-      (viewport rect at last layout: 0.00 200.00 785.00 600.00)
-      (layer position at last layout 597.00 396.00)
</del><ins>+      (viewport rect at last layout: 0.00 100.00 785.00 600.00)
+      (layer position at last layout 597.00 296.00)
</ins><span class="cx">     )
</span><span class="cx">     (Fixed node
</span><span class="cx">       (anchor edges: AnchorEdgeLeft AnchorEdgeBottom)
</span><del>-      (viewport rect at last layout: 0.00 200.00 785.00 600.00)
-      (layer position at last layout 0.00 712.00)
</del><ins>+      (viewport rect at last layout: 0.00 100.00 785.00 600.00)
+      (layer position at last layout 0.00 612.00)
</ins><span class="cx">     )
</span><span class="cx">   )
</span><span class="cx"> )
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (210341 => 210342)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/ChangeLog        2017-01-05 17:08:58 UTC (rev 210341)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog        2017-01-05 17:09:02 UTC (rev 210342)
</span><span class="lines">@@ -1,5 +1,41 @@
</span><span class="cx"> 2017-01-05  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r210059. rdar://problem/29727145
+
+    2016-12-21  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+            Fixed bars are positioned incorrectly when there are header and footer banners
+            https://bugs.webkit.org/show_bug.cgi?id=166302
+            rdar://problem/29727145
+
+            Reviewed by Tim Horton.
+
+            The computation of the visual viewport was wrong in the presence of header and footer
+            banners. It needs to take into account the fact that &quot;visibleContentRect&quot; applies to the
+            scroll view contents, which includes header and footer (unscaled), and the potentially scaled
+            document, and we need to return a rectangle in unscaled document coordinates.
+
+            Make a static method in FrameView to do this computation, and call it from FrameView::visualViewportRect()
+            and ScrollingTreeFrameScrollingNode::layoutViewportForScrollPosition().
+
+            layoutViewportForScrollPosition() is only called on Mac, so remove the #ifdeffing related to scaling,
+            and pass in an unscaled scroll position.
+
+            Test: fast/visual-viewport/zoomed-fixed-header-and-footer.html
+
+            * page/FrameView.cpp:
+            (WebCore::FrameView::updateLayoutViewport):
+            (WebCore::FrameView::maxStableLayoutViewportOrigin):
+            (WebCore::FrameView::visibleDocumentRect):
+            (WebCore::FrameView::visualViewportRect):
+            * page/FrameView.h:
+            * page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
+            (WebCore::ScrollingTreeFrameScrollingNode::layoutViewportForScrollPosition):
+            * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+            (WebCore::ScrollingTreeFrameScrollingNodeMac::setScrollPositionWithoutContentEdgeConstraints):
+
+2017-01-05  Matthew Hanson  &lt;matthew_hanson@apple.com&gt;
+
</ins><span class="cx">         Merge r210035. rdar://problem/29704862
</span><span class="cx"> 
</span><span class="cx">     2016-12-20  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/page/FrameView.cpp (210341 => 210342)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/page/FrameView.cpp        2017-01-05 17:08:58 UTC (rev 210341)
+++ branches/safari-603-branch/Source/WebCore/page/FrameView.cpp        2017-01-05 17:09:02 UTC (rev 210342)
</span><span class="lines">@@ -1876,7 +1876,7 @@
</span><span class="cx"> 
</span><span class="cx">     LayoutRect layoutViewport = layoutViewportRect();
</span><span class="cx"> 
</span><del>-    LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;\nFrameView &quot; &lt;&lt; this &lt;&lt; &quot; updateLayoutViewport()&quot;);
</del><ins>+    LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;\nFrameView &quot; &lt;&lt; this &lt;&lt; &quot; updateLayoutViewport() totalContentSize &quot; &lt;&lt; totalContentsSize() &lt;&lt; &quot; unscaledDocumentRect &quot; &lt;&lt; (renderView() ? renderView()-&gt;unscaledDocumentRect() : IntRect()) &lt;&lt; &quot; header height &quot; &lt;&lt; headerHeight() &lt;&lt; &quot; footer height &quot; &lt;&lt; footerHeight());
</ins><span class="cx">     LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;layoutViewport: &quot; &lt;&lt; layoutViewport);
</span><span class="cx">     LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;visualViewport: &quot; &lt;&lt; visualViewportRect());
</span><span class="cx">     LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;scroll positions: min: &quot; &lt;&lt; unscaledMinimumScrollPosition() &lt;&lt; &quot; max: &quot;&lt;&lt; unscaledMaximumScrollPosition());
</span><span class="lines">@@ -1895,7 +1895,9 @@
</span><span class="cx"> 
</span><span class="cx"> LayoutPoint FrameView::maxStableLayoutViewportOrigin() const
</span><span class="cx"> {
</span><del>-    return unscaledMaximumScrollPosition();
</del><ins>+    LayoutPoint maxPosition = unscaledMaximumScrollPosition();
+    maxPosition = (maxPosition - LayoutSize(0, headerHeight() + footerHeight())).expandedTo({ });
+    return maxPosition;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntPoint FrameView::unscaledScrollOrigin() const
</span><span class="lines">@@ -1915,12 +1917,29 @@
</span><span class="cx">     return LayoutRect(m_layoutViewportOrigin, renderView() ? renderView()-&gt;size() : size());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// visibleContentRect is in the bounds of the scroll view content. That consists of an
+// optional header, the document, and an optional footer. Only the document is scaled,
+// so we have to compute the visible part of the document in unscaled document coordinates.
+// On iOS, pageScaleFactor is always 1 here, and we never have headers and footers.
+LayoutRect FrameView::visibleDocumentRect(const FloatRect&amp; visibleContentRect, float headerHeight, float footerHeight, const FloatSize&amp; totalContentsSize, float pageScaleFactor)
+{
+    FloatRect visibleDocumentRect = visibleContentRect;
+
+    float contentsHeight = totalContentsSize.height() - headerHeight - footerHeight;
+
+    float visibleScaledDocumentTop = std::max&lt;float&gt;(visibleContentRect.y() - headerHeight, 0);
+    float visibleScaledDocumentBottom = std::min&lt;float&gt;(visibleContentRect.maxY() - headerHeight, contentsHeight);
+
+    visibleDocumentRect.setY(visibleScaledDocumentTop);
+    visibleDocumentRect.setHeight(std::max&lt;float&gt;(visibleScaledDocumentBottom - visibleScaledDocumentTop, 0));
+    visibleDocumentRect.scale(1 / pageScaleFactor);
+    return LayoutRect(visibleDocumentRect);
+}
+
</ins><span class="cx"> LayoutRect FrameView::visualViewportRect() const
</span><span class="cx"> {
</span><del>-    // This isn't visibleContentRect(), because that uses a scaled scroll origin. Confused? Me too.
</del><span class="cx">     FloatRect visibleContentRect = this-&gt;visibleContentRect(LegacyIOSDocumentVisibleRect);
</span><del>-    visibleContentRect.scale(1 / frameScaleFactor()); // Note that frameScaleFactor() returns 1 for delegated scrolling (e.g. iOS WK2)
-    return LayoutRect(visibleContentRect);
</del><ins>+    return visibleDocumentRect(visibleContentRect, headerHeight(), footerHeight(), totalContentsSize(), frameScaleFactor());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> LayoutRect FrameView::viewportConstrainedVisibleContentRect() const
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorepageFrameViewh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/page/FrameView.h (210341 => 210342)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/page/FrameView.h        2017-01-05 17:08:58 UTC (rev 210341)
+++ branches/safari-603-branch/Source/WebCore/page/FrameView.h        2017-01-05 17:09:02 UTC (rev 210342)
</span><span class="lines">@@ -268,6 +268,8 @@
</span><span class="cx">     // These are in document coordinates, unaffected by zooming.
</span><span class="cx">     WEBCORE_EXPORT LayoutRect layoutViewportRect() const;
</span><span class="cx">     WEBCORE_EXPORT LayoutRect visualViewportRect() const;
</span><ins>+    
+    static LayoutRect visibleDocumentRect(const FloatRect&amp; visibleContentRect, float headerHeight, float footerHeight, const FloatSize&amp; totalContentsSize, float pageScaleFactor);
</ins><span class="cx"> 
</span><span class="cx">     // This is different than visibleContentRect() in that it ignores negative (or overly positive)
</span><span class="cx">     // offsets from rubber-banding, and it takes zooming into account. 
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorepagescrollingScrollingTreeFrameScrollingNodecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp (210341 => 210342)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp        2017-01-05 17:08:58 UTC (rev 210341)
+++ branches/safari-603-branch/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp        2017-01-05 17:09:02 UTC (rev 210342)
</span><span class="lines">@@ -102,21 +102,14 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(scrollingTree().visualViewportEnabled());
</span><span class="cx"> 
</span><del>-    FloatSize visibleContentSize = scrollableAreaSize();
-#if PLATFORM(MAC)
-    // On Mac, FrameView.visibleContentRect(), which was used to set scrollableAreaSize(), returns a rect with scale applied (so it's not really a &quot;content rect&quot;),
-    // so we have to convert back to unscaled coordinates here.
-    visibleContentSize.scale(1 / scale);
-#else
-    UNUSED_PARAM(scale);
-#endif
-    FloatRect visualViewport(visibleContentOrigin, visibleContentSize);
</del><ins>+    FloatRect visibleContentRect(visibleContentOrigin, scrollableAreaSize());
+    LayoutRect visualViewport(FrameView::visibleDocumentRect(visibleContentRect, headerHeight(), footerHeight(), totalContentsSize(), scale));
</ins><span class="cx">     LayoutRect layoutViewport(m_layoutViewport);
</span><span class="cx"> 
</span><span class="cx">     LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;\nScrolling thread: &quot; &lt;&lt; &quot;(visibleContentOrigin &quot; &lt;&lt; visibleContentOrigin &lt;&lt; &quot;)&quot;);
</span><del>-    LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;layoutViewport: &quot; &lt;&lt; layoutViewport);
-    LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;visualViewport: &quot; &lt;&lt; visualViewport);
-    LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;scroll positions: min: &quot; &lt;&lt; minLayoutViewportOrigin() &lt;&lt; &quot; max: &quot;&lt;&lt; maxLayoutViewportOrigin());
</del><ins>+    LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;  layoutViewport: &quot; &lt;&lt; layoutViewport);
+    LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;  visualViewport: &quot; &lt;&lt; visualViewport);
+    LOG_WITH_STREAM(Scrolling, stream &lt;&lt; &quot;  scroll positions: min: &quot; &lt;&lt; minLayoutViewportOrigin() &lt;&lt; &quot; max: &quot;&lt;&lt; maxLayoutViewportOrigin());
</ins><span class="cx"> 
</span><span class="cx">     LayoutPoint newLocation = FrameView::computeLayoutViewportOrigin(LayoutRect(visualViewport), LayoutPoint(minLayoutViewportOrigin()), LayoutPoint(maxLayoutViewportOrigin()), layoutViewport);
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorepagescrollingmacScrollingTreeFrameScrollingNodeMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm (210341 => 210342)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm        2017-01-05 17:08:58 UTC (rev 210341)
+++ branches/safari-603-branch/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm        2017-01-05 17:09:02 UTC (rev 210342)
</span><span class="lines">@@ -391,8 +391,6 @@
</span><span class="cx">     std::optional&lt;FloatPoint&gt; layoutViewportOrigin;
</span><span class="cx">     if (scrollingTree().visualViewportEnabled()) {
</span><span class="cx">         FloatPoint visibleContentOrigin = scrollPosition;
</span><del>-        float counterScale = 1 / frameScaleFactor();
-        visibleContentOrigin.scale(counterScale, counterScale);
</del><span class="cx">         FloatRect newLayoutViewport = layoutViewportForScrollPosition(visibleContentOrigin, frameScaleFactor());
</span><span class="cx">         setLayoutViewport(newLayoutViewport);
</span><span class="cx">         layoutViewportOrigin = newLayoutViewport.location();
</span></span></pre>
</div>
</div>

</body>
</html>