<!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>[209297] 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/209297">209297</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2016-12-03 08:36:14 -0800 (Sat, 03 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>localToAbsolute() does incorrect conversion for elements inside position:fixed with zooming
https://bugs.webkit.org/show_bug.cgi?id=165244

Reviewed by Zalan Bujtas.

Source/WebCore:

RenderView::mapLocalToContainer() and RenderView::mapAbsoluteToLocalPoint() handle the coordinate
mapping through the RenderView's transform (when zoomed), and apply the scroll offset for position:fixed
elements.

They did this in the wrong order; &quot;local to absolute&quot; applied the zoom scale, and then adjusted for the scroll position,
and &quot;absolute to local&quot; applied the scroll position and then the transform.

However that scroll position adjustment should be in unzoomed coordinates, since it's accounting for the
layout adjustment that position:fixed receives (which actually occurs via the localToAbsolute() call
in RenderLayer's accumulateOffsetTowardsAncestor()). &quot;local to absolute&quot; should therefore apply the scroll
adjustment first before the transform, and &quot;absolute to local&quot; the reverse.

In both visual viewport mode, and legacy drifty fixed mode FrameView::scrollPositionForFixedPosition()
returns a scroll offset that is unaffected by zoom, which is correct and confirms this change.

[Confusingly, ScrollView scroll positions _are_ affected by zoom, as the entire document gets bigger.]

RenderGeometryMap::mapToContainer(), which is an optimization on top of RenderView::mapLocalToContainer(),
gets a similar fix.

Test: fast/zooming/client-rect-in-fixed-zoomed.html

* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer):
* rendering/RenderView.cpp:
(WebCore::RenderView::mapLocalToContainer):
(WebCore::RenderView::mapAbsoluteToLocalPoint):

LayoutTests:

Test getBoundingClientRect() (which internally calls localToAbsolute())
for an element inside position:fixed after zooming.

* fast/visual-viewport/zoomed-fixed-expected.txt: Rebaseline
* fast/zooming/client-rect-in-fixed-zoomed-expected.txt: Added.
* fast/zooming/client-rect-in-fixed-zoomed.html: Added.
* platform/ios-simulator/TestExpectations: Skip new test on iOS; test requires window.scrollTo to be synchronous.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastvisualviewportzoomedfixedexpectedtxt">trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorTestExpectations">trunk/LayoutTests/platform/ios-simulator/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderGeometryMapcpp">trunk/Source/WebCore/rendering/RenderGeometryMap.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderViewcpp">trunk/Source/WebCore/rendering/RenderView.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastzoomingclientrectinfixedzoomedexpectedtxt">trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastzoomingclientrectinfixedzoomedhtml">trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (209296 => 209297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-12-03 07:28:25 UTC (rev 209296)
+++ trunk/LayoutTests/ChangeLog        2016-12-03 16:36:14 UTC (rev 209297)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-11-30  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        localToAbsolute() does incorrect conversion for elements inside position:fixed with zooming
+        https://bugs.webkit.org/show_bug.cgi?id=165244
+
+        Reviewed by Zalan Bujtas.
+        
+        Test getBoundingClientRect() (which internally calls localToAbsolute())
+        for an element inside position:fixed after zooming.
+
+        * fast/visual-viewport/zoomed-fixed-expected.txt: Rebaseline
+        * fast/zooming/client-rect-in-fixed-zoomed-expected.txt: Added.
+        * fast/zooming/client-rect-in-fixed-zoomed.html: Added.
+        * platform/ios-simulator/TestExpectations: Skip new test on iOS; test requires window.scrollTo to be synchronous.
+
+
</ins><span class="cx"> 2016-12-02  Antoine Quint  &lt;graouts@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Modern Media Controls] Update the media controls size as the media element is resized
</span></span></pre></div>
<a id="trunkLayoutTestsfastvisualviewportzoomedfixedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-expected.txt (209296 => 209297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-expected.txt        2016-12-03 07:28:25 UTC (rev 209296)
+++ trunk/LayoutTests/fast/visual-viewport/zoomed-fixed-expected.txt        2016-12-03 16:36:14 UTC (rev 209297)
</span><span class="lines">@@ -18,37 +18,37 @@
</span><span class="cx"> JSON.stringify(internals.layoutViewportRect()) is {&quot;top&quot;:232.5,&quot;right&quot;:867.5,&quot;bottom&quot;:817.5,&quot;left&quot;:82.5,&quot;width&quot;:785,&quot;height&quot;:585}
</span><span class="cx"> JSON.stringify(internals.visualViewportRect()) is {&quot;top&quot;:525,&quot;right&quot;:867.5,&quot;bottom&quot;:817.5,&quot;left&quot;:475,&quot;width&quot;:392.5,&quot;height&quot;:292.5}
</span><span class="cx"> client rect of top:
</span><del>-JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-408.75,&quot;right&quot;:351.25,&quot;bottom&quot;:-308.75,&quot;left&quot;:-433.75,&quot;width&quot;:785,&quot;height&quot;:100}
</del><ins>+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-292.5,&quot;right&quot;:392.5,&quot;bottom&quot;:-192.5,&quot;left&quot;:-392.5,&quot;width&quot;:785,&quot;height&quot;:100}
</ins><span class="cx"> client rect of bottom:
</span><del>-JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:76.25,&quot;right&quot;:351.25,&quot;bottom&quot;:176.25,&quot;left&quot;:-433.75,&quot;width&quot;:785,&quot;height&quot;:100}
</del><ins>+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:192.5,&quot;right&quot;:392.5,&quot;bottom&quot;:292.5,&quot;left&quot;:-392.5,&quot;width&quot;:785,&quot;height&quot;:100}
</ins><span class="cx"> client rect of left:
</span><del>-JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-408.75,&quot;right&quot;:-333.75,&quot;bottom&quot;:176.25,&quot;left&quot;:-433.75,&quot;width&quot;:100,&quot;height&quot;:585}
</del><ins>+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-292.5,&quot;right&quot;:-292.5,&quot;bottom&quot;:292.5,&quot;left&quot;:-392.5,&quot;width&quot;:100,&quot;height&quot;:585}
</ins><span class="cx"> client rect of right:
</span><del>-JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-408.75,&quot;right&quot;:351.25,&quot;bottom&quot;:176.25,&quot;left&quot;:251.25,&quot;width&quot;:100,&quot;height&quot;:585}
</del><ins>+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-292.5,&quot;right&quot;:392.5,&quot;bottom&quot;:292.5,&quot;left&quot;:292.5,&quot;width&quot;:100,&quot;height&quot;:585}
</ins><span class="cx"> 
</span><span class="cx"> Scrolled to 100, 776
</span><span class="cx"> JSON.stringify(internals.layoutViewportRect()) is {&quot;top&quot;:483.5,&quot;right&quot;:867.5,&quot;bottom&quot;:1068.5,&quot;left&quot;:82.5,&quot;width&quot;:785,&quot;height&quot;:585}
</span><span class="cx"> JSON.stringify(internals.visualViewportRect()) is {&quot;top&quot;:776,&quot;right&quot;:492.5,&quot;bottom&quot;:1068.5,&quot;left&quot;:100,&quot;width&quot;:392.5,&quot;height&quot;:292.5}
</span><span class="cx"> client rect of top:
</span><del>-JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-534.25,&quot;right&quot;:726.25,&quot;bottom&quot;:-434.25,&quot;left&quot;:-58.75,&quot;width&quot;:785,&quot;height&quot;:100}
</del><ins>+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-292.5,&quot;right&quot;:767.5,&quot;bottom&quot;:-192.5,&quot;left&quot;:-17.5,&quot;width&quot;:785,&quot;height&quot;:100}
</ins><span class="cx"> client rect of bottom:
</span><del>-JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-49.25,&quot;right&quot;:726.25,&quot;bottom&quot;:50.75,&quot;left&quot;:-58.75,&quot;width&quot;:785,&quot;height&quot;:100}
</del><ins>+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:192.5,&quot;right&quot;:767.5,&quot;bottom&quot;:292.5,&quot;left&quot;:-17.5,&quot;width&quot;:785,&quot;height&quot;:100}
</ins><span class="cx"> client rect of left:
</span><del>-JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-534.25,&quot;right&quot;:41.25,&quot;bottom&quot;:50.75,&quot;left&quot;:-58.75,&quot;width&quot;:100,&quot;height&quot;:585}
</del><ins>+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-292.5,&quot;right&quot;:82.5,&quot;bottom&quot;:292.5,&quot;left&quot;:-17.5,&quot;width&quot;:100,&quot;height&quot;:585}
</ins><span class="cx"> client rect of right:
</span><del>-JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-534.25,&quot;right&quot;:726.25,&quot;bottom&quot;:50.75,&quot;left&quot;:626.25,&quot;width&quot;:100,&quot;height&quot;:585}
</del><ins>+JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-292.5,&quot;right&quot;:767.5,&quot;bottom&quot;:292.5,&quot;left&quot;:667.5,&quot;width&quot;:100,&quot;height&quot;:585}
</ins><span class="cx"> 
</span><span class="cx"> Scrolled to 50, 300
</span><span class="cx"> JSON.stringify(internals.layoutViewportRect()) is {&quot;top&quot;:300,&quot;right&quot;:835,&quot;bottom&quot;:885,&quot;left&quot;:50,&quot;width&quot;:785,&quot;height&quot;:585}
</span><span class="cx"> JSON.stringify(internals.visualViewportRect()) is {&quot;top&quot;:300,&quot;right&quot;:442.5,&quot;bottom&quot;:592.5,&quot;left&quot;:50,&quot;width&quot;:392.5,&quot;height&quot;:292.5}
</span><span class="cx"> client rect of top:
</span><del>-JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-150,&quot;right&quot;:760,&quot;bottom&quot;:-50,&quot;left&quot;:-25,&quot;width&quot;:785,&quot;height&quot;:100}
</del><ins>+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}
</ins><span class="cx"> client rect of bottom:
</span><del>-JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:335,&quot;right&quot;:760,&quot;bottom&quot;:435,&quot;left&quot;:-25,&quot;width&quot;:785,&quot;height&quot;:100}
</del><ins>+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}
</ins><span class="cx"> client rect of left:
</span><del>-JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-150,&quot;right&quot;:75,&quot;bottom&quot;:435,&quot;left&quot;:-25,&quot;width&quot;:100,&quot;height&quot;:585}
</del><ins>+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}
</ins><span class="cx"> client rect of right:
</span><del>-JSON.stringify(fixedElement.getBoundingClientRect()) is {&quot;top&quot;:-150,&quot;right&quot;:760,&quot;bottom&quot;:435,&quot;left&quot;:660,&quot;width&quot;:100,&quot;height&quot;:585}
</del><ins>+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}
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsfastzoomingclientrectinfixedzoomedexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed-expected.txt (0 => 209297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed-expected.txt        2016-12-03 16:36:14 UTC (rev 209297)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Tests localToAbsolute coordinate conversion for an element inside position:fixed after zoom.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS internals.pageScaleFactor() is 2
+PASS JSON.stringify(clientRect) is JSON.stringify({top: 9.515625, right: 42, bottom: 19.515625, left: 22, width: 20, height: 10})
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastzoomingclientrectinfixedzoomedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed.html (0 => 209297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed.html                                (rev 0)
+++ trunk/LayoutTests/fast/zooming/client-rect-in-fixed-zoomed.html        2016-12-03 16:36:14 UTC (rev 209297)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        body {
+            height: 2000px;
+            width: 2000px;
+        }
+        
+        .container {
+            position: fixed;
+            top: 20px;
+            left: 10px;
+            width: 200px;
+            height: 100px;
+            background-color: silver;
+        }
+        #box {
+            width: 20px;
+            height: 10px;
+            margin: 12px;
+            background-color: blue;
+        }
+        
+    &lt;/style&gt;
+    &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        description(&quot;Tests localToAbsolute coordinate conversion for an element inside position:fixed after zoom.&quot;);
+
+        window.jsTestIsAsync = true;
+
+        var clientRect;
+        function doAfterZooming()
+        {
+            window.scrollTo(0, 140);
+
+            shouldBe('internals.pageScaleFactor()', '2');
+            
+            var box = document.getElementById('box');
+            clientRect = box.getBoundingClientRect();
+            
+            shouldBe('JSON.stringify(clientRect)', 'JSON.stringify({top: 9.515625, right: 42, bottom: 19.515625, left: 22, width: 20, height: 10})');
+            
+            finishJSTest();
+        }
+        
+        function getUIScript()
+        {
+            return `(function() {
+                uiController.zoomToScale(2, function() {
+                    uiController.uiScriptComplete(uiController.zoomScale);
+                });
+            })();`;
+        }
+
+        function doTest()
+        {
+            if (window.testRunner) {
+                testRunner.runUIScript(getUIScript(), function(zoomScale) {
+                    doAfterZooming();
+                })
+            } else
+                window.setTimeout(doAfterZooming, 1000);
+        }
+        
+        window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div class=&quot;container&quot;&gt;
+        &lt;div id=&quot;box&quot;&gt;&lt;/div&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="trunkLayoutTestsplatformiossimulatorTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (209296 => 209297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/TestExpectations        2016-12-03 07:28:25 UTC (rev 209296)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations        2016-12-03 16:36:14 UTC (rev 209297)
</span><span class="lines">@@ -2764,3 +2764,6 @@
</span><span class="cx"> webkit.org/b/164594 http/tests/cache/disk-cache/disk-cache-request-headers.html [ Pass Timeout ]
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/163046 js/regress-141098.html [ Pass Failure ]
</span><ins>+
+# Test relies on window.scrollTo
+fast/zooming/client-rect-in-fixed-zoomed.html [ Skip ]
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (209296 => 209297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-12-03 07:28:25 UTC (rev 209296)
+++ trunk/Source/WebCore/ChangeLog        2016-12-03 16:36:14 UTC (rev 209297)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2016-11-30  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        localToAbsolute() does incorrect conversion for elements inside position:fixed with zooming
+        https://bugs.webkit.org/show_bug.cgi?id=165244
+
+        Reviewed by Zalan Bujtas.
+        
+        RenderView::mapLocalToContainer() and RenderView::mapAbsoluteToLocalPoint() handle the coordinate
+        mapping through the RenderView's transform (when zoomed), and apply the scroll offset for position:fixed
+        elements.
+        
+        They did this in the wrong order; &quot;local to absolute&quot; applied the zoom scale, and then adjusted for the scroll position,
+        and &quot;absolute to local&quot; applied the scroll position and then the transform.
+        
+        However that scroll position adjustment should be in unzoomed coordinates, since it's accounting for the
+        layout adjustment that position:fixed receives (which actually occurs via the localToAbsolute() call
+        in RenderLayer's accumulateOffsetTowardsAncestor()). &quot;local to absolute&quot; should therefore apply the scroll
+        adjustment first before the transform, and &quot;absolute to local&quot; the reverse.
+        
+        In both visual viewport mode, and legacy drifty fixed mode FrameView::scrollPositionForFixedPosition()
+        returns a scroll offset that is unaffected by zoom, which is correct and confirms this change.
+        
+        [Confusingly, ScrollView scroll positions _are_ affected by zoom, as the entire document gets bigger.]
+        
+        RenderGeometryMap::mapToContainer(), which is an optimization on top of RenderView::mapLocalToContainer(),
+        gets a similar fix.
+        
+        Test: fast/zooming/client-rect-in-fixed-zoomed.html
+
+        * rendering/RenderGeometryMap.cpp:
+        (WebCore::RenderGeometryMap::mapToContainer):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::mapLocalToContainer):
+        (WebCore::RenderView::mapAbsoluteToLocalPoint):
+
</ins><span class="cx"> 2016-12-02  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Put names on layers in release builds
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderGeometryMapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderGeometryMap.cpp (209296 => 209297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderGeometryMap.cpp        2016-12-03 07:28:25 UTC (rev 209296)
+++ trunk/Source/WebCore/rendering/RenderGeometryMap.cpp        2016-12-03 16:36:14 UTC (rev 209297)
</span><span class="lines">@@ -81,13 +81,13 @@
</span><span class="cx">             inFixed = true;
</span><span class="cx"> 
</span><span class="cx">         if (!i) {
</span><ins>+            // The root gets special treatment for fixed position
+            if (inFixed)
+                transformState.move(currentStep.m_offset.width(), currentStep.m_offset.height());
+
</ins><span class="cx">             // A null container indicates mapping through the RenderView, so including its transform (the page scale).
</span><span class="cx">             if (!container &amp;&amp; currentStep.m_transform)
</span><span class="cx">                 transformState.applyTransform(*currentStep.m_transform.get());
</span><del>-
-            // The root gets special treatment for fixed position
-            if (inFixed)
-                transformState.move(currentStep.m_offset.width(), currentStep.m_offset.height());
</del><span class="cx">         } else {
</span><span class="cx">             TransformState::TransformAccumulation accumulate = currentStep.m_accumulatingTransform ? TransformState::AccumulateTransform : TransformState::FlattenTransform;
</span><span class="cx">             if (currentStep.m_transform)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderView.cpp (209296 => 209297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderView.cpp        2016-12-03 07:28:25 UTC (rev 209296)
+++ trunk/Source/WebCore/rendering/RenderView.cpp        2016-12-03 16:36:14 UTC (rev 209297)
</span><span class="lines">@@ -437,14 +437,14 @@
</span><span class="cx">     ASSERT_ARG(repaintContainer, !repaintContainer || repaintContainer == this);
</span><span class="cx">     ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == (mode &amp; IsFixed));
</span><span class="cx"> 
</span><ins>+    if (mode &amp; IsFixed)
+        transformState.move(toLayoutSize(frameView().scrollPositionRespectingCustomFixedPosition()));
+
</ins><span class="cx">     if (!repaintContainer &amp;&amp; mode &amp; UseTransforms &amp;&amp; shouldUseTransformFromContainer(nullptr)) {
</span><span class="cx">         TransformationMatrix t;
</span><span class="cx">         getTransformFromContainer(nullptr, LayoutSize(), t);
</span><span class="cx">         transformState.applyTransform(t);
</span><span class="cx">     }
</span><del>-    
-    if (mode &amp; IsFixed)
-        transformState.move(toLayoutSize(frameView().scrollPositionRespectingCustomFixedPosition()));
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> const RenderObject* RenderView::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&amp; geometryMap) const
</span><span class="lines">@@ -467,14 +467,14 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderView::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState&amp; transformState) const
</span><span class="cx"> {
</span><del>-    if (mode &amp; IsFixed)
-        transformState.move(toLayoutSize(frameView().scrollPositionRespectingCustomFixedPosition()));
-
</del><span class="cx">     if (mode &amp; UseTransforms &amp;&amp; shouldUseTransformFromContainer(nullptr)) {
</span><span class="cx">         TransformationMatrix t;
</span><span class="cx">         getTransformFromContainer(nullptr, LayoutSize(), t);
</span><span class="cx">         transformState.applyTransform(t);
</span><span class="cx">     }
</span><ins>+
+    if (mode &amp; IsFixed)
+        transformState.move(toLayoutSize(frameView().scrollPositionRespectingCustomFixedPosition()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool RenderView::requiresColumns(int) const
</span></span></pre>
</div>
</div>

</body>
</html>