<!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>[208409] 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/208409">208409</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2016-11-04 17:41:50 -0700 (Fri, 04 Nov 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Layout viewport wrong with RTL documents
https://bugs.webkit.org/show_bug.cgi?id=164434
Reviewed by Tim Horton.
Source/WebCore:
The layoutViewportRect was computed incorrectly in RTL documents, because
FrameView::unscaledMaximumScrollPosition() was wrong; it erroneously mapped
what it thought was a scrollOffset to a scrollPosition.
Unscaled scroll positions are in the same coordinate space as unscaledDocumentRect,
so we should not call scrollPositionFromOffset() in FrameView::unscaledMaximumScrollPosition().
Changed FrameView::unscaledMinimumScrollPosition() to also just grab the location of
unscaledDocumentRect, for symmetry.
Finally fixed the tiled scrolling indicator's viewport rect for zoomed RTL documents
by using the unscaled scroll origin.
Tests: fast/visual-viewport/rtl-nonzoomed-rects.html
fast/visual-viewport/rtl-zoomed-rects.html
* page/FrameView.cpp:
(WebCore::FrameView::setLayoutViewportOrigin):
(WebCore::FrameView::unscaledScrollOrigin):
(WebCore::FrameView::unscaledMinimumScrollPosition):
(WebCore::FrameView::unscaledMaximumScrollPosition):
* page/FrameView.h:
LayoutTests:
* fast/visual-viewport/rtl-nonzoomed-rects-expected.txt: Added.
* fast/visual-viewport/rtl-nonzoomed-rects.html: Added.
* fast/visual-viewport/rtl-zoomed-rects-expected.txt: Added.
* fast/visual-viewport/rtl-zoomed-rects.html: Added.
* platform/ios-simulator/fast/visual-viewport/rtl-nonzoomed-rects-expected.txt: Added.
* platform/ios-simulator/fast/visual-viewport/rtl-zoomed-rects-expected.txt: Added.
* platform/mac-wk1/fast/visual-viewport/rtl-zoomed-rects-expected.txt: Added. WK1 and RTL are weird.</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="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewh">trunk/Source/WebCore/page/FrameView.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastvisualviewportrtlnonzoomedrectsexpectedtxt">trunk/LayoutTests/fast/visual-viewport/rtl-nonzoomed-rects-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastvisualviewportrtlnonzoomedrectshtml">trunk/LayoutTests/fast/visual-viewport/rtl-nonzoomed-rects.html</a></li>
<li><a href="#trunkLayoutTestsfastvisualviewportrtlzoomedrectsexpectedtxt">trunk/LayoutTests/fast/visual-viewport/rtl-zoomed-rects-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastvisualviewportrtlzoomedrectshtml">trunk/LayoutTests/fast/visual-viewport/rtl-zoomed-rects.html</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorfastvisualviewportrtlnonzoomedrectsexpectedtxt">trunk/LayoutTests/platform/ios-simulator/fast/visual-viewport/rtl-nonzoomed-rects-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorfastvisualviewportrtlzoomedrectsexpectedtxt">trunk/LayoutTests/platform/ios-simulator/fast/visual-viewport/rtl-zoomed-rects-expected.txt</a></li>
<li>trunk/LayoutTests/platform/mac-wk1/fast/visual-viewport/</li>
<li><a href="#trunkLayoutTestsplatformmacwk1fastvisualviewportrtlzoomedrectsexpectedtxt">trunk/LayoutTests/platform/mac-wk1/fast/visual-viewport/rtl-zoomed-rects-expected.txt</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208408 => 208409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-05 00:03:32 UTC (rev 208408)
+++ trunk/LayoutTests/ChangeLog        2016-11-05 00:41:50 UTC (rev 208409)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-11-04 Simon Fraser <simon.fraser@apple.com>
+
+ Layout viewport wrong with RTL documents
+ https://bugs.webkit.org/show_bug.cgi?id=164434
+
+ Reviewed by Tim Horton.
+
+ * fast/visual-viewport/rtl-nonzoomed-rects-expected.txt: Added.
+ * fast/visual-viewport/rtl-nonzoomed-rects.html: Added.
+ * fast/visual-viewport/rtl-zoomed-rects-expected.txt: Added.
+ * fast/visual-viewport/rtl-zoomed-rects.html: Added.
+ * platform/ios-simulator/fast/visual-viewport/rtl-nonzoomed-rects-expected.txt: Added.
+ * platform/ios-simulator/fast/visual-viewport/rtl-zoomed-rects-expected.txt: Added.
+ * platform/mac-wk1/fast/visual-viewport/rtl-zoomed-rects-expected.txt: Added. WK1 and RTL are weird.
+
</ins><span class="cx"> 2016-11-04 Wenson Hsieh <wenson_hsieh@apple.com>
</span><span class="cx">
</span><span class="cx"> Safari does not emit composition end if blurred for dead key / Japanese IME
</span></span></pre></div>
<a id="trunkLayoutTestsfastvisualviewportrtlnonzoomedrectsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/visual-viewport/rtl-nonzoomed-rects-expected.txt (0 => 208409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/visual-viewport/rtl-nonzoomed-rects-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/rtl-nonzoomed-rects-expected.txt        2016-11-05 00:41:50 UTC (rev 208409)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+This test scrolls the page and checks that the layout and visual viewports respond as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+JSON.stringify(internals.layoutViewportRect()) is {"top":0,"right":785,"bottom":585,"left":0,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":0,"right":785,"bottom":585,"left":0,"width":785,"height":585}
+
+Scrolled to -475, 525
+JSON.stringify(internals.layoutViewportRect()) is {"top":525,"right":310,"bottom":1110,"left":-475,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":525,"right":310,"bottom":1110,"left":-475,"width":785,"height":585}
+
+Scrolled to -100, 776
+JSON.stringify(internals.layoutViewportRect()) is {"top":776,"right":685,"bottom":1361,"left":-100,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":776,"right":685,"bottom":1361,"left":-100,"width":785,"height":585}
+
+Scrolled to -50, 300
+JSON.stringify(internals.layoutViewportRect()) is {"top":300,"right":735,"bottom":885,"left":-50,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":300,"right":735,"bottom":885,"left":-50,"width":785,"height":585}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastvisualviewportrtlnonzoomedrectshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/visual-viewport/rtl-nonzoomed-rects.html (0 => 208409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/visual-viewport/rtl-nonzoomed-rects.html         (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/rtl-nonzoomed-rects.html        2016-11-05 00:41:50 UTC (rev 208409)
</span><span class="lines">@@ -0,0 +1,61 @@
</span><ins>+<!DOCTYPE html>
+
+<html dir="rtl">
+<head>
+ <script src="../../resources/js-test-pre.js"></script>
+ <style>
+ body {
+ height: 2000px;
+ width: 2000px;
+ }
+ </style>
+ <script>
+ description("This test scrolls the page and checks that the layout and visual viewports respond as expected.");
+
+ if (window.internals)
+ internals.settings.setVisualViewportEnabled(true);
+
+ window.jsTestIsAsync = true;
+
+ function doTest()
+ {
+ // Zooming may scroll the view away from the origin.
+ window.scrollTo(0, 0);
+
+ // Don't use shouldBeEqualToString() to avoid showing failures when correct output differs between platforms.
+ evalAndLogResult("JSON.stringify(internals.layoutViewportRect())");
+ evalAndLogResult("JSON.stringify(internals.visualViewportRect())");
+
+ debug('');
+ window.scrollTo(-475, 525);
+ debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
+
+ evalAndLogResult("JSON.stringify(internals.layoutViewportRect())");
+ evalAndLogResult("JSON.stringify(internals.visualViewportRect())");
+
+ debug('');
+ window.scrollTo(-100, 776);
+ debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
+
+ evalAndLogResult("JSON.stringify(internals.layoutViewportRect())");
+ evalAndLogResult("JSON.stringify(internals.visualViewportRect())");
+
+ debug('');
+ window.scrollTo(-50, 300);
+ debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
+
+ evalAndLogResult("JSON.stringify(internals.layoutViewportRect())");
+ evalAndLogResult("JSON.stringify(internals.visualViewportRect())");
+
+ window.scrollTo(0, 0);
+
+ finishJSTest();
+ }
+
+ window.addEventListener('load', doTest, false);
+ </script>
+</head>
+<body>
+ <script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastvisualviewportrtlzoomedrectsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/visual-viewport/rtl-zoomed-rects-expected.txt (0 => 208409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/visual-viewport/rtl-zoomed-rects-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/rtl-zoomed-rects-expected.txt        2016-11-05 00:41:50 UTC (rev 208409)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+This test zooms and scrolls the page and checks that the layout and visual viewports respond as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+JSON.stringify(internals.layoutViewportRect()) is {"top":0,"right":785,"bottom":585,"left":0,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":0,"right":392.5,"bottom":292.5,"left":0,"width":392.5,"height":292.5}
+
+Scrolled to -475, 525
+JSON.stringify(internals.layoutViewportRect()) is {"top":232.5,"right":310,"bottom":817.5,"left":-475,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":525,"right":-82.5,"bottom":817.5,"left":-475,"width":392.5,"height":292.5}
+
+Scrolled to -100, 776
+JSON.stringify(internals.layoutViewportRect()) is {"top":483.5,"right":310,"bottom":1068.5,"left":-475,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":776,"right":292.5,"bottom":1068.5,"left":-100,"width":392.5,"height":292.5}
+
+Scrolled to -50, 300
+JSON.stringify(internals.layoutViewportRect()) is {"top":300,"right":342.5,"bottom":885,"left":-442.5,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":300,"right":342.5,"bottom":592.5,"left":-50,"width":392.5,"height":292.5}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastvisualviewportrtlzoomedrectshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/visual-viewport/rtl-zoomed-rects.html (0 => 208409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/visual-viewport/rtl-zoomed-rects.html         (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/rtl-zoomed-rects.html        2016-11-05 00:41:50 UTC (rev 208409)
</span><span class="lines">@@ -0,0 +1,78 @@
</span><ins>+<!DOCTYPE html>
+
+<html dir="rtl">
+<head>
+ <style>
+ body {
+ height: 2000px;
+ width: 2000px;
+ }
+ </style>
+ <script src="../../resources/js-test-pre.js"></script>
+ <script>
+ description("This test zooms and scrolls the page and checks that the layout and visual viewports respond as expected.");
+
+ if (window.internals)
+ internals.settings.setVisualViewportEnabled(true);
+
+ window.jsTestIsAsync = true;
+
+ function doAfterZooming()
+ {
+ window.scrollTo(0, 0);
+
+ evalAndLogResult("JSON.stringify(internals.layoutViewportRect())");
+ evalAndLogResult("JSON.stringify(internals.visualViewportRect())");
+
+ debug('');
+ window.scrollTo(-475, 525);
+ debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
+
+ evalAndLogResult("JSON.stringify(internals.layoutViewportRect())");
+ evalAndLogResult("JSON.stringify(internals.visualViewportRect())");
+
+ debug('');
+ window.scrollTo(-100, 776);
+ debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
+
+ evalAndLogResult("JSON.stringify(internals.layoutViewportRect())");
+ evalAndLogResult("JSON.stringify(internals.visualViewportRect())");
+
+ debug('');
+ window.scrollTo(-50, 300);
+ debug('Scrolled to ' + window.scrollX + ', ' + window.scrollY);
+
+ evalAndLogResult("JSON.stringify(internals.layoutViewportRect())");
+ evalAndLogResult("JSON.stringify(internals.visualViewportRect())");
+
+ 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);
+ </script>
+</head>
+<body>
+ <script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorfastvisualviewportrtlnonzoomedrectsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-simulator/fast/visual-viewport/rtl-nonzoomed-rects-expected.txt (0 => 208409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/fast/visual-viewport/rtl-nonzoomed-rects-expected.txt         (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/fast/visual-viewport/rtl-nonzoomed-rects-expected.txt        2016-11-05 00:41:50 UTC (rev 208409)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+This test scrolls the page and checks that the layout and visual viewports respond as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+JSON.stringify(internals.layoutViewportRect()) is {"top":0,"right":800,"bottom":600,"left":0,"width":800,"height":600}
+JSON.stringify(internals.visualViewportRect()) is {"top":0,"right":800,"bottom":600,"left":0,"width":800,"height":600}
+
+Scrolled to -475, 525
+JSON.stringify(internals.layoutViewportRect()) is {"top":525,"right":325,"bottom":1125,"left":-475,"width":800,"height":600}
+JSON.stringify(internals.visualViewportRect()) is {"top":525,"right":325,"bottom":1125,"left":-475,"width":800,"height":600}
+
+Scrolled to -100, 776
+JSON.stringify(internals.layoutViewportRect()) is {"top":776,"right":700,"bottom":1376,"left":-100,"width":800,"height":600}
+JSON.stringify(internals.visualViewportRect()) is {"top":776,"right":700,"bottom":1376,"left":-100,"width":800,"height":600}
+
+Scrolled to -50, 300
+JSON.stringify(internals.layoutViewportRect()) is {"top":300,"right":750,"bottom":900,"left":-50,"width":800,"height":600}
+JSON.stringify(internals.visualViewportRect()) is {"top":300,"right":750,"bottom":900,"left":-50,"width":800,"height":600}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorfastvisualviewportrtlzoomedrectsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-simulator/fast/visual-viewport/rtl-zoomed-rects-expected.txt (0 => 208409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/fast/visual-viewport/rtl-zoomed-rects-expected.txt         (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/fast/visual-viewport/rtl-zoomed-rects-expected.txt        2016-11-05 00:41:50 UTC (rev 208409)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+This test zooms and scrolls the page and checks that the layout and visual viewports respond as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+JSON.stringify(internals.layoutViewportRect()) is {"top":0,"right":800,"bottom":600,"left":0,"width":800,"height":600}
+JSON.stringify(internals.visualViewportRect()) is {"top":0,"right":400,"bottom":300,"left":0,"width":400,"height":300}
+
+Scrolled to -475, 525
+JSON.stringify(internals.layoutViewportRect()) is {"top":225,"right":325,"bottom":825,"left":-475,"width":800,"height":600}
+JSON.stringify(internals.visualViewportRect()) is {"top":525,"right":-75,"bottom":825,"left":-475,"width":400,"height":300}
+
+Scrolled to -100, 776
+JSON.stringify(internals.layoutViewportRect()) is {"top":476,"right":325,"bottom":1076,"left":-475,"width":800,"height":600}
+JSON.stringify(internals.visualViewportRect()) is {"top":776,"right":300,"bottom":1076,"left":-100,"width":400,"height":300}
+
+Scrolled to -50, 300
+JSON.stringify(internals.layoutViewportRect()) is {"top":300,"right":350,"bottom":900,"left":-450,"width":800,"height":600}
+JSON.stringify(internals.visualViewportRect()) is {"top":300,"right":350,"bottom":600,"left":-50,"width":400,"height":300}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk1fastvisualviewportrtlzoomedrectsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac-wk1/fast/visual-viewport/rtl-zoomed-rects-expected.txt (0 => 208409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk1/fast/visual-viewport/rtl-zoomed-rects-expected.txt         (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/fast/visual-viewport/rtl-zoomed-rects-expected.txt        2016-11-05 00:41:50 UTC (rev 208409)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+This test zooms and scrolls the page and checks that the layout and visual viewports respond as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+JSON.stringify(internals.layoutViewportRect()) is {"top":0,"right":392.5,"bottom":585,"left":-392.5,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":0,"right":392.5,"bottom":292.5,"left":0,"width":392.5,"height":292.5}
+
+Scrolled to -475, 525
+JSON.stringify(internals.layoutViewportRect()) is {"top":232.5,"right":310,"bottom":817.5,"left":-475,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":525,"right":-82.5,"bottom":817.5,"left":-475,"width":392.5,"height":292.5}
+
+Scrolled to -100, 776
+JSON.stringify(internals.layoutViewportRect()) is {"top":483.5,"right":310,"bottom":1068.5,"left":-475,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":776,"right":292.5,"bottom":1068.5,"left":-100,"width":392.5,"height":292.5}
+
+Scrolled to -50, 300
+JSON.stringify(internals.layoutViewportRect()) is {"top":300,"right":342.5,"bottom":885,"left":-442.5,"width":785,"height":585}
+JSON.stringify(internals.visualViewportRect()) is {"top":300,"right":342.5,"bottom":592.5,"left":-50,"width":392.5,"height":292.5}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208408 => 208409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-05 00:03:32 UTC (rev 208408)
+++ trunk/Source/WebCore/ChangeLog        2016-11-05 00:41:50 UTC (rev 208409)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2016-11-04 Simon Fraser <simon.fraser@apple.com>
+
+ Layout viewport wrong with RTL documents
+ https://bugs.webkit.org/show_bug.cgi?id=164434
+
+ Reviewed by Tim Horton.
+
+ The layoutViewportRect was computed incorrectly in RTL documents, because
+ FrameView::unscaledMaximumScrollPosition() was wrong; it erroneously mapped
+ what it thought was a scrollOffset to a scrollPosition.
+
+ Unscaled scroll positions are in the same coordinate space as unscaledDocumentRect,
+ so we should not call scrollPositionFromOffset() in FrameView::unscaledMaximumScrollPosition().
+
+ Changed FrameView::unscaledMinimumScrollPosition() to also just grab the location of
+ unscaledDocumentRect, for symmetry.
+
+ Finally fixed the tiled scrolling indicator's viewport rect for zoomed RTL documents
+ by using the unscaled scroll origin.
+
+ Tests: fast/visual-viewport/rtl-nonzoomed-rects.html
+ fast/visual-viewport/rtl-zoomed-rects.html
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::setLayoutViewportOrigin):
+ (WebCore::FrameView::unscaledScrollOrigin):
+ (WebCore::FrameView::unscaledMinimumScrollPosition):
+ (WebCore::FrameView::unscaledMaximumScrollPosition):
+ * page/FrameView.h:
+
</ins><span class="cx"> 2016-11-04 Sam Weinig <sam@webkit.org>
</span><span class="cx">
</span><span class="cx"> [WebIDL] Add support for modern callback syntax
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (208408 => 208409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2016-11-05 00:03:32 UTC (rev 208408)
+++ trunk/Source/WebCore/page/FrameView.cpp        2016-11-05 00:41:50 UTC (rev 208409)
</span><span class="lines">@@ -1821,8 +1821,11 @@
</span><span class="cx"> m_layoutViewportOrigin = origin;
</span><span class="cx"> setViewportConstrainedObjectsNeedLayout();
</span><span class="cx">
</span><del>- if (TiledBacking* tiledBacking = this->tiledBacking())
- tiledBacking->setLayoutViewportRect(FloatRect(layoutViewportRect()));
</del><ins>+ if (TiledBacking* tiledBacking = this->tiledBacking()) {
+ FloatRect layoutViewport = layoutViewportRect();
+ layoutViewport.moveBy(unscaledScrollOrigin()); // tiledBacking deals in top-left relative coordinates.
+ tiledBacking->setLayoutViewportRect(layoutViewport);
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void FrameView::updateLayoutViewport()
</span><span class="lines">@@ -1854,6 +1857,14 @@
</span><span class="cx"> return unscaledMaximumScrollPosition();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+IntPoint FrameView::unscaledScrollOrigin() const
+{
+ if (RenderView* renderView = this->renderView())
+ return -renderView->unscaledDocumentRect().location(); // Akin to code in adjustViewSize().
+
+ return { };
+}
+
</ins><span class="cx"> // Size of initial containing block, anchored at scroll position, in document coordinates (unchanged by scale factor).
</span><span class="cx"> LayoutRect FrameView::layoutViewportRect() const
</span><span class="cx"> {
</span><span class="lines">@@ -2038,16 +2049,14 @@
</span><span class="cx"> {
</span><span class="cx"> if (RenderView* renderView = this->renderView()) {
</span><span class="cx"> IntRect unscaledDocumentRect = renderView->unscaledDocumentRect();
</span><ins>+ ScrollPosition minimumPosition = unscaledDocumentRect.location() - visibleSize();
</ins><span class="cx">
</span><del>- IntPoint unscaledScrollOrigin = -unscaledDocumentRect.location();
- ScrollPosition minimumPosition = scrollPositionFromOffset(ScrollOffset(), toIntSize(unscaledScrollOrigin));
-
</del><span class="cx"> if (frame().isMainFrame() && m_scrollPinningBehavior == PinToBottom)
</span><span class="cx"> minimumPosition.setY(unscaledMaximumScrollPosition().y());
</span><span class="cx">
</span><span class="cx"> return minimumPosition;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> return minimumScrollPosition();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2056,11 +2065,7 @@
</span><span class="cx"> if (RenderView* renderView = this->renderView()) {
</span><span class="cx"> IntRect unscaledDocumentRect = renderView->unscaledDocumentRect();
</span><span class="cx"> unscaledDocumentRect.expand(0, headerHeight() + footerHeight());
</span><del>-
- // Max scroll position is size - visible - scrollOrigin, which is max - visible.
- ScrollOffset maximumOffset = unscaledDocumentRect.maxXMaxYCorner() - visibleSize();
- IntPoint unscaledScrollOrigin = -unscaledDocumentRect.location();
- ScrollPosition maximumPosition = scrollPositionFromOffset(maximumOffset, toIntSize(unscaledScrollOrigin));
</del><ins>+ ScrollPosition maximumPosition = unscaledDocumentRect.maxXMaxYCorner() - visibleSize();
</ins><span class="cx">
</span><span class="cx"> if (frame().isMainFrame() && m_scrollPinningBehavior == PinToTop)
</span><span class="cx"> maximumPosition.setY(unscaledMinimumScrollPosition().y());
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.h (208408 => 208409)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.h        2016-11-05 00:03:32 UTC (rev 208408)
+++ trunk/Source/WebCore/page/FrameView.h        2016-11-05 00:41:50 UTC (rev 208409)
</span><span class="lines">@@ -250,6 +250,8 @@
</span><span class="cx"> ScrollPosition unscaledMinimumScrollPosition() const;
</span><span class="cx"> ScrollPosition unscaledMaximumScrollPosition() const;
</span><span class="cx">
</span><ins>+ IntPoint unscaledScrollOrigin() const;
+
</ins><span class="cx"> void setLayoutViewportOrigin(LayoutPoint);
</span><span class="cx"> LayoutPoint layoutViewportOrigin() const { return m_layoutViewportOrigin; }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>