Title: [164094] trunk/Source/WebKit2
Revision
164094
Author
m...@apple.com
Date
2014-02-13 22:04:27 -0800 (Thu, 13 Feb 2014)

Log Message

[Cocoa] Expose the bundle form client
https://bugs.webkit.org/show_bug.cgi?id=128792

Reviewed by Anders Carlsson.

* WebKit2.xcodeproj/project.pbxproj: Added new file.
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h: Added.
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
(didFocusTextField): Implemented this WKBundlePageFormClient callback by calling the form
delegate.
(setUpFormClient): Added. Initializes the form client with the above function.
(-[WKWebProcessPlugInBrowserContextController _formDelegate]): Added this getter.
(-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]): Added. Initializes or
clears the form client.
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h:
Declared _formDelegate property.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (164093 => 164094)


--- trunk/Source/WebKit2/ChangeLog	2014-02-14 06:03:34 UTC (rev 164093)
+++ trunk/Source/WebKit2/ChangeLog	2014-02-14 06:04:27 UTC (rev 164094)
@@ -1,5 +1,24 @@
 2014-02-13  Dan Bernstein  <m...@apple.com>
 
+        [Cocoa] Expose the bundle form client
+        https://bugs.webkit.org/show_bug.cgi?id=128792
+
+        Reviewed by Anders Carlsson.
+
+        * WebKit2.xcodeproj/project.pbxproj: Added new file.
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h: Added.
+        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
+        (didFocusTextField): Implemented this WKBundlePageFormClient callback by calling the form
+        delegate.
+        (setUpFormClient): Added. Initializes the form client with the above function.
+        (-[WKWebProcessPlugInBrowserContextController _formDelegate]): Added this getter.
+        (-[WKWebProcessPlugInBrowserContextController _setFormDelegate:]): Added. Initializes or
+        clears the form client.
+        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h:
+        Declared _formDelegate property.
+
+2014-02-13  Dan Bernstein  <m...@apple.com>
+
         [Cocoa] Add a way to get the page from a frame in the injected bundle
         https://bugs.webkit.org/show_bug.cgi?id=128791
 

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (164093 => 164094)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-02-14 06:03:34 UTC (rev 164093)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-02-14 06:04:27 UTC (rev 164094)
@@ -598,6 +598,7 @@
 		37948404150C350600E52CE9 /* WebRenderLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 37948402150C350600E52CE9 /* WebRenderLayer.h */; };
 		37948408150C4B9700E52CE9 /* WKRenderLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37948406150C4B9600E52CE9 /* WKRenderLayer.cpp */; };
 		37948409150C4B9700E52CE9 /* WKRenderLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 37948407150C4B9600E52CE9 /* WKRenderLayer.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		3795789C18AD4F1900B9ED2E /* WKWebProcessPlugInFormDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 3795789B18AD4F1100B9ED2E /* WKWebProcessPlugInFormDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		37C4C08618149C5B003688B9 /* WKBackForwardListItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37C4C08418149C5B003688B9 /* WKBackForwardListItem.mm */; };
 		37C4C08718149C5B003688B9 /* WKBackForwardListItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C4C08518149C5B003688B9 /* WKBackForwardListItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		37C4C08918149F23003688B9 /* WKBackForwardListItemInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C4C08818149F23003688B9 /* WKBackForwardListItemInternal.h */; };
@@ -2308,6 +2309,7 @@
 		37948402150C350600E52CE9 /* WebRenderLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebRenderLayer.h; sourceTree = "<group>"; };
 		37948406150C4B9600E52CE9 /* WKRenderLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKRenderLayer.cpp; sourceTree = "<group>"; };
 		37948407150C4B9600E52CE9 /* WKRenderLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRenderLayer.h; sourceTree = "<group>"; };
+		3795789B18AD4F1100B9ED2E /* WKWebProcessPlugInFormDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInFormDelegatePrivate.h; sourceTree = "<group>"; };
 		37C4C08418149C5B003688B9 /* WKBackForwardListItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKBackForwardListItem.mm; sourceTree = "<group>"; };
 		37C4C08518149C5B003688B9 /* WKBackForwardListItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBackForwardListItem.h; sourceTree = "<group>"; };
 		37C4C08818149F23003688B9 /* WKBackForwardListItemInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBackForwardListItemInternal.h; sourceTree = "<group>"; };
@@ -4108,6 +4110,7 @@
 		1F0181681858DC1500F92884 /* Cocoa */ = {
 			isa = PBXGroup;
 			children = (
+				3795789B18AD4F1100B9ED2E /* WKWebProcessPlugInFormDelegatePrivate.h */,
 				1F0181691858DC1500F92884 /* WKWebProcessPlugInFrame.h */,
 				1F01816A1858DC1500F92884 /* WKWebProcessPlugInFrame.mm */,
 				1F01816B1858DC1500F92884 /* WKWebProcessPlugInFrameInternal.h */,
@@ -6795,6 +6798,7 @@
 				BC5C75C814954DA600BC4775 /* WKConnectionInternal.h in Headers */,
 				BC4A6297147313A0006C681A /* WKConnectionRef.h in Headers */,
 				BCB9E24B1120E15C00A137E0 /* WKContext.h in Headers */,
+				3795789C18AD4F1900B9ED2E /* WKWebProcessPlugInFormDelegatePrivate.h in Headers */,
 				51A555F6128C6C47009ABCEC /* WKContextMenuItem.h in Headers */,
 				51A55601128C6D92009ABCEC /* WKContextMenuItemTypes.h in Headers */,
 				1A15841A189044F50017616C /* WKProcessClass.h in Headers */,

Added: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h (0 => 164094)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h	2014-02-14 06:04:27 UTC (rev 164094)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebKit2/WKFoundation.h>
+
+#if WK_API_ENABLED
+
+#import <WebKit2/WKWebProcessPlugInBrowserContextController.h>
+#import <WebKit2/WKWebProcessPlugInFrame.h>
+#import <WebKit2/WKWebProcessPlugInNodeHandle.h>
+
+@protocol WKWebProcessPlugInFormDelegatePrivate <NSObject>
+
+@optional
+
+- (void)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didFocusTextField:(WKWebProcessPlugInNodeHandle *)textField inFrame:(WKWebProcessPlugInFrame *)frame;
+
+@end
+
+#endif // WK_API_ENABLED

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm (164093 => 164094)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm	2014-02-14 06:03:34 UTC (rev 164093)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm	2014-02-14 06:04:27 UTC (rev 164094)
@@ -42,7 +42,9 @@
 #import "WKURLRequestNS.h"
 #import "WKWebProcessPluginFrameInternal.h"
 #import "WKWebProcessPlugInInternal.h"
+#import "WKWebProcessPlugInFormDelegatePrivate.h"
 #import "WKWebProcessPlugInLoadDelegate.h"
+#import "WKWebProcessPlugInNodeHandleInternal.h"
 #import "WKWebProcessPlugInPageGroupInternal.h"
 #import "WKWebProcessPlugInScriptWorldInternal.h"
 #import "WeakObjCPtr.h"
@@ -57,6 +59,7 @@
 @implementation WKWebProcessPlugInBrowserContextController {
     API::ObjectStorage<WebPage> _page;
     WeakObjCPtr<id <WKWebProcessPlugInLoadDelegate>> _loadDelegate;
+    WeakObjCPtr<id <WKWebProcessPlugInFormDelegatePrivate>> _formDelegate;
     
     RetainPtr<WKRemoteObjectRegistry> _remoteObjectRegistry;
 }
@@ -203,6 +206,27 @@
     page.initializeInjectedBundleResourceLoadClient(&client.base);
 }
 
+static void didFocusTextField(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandleRef, WKBundleFrameRef frameRef, const void* clientInfo)
+{
+    WKWebProcessPlugInBrowserContextController *controller = (WKWebProcessPlugInBrowserContextController *)clientInfo;
+    auto formDelegate = controller->_formDelegate.get();
+
+    if ([formDelegate respondsToSelector:@selector(_webProcessPlugInBrowserContextController:didFocusTextField:inFrame:)])
+        [formDelegate _webProcessPlugInBrowserContextController:controller didFocusTextField:wrapper(*toImpl(htmlInputElementHandleRef)) inFrame:wrapper(*toImpl(frameRef))];
+}
+
+static void setUpFormClient(WKWebProcessPlugInBrowserContextController *contextController, WebPage& page)
+{
+    WKBundlePageFormClientV2 client;
+    memset(&client, 0, sizeof(client));
+
+    client.base.version = 2;
+    client.base.clientInfo = contextController;
+    client.didFocusTextField = didFocusTextField;
+
+    page.initializeInjectedBundleFormClient(&client.base);
+}
+
 - (id <WKWebProcessPlugInLoadDelegate>)loadDelegate
 {
     return _loadDelegate.getAutoreleased();
@@ -300,6 +324,21 @@
     return _remoteObjectRegistry.get();
 }
 
+- (id <WKWebProcessPlugInFormDelegatePrivate>)_formDelegate
+{
+    return _formDelegate.getAutoreleased();
+}
+
+- (void)_setFormDelegate:(id <WKWebProcessPlugInFormDelegatePrivate>)formDelegate
+{
+    _formDelegate = formDelegate;
+
+    if (formDelegate)
+        setUpFormClient(self, *_page);
+    else
+        _page->initializeInjectedBundleFormClient(nullptr);
+}
+
 @end
 
 #endif // WK_API_ENABLED

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h (164093 => 164094)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h	2014-02-14 06:03:34 UTC (rev 164093)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h	2014-02-14 06:04:27 UTC (rev 164094)
@@ -31,6 +31,7 @@
 
 @class WKBrowsingContextHandle;
 @class WKRemoteObjectRegistry;
+@protocol WKWebProcessPlugInFormDelegatePrivate;
 
 @interface WKWebProcessPlugInBrowserContextController (Private)
 
@@ -40,6 +41,8 @@
 
 @property (nonatomic, readonly) WKRemoteObjectRegistry *remoteObjectRegistry;
 
+@property (weak, setter=_setFormDelegate:) id <WKWebProcessPlugInFormDelegatePrivate> _formDelegate;
+
 + (instancetype)lookUpBrowsingContextFromHandle:(WKBrowsingContextHandle *)handle;
 
 @end
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to