Changeset 166730 in webkit


Ignore:
Timestamp:
Apr 3, 2014 10:56:03 AM (10 years ago)
Author:
andersca@apple.com
Message:

Make actionsForElement a proper API::UIClient member function
https://bugs.webkit.org/show_bug.cgi?id=131171

Reviewed by Sam Weinig.

  • UIProcess/API/APIUIClient.h:

(API::UIClient::actionsForElement):

  • UIProcess/Cocoa/UIDelegate.h:
  • UIProcess/Cocoa/UIDelegate.mm:

(WebKit::UIClient::actionsForElement):

  • UIProcess/ios/WKActionSheetAssistant.mm:

(-[WKActionSheetAssistant showImageSheet]):
(-[WKActionSheetAssistant showLinkSheet]):

Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r166728 r166730  
     12014-04-03  Anders Carlsson  <andersca@apple.com>
     2
     3        Make actionsForElement a proper API::UIClient member function
     4        https://bugs.webkit.org/show_bug.cgi?id=131171
     5
     6        Reviewed by Sam Weinig.
     7
     8        * UIProcess/API/APIUIClient.h:
     9        (API::UIClient::actionsForElement):
     10        * UIProcess/Cocoa/UIDelegate.h:
     11        * UIProcess/Cocoa/UIDelegate.mm:
     12        (WebKit::UIClient::actionsForElement):
     13        * UIProcess/ios/WKActionSheetAssistant.mm:
     14        (-[WKActionSheetAssistant showImageSheet]):
     15        (-[WKActionSheetAssistant showLinkSheet]):
     16
    1172014-04-03  Martin Hodovan  <mhodovan@inf.u-szeged.hu>
    218
  • trunk/Source/WebKit2/UIProcess/API/APIUIClient.h

    r166265 r166730  
    3434#include <functional>
    3535#include <wtf/PassRefPtr.h>
     36
     37#if PLATFORM(IOS)
     38OBJC_CLASS NSArray;
     39OBJC_CLASS _WKActivatedElementInfo;
     40#endif
    3641
    3742namespace WebCore {
     
    137142
    138143    virtual bool shouldInterruptJavaScript(WebKit::WebPageProxy*) { return false; }
     144
     145#if PLATFORM(IOS)
     146    virtual RetainPtr<NSArray> actionsForElement(_WKActivatedElementInfo *, RetainPtr<NSArray> defaultActions) { return std::move(defaultActions); }
     147#endif
    139148};
    140149
  • trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h

    r166720 r166730  
    4949    void setDelegate(id <WKUIDelegate>);
    5050
    51     NSArray *actionsForElement(_WKActivatedElementInfo *, NSArray *defaultActions);
    52 
    5351private:
    5452    // API::UIClient
     
    5755    virtual void runJavaScriptConfirm(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*, std::function<void (bool)> completionHandler) override;
    5856    virtual void runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, WebKit::WebFrameProxy*, std::function<void (const WTF::String&)> completionHandler) override;
     57#if PLATFORM(IOS)
     58    virtual RetainPtr<NSArray> actionsForElement(_WKActivatedElementInfo *, RetainPtr<NSArray> defaultActions) override;
     59#endif
    5960
    6061    WKWebView *m_webView;
  • trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm

    r166720 r166730  
    6363    m_delegateMethods.webViewActionsForElementDefaultActions = [delegate respondsToSelector:@selector(_webView:actionsForElement:defaultActions:)];
    6464#endif
    65 }
    66 
    67 NSArray *UIClient::actionsForElement(_WKActivatedElementInfo *elementInfo, NSArray *defaultActions)
    68 {
    69 #if PLATFORM(IOS)
    70     if (!m_delegateMethods.webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler)
    71         return defaultActions;
    72 
    73     auto delegate = m_delegate.get();
    74     if (!delegate)
    75         return defaultActions;
    76 
    77     return [(id <WKUIDelegatePrivate>)delegate _webView:m_webView actionsForElement:elementInfo defaultActions:defaultActions];
    78 #endif
    79     return defaultActions;
    8065}
    8166
     
    164149}
    165150
     151#if PLATFORM(IOS)
     152RetainPtr<NSArray> UIClient::actionsForElement(_WKActivatedElementInfo *elementInfo, RetainPtr<NSArray> defaultActions)
     153{
     154    if (!m_delegateMethods.webViewActionsForElementDefaultActions)
     155        return std::move(defaultActions);
     156
     157    auto delegate = m_delegate.get();
     158    if (!delegate)
     159        return defaultActions;
     160
     161    return [(id <WKUIDelegatePrivate>)delegate _webView:m_webView actionsForElement:elementInfo defaultActions:defaultActions.get()];
     162}
     163#endif
     164
    166165} // namespace WebKit
    167166
  • trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm

    r166725 r166730  
    228228
    229229    NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
    230     NSMutableArray *defaultActions = [NSMutableArray array];
     230    auto defaultActions = adoptNS([[NSMutableArray alloc] init]);
    231231    if (!positionInformation.url.isEmpty())
    232232        [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeOpen]];
     
    238238        [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeCopy]];
    239239
    240     RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage
     240    auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage
    241241        URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds]);
    242242
    243     RetainPtr<NSArray> actions = static_cast<UIClient&>(_view.page->uiClient()).actionsForElement(elementInfo.get(), [[defaultActions copy] autorelease]);
     243    RetainPtr<NSArray> actions = _view.page->uiClient().actionsForElement(elementInfo.get(), std::move(defaultActions));
    244244
    245245    if (![actions count])
     
    267267        return;
    268268
    269     NSMutableArray *defaultActions = [NSMutableArray array];
     269    auto defaultActions = adoptNS([[NSMutableArray alloc] init]);
    270270    [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeOpen]];
    271271    if ([getSSReadingListClass() supportsURL:targetURL])
     
    277277        URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds]);
    278278
    279     RetainPtr<NSArray> actions = static_cast<UIClient&>(_view.page->uiClient()).actionsForElement(elementInfo.get(), [[defaultActions copy] autorelease]);
     279    RetainPtr<NSArray> actions = _view.page->uiClient().actionsForElement(elementInfo.get(), std::move(defaultActions));
    280280
    281281    if (![actions count])
Note: See TracChangeset for help on using the changeset viewer.