Changeset 211095 in webkit


Ignore:
Timestamp:
Jan 24, 2017 12:44:38 PM (7 years ago)
Author:
n_wang@apple.com
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:
Location:
trunk
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r211093 r211095  
     12017-01-24  Nan Wang  <n_wang@apple.com>
     2
     3        AX: Speak Selection does not work in an iframe
     4        https://bugs.webkit.org/show_bug.cgi?id=166794
     5        <rdar://problem/29913013>
     6
     7        Reviewed by Chris Fleizach.
     8
     9        * accessibility/ios-simulator/speak-selection-content-expected.txt: Added.
     10        * accessibility/ios-simulator/speak-selection-content.html: Added.
     11        * platform/ios-simulator-wk1/TestExpectations:
     12
    1132017-01-24  Ryan Haddad  <ryanhaddad@apple.com>
    214
  • trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations

    r209826 r211095  
    105105# Zooming works differently in iOS DRT
    106106fast/zooming/uiscript-zooming.html [ Failure ]
     107
     108# Not supported on WK1
     109accessibility/ios-simulator/speak-selection-content.html [ Skip ]
    107110
    108111# FIXME: Tests that fail due to lack of textInputController <rdar://problem/5106287>
  • trunk/Source/WebKit2/ChangeLog

    r211094 r211095  
     12017-01-24  Nan Wang  <n_wang@apple.com>
     2
     3        AX: Speak Selection does not work in an iframe
     4        https://bugs.webkit.org/show_bug.cgi?id=166794
     5        <rdar://problem/29913013>
     6
     7        Reviewed by Chris Fleizach.
     8
     9        Making sure WebPage::getSelectionOrContentsAsString() is getting the
     10        selection content in the right frame.
     11
     12        * UIProcess/API/Cocoa/WKWebView.mm:
     13        (-[WKWebView _accessibilityRetrieveSpeakSelectionContent]):
     14        (-[WKWebView _accessibilityDidGetSpeakSelectionContent:]):
     15        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
     16        * UIProcess/ios/WKContentViewInteraction.h:
     17        * UIProcess/ios/WKContentViewInteraction.mm:
     18        (-[WKContentView accessibilityRetrieveSpeakSelectionContent]):
     19        * WebProcess/WebPage/WebPage.cpp:
     20        (WebKit::WebPage::getSelectionOrContentsAsString):
     21
    1222017-01-24  Jer Noble  <jer.noble@apple.com>
    223
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r211045 r211095  
    34653465    return [_contentView _dataDetectionResults];
    34663466}
     3467
     3468- (void)_accessibilityRetrieveSpeakSelectionContent
     3469{
     3470    [_contentView accessibilityRetrieveSpeakSelectionContent];
     3471}
     3472
     3473// This method is for subclasses to override.
     3474// Currently it's only in TestRunnerWKWebView.
     3475- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content
     3476{
     3477}
     3478
    34673479#endif
    34683480
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r211045 r211095  
    182182- (NSArray *)_dataDetectionResults;
    183183
     184- (void)_accessibilityRetrieveSpeakSelectionContent;
     185- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content;
     186
    184187#else
    185188@property (readonly) NSColor *_pageExtendedBackgroundColor;
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r209931 r211095  
    232232- (NSArray *)_dataDetectionResults;
    233233- (NSArray<NSValue *> *)_uiTextSelectionRects;
     234- (void)accessibilityRetrieveSpeakSelectionContent;
    234235@end
    235236
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r210525 r211095  
    20912091{
    20922092    RetainPtr<WKContentView> view = self;
    2093     _page->getSelectionOrContentsAsString([view](const String& string, WebKit::CallbackBase::Error error) {
     2093    RetainPtr<WKWebView> webView = _webView;
     2094    _page->getSelectionOrContentsAsString([view, webView](const String& string, WebKit::CallbackBase::Error error) {
    20942095        if (error != WebKit::CallbackBase::Error::None)
    20952096            return;
     2097        [webView _accessibilityDidGetSpeakSelectionContent:string];
    20962098        if ([view respondsToSelector:@selector(accessibilitySpeakSelectionSetContent:)])
    20972099            [view accessibilitySpeakSelectionSetContent:string];
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r211007 r211095  
    28332833void WebPage::getSelectionOrContentsAsString(uint64_t callbackID)
    28342834{
    2835     String resultString = m_mainFrame->selectionAsString();
     2835    WebFrame* focusedOrMainFrame = WebFrame::fromCoreFrame(m_page->focusController().focusedOrMainFrame());
     2836    String resultString = focusedOrMainFrame->selectionAsString();
    28362837    if (resultString.isEmpty())
    2837         resultString = m_mainFrame->contentsAsString();
     2838        resultString = focusedOrMainFrame->contentsAsString();
    28382839    send(Messages::WebPageProxy::StringCallback(resultString, callbackID));
    28392840}
  • trunk/Tools/ChangeLog

    r211087 r211095  
     12017-01-24  Nan Wang  <n_wang@apple.com>
     2
     3        AX: Speak Selection does not work in an iframe
     4        https://bugs.webkit.org/show_bug.cgi?id=166794
     5        <rdar://problem/29913013>
     6
     7        Reviewed by Chris Fleizach.
     8
     9        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
     10        (WTR::UIScriptController::retrieveSpeakSelectionContent):
     11        (WTR::UIScriptController::accessibilitySpeakSelectionContent):
     12        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
     13        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
     14        (WTR::UIScriptController::retrieveSpeakSelectionContent):
     15        (WTR::UIScriptController::accessibilitySpeakSelectionContent):
     16        * TestRunnerShared/UIScriptContext/UIScriptController.h:
     17        * WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
     18        * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
     19        (-[TestRunnerWKWebView dealloc]):
     20        (-[TestRunnerWKWebView _accessibilityDidGetSpeakSelectionContent:]):
     21        (-[TestRunnerWKWebView accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:]):
     22        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
     23        (WTR::UIScriptController::retrieveSpeakSelectionContent):
     24        (WTR::UIScriptController::accessibilitySpeakSelectionContent):
     25
    1262017-01-24  Daniel Bates  <dabates@apple.com>
    227
  • trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm

    r210048 r211095  
    290290}
    291291
     292void UIScriptController::retrieveSpeakSelectionContent(JSValueRef)
     293{
     294}
     295
     296JSRetainPtr<JSStringRef> UIScriptController::accessibilitySpeakSelectionContent() const
     297{
     298    return nullptr;
     299}
     300
    292301}
    293302
  • trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl

    r209967 r211095  
    215215
    216216    void uiScriptComplete(DOMString result);
     217
     218    void retrieveSpeakSelectionContent(object callback);
     219    readonly attribute DOMString accessibilitySpeakSelectionContent;
    217220};
  • trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp

    r210048 r211095  
    376376{
    377377}
     378
     379void UIScriptController::retrieveSpeakSelectionContent(JSValueRef)
     380{
     381}
     382
     383JSRetainPtr<JSStringRef> UIScriptController::accessibilitySpeakSelectionContent() const
     384{
     385    return nullptr;
     386}
     387
    378388#endif
    379389
  • trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h

    r210048 r211095  
    140140
    141141    void uiScriptComplete(JSStringRef result);
     142   
     143    void retrieveSpeakSelectionContent(JSValueRef callback);
     144    JSRetainPtr<JSStringRef> accessibilitySpeakSelectionContent() const;
    142145
    143146private:
  • trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h

    r208926 r211095  
    4141@property (nonatomic, copy) void (^didHideKeyboardCallback)(void);
    4242@property (nonatomic, copy) void (^didEndScrollingCallback)(void);
     43@property (nonatomic, copy) NSString *accessibilitySpeakSelectionContent;
    4344
    4445- (void)zoomToScale:(double)scale animated:(BOOL)animated completionHandler:(void (^)(void))completionHandler;
     46- (void)accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:(void (^)(void))completionHandler;
     47
    4548#endif
    4649
  • trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm

    r209931 r211095  
    3232
    3333#if PLATFORM(IOS)
     34#import <WebKit/WKWebViewPrivate.h>
    3435@interface WKWebView ()
    3536
     
    5152@property (nonatomic, copy) void (^zoomToScaleCompletionHandler)(void);
    5253@property (nonatomic, copy) void (^showKeyboardCompletionHandler)(void);
     54@property (nonatomic, copy) void (^retrieveSpeakSelectionContentCompletionHandler)(void);
    5355@property (nonatomic) BOOL isShowingKeyboard;
    5456
     
    9294    self.zoomToScaleCompletionHandler = nil;
    9395    self.showKeyboardCompletionHandler = nil;
     96    self.retrieveSpeakSelectionContentCompletionHandler = nil;
    9497
    9598    [super dealloc];
     
    188191}
    189192
     193- (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content
     194{
     195    self.accessibilitySpeakSelectionContent = content;
     196    if (self.retrieveSpeakSelectionContentCompletionHandler)
     197        self.retrieveSpeakSelectionContentCompletionHandler();
     198}
     199
     200- (void)accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:(void (^)(void))completionHandler
     201{
     202    self.retrieveSpeakSelectionContentCompletionHandler = completionHandler;
     203    [self _accessibilityRetrieveSpeakSelectionContent];
     204}
     205
    190206#endif
    191207
  • trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

    r210048 r211095  
    108108}
    109109
     110void UIScriptController::retrieveSpeakSelectionContent(JSValueRef callback)
     111{
     112    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
     113   
     114    unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
     115   
     116    [webView accessibilityRetrieveSpeakSelectionContentWithCompletionHandler:^() {
     117        if (!m_context)
     118            return;
     119        m_context->asyncTaskComplete(callbackID);
     120    }];
     121}
     122
     123JSRetainPtr<JSStringRef> UIScriptController::accessibilitySpeakSelectionContent() const
     124{
     125    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
     126    return JSStringCreateWithCFString((CFStringRef)webView.accessibilitySpeakSelectionContent);
     127}
     128
    110129void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef callback)
    111130{
Note: See TracChangeset for help on using the changeset viewer.