Title: [160245] trunk/Source/WebKit2
Revision
160245
Author
[email protected]
Date
2013-12-06 13:40:34 -0800 (Fri, 06 Dec 2013)

Log Message

<rdar://problem/15606872> REGRESSION (r160148): Mail throws an exception during launch
https://bugs.webkit.org/show_bug.cgi?id=125362

Reviewed by Sam Weinig.

There were two problems in how WKConnection was made to work with WKObject: first,
API::Object::newObject() was not updated to allocate the correct wrapper class, and second,
WebConnection has subclasses with additional data members, which don’t fit in the object
storage ivar.

* Shared/Cocoa/APIObject.mm:
(API::Object::newObject): Changed to allocate a WKConnection of the required size.
* UIProcess/API/Cocoa/WKConnection.mm:
Removed _connection ivar.
(-[WKConnection dealloc]): Changed to use -_connection accessor instead of ivar.
(-[WKConnection setDelegate:]): Ditto.
(-[WKConnection sendMessageWithName:body:]): Ditto.
(-[WKConnection remoteObjectRegistry]): Ditto.
(-[WKConnection _connection]): Added.
(-[WKConnection _apiObject]): Changed to return the object in the instance extra storage.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (160244 => 160245)


--- trunk/Source/WebKit2/ChangeLog	2013-12-06 21:38:26 UTC (rev 160244)
+++ trunk/Source/WebKit2/ChangeLog	2013-12-06 21:40:34 UTC (rev 160245)
@@ -1,5 +1,28 @@
 2013-12-06  Dan Bernstein  <[email protected]>
 
+        <rdar://problem/15606872> REGRESSION (r160148): Mail throws an exception during launch
+        https://bugs.webkit.org/show_bug.cgi?id=125362
+
+        Reviewed by Sam Weinig.
+
+        There were two problems in how WKConnection was made to work with WKObject: first,
+        API::Object::newObject() was not updated to allocate the correct wrapper class, and second,
+        WebConnection has subclasses with additional data members, which don’t fit in the object
+        storage ivar.
+
+        * Shared/Cocoa/APIObject.mm:
+        (API::Object::newObject): Changed to allocate a WKConnection of the required size.
+        * UIProcess/API/Cocoa/WKConnection.mm:
+        Removed _connection ivar.
+        (-[WKConnection dealloc]): Changed to use -_connection accessor instead of ivar.
+        (-[WKConnection setDelegate:]): Ditto.
+        (-[WKConnection sendMessageWithName:body:]): Ditto.
+        (-[WKConnection remoteObjectRegistry]): Ditto.
+        (-[WKConnection _connection]): Added.
+        (-[WKConnection _apiObject]): Changed to return the object in the instance extra storage.
+
+2013-12-06  Dan Bernstein  <[email protected]>
+
         [Cocoa] Add load delegate methods for responding to authentication challenges
         https://bugs.webkit.org/show_bug.cgi?id=125333
 

Modified: trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm (160244 => 160245)


--- trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm	2013-12-06 21:38:26 UTC (rev 160244)
+++ trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm	2013-12-06 21:40:34 UTC (rev 160245)
@@ -33,6 +33,7 @@
 #import "WKBrowsingContextControllerInternal.h"
 #import "WKBrowsingContextGroupInternal.h"
 #import "WKNSArray.h"
+#import "WKConnectionInternal.h"
 #import "WKNSDictionary.h"
 #import "WKNSError.h"
 #import "WKNSString.h"
@@ -79,6 +80,10 @@
         wrapper = [WKBackForwardListItem alloc];
         break;
 
+    case Type::Connection:
+        wrapper = NSAllocateObject([WKConnection self], size, nullptr);
+        break;
+
     case Type::Context:
         wrapper = [WKProcessGroup alloc];
         break;

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKConnection.mm (160244 => 160245)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKConnection.mm	2013-12-06 21:38:26 UTC (rev 160244)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKConnection.mm	2013-12-06 21:40:34 UTC (rev 160245)
@@ -40,15 +40,13 @@
 using namespace WebKit;
 
 @implementation WKConnection {
-    API::ObjectStorage<WebConnection> _connection;
     RetainPtr<WKRemoteObjectRegistry> _remoteObjectRegistry;
-
     WeakObjCPtr<id <WKConnectionDelegate>> _delegate;
 }
 
 - (void)dealloc
 {
-    _connection->~WebConnection();
+    self._connection.~WebConnection();
 
     [super dealloc];
 }
@@ -98,30 +96,35 @@
 {
     _delegate = delegate;
     if (delegate)
-        setUpClient(self, *_connection);
+        setUpClient(self, self._connection);
     else
-        _connection->initializeConnectionClient(nullptr);
+        self._connection.initializeConnectionClient(nullptr);
 }
 
 - (void)sendMessageWithName:(NSString *)messageName body:(id)messageBody
 {
     RefPtr<ObjCObjectGraph> wkMessageBody = ObjCObjectGraph::create(messageBody);
-    _connection->postMessage(messageName, wkMessageBody.get());
+    self._connection.postMessage(messageName, wkMessageBody.get());
 }
 
 - (WKRemoteObjectRegistry *)remoteObjectRegistry
 {
     if (!_remoteObjectRegistry)
-        _remoteObjectRegistry = adoptNS([[WKRemoteObjectRegistry alloc] _initWithConnectionRef:toAPI(_connection.get())]);
+        _remoteObjectRegistry = adoptNS([[WKRemoteObjectRegistry alloc] _initWithConnectionRef:toAPI(&self._connection)]);
 
     return _remoteObjectRegistry.get();
 }
 
+- (WebConnection&)_connection
+{
+    return *static_cast<WebConnection*>(object_getIndexedIvars(self));
+}
+
 #pragma mark WKObject protocol implementation
 
 - (API::Object&)_apiObject
 {
-    return *_connection;
+    return *static_cast<API::Object*>(object_getIndexedIvars(self));
 }
 
 @end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to