<!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>[211095] 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/211095">211095</a></dd>
<dt>Author</dt> <dd>n_wang@apple.com</dd>
<dt>Date</dt> <dd>2017-01-24 12:44:38 -0800 (Tue, 24 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>AX: Speak Selection does not work in an iframe
https://bugs.webkit.org/show_bug.cgi?id=166794
&lt;rdar://problem/29913013&gt;

Reviewed by Chris Fleizach.

Source/WebKit2:

Making sure WebPage::getSelectionOrContentsAsString() is getting the
selection content in the right frame.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _accessibilityRetrieveSpeakSelectionContent]):
(-[WKWebView _accessibilityDidGetSpeakSelectionContent:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView accessibilityRetrieveSpeakSelectionContent]):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::getSelectionOrContentsAsString):

Tools:

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::retrieveSpeakSelectionContent):
(WTR::UIScriptController::accessibilitySpeakSelectionContent):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::retrieveSpeakSelectionContent):
(WTR::UIScriptController::accessibilitySpeakSelectionContent):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
* WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView dealloc]):
(-[TestRunnerWKWebView _accessibilityDidGetSpeakSelectionContent:]):
(-[TestRunnerWKWebView accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:]):
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::retrieveSpeakSelectionContent):
(WTR::UIScriptController::accessibilitySpeakSelectionContent):

LayoutTests:

* accessibility/ios-simulator/speak-selection-content-expected.txt: Added.
* accessibility/ios-simulator/speak-selection-content.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="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionh">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreeiosUIScriptControllerIOSmm">trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm</a></li>
<li><a href="#trunkToolsTestRunnerSharedUIScriptContextBindingsUIScriptControlleridl">trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl</a></li>
<li><a href="#trunkToolsTestRunnerSharedUIScriptContextUIScriptControllercpp">trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp</a></li>
<li><a href="#trunkToolsTestRunnerSharedUIScriptContextUIScriptControllerh">trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnercocoaTestRunnerWKWebViewh">trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnercocoaTestRunnerWKWebViewmm">trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm</a></li>
<li><a href="#trunkToolsWebKitTestRunneriosUIScriptControllerIOSmm">trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsaccessibilityiossimulatorspeakselectioncontentexpectedtxt">trunk/LayoutTests/accessibility/ios-simulator/speak-selection-content-expected.txt</a></li>
<li><a href="#trunkLayoutTestsaccessibilityiossimulatorspeakselectioncontenthtml">trunk/LayoutTests/accessibility/ios-simulator/speak-selection-content.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/LayoutTests/ChangeLog        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2017-01-24  Nan Wang  &lt;n_wang@apple.com&gt;
+
+        AX: Speak Selection does not work in an iframe
+        https://bugs.webkit.org/show_bug.cgi?id=166794
+        &lt;rdar://problem/29913013&gt;
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/ios-simulator/speak-selection-content-expected.txt: Added.
+        * accessibility/ios-simulator/speak-selection-content.html: Added.
+        * platform/ios-simulator-wk1/TestExpectations:
+
</ins><span class="cx"> 2017-01-24  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         modern-media-controls LayoutTest gardening.
</span></span></pre></div>
<a id="trunkLayoutTestsaccessibilityiossimulatorspeakselectioncontentexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/accessibility/ios-simulator/speak-selection-content-expected.txt (0 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/ios-simulator/speak-selection-content-expected.txt                                (rev 0)
+++ trunk/LayoutTests/accessibility/ios-simulator/speak-selection-content-expected.txt        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+This test has to run in iOS WebKitTestRunner.
+

+This tests that accessibility speak selection content is correct.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Content: Text outside iframe
+Content: Text inside iframe
+Content: text3
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsaccessibilityiossimulatorspeakselectioncontenthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/accessibility/ios-simulator/speak-selection-content.html (0 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/accessibility/ios-simulator/speak-selection-content.html                                (rev 0)
+++ trunk/LayoutTests/accessibility/ios-simulator/speak-selection-content.html        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -0,0 +1,84 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../editing/editing.js&quot; language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot; &gt;&lt;/script&gt;
+&lt;script id=&quot;ui-script&quot; type=&quot;text/plain&quot;&gt;
+    (function() {
+        uiController.retrieveSpeakSelectionContent(function() {
+            uiController.uiScriptComplete(uiController.accessibilitySpeakSelectionContent);
+        });
+    })();
+&lt;/script&gt;
+&lt;/head&gt;
+
+&lt;body onload=&quot;runTest();&quot;&gt;
+&lt;p id=&quot;result&quot;&gt;This test has to run in iOS WebKitTestRunner.&lt;/p&gt;
+
+&lt;input type=&quot;text&quot; id=&quot;myText&quot; value=&quot;Text outside iframe&quot;&gt;
+&lt;iframe id=&quot;frame&quot; srcdoc=&quot;&lt;html&gt;&lt;body&gt;&lt;input id='myText2' type='text' value='Text inside iframe'&gt;&lt;span tabindex=0 id='myText3'&gt;text3&lt;/span&gt;&lt;/body&gt;&lt;/html&gt;&quot;&gt;&lt;/iframe&gt;
+
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+    description(&quot;This tests that accessibility speak selection content is correct.&quot;);
+
+    if (window.testRunner)
+        window.jsTestIsAsync = true;
+
+    function runTest() {
+        var input1 = document.getElementById(&quot;myText&quot;);
+        selectInputContent(input1);
+        if (testRunner.runUIScript) {
+            var uiScript = document.getElementById('ui-script').text;
+            testRunner.runUIScript(uiScript, function(result) {
+                debug(&quot;Content: &quot; + result);
+                testInsideFrame(document.getElementById('frame').contentWindow.document);
+            });
+        }
+    }
+    
+    function testInsideFrame(iframeDocument) {
+        var input2 = iframeDocument.getElementById(&quot;myText2&quot;);
+        selectInputContent(input2);
+        if (testRunner.runUIScript) {
+            var uiScript = document.getElementById('ui-script').text;
+            testRunner.runUIScript(uiScript, function(result) {
+                debug(&quot;Content: &quot; + result);
+                testNonInputInsideFrame(iframeDocument);
+            });
+        }
+    }
+    
+    function testNonInputInsideFrame(iframeDocument) {
+        var text3 =  iframeDocument.getElementById(&quot;myText3&quot;);
+        var text3Obj = accessibilityController.accessibleElementById(&quot;myText3&quot;);
+        selectElementContent(text3, text3Obj, 5);
+        if (testRunner.runUIScript) {
+            var uiScript = document.getElementById('ui-script').text;
+            testRunner.runUIScript(uiScript, function(result) {
+                debug(&quot;Content: &quot; + result);
+                finishJSTest();
+            });
+        }
+    }
+    
+    function selectInputContent(input) {
+        input.focus();
+        input.selectionStart = 0;
+        input.selectionEnd = 100;
+    }
+    
+    function selectElementContent(element, elementObj, length) {
+        element.focus();
+        setSelectionCommand(element, 0, element, 0);
+        for (var i = 0; i &lt; length; i++)
+            elementObj.increaseTextSelection;
+    }
+    
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -105,6 +105,9 @@
</span><span class="cx"> # Zooming works differently in iOS DRT
</span><span class="cx"> fast/zooming/uiscript-zooming.html [ Failure ]
</span><span class="cx"> 
</span><ins>+# Not supported on WK1
+accessibility/ios-simulator/speak-selection-content.html [ Skip ]
+
</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="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Source/WebKit2/ChangeLog        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2017-01-24  Nan Wang  &lt;n_wang@apple.com&gt;
+
+        AX: Speak Selection does not work in an iframe
+        https://bugs.webkit.org/show_bug.cgi?id=166794
+        &lt;rdar://problem/29913013&gt;
+
+        Reviewed by Chris Fleizach.
+
+        Making sure WebPage::getSelectionOrContentsAsString() is getting the
+        selection content in the right frame. 
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _accessibilityRetrieveSpeakSelectionContent]):
+        (-[WKWebView _accessibilityDidGetSpeakSelectionContent:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView accessibilityRetrieveSpeakSelectionContent]):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::getSelectionOrContentsAsString):
+
</ins><span class="cx"> 2017-01-24  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make _WKFullscreenDelegate available to users of the WebKit2 C-API.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -3464,6 +3464,18 @@
</span><span class="cx"> {
</span><span class="cx">     return [_contentView _dataDetectionResults];
</span><span class="cx"> }
</span><ins>+
+- (void)_accessibilityRetrieveSpeakSelectionContent
+{
+    [_contentView accessibilityRetrieveSpeakSelectionContent];
+}
+
+// This method is for subclasses to override.
+// Currently it's only in TestRunnerWKWebView.
+- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content
+{
+}
+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> - (void)_didRelaunchProcess
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -181,6 +181,9 @@
</span><span class="cx"> - (id)_snapshotLayerContentsForBackForwardListItem:(WKBackForwardListItem *)item WK_API_AVAILABLE(ios(9_0));
</span><span class="cx"> - (NSArray *)_dataDetectionResults;
</span><span class="cx"> 
</span><ins>+- (void)_accessibilityRetrieveSpeakSelectionContent;
+- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content;
+
</ins><span class="cx"> #else
</span><span class="cx"> @property (readonly) NSColor *_pageExtendedBackgroundColor;
</span><span class="cx"> @property (nonatomic, setter=_setDrawsBackground:) BOOL _drawsBackground;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -231,6 +231,7 @@
</span><span class="cx"> - (void)_setDoubleTapGesturesEnabled:(BOOL)enabled;
</span><span class="cx"> - (NSArray *)_dataDetectionResults;
</span><span class="cx"> - (NSArray&lt;NSValue *&gt; *)_uiTextSelectionRects;
</span><ins>+- (void)accessibilityRetrieveSpeakSelectionContent;
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @interface WKContentView (WKTesting)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -2090,9 +2090,11 @@
</span><span class="cx"> - (void)accessibilityRetrieveSpeakSelectionContent
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;WKContentView&gt; view = self;
</span><del>-    _page-&gt;getSelectionOrContentsAsString([view](const String&amp; string, WebKit::CallbackBase::Error error) {
</del><ins>+    RetainPtr&lt;WKWebView&gt; webView = _webView;
+    _page-&gt;getSelectionOrContentsAsString([view, webView](const String&amp; string, WebKit::CallbackBase::Error error) {
</ins><span class="cx">         if (error != WebKit::CallbackBase::Error::None)
</span><span class="cx">             return;
</span><ins>+        [webView _accessibilityDidGetSpeakSelectionContent:string];
</ins><span class="cx">         if ([view respondsToSelector:@selector(accessibilitySpeakSelectionSetContent:)])
</span><span class="cx">             [view accessibilitySpeakSelectionSetContent:string];
</span><span class="cx">     });
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -2832,9 +2832,10 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPage::getSelectionOrContentsAsString(uint64_t callbackID)
</span><span class="cx"> {
</span><del>-    String resultString = m_mainFrame-&gt;selectionAsString();
</del><ins>+    WebFrame* focusedOrMainFrame = WebFrame::fromCoreFrame(m_page-&gt;focusController().focusedOrMainFrame());
+    String resultString = focusedOrMainFrame-&gt;selectionAsString();
</ins><span class="cx">     if (resultString.isEmpty())
</span><del>-        resultString = m_mainFrame-&gt;contentsAsString();
</del><ins>+        resultString = focusedOrMainFrame-&gt;contentsAsString();
</ins><span class="cx">     send(Messages::WebPageProxy::StringCallback(resultString, callbackID));
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Tools/ChangeLog        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2017-01-24  Nan Wang  &lt;n_wang@apple.com&gt;
+
+        AX: Speak Selection does not work in an iframe
+        https://bugs.webkit.org/show_bug.cgi?id=166794
+        &lt;rdar://problem/29913013&gt;
+
+        Reviewed by Chris Fleizach.
+
+        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::retrieveSpeakSelectionContent):
+        (WTR::UIScriptController::accessibilitySpeakSelectionContent):
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+        (WTR::UIScriptController::retrieveSpeakSelectionContent):
+        (WTR::UIScriptController::accessibilitySpeakSelectionContent):
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+        (-[TestRunnerWKWebView dealloc]):
+        (-[TestRunnerWKWebView _accessibilityDidGetSpeakSelectionContent:]):
+        (-[TestRunnerWKWebView accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:]):
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::retrieveSpeakSelectionContent):
+        (WTR::UIScriptController::accessibilitySpeakSelectionContent):
+
</ins><span class="cx"> 2017-01-24  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         StringView.split() should use an iterator design pattern instead of allocating a Vector
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreeiosUIScriptControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -289,6 +289,15 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UIScriptController::retrieveSpeakSelectionContent(JSValueRef)
+{
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JSRetainPtr&lt;JSStringRef&gt; UIScriptController::accessibilitySpeakSelectionContent() const
+{
+    return nullptr;
+}
+
+}
+
</ins><span class="cx"> #endif // PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkToolsTestRunnerSharedUIScriptContextBindingsUIScriptControlleridl"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -214,4 +214,7 @@
</span><span class="cx">     readonly attribute DOMString scrollingTreeAsText;
</span><span class="cx"> 
</span><span class="cx">     void uiScriptComplete(DOMString result);
</span><ins>+
+    void retrieveSpeakSelectionContent(object callback);
+    readonly attribute DOMString accessibilitySpeakSelectionContent;
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkToolsTestRunnerSharedUIScriptContextUIScriptControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -375,6 +375,16 @@
</span><span class="cx"> void UIScriptController::platformClearAllCallbacks()
</span><span class="cx"> {
</span><span class="cx"> }
</span><ins>+
+void UIScriptController::retrieveSpeakSelectionContent(JSValueRef)
+{
+}
+
+JSRetainPtr&lt;JSStringRef&gt; UIScriptController::accessibilitySpeakSelectionContent() const
+{
+    return nullptr;
+}
+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkToolsTestRunnerSharedUIScriptContextUIScriptControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -139,6 +139,9 @@
</span><span class="cx">     JSRetainPtr&lt;JSStringRef&gt; scrollingTreeAsText() const;
</span><span class="cx"> 
</span><span class="cx">     void uiScriptComplete(JSStringRef result);
</span><ins>+    
+    void retrieveSpeakSelectionContent(JSValueRef callback);
+    JSRetainPtr&lt;JSStringRef&gt; accessibilitySpeakSelectionContent() const;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     UIScriptController(UIScriptContext&amp;);
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnercocoaTestRunnerWKWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -40,8 +40,11 @@
</span><span class="cx"> @property (nonatomic, copy) void (^didShowKeyboardCallback)(void);
</span><span class="cx"> @property (nonatomic, copy) void (^didHideKeyboardCallback)(void);
</span><span class="cx"> @property (nonatomic, copy) void (^didEndScrollingCallback)(void);
</span><ins>+@property (nonatomic, copy) NSString *accessibilitySpeakSelectionContent;
</ins><span class="cx"> 
</span><span class="cx"> - (void)zoomToScale:(double)scale animated:(BOOL)animated completionHandler:(void (^)(void))completionHandler;
</span><ins>+- (void)accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:(void (^)(void))completionHandler;
+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, retain, setter=_setStableStateOverride:) NSNumber *_stableStateOverride;
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnercocoaTestRunnerWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><ins>+#import &lt;WebKit/WKWebViewPrivate.h&gt;
</ins><span class="cx"> @interface WKWebView ()
</span><span class="cx"> 
</span><span class="cx"> // FIXME: move these to WKWebView_Private.h
</span><span class="lines">@@ -50,6 +51,7 @@
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, copy) void (^zoomToScaleCompletionHandler)(void);
</span><span class="cx"> @property (nonatomic, copy) void (^showKeyboardCompletionHandler)(void);
</span><ins>+@property (nonatomic, copy) void (^retrieveSpeakSelectionContentCompletionHandler)(void);
</ins><span class="cx"> @property (nonatomic) BOOL isShowingKeyboard;
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="lines">@@ -91,6 +93,7 @@
</span><span class="cx"> 
</span><span class="cx">     self.zoomToScaleCompletionHandler = nil;
</span><span class="cx">     self.showKeyboardCompletionHandler = nil;
</span><ins>+    self.retrieveSpeakSelectionContentCompletionHandler = nil;
</ins><span class="cx"> 
</span><span class="cx">     [super dealloc];
</span><span class="cx"> }
</span><span class="lines">@@ -187,6 +190,19 @@
</span><span class="cx">     [self _updateVisibleContentRects];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content
+{
+    self.accessibilitySpeakSelectionContent = content;
+    if (self.retrieveSpeakSelectionContentCompletionHandler)
+        self.retrieveSpeakSelectionContentCompletionHandler();
+}
+
+- (void)accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:(void (^)(void))completionHandler
+{
+    self.retrieveSpeakSelectionContentCompletionHandler = completionHandler;
+    [self _accessibilityRetrieveSpeakSelectionContent];
+}
+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunneriosUIScriptControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (211094 => 211095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm        2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm        2017-01-24 20:44:38 UTC (rev 211095)
</span><span class="lines">@@ -107,6 +107,25 @@
</span><span class="cx">     }];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UIScriptController::retrieveSpeakSelectionContent(JSValueRef callback)
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()-&gt;platformView();
+    
+    unsigned callbackID = m_context-&gt;prepareForAsyncTask(callback, CallbackTypeNonPersistent);
+    
+    [webView accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:^() {
+        if (!m_context)
+            return;
+        m_context-&gt;asyncTaskComplete(callbackID);
+    }];
+}
+
+JSRetainPtr&lt;JSStringRef&gt; UIScriptController::accessibilitySpeakSelectionContent() const
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()-&gt;platformView();
+    return JSStringCreateWithCFString((CFStringRef)webView.accessibilitySpeakSelectionContent);
+}
+
</ins><span class="cx"> void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef callback)
</span><span class="cx"> {
</span><span class="cx">     unsigned callbackID = m_context-&gt;prepareForAsyncTask(callback, CallbackTypeNonPersistent);
</span></span></pre>
</div>
</div>

</body>
</html>