<!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>[208207] 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/208207">208207</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2016-10-31 19:43:47 -0700 (Mon, 31 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make UIScriptController::zoomToScale() work on Mac WK1 and WK2
https://bugs.webkit.org/show_bug.cgi?id=164238

Reviewed by Dean Jackson.

Source/WebCore:

Test: fast/zooming/uiscript-zooming.html

Expose pageScaleFactor() for tests.

* testing/Internals.cpp:
(WebCore::Internals::pageScaleFactor):
* testing/Internals.h:
* testing/Internals.idl:

Tools:

Implement UIScriptController::zoomToScale() for WTR and DRT on Mac.

* DumpRenderTree/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::zoomToScale):
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
* WebKitTestRunner/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::zoomToScale):

LayoutTests:

* fast/zooming/uiscript-zooming-expected.txt: Added.
* fast/zooming/uiscript-zooming.html: Added.
* platform/ios-simulator-wk1/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk1TestExpectations">trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreemacUIScriptControllerMacmm">trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm</a></li>
<li><a href="#trunkToolsTestRunnerSharedUIScriptContextUIScriptControllercpp">trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnermacUIScriptControllerMacmm">trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastzoominguiscriptzoomingexpectedtxt">trunk/LayoutTests/fast/zooming/uiscript-zooming-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastzoominguiscriptzoominghtml">trunk/LayoutTests/fast/zooming/uiscript-zooming.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (208206 => 208207)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-01 01:36:00 UTC (rev 208206)
+++ trunk/LayoutTests/ChangeLog        2016-11-01 02:43:47 UTC (rev 208207)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-10-31  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Make UIScriptController::zoomToScale() work on Mac WK1 and WK2
+        https://bugs.webkit.org/show_bug.cgi?id=164238
+
+        Reviewed by Dean Jackson.
+
+        * fast/zooming/uiscript-zooming-expected.txt: Added.
+        * fast/zooming/uiscript-zooming.html: Added.
+        * platform/ios-simulator-wk1/TestExpectations:
+
</ins><span class="cx"> 2016-10-31  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove test workaround now that original issue is fixed
</span></span></pre></div>
<a id="trunkLayoutTestsfastzoominguiscriptzoomingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/zooming/uiscript-zooming-expected.txt (0 => 208207)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/zooming/uiscript-zooming-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/zooming/uiscript-zooming-expected.txt        2016-11-01 02:43:47 UTC (rev 208207)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test that uiController.zoomToScale() works.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS internals.pageScaleFactor() is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastzoominguiscriptzoominghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/zooming/uiscript-zooming.html (0 => 208207)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/zooming/uiscript-zooming.html                                (rev 0)
+++ trunk/LayoutTests/fast/zooming/uiscript-zooming.html        2016-11-01 02:43:47 UTC (rev 208207)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        body {
+            height: 2000px;
+            width: 2000px;
+        }
+    &lt;/style&gt;
+    &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        description(&quot;Test that uiController.zoomToScale() works.&quot;);
+
+        window.jsTestIsAsync = true;
+
+        function doAfterZooming()
+        {
+            shouldBe('internals.pageScaleFactor()', '2');
+            finishJSTest();
+        }
+        
+        function getUIScript()
+        {
+            return `(function() {
+                uiController.zoomToScale(2, function() {
+                    uiController.uiScriptComplete(uiController.zoomScale);
+                });
+            })();`;
+        }
+
+        function doTest()
+        {
+            if (window.testRunner)
+                testRunner.runUIScript(getUIScript(), function(zoomScale) {
+                    doAfterZooming();
+                })
+        }
+        
+        window.addEventListener('load', doTest, false);
+    &lt;/script&gt;
+&lt;/head&gt;
+&lt;body&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="trunkLayoutTestsplatformiossimulatorwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (208206 => 208207)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations        2016-11-01 01:36:00 UTC (rev 208206)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations        2016-11-01 02:43:47 UTC (rev 208207)
</span><span class="lines">@@ -100,6 +100,9 @@
</span><span class="cx"> editing/unsupported-content/table-type-after.html
</span><span class="cx"> editing/unsupported-content/table-type-before.html
</span><span class="cx"> 
</span><ins>+# Zooming works differently in iOS DRT
+fast/zooming/uiscript-zooming.html [ Failure ]
+
</ins><span class="cx"> # FIXME: Tests that fail due to lack of textInputController &lt;rdar://problem/5106287&gt;
</span><span class="cx"> editing/inserting/insert-composition-whitespace.html [ Failure ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208206 => 208207)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-01 01:36:00 UTC (rev 208206)
+++ trunk/Source/WebCore/ChangeLog        2016-11-01 02:43:47 UTC (rev 208207)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-10-31  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Make UIScriptController::zoomToScale() work on Mac WK1 and WK2
+        https://bugs.webkit.org/show_bug.cgi?id=164238
+
+        Reviewed by Dean Jackson.
+
+        Test: fast/zooming/uiscript-zooming.html
+        
+        Expose pageScaleFactor() for tests.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::pageScaleFactor):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
</ins><span class="cx"> 2016-10-31  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Migrate CanvasRenderingContext's internal canvas pointer to a reference
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (208206 => 208207)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2016-11-01 01:36:00 UTC (rev 208206)
+++ trunk/Source/WebCore/testing/Internals.cpp        2016-11-01 02:43:47 UTC (rev 208207)
</span><span class="lines">@@ -2017,6 +2017,15 @@
</span><span class="cx">     return PrintContext::pageSizeAndMarginsInPixels(frame(), pageNumber, width, height, marginTop, marginRight, marginBottom, marginLeft);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ExceptionOr&lt;float&gt; Internals::pageScaleFactor() const
+{
+    Document* document = contextDocument();
+    if (!document || !document-&gt;page())
+        return Exception { INVALID_ACCESS_ERR };
+
+    return document-&gt;page()-&gt;pageScaleFactor();
+}
+
</ins><span class="cx"> ExceptionOr&lt;void&gt; Internals::setPageScaleFactor(float scaleFactor, int x, int y)
</span><span class="cx"> {
</span><span class="cx">     Document* document = contextDocument();
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (208206 => 208207)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2016-11-01 01:36:00 UTC (rev 208206)
+++ trunk/Source/WebCore/testing/Internals.h        2016-11-01 02:43:47 UTC (rev 208207)
</span><span class="lines">@@ -284,6 +284,8 @@
</span><span class="cx">     ExceptionOr&lt;String&gt; pageProperty(const String&amp; propertyName, int pageNumber) const;
</span><span class="cx">     ExceptionOr&lt;String&gt; pageSizeAndMarginsInPixels(int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft) const;
</span><span class="cx"> 
</span><ins>+    ExceptionOr&lt;float&gt; pageScaleFactor() const;
+
</ins><span class="cx">     ExceptionOr&lt;void&gt; setPageScaleFactor(float scaleFactor, int x, int y);
</span><span class="cx">     ExceptionOr&lt;void&gt; setPageZoomFactor(float);
</span><span class="cx">     ExceptionOr&lt;void&gt; setTextZoomFactor(float);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (208206 => 208207)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2016-11-01 01:36:00 UTC (rev 208206)
+++ trunk/Source/WebCore/testing/Internals.idl        2016-11-01 02:43:47 UTC (rev 208207)
</span><span class="lines">@@ -278,6 +278,8 @@
</span><span class="cx">     [MayThrowException] DOMString pageSizeAndMarginsInPixels(long pageIndex, long width, long height, long marginTop, long marginRight, long marginBottom, long marginLeft);
</span><span class="cx"> 
</span><span class="cx">     [MayThrowException] void setPageScaleFactor(unrestricted float scaleFactor, long x, long y);
</span><ins>+    [MayThrowException] float pageScaleFactor();
+
</ins><span class="cx">     [MayThrowException] void setPageZoomFactor(unrestricted float zoomFactor);
</span><span class="cx">     [MayThrowException] void setTextZoomFactor(unrestricted float zoomFactor);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (208206 => 208207)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-11-01 01:36:00 UTC (rev 208206)
+++ trunk/Tools/ChangeLog        2016-11-01 02:43:47 UTC (rev 208207)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-10-31  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Make UIScriptController::zoomToScale() work on Mac WK1 and WK2
+        https://bugs.webkit.org/show_bug.cgi?id=164238
+
+        Reviewed by Dean Jackson.
+
+        Implement UIScriptController::zoomToScale() for WTR and DRT on Mac.
+
+        * DumpRenderTree/mac/UIScriptControllerMac.mm:
+        (WTR::UIScriptController::zoomToScale):
+        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+        * WebKitTestRunner/mac/UIScriptControllerMac.mm:
+        (WTR::UIScriptController::zoomToScale):
+
</ins><span class="cx"> 2016-10-31  Dewei Zhu  &lt;dewei_zhu@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Update twisted version in webkitpy.thirdparty.autoinstalled module.
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreemacUIScriptControllerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm (208206 => 208207)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm        2016-11-01 01:36:00 UTC (rev 208206)
+++ trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm        2016-11-01 02:43:47 UTC (rev 208207)
</span><span class="lines">@@ -26,7 +26,10 @@
</span><span class="cx"> #import &quot;config.h&quot;
</span><span class="cx"> #import &quot;UIScriptController.h&quot;
</span><span class="cx"> 
</span><ins>+#import &quot;DumpRenderTree.h&quot;
</ins><span class="cx"> #import &quot;UIScriptContext.h&quot;
</span><ins>+#import &lt;WebKit/WebKit.h&gt;
+#import &lt;WebKit/WebViewPrivate.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> 
</span><span class="lines">@@ -47,6 +50,20 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UIScriptController::zoomToScale(double scale, JSValueRef callback)
+{
+    unsigned callbackID = m_context-&gt;prepareForAsyncTask(callback, CallbackTypeNonPersistent);
+
+    WebView *webView = [mainFrame webView];
+    [webView _scaleWebView:scale atOrigin:NSZeroPoint];
+
+    dispatch_async(dispatch_get_main_queue(), ^ {
+        if (!m_context)
+            return;
+        m_context-&gt;asyncTaskComplete(callbackID);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+}
+
</ins><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkToolsTestRunnerSharedUIScriptContextUIScriptControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (208206 => 208207)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp        2016-11-01 01:36:00 UTC (rev 208206)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp        2016-11-01 02:43:47 UTC (rev 208207)
</span><span class="lines">@@ -157,11 +157,13 @@
</span><span class="cx">     return m_context-&gt;callbackWithID(CallbackTypeDidHideKeyboard);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if !PLATFORM(IOS)
</del><ins>+#if !PLATFORM(COCOA)
</ins><span class="cx"> void UIScriptController::zoomToScale(double, JSValueRef)
</span><span class="cx"> {
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><ins>+#if !PLATFORM(IOS)
</ins><span class="cx"> void UIScriptController::touchDownAtPoint(long x, long y, long touchCount, JSValueRef)
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnermacUIScriptControllerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm (208206 => 208207)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm        2016-11-01 01:36:00 UTC (rev 208206)
+++ trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm        2016-11-01 02:43:47 UTC (rev 208207)
</span><span class="lines">@@ -66,4 +66,23 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UIScriptController::zoomToScale(double scale, JSValueRef callback)
+{
+#if WK_API_ENABLED
+    unsigned callbackID = m_context-&gt;prepareForAsyncTask(callback, CallbackTypeNonPersistent);
+
+    auto* webView = TestController::singleton().mainWebView()-&gt;platformView();
+    [webView _setPageScale:scale withOrigin:CGPointZero];
+
+    [webView _doAfterNextPresentationUpdate: ^ {
+        if (!m_context)
+            return;
+        m_context-&gt;asyncTaskComplete(callbackID);
+    }];
+#else
+    UNUSED_PARAM(scale);
+    UNUSED_PARAM(callback);
+#endif
</ins><span class="cx"> }
</span><ins>+
+} // namespace WTR
</ins></span></pre>
</div>
</div>

</body>
</html>