Title: [211095] trunk
Revision
211095
Author
n_w...@apple.com
Date
2017-01-24 12:44:38 -0800 (Tue, 24 Jan 2017)

Log Message

AX: Speak Selection does not work in an iframe
https://bugs.webkit.org/show_bug.cgi?id=166794
<rdar://problem/29913013>

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:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (211094 => 211095)


--- trunk/LayoutTests/ChangeLog	2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/LayoutTests/ChangeLog	2017-01-24 20:44:38 UTC (rev 211095)
@@ -1,3 +1,15 @@
+2017-01-24  Nan Wang  <n_w...@apple.com>
+
+        AX: Speak Selection does not work in an iframe
+        https://bugs.webkit.org/show_bug.cgi?id=166794
+        <rdar://problem/29913013>
+
+        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:
+
 2017-01-24  Ryan Haddad  <ryanhad...@apple.com>
 
         modern-media-controls LayoutTest gardening.

Added: trunk/LayoutTests/accessibility/ios-simulator/speak-selection-content-expected.txt (0 => 211095)


--- 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)
@@ -0,0 +1,15 @@
+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 "PASS" messages, followed by "TEST COMPLETE".
+
+
+Content: Text outside iframe
+Content: Text inside iframe
+Content: text3
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/ios-simulator/speak-selection-content.html (0 => 211095)


--- 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)
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src="" language="_javascript_" type="text/_javascript_" ></script>
+<script id="ui-script" type="text/plain">
+    (function() {
+        uiController.retrieveSpeakSelectionContent(function() {
+            uiController.uiScriptComplete(uiController.accessibilitySpeakSelectionContent);
+        });
+    })();
+</script>
+</head>
+
+<body _onload_="runTest();">
+<p id="result">This test has to run in iOS WebKitTestRunner.</p>
+
+<input type="text" id="myText" value="Text outside iframe">
+<iframe id="frame" srcdoc="<html><body><input id='myText2' type='text' value='Text inside iframe'><span tabindex=0 id='myText3'>text3</span></body></html>"></iframe>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests that accessibility speak selection content is correct.");
+
+    if (window.testRunner)
+        window.jsTestIsAsync = true;
+
+    function runTest() {
+        var input1 = document.getElementById("myText");
+        selectInputContent(input1);
+        if (testRunner.runUIScript) {
+            var uiScript = document.getElementById('ui-script').text;
+            testRunner.runUIScript(uiScript, function(result) {
+                debug("Content: " + result);
+                testInsideFrame(document.getElementById('frame').contentWindow.document);
+            });
+        }
+    }
+    
+    function testInsideFrame(iframeDocument) {
+        var input2 = iframeDocument.getElementById("myText2");
+        selectInputContent(input2);
+        if (testRunner.runUIScript) {
+            var uiScript = document.getElementById('ui-script').text;
+            testRunner.runUIScript(uiScript, function(result) {
+                debug("Content: " + result);
+                testNonInputInsideFrame(iframeDocument);
+            });
+        }
+    }
+    
+    function testNonInputInsideFrame(iframeDocument) {
+        var text3 =  iframeDocument.getElementById("myText3");
+        var text3Obj = accessibilityController.accessibleElementById("myText3");
+        selectElementContent(text3, text3Obj, 5);
+        if (testRunner.runUIScript) {
+            var uiScript = document.getElementById('ui-script').text;
+            testRunner.runUIScript(uiScript, function(result) {
+                debug("Content: " + 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 < length; i++)
+            elementObj.increaseTextSelection;
+    }
+    
+</script>
+
+<script src=""
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (211094 => 211095)


--- 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)
@@ -105,6 +105,9 @@
 # Zooming works differently in iOS DRT
 fast/zooming/uiscript-zooming.html [ Failure ]
 
+# Not supported on WK1
+accessibility/ios-simulator/speak-selection-content.html [ Skip ]
+
 # FIXME: Tests that fail due to lack of textInputController <rdar://problem/5106287>
 editing/inserting/insert-composition-whitespace.html [ Failure ]
 

Modified: trunk/Source/WebKit2/ChangeLog (211094 => 211095)


--- 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)
@@ -1,3 +1,24 @@
+2017-01-24  Nan Wang  <n_w...@apple.com>
+
+        AX: Speak Selection does not work in an iframe
+        https://bugs.webkit.org/show_bug.cgi?id=166794
+        <rdar://problem/29913013>
+
+        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):
+
 2017-01-24  Jer Noble  <jer.no...@apple.com>
 
         Make _WKFullscreenDelegate available to users of the WebKit2 C-API.

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (211094 => 211095)


--- 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)
@@ -3464,6 +3464,18 @@
 {
     return [_contentView _dataDetectionResults];
 }
+
+- (void)_accessibilityRetrieveSpeakSelectionContent
+{
+    [_contentView accessibilityRetrieveSpeakSelectionContent];
+}
+
+// This method is for subclasses to override.
+// Currently it's only in TestRunnerWKWebView.
+- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content
+{
+}
+
 #endif
 
 - (void)_didRelaunchProcess

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (211094 => 211095)


--- 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)
@@ -181,6 +181,9 @@
 - (id)_snapshotLayerContentsForBackForwardListItem:(WKBackForwardListItem *)item WK_API_AVAILABLE(ios(9_0));
 - (NSArray *)_dataDetectionResults;
 
+- (void)_accessibilityRetrieveSpeakSelectionContent;
+- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content;
+
 #else
 @property (readonly) NSColor *_pageExtendedBackgroundColor;
 @property (nonatomic, setter=_setDrawsBackground:) BOOL _drawsBackground;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (211094 => 211095)


--- 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)
@@ -231,6 +231,7 @@
 - (void)_setDoubleTapGesturesEnabled:(BOOL)enabled;
 - (NSArray *)_dataDetectionResults;
 - (NSArray<NSValue *> *)_uiTextSelectionRects;
+- (void)accessibilityRetrieveSpeakSelectionContent;
 @end
 
 @interface WKContentView (WKTesting)

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (211094 => 211095)


--- 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)
@@ -2090,9 +2090,11 @@
 - (void)accessibilityRetrieveSpeakSelectionContent
 {
     RetainPtr<WKContentView> view = self;
-    _page->getSelectionOrContentsAsString([view](const String& string, WebKit::CallbackBase::Error error) {
+    RetainPtr<WKWebView> webView = _webView;
+    _page->getSelectionOrContentsAsString([view, webView](const String& string, WebKit::CallbackBase::Error error) {
         if (error != WebKit::CallbackBase::Error::None)
             return;
+        [webView _accessibilityDidGetSpeakSelectionContent:string];
         if ([view respondsToSelector:@selector(accessibilitySpeakSelectionSetContent:)])
             [view accessibilitySpeakSelectionSetContent:string];
     });

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (211094 => 211095)


--- 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)
@@ -2832,9 +2832,10 @@
 
 void WebPage::getSelectionOrContentsAsString(uint64_t callbackID)
 {
-    String resultString = m_mainFrame->selectionAsString();
+    WebFrame* focusedOrMainFrame = WebFrame::fromCoreFrame(m_page->focusController().focusedOrMainFrame());
+    String resultString = focusedOrMainFrame->selectionAsString();
     if (resultString.isEmpty())
-        resultString = m_mainFrame->contentsAsString();
+        resultString = focusedOrMainFrame->contentsAsString();
     send(Messages::WebPageProxy::StringCallback(resultString, callbackID));
 }
 

Modified: trunk/Tools/ChangeLog (211094 => 211095)


--- trunk/Tools/ChangeLog	2017-01-24 19:55:56 UTC (rev 211094)
+++ trunk/Tools/ChangeLog	2017-01-24 20:44:38 UTC (rev 211095)
@@ -1,3 +1,28 @@
+2017-01-24  Nan Wang  <n_w...@apple.com>
+
+        AX: Speak Selection does not work in an iframe
+        https://bugs.webkit.org/show_bug.cgi?id=166794
+        <rdar://problem/29913013>
+
+        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):
+
 2017-01-24  Daniel Bates  <daba...@apple.com>
 
         StringView.split() should use an iterator design pattern instead of allocating a Vector

Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (211094 => 211095)


--- 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)
@@ -289,6 +289,15 @@
     return nullptr;
 }
 
+void UIScriptController::retrieveSpeakSelectionContent(JSValueRef)
+{
 }
 
+JSRetainPtr<JSStringRef> UIScriptController::accessibilitySpeakSelectionContent() const
+{
+    return nullptr;
+}
+
+}
+
 #endif // PLATFORM(IOS)

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (211094 => 211095)


--- 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)
@@ -214,4 +214,7 @@
     readonly attribute DOMString scrollingTreeAsText;
 
     void uiScriptComplete(DOMString result);
+
+    void retrieveSpeakSelectionContent(object callback);
+    readonly attribute DOMString accessibilitySpeakSelectionContent;
 };

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (211094 => 211095)


--- 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)
@@ -375,6 +375,16 @@
 void UIScriptController::platformClearAllCallbacks()
 {
 }
+
+void UIScriptController::retrieveSpeakSelectionContent(JSValueRef)
+{
+}
+
+JSRetainPtr<JSStringRef> UIScriptController::accessibilitySpeakSelectionContent() const
+{
+    return nullptr;
+}
+
 #endif
 
 #if !PLATFORM(MAC)

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (211094 => 211095)


--- 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)
@@ -139,6 +139,9 @@
     JSRetainPtr<JSStringRef> scrollingTreeAsText() const;
 
     void uiScriptComplete(JSStringRef result);
+    
+    void retrieveSpeakSelectionContent(JSValueRef callback);
+    JSRetainPtr<JSStringRef> accessibilitySpeakSelectionContent() const;
 
 private:
     UIScriptController(UIScriptContext&);

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h (211094 => 211095)


--- 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)
@@ -40,8 +40,11 @@
 @property (nonatomic, copy) void (^didShowKeyboardCallback)(void);
 @property (nonatomic, copy) void (^didHideKeyboardCallback)(void);
 @property (nonatomic, copy) void (^didEndScrollingCallback)(void);
+@property (nonatomic, copy) NSString *accessibilitySpeakSelectionContent;
 
 - (void)zoomToScale:(double)scale animated:(BOOL)animated completionHandler:(void (^)(void))completionHandler;
+- (void)accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:(void (^)(void))completionHandler;
+
 #endif
 
 @property (nonatomic, retain, setter=_setStableStateOverride:) NSNumber *_stableStateOverride;

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm (211094 => 211095)


--- 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)
@@ -31,6 +31,7 @@
 #import <wtf/RetainPtr.h>
 
 #if PLATFORM(IOS)
+#import <WebKit/WKWebViewPrivate.h>
 @interface WKWebView ()
 
 // FIXME: move these to WKWebView_Private.h
@@ -50,6 +51,7 @@
 
 @property (nonatomic, copy) void (^zoomToScaleCompletionHandler)(void);
 @property (nonatomic, copy) void (^showKeyboardCompletionHandler)(void);
+@property (nonatomic, copy) void (^retrieveSpeakSelectionContentCompletionHandler)(void);
 @property (nonatomic) BOOL isShowingKeyboard;
 
 @end
@@ -91,6 +93,7 @@
 
     self.zoomToScaleCompletionHandler = nil;
     self.showKeyboardCompletionHandler = nil;
+    self.retrieveSpeakSelectionContentCompletionHandler = nil;
 
     [super dealloc];
 }
@@ -187,6 +190,19 @@
     [self _updateVisibleContentRects];
 }
 
+- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content
+{
+    self.accessibilitySpeakSelectionContent = content;
+    if (self.retrieveSpeakSelectionContentCompletionHandler)
+        self.retrieveSpeakSelectionContentCompletionHandler();
+}
+
+- (void)accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:(void (^)(void))completionHandler
+{
+    self.retrieveSpeakSelectionContentCompletionHandler = completionHandler;
+    [self _accessibilityRetrieveSpeakSelectionContent];
+}
+
 #endif
 
 @end

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (211094 => 211095)


--- 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)
@@ -107,6 +107,25 @@
     }];
 }
 
+void UIScriptController::retrieveSpeakSelectionContent(JSValueRef callback)
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    
+    unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
+    
+    [webView accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:^() {
+        if (!m_context)
+            return;
+        m_context->asyncTaskComplete(callbackID);
+    }];
+}
+
+JSRetainPtr<JSStringRef> UIScriptController::accessibilitySpeakSelectionContent() const
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    return JSStringCreateWithCFString((CFStringRef)webView.accessibilitySpeakSelectionContent);
+}
+
 void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef callback)
 {
     unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to