More work on WKBrowsingContextHandle
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Nov 2013 20:22:36 +0000 (20:22 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Nov 2013 20:22:36 +0000 (20:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124060

Reviewed by Beth Dakin.

Implement -hash and -isEqual: and add -[WKWebProcessPlugInBrowserContextController handle].

* Shared/API/Cocoa/WKBrowsingContextHandle.mm:
(-[WKBrowsingContextHandle hash]):
(-[WKBrowsingContextHandle isEqual:]):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
(decodeInvocation):
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
(-[WKWebProcessPlugInBrowserContextController mainFrameDocument]):
(-[WKWebProcessPlugInBrowserContextController selectedRange]):
(-[WKWebProcessPlugInBrowserContextController handle]):
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerInternal.h:
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158939 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/Cocoa/WKBrowsingContextHandle.mm
Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerInternal.h
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h

index ce3bfd2..733ae25 100644 (file)
@@ -1,5 +1,26 @@
 2013-11-08  Anders Carlsson  <andersca@apple.com>
 
+        More work on WKBrowsingContextHandle
+        https://bugs.webkit.org/show_bug.cgi?id=124060
+
+        Reviewed by Beth Dakin.
+
+        Implement -hash and -isEqual: and add -[WKWebProcessPlugInBrowserContextController handle].
+
+        * Shared/API/Cocoa/WKBrowsingContextHandle.mm:
+        (-[WKBrowsingContextHandle hash]):
+        (-[WKBrowsingContextHandle isEqual:]):
+        * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
+        (decodeInvocation):
+        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
+        (-[WKWebProcessPlugInBrowserContextController mainFrameDocument]):
+        (-[WKWebProcessPlugInBrowserContextController selectedRange]):
+        (-[WKWebProcessPlugInBrowserContextController handle]):
+        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerInternal.h:
+        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextControllerPrivate.h:
+
+2013-11-08  Anders Carlsson  <andersca@apple.com>
+
         Add A WKBrowsingContextHandle class
         https://bugs.webkit.org/show_bug.cgi?id=124058
 
index dfe2e4a..e74002e 100644 (file)
     return self;
 }
 
+- (NSUInteger)hash
+{
+    return _pageID;
+}
+
+- (BOOL)isEqual:(id)object
+{
+    if (![object isKindOfClass:[WKBrowsingContextHandle class]])
+        return NO;
+
+    return _pageID == static_cast<WKBrowsingContextHandle *>(object)->_pageID;
+}
+
 - (void)encodeWithCoder:(NSCoder *)coder
 {
     [coder encodeInt64:_pageID forKey:@"pageID"];
index 3625512..9c9b7b6 100644 (file)
@@ -420,7 +420,7 @@ static NSInvocation *decodeInvocation(WKRemoteObjectDecoder *decoder)
         [NSException raise:NSInvalidUnarchiveOperationException format:@"Invocation had no type signature"];
 
     NSMethodSignature *remoteMethodSignature = [NSMethodSignature signatureWithObjCTypes:typeSignature.UTF8String];
-    if (![localMethodSignature isEqualTo:remoteMethodSignature])
+    if (![localMethodSignature isEqual:remoteMethodSignature])
         [NSException raise:NSInvalidUnarchiveOperationException format:@"Local and remote method signatures are not equal for method \"%@\"", selectorString];
 
     NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:localMethodSignature];
index e805ce0..1ddba7e 100644 (file)
 
 #import "config.h"
 
-#import "WKWebProcessPlugInBrowserContextController.h"
 #import "WKWebProcessPlugInBrowserContextControllerInternal.h"
-#import "WKWebProcessPlugInBrowserContextControllerPrivate.h"
 
 #if WK_API_ENABLED
 
+#import "WKBrowsingContextHandleInternal.h"
 #import "WKBundleAPICast.h"
 #import "WKBundlePage.h"
 #import "WKBundlePagePrivate.h"
 #import <WebCore/Document.h>
 #import <WebCore/Frame.h>
 
-@interface WKWebProcessPlugInBrowserContextController () {
-    // Underlying WKBundlePageRef.
+using namespace WebCore;
+using namespace WebKit;
+
+@implementation WKWebProcessPlugInBrowserContextController {
     WKRetainPtr<WKBundlePageRef> _bundlePageRef;
 }
-@end
-
-@implementation WKWebProcessPlugInBrowserContextController (Internal)
 
 - (id)_initWithBundlePageRef:(WKBundlePageRef)bundlePageRef
 {
     return self;
 }
 
-@end
-
-@implementation WKWebProcessPlugInBrowserContextController
-
 - (WKDOMDocument *)mainFrameDocument
 {
-    WebCore::Frame* webCoreMainFrame = WebKit::toImpl(self._bundlePageRef)->mainFrame();
+    WebCore::Frame* webCoreMainFrame = toImpl(_bundlePageRef.get())->mainFrame();
     if (!webCoreMainFrame)
         return nil;
 
-    return WebKit::toWKDOMDocument(webCoreMainFrame->document());
+    return toWKDOMDocument(webCoreMainFrame->document());
 }
 
 - (WKDOMRange *)selectedRange
 {
-    RefPtr<WebCore::Range> range = WebKit::toImpl(self._bundlePageRef)->currentSelectionAsRange();
+    RefPtr<WebCore::Range> range = toImpl(_bundlePageRef.get())->currentSelectionAsRange();
     if (!range)
         return nil;
 
-    return WebKit::toWKDOMRange(range.get());
+    return toWKDOMRange(range.get());
 }
 
 @end
     return _bundlePageRef.get();
 }
 
+- (WKBrowsingContextHandle *)handle
+{
+    return [[[WKBrowsingContextHandle alloc] _initWithPageID:toImpl(_bundlePageRef.get())->pageID()] autorelease];
+}
+
 @end
 
 #endif // WK_API_ENABLED
index 29265bd..8697b1d 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "WKWebProcessPlugInBrowserContextController.h"
+#import "WKWebProcessPlugInBrowserContextControllerPrivate.h"
 #import "WKBase.h"
 
 #if WK_API_ENABLED
 
-@interface WKWebProcessPlugInBrowserContextController (Internal)
+@interface WKWebProcessPlugInBrowserContextController ()
 
 - (id)_initWithBundlePageRef:(WKBundlePageRef)bundlePageRef;
 
index 8b15700..8b830d3 100644 (file)
 
 #if WK_API_ENABLED
 
+#import <WebKit2/WKBase.h>
+
+@class WKBrowsingContextHandle;
+
 @interface WKWebProcessPlugInBrowserContextController (Private)
 
-@property(readonly) WKBundlePageRef _bundlePageRef;
+@property (nonatomic, readonly) WKBundlePageRef _bundlePageRef;
+
+@property (nonatomic, readonly) WKBrowsingContextHandle *handle;
 
 @end