Changeset 166900 in webkit


Ignore:
Timestamp:
Apr 7, 2014, 5:39:55 PM (11 years ago)
Author:
mitz@apple.com
Message:

Add bundle client function corresponding to startAssistingNode
https://bugs.webkit.org/show_bug.cgi?id=131332

Reviewed by Anders Carlsson.

  • UIProcess/PageClient.h: Added userData parameter to startAssistingNode.
  • UIProcess/WebPageProxy.h: Added message decoder parameter to startAssistingNode.
  • UIProcess/WebPageProxy.messages.in: Added message decoder parameter to StartAssistingNode.
  • UIProcess/ios/PageClientImplIOS.h: Updated startAssistingNode override.
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::startAssistingNode): Decode the user data into an NSObject and pass
it on to the content view.

  • UIProcess/ios/WKContentViewInteraction.h: Added userObject parameter to

-_startAssitingNode:.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _startAssistingNode:userObject:]): Added userObject parameter. We will pass
it to a future delegate method.

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::startAssistingNode): Decode the user data and pass it to the client.

  • WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h: Declared new

delegate method.

  • WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:

(-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]): Added an implementation
of API::InjectedBundle::FormClient::willBeginInputSession which calls the new delegate
method, and encodes the user object into userData.

  • WebProcess/InjectedBundle/APIInjectedBundleFormClient.h:

(API::InjectedBundle::FormClient::willBeginInputSession): Added willBeginInputSession.

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::elementDidFocus): Call willBeginInputSession and send the user data along
with the StartAssistingNode message to the UI process.

Location:
trunk/Source/WebKit2
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r166899 r166900  
     12014-04-07  Dan Bernstein  <mitz@apple.com>
     2
     3        Add bundle client function corresponding to startAssistingNode
     4        https://bugs.webkit.org/show_bug.cgi?id=131332
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * UIProcess/PageClient.h: Added userData parameter to startAssistingNode.
     9
     10        * UIProcess/WebPageProxy.h: Added message decoder parameter to startAssistingNode.
     11        * UIProcess/WebPageProxy.messages.in: Added message decoder parameter to StartAssistingNode.
     12
     13        * UIProcess/ios/PageClientImplIOS.h: Updated startAssistingNode override.
     14        * UIProcess/ios/PageClientImplIOS.mm:
     15        (WebKit::PageClientImpl::startAssistingNode): Decode the user data into an NSObject and pass
     16        it on to the content view.
     17
     18        * UIProcess/ios/WKContentViewInteraction.h: Added userObject parameter to
     19        -_startAssitingNode:.
     20        * UIProcess/ios/WKContentViewInteraction.mm:
     21        (-[WKContentView _startAssistingNode:userObject:]): Added userObject parameter. We will pass
     22        it to a future delegate method.
     23
     24        * UIProcess/ios/WebPageProxyIOS.mm:
     25        (WebKit::WebPageProxy::startAssistingNode): Decode the user data and pass it to the client.
     26
     27        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h: Declared new
     28        delegate method.
     29        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
     30        (-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]): Added an implementation
     31        of API::InjectedBundle::FormClient::willBeginInputSession which calls the new delegate
     32        method, and encodes the user object into userData.
     33
     34        * WebProcess/InjectedBundle/APIInjectedBundleFormClient.h:
     35        (API::InjectedBundle::FormClient::willBeginInputSession): Added willBeginInputSession.
     36
     37        * WebProcess/WebPage/ios/WebPageIOS.mm:
     38        (WebKit::WebPage::elementDidFocus): Call willBeginInputSession and send the user data along
     39        with the StartAssistingNode message to the UI process.
     40
    1412014-04-07  Jinwoo Song  <jinwoo7.song@samsung.com>
    242
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r166466 r166900  
    241241    virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&) = 0;
    242242
    243     virtual void startAssistingNode(const AssistedNodeInformation&) = 0;
     243    virtual void startAssistingNode(const AssistedNodeInformation&, API::Object* userData) = 0;
    244244    virtual void stopAssistingNode() = 0;
    245245    virtual void selectionDidChange() = 0;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r166888 r166900  
    13361336    void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color& color, const Vector<WebCore::FloatQuad>& geometries, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius);
    13371337
    1338     void startAssistingNode(const AssistedNodeInformation&);
     1338    void startAssistingNode(const AssistedNodeInformation&, IPC::MessageDecoder&);
    13391339    void stopAssistingNode();
    13401340
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r166888 r166900  
    319319    DidGetTapHighlightGeometries(uint64_t requestID, WebCore::Color color, Vector<WebCore::FloatQuad> geometries, WebCore::IntSize topLeftRadius, WebCore::IntSize topRightRadius, WebCore::IntSize bottomLeftRadius, WebCore::IntSize bottomRightRadius)
    320320
    321     StartAssistingNode(WebKit::AssistedNodeInformation information)
     321    StartAssistingNode(WebKit::AssistedNodeInformation information, WebKit::InjectedBundleUserMessageEncoder userData) Variadic
    322322    StopAssistingNode()
    323323    NotifyRevealedSelection()
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h

    r166466 r166900  
    108108    virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&) override;
    109109
    110     virtual void startAssistingNode(const AssistedNodeInformation&) override;
     110    virtual void startAssistingNode(const AssistedNodeInformation&, API::Object* userData) override;
    111111    virtual void stopAssistingNode() override;
    112112    virtual void selectionDidChange() override;
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm

    r166861 r166900  
    2929#if PLATFORM(IOS)
    3030
    31 #import "_WKDownloadInternal.h"
     31#import "APIData.h"
    3232#import "DataReference.h"
    3333#import "DownloadProxy.h"
     
    4040#import "WebContextMenuProxy.h"
    4141#import "WebEditCommandProxy.h"
     42#import "WebProcessProxy.h"
     43#import "_WKDownloadInternal.h"
    4244#import <UIKit/UIImagePickerController_Private.h>
    4345#import <UIKit/UIWebTouchEventsGestureRecognizer.h>
     
    4648#import <WebCore/SharedBuffer.h>
    4749
     50#define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_webView->_page->process().connection())
     51
    4852@interface UIView (IPI)
    4953- (UIScrollView *)_scroller;
     
    359363}
    360364
    361 void PageClientImpl::startAssistingNode(const AssistedNodeInformation& nodeInformation)
    362 {
    363     [m_contentView _startAssistingNode:nodeInformation];
     365void PageClientImpl::startAssistingNode(const AssistedNodeInformation& nodeInformation, API::Object* userData)
     366{
     367    MESSAGE_CHECK(!userData || userData->type() == API::Object::Type::Data);
     368
     369    NSObject <NSSecureCoding> *userObject = nil;
     370    if (API::Data* data = static_cast<API::Data*>(userData)) {
     371        auto nsData = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(data->bytes())) length:data->size() freeWhenDone:NO]);
     372        auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:nsData.get()]);
     373        [unarchiver setRequiresSecureCoding:YES];
     374        @try {
     375            userObject = [unarchiver decodeObjectOfClass:[NSObject class] forKey:@"userObject"];
     376        } @catch (NSException *exception) {
     377            LOG_ERROR("Failed to decode user data: %@", exception);
     378        }
     379    }
     380
     381    [m_contentView _startAssistingNode:nodeInformation userObject:userObject];
    364382}
    365383
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r166861 r166900  
    130130- (void)_didGetTapHighlightForRequest:(uint64_t)requestID color:(const WebCore::Color&)color quads:(const Vector<WebCore::FloatQuad>&)highlightedQuads topLeftRadius:(const WebCore::IntSize&)topLeftRadius topRightRadius:(const WebCore::IntSize&)topRightRadius bottomLeftRadius:(const WebCore::IntSize&)bottomLeftRadius bottomRightRadius:(const WebCore::IntSize&)bottomRightRadius;
    131131
    132 - (void)_startAssistingNode:(const WebKit::AssistedNodeInformation&)information;
     132- (void)_startAssistingNode:(const WebKit::AssistedNodeInformation&)information userObject:(NSObject <NSSecureCoding> *)userObject;
    133133- (void)_stopAssistingNode;
    134134- (void)_selectionChanged;
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r166861 r166900  
    18751875}
    18761876
    1877 - (void)_startAssistingNode:(const AssistedNodeInformation&)information
     1877- (void)_startAssistingNode:(const AssistedNodeInformation&)information userObject:(NSObject <NSSecureCoding> *)userObject
    18781878{
    18791879    _isEditable = YES;
  • trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm

    r166431 r166900  
    3636#import "ViewUpdateDispatcherMessages.h"
    3737#import "WKBrowsingContextControllerInternal.h"
     38#import "WebContextUserMessageCoders.h"
    3839#import "WebKitSystemInterfaceIOS.h"
    3940#import "WebPageMessages.h"
     
    463464}
    464465
    465 void WebPageProxy::startAssistingNode(const AssistedNodeInformation& information)
    466 {
    467     m_pageClient.startAssistingNode(information);
     466void WebPageProxy::startAssistingNode(const AssistedNodeInformation& information, IPC::MessageDecoder& decoder)
     467{
     468    RefPtr<API::Object> userData;
     469    WebContextUserMessageDecoder messageDecoder(userData, process());
     470    if (!decoder.decode(messageDecoder))
     471        return;
     472
     473    m_pageClient.startAssistingNode(information, userData.get());
    468474}
    469475
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h

    r166433 r166900  
    3838- (void)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didFocusTextField:(WKWebProcessPlugInNodeHandle *)textField inFrame:(WKWebProcessPlugInFrame *)frame;
    3939- (void)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller willSubmitForm:(WKWebProcessPlugInNodeHandle *)form toFrame:(WKWebProcessPlugInFrame *)frame fromFrame:(WKWebProcessPlugInFrame *)sourceFrame withValues:(NSDictionary *)values;
     40- (NSObject <NSSecureCoding> *)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller willBeginInputSessionForElement:(WKWebProcessPlugInNodeHandle *)node inFrame:(WKWebProcessPlugInFrame *)frame;
    4041
    4142@end
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm

    r166890 r166900  
    2929#if WK_API_ENABLED
    3030
     31#import "APIData.h"
    3132#import "RemoteObjectRegistry.h"
    3233#import "RemoteObjectRegistryMessages.h"
     
    406407        }
    407408
     409        static void releaseNSData(unsigned char*, const void* untypedData)
     410        {
     411            [(NSData *)untypedData release];
     412        }
     413
     414        virtual void willBeginInputSession(WebPage*, Element* element, WebFrame* frame, RefPtr<API::Object>& userData) override
     415        {
     416            auto formDelegate = m_controller->_formDelegate.get();
     417
     418            if (![formDelegate respondsToSelector:@selector(_webProcessPlugInBrowserContextController:willBeginInputSessionForElement:inFrame:)])
     419                return;
     420
     421            NSObject <NSSecureCoding> *userObject = [formDelegate _webProcessPlugInBrowserContextController:m_controller willBeginInputSessionForElement:wrapper(*WebKit::InjectedBundleNodeHandle::getOrCreate(element)) inFrame:wrapper(*frame)];
     422            if (!userObject)
     423                return;
     424
     425            auto data = adoptNS([[NSMutableData alloc] init]);
     426            auto archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
     427            [archiver setRequiresSecureCoding:YES];
     428            @try {
     429                [archiver encodeObject:userObject forKey:@"userObject"];
     430            } @catch (NSException *exception) {
     431                LOG_ERROR("Failed to encode user object: %@", exception);
     432                return;
     433            }
     434            [archiver finishEncoding];
     435
     436            userData = API::Data::createWithoutCopying((const unsigned char*)[data bytes], [data length], releaseNSData, data.leakRef()).leakRef();
     437        }
     438
    408439    private:
    409440        WKWebProcessPlugInBrowserContextController *m_controller;
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/APIInjectedBundleFormClient.h

    r166890 r166900  
    7373    virtual void didAssociateFormControls(WebKit::WebPage*, const Vector<RefPtr<WebCore::Element>>&) { }
    7474    virtual bool shouldNotifyOnFormChanges(WebKit::WebPage*) { return false; }
     75    virtual void willBeginInputSession(WebKit::WebPage*, WebCore::Element*, WebKit::WebFrame*, RefPtr<API::Object>& userData) { UNUSED_PARAM(userData); }
    7576};
    7677
  • trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm

    r166861 r166900  
    3434#import "EditorState.h"
    3535#import "GestureTypes.h"
     36#import "InjectedBundleUserMessageCoders.h"
    3637#import "InteractionInformationAtPosition.h"
    3738#import "LayerTreeHost.h"
     
    16861687        AssistedNodeInformation information;
    16871688        getAssistedNodeInformation(information);
    1688         send(Messages::WebPageProxy::StartAssistingNode(information));
     1689        RefPtr<API::Object> userData;
     1690        m_formClient->willBeginInputSession(this, toElement(node), WebFrame::fromCoreFrame(*node->document().frame()), userData);
     1691        send(Messages::WebPageProxy::StartAssistingNode(information, InjectedBundleUserMessageEncoder(userData.get())));
    16891692    }
    16901693}
Note: See TracChangeset for help on using the changeset viewer.