Diff
Modified: trunk/Source/WebKit2/ChangeLog (159823 => 159824)
--- trunk/Source/WebKit2/ChangeLog 2013-11-27 21:03:51 UTC (rev 159823)
+++ trunk/Source/WebKit2/ChangeLog 2013-11-27 22:48:32 UTC (rev 159824)
@@ -1,3 +1,56 @@
+2013-11-27 Sam Weinig <s...@webkit.org>
+
+ Make WKBrowsingContextGroup work with WKObject wrapping
+ https://bugs.webkit.org/show_bug.cgi?id=124948
+
+ Reviewed by Dan Bernstein.
+
+ - Adds mechanism to use the inline data wrapping mechanism when the Objective-C wrapper is created
+ by the caller (rather than by Object::newObject).
+ - Adopts the mechanism for WKBrowsingContextGroup.
+
+ * Shared/APIObject.h:
+ (API::Object::constructInWrapper):
+ Add a helper which does a forwarding placement-new into the API::Object of the passed in wrapper, after which it sets up m_wrapper.
+
+ (API::TypedObject::operator new):
+ Add a operator new to for placement-new. Also make TypedObject friends with Object so that constructInWrapper can call this.
+
+ * Shared/Cocoa/APIObject.mm:
+ (API::Object::newObject):
+ Add support for WKBrowsingContextGroup.
+
+ * UIProcess/API/mac/WKBrowsingContextGroup.mm:
+ (-[WKBrowsingContextGroup API::]):
+ (-[WKBrowsingContextGroup dealloc]):
+ (-[WKBrowsingContextGroup initWithIdentifier:]):
+ (-[WKBrowsingContextGroup allowsJavaScript]):
+ (-[WKBrowsingContextGroup setAllowsJavaScript:]):
+ (-[WKBrowsingContextGroup allowsJavaScriptMarkup]):
+ (-[WKBrowsingContextGroup setAllowsJavaScriptMarkup:]):
+ (-[WKBrowsingContextGroup allowsPlugIns]):
+ (-[WKBrowsingContextGroup setAllowsPlugIns:]):
+ (-[WKBrowsingContextGroup addUserStyleSheet:baseURL:whitelistedURLPatterns:blacklistedURLPatterns:mainFrameOnly:]):
+ (-[WKBrowsingContextGroup removeAllUserStyleSheets]):
+ (-[WKBrowsingContextGroup addUserScript:baseURL:whitelistedURLPatterns:blacklistedURLPatterns:injectionTime:mainFrameOnly:]):
+ (-[WKBrowsingContextGroup removeAllUserScripts]):
+ (-[WKBrowsingContextGroup _pageGroupRef]):
+ Convert from wrapping the C-SPI type to storing the bits of the wrapped object inline (modeled on WKBackForwardList).
+
+ * UIProcess/API/mac/WKBrowsingContextGroupInternal.h: Added.
+ (WebKit::wrapper):
+ Add wrapper() helper and declare conformance to the WKObject protocol.
+
+ * UIProcess/WebPageGroup.cpp:
+ (WebKit::WebPageGroup::create):
+ (WebKit::WebPageGroup::WebPageGroup):
+ * UIProcess/WebPageGroup.h:
+ Make the WebPageGroup constructor public (for use with Object::constructInWrapper) and move being set in the webPageGroupMap()
+ to the constructor.
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ Add new file.
+
2013-11-27 Nick Diego Yamane <nick.yam...@openbossa.org>
Remove Qt-specific .qrc files
Modified: trunk/Source/WebKit2/Shared/APIObject.h (159823 => 159824)
--- trunk/Source/WebKit2/Shared/APIObject.h 2013-11-27 21:03:51 UTC (rev 159823)
+++ trunk/Source/WebKit2/Shared/APIObject.h 2013-11-27 22:48:32 UTC (rev 159824)
@@ -30,7 +30,10 @@
#if PLATFORM(MAC)
#include "WKFoundation.h"
+#ifdef __OBJC__
+#include "WKObject.h"
#endif
+#endif
#define DELEGATE_REF_COUNTING_TO_COCOA (PLATFORM(MAC) && WK_API_ENABLED)
@@ -165,6 +168,15 @@
virtual Type type() const = 0;
#if DELEGATE_REF_COUNTING_TO_COCOA
+#ifdef __OBJC__
+ template<typename T, typename... Args>
+ static void constructInWrapper(NSObject <WKObject> *wrapper, Args&&... args)
+ {
+ Object* object = new (&wrapper._apiObject) T(std::forward<Args>(args)...);
+ object->m_wrapper = wrapper;
+ }
+#endif
+
NSObject *wrapper() { return m_wrapper; }
void ref();
@@ -195,6 +207,8 @@
}
protected:
+ friend Object;
+
TypedObject()
{
}
@@ -203,6 +217,7 @@
#if DELEGATE_REF_COUNTING_TO_COCOA
void* operator new(size_t size) { return newObject(size, APIType); }
+ void* operator new(size_t size, void* value) { return value; }
#endif
};
Modified: trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm (159823 => 159824)
--- trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm 2013-11-27 21:03:51 UTC (rev 159823)
+++ trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm 2013-11-27 22:48:32 UTC (rev 159824)
@@ -30,6 +30,7 @@
#import "WKBackForwardListInternal.h"
#import "WKBackForwardListItemInternal.h"
+#import "WKBrowsingContextGroupInternal.h"
#import "WKNSArray.h"
#import "WKNSDictionary.h"
#import "WKNSError.h"
@@ -82,6 +83,10 @@
wrapper = [WKNavigationData alloc];
break;
+ case Type::PageGroup:
+ wrapper = [WKBrowsingContextGroup alloc];
+ break;
+
case Type::String:
wrapper = NSAllocateObject([WKNSString class], size, nullptr);
break;
@@ -95,11 +100,12 @@
break;
}
- Object* object = &wrapper._apiObject;
- object->m_wrapper = wrapper;
- return object;
+ Object& object = wrapper._apiObject;
+ object.m_wrapper = wrapper;
+
+ return &object;
}
-} // namespace WebKit
+} // namespace API
#endif // WK_API_ENABLED
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.mm (159823 => 159824)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.mm 2013-11-27 21:03:51 UTC (rev 159823)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.mm 2013-11-27 22:48:32 UTC (rev 159824)
@@ -24,6 +24,7 @@
*/
#import "config.h"
+#import "WKBrowsingContextGroupInternal.h"
#import "WKBrowsingContextGroupPrivate.h"
#if WK_API_ENABLED
@@ -43,54 +44,61 @@
using namespace WebKit;
@implementation WKBrowsingContextGroup {
- WKRetainPtr<WKPageGroupRef> _pageGroupRef;
+ std::aligned_storage<sizeof(WebPageGroup), std::alignment_of<WebPageGroup>::value>::type _pageGroup;
}
+- (void)dealloc
+{
+ reinterpret_cast<WebPageGroup*>(&_pageGroup)->~WebPageGroup();
+
+ [super dealloc];
+}
+
- (id)initWithIdentifier:(NSString *)identifier
{
self = [super init];
if (!self)
return nil;
- _pageGroupRef = adoptWK(WKPageGroupCreateWithIdentifier(adoptWK(WKStringCreateWithCFString((CFStringRef)identifier)).get()));
+ API::Object::constructInWrapper<WebPageGroup>(self, identifier);
// Give the WKBrowsingContextGroup a identifier-less preferences, so that they
// don't get automatically written to the disk. The automatic writing has proven
// confusing to users of the API.
WKRetainPtr<WKPreferencesRef> preferences = adoptWK(WKPreferencesCreate());
- WKPageGroupSetPreferences(_pageGroupRef.get(), preferences.get());
+ WKPageGroupSetPreferences(toAPI(reinterpret_cast<WebPageGroup*>(&_pageGroup)), preferences.get());
return self;
}
- (BOOL)allowsJavaScript
{
- return WKPreferencesGetJavaScriptEnabled(WKPageGroupGetPreferences(_pageGroupRef.get()));
+ return WKPreferencesGetJavaScriptEnabled(WKPageGroupGetPreferences(toAPI(reinterpret_cast<WebPageGroup*>(&_pageGroup))));
}
- (void)setAllowsJavaScript:(BOOL)allowsJavaScript
{
- WKPreferencesSetJavaScriptEnabled(WKPageGroupGetPreferences(_pageGroupRef.get()), allowsJavaScript);
+ WKPreferencesSetJavaScriptEnabled(WKPageGroupGetPreferences(toAPI(reinterpret_cast<WebPageGroup*>(&_pageGroup))), allowsJavaScript);
}
- (BOOL)allowsJavaScriptMarkup
{
- return WKPreferencesGetJavaScriptMarkupEnabled(WKPageGroupGetPreferences(_pageGroupRef.get()));
+ return WKPreferencesGetJavaScriptMarkupEnabled(WKPageGroupGetPreferences(toAPI(reinterpret_cast<WebPageGroup*>(&_pageGroup))));
}
- (void)setAllowsJavaScriptMarkup:(BOOL)allowsJavaScriptMarkup
{
- WKPreferencesSetJavaScriptMarkupEnabled(WKPageGroupGetPreferences(_pageGroupRef.get()), allowsJavaScriptMarkup);
+ WKPreferencesSetJavaScriptMarkupEnabled(WKPageGroupGetPreferences(toAPI(reinterpret_cast<WebPageGroup*>(&_pageGroup))), allowsJavaScriptMarkup);
}
- (BOOL)allowsPlugIns
{
- return WKPreferencesGetPluginsEnabled(WKPageGroupGetPreferences(_pageGroupRef.get()));
+ return WKPreferencesGetPluginsEnabled(WKPageGroupGetPreferences(toAPI(reinterpret_cast<WebPageGroup*>(&_pageGroup))));
}
- (void)setAllowsPlugIns:(BOOL)allowsPlugIns
{
- WKPreferencesSetPluginsEnabled(WKPageGroupGetPreferences(_pageGroupRef.get()), allowsPlugIns);
+ WKPreferencesSetPluginsEnabled(WKPageGroupGetPreferences(toAPI(reinterpret_cast<WebPageGroup*>(&_pageGroup))), allowsPlugIns);
}
static WKRetainPtr<WKArrayRef> createWKArray(NSArray *array)
@@ -122,12 +130,12 @@
auto wkBlacklist = createWKArray(blacklist);
WKUserContentInjectedFrames injectedFrames = mainFrameOnly ? kWKInjectInTopFrameOnly : kWKInjectInAllFrames;
- WKPageGroupAddUserStyleSheet(_pageGroupRef.get(), wkSource.get(), wkBaseURL.get(), wkWhitelist.get(), wkBlacklist.get(), injectedFrames);
+ WKPageGroupAddUserStyleSheet(toAPI(reinterpret_cast<WebPageGroup*>(&_pageGroup)), wkSource.get(), wkBaseURL.get(), wkWhitelist.get(), wkBlacklist.get(), injectedFrames);
}
- (void)removeAllUserStyleSheets
{
- WKPageGroupRemoveAllUserStyleSheets(_pageGroupRef.get());
+ WKPageGroupRemoveAllUserStyleSheets(toAPI(reinterpret_cast<WebPageGroup*>(&_pageGroup)));
}
- (void)addUserScript:(NSString *)source baseURL:(NSURL *)baseURL whitelistedURLPatterns:(NSArray *)whitelist blacklistedURLPatterns:(NSArray *)blacklist injectionTime:(WKUserScriptInjectionTime)injectionTime mainFrameOnly:(BOOL)mainFrameOnly
@@ -141,21 +149,28 @@
auto wkBlacklist = createWKArray(blacklist);
WKUserContentInjectedFrames injectedFrames = mainFrameOnly ? kWKInjectInTopFrameOnly : kWKInjectInAllFrames;
- WKPageGroupAddUserScript(_pageGroupRef.get(), wkSource.get(), wkBaseURL.get(), wkWhitelist.get(), wkBlacklist.get(), injectedFrames, injectionTime);
+ WKPageGroupAddUserScript(toAPI(reinterpret_cast<WebPageGroup*>(&_pageGroup)), wkSource.get(), wkBaseURL.get(), wkWhitelist.get(), wkBlacklist.get(), injectedFrames, injectionTime);
}
- (void)removeAllUserScripts
{
- WKPageGroupRemoveAllUserScripts(_pageGroupRef.get());
+ WKPageGroupRemoveAllUserScripts(toAPI(reinterpret_cast<WebPageGroup*>(&_pageGroup)));
}
+#pragma mark WKObject protocol implementation
+
+- (API::Object&)_apiObject
+{
+ return *reinterpret_cast<API::Object*>(&_pageGroup);
+}
+
@end
@implementation WKBrowsingContextGroup (Private)
- (WKPageGroupRef)_pageGroupRef
{
- return _pageGroupRef.get();
+ return toAPI(reinterpret_cast<WebPageGroup*>(&_pageGroup));
}
@end
Added: trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroupInternal.h (0 => 159824)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroupInternal.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroupInternal.h 2013-11-27 22:48:32 UTC (rev 159824)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2013 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 "WKBrowsingContextGroup.h"
+
+#if WK_API_ENABLED
+
+#import "WKObject.h"
+#import "WebPageGroup.h"
+
+namespace WebKit {
+
+inline WKBrowsingContextGroup *wrapper(WebPageGroup& pageGroup)
+{
+ ASSERT([pageGroup.wrapper() isKindOfClass:[WKBrowsingContextGroup class]]);
+ return (WKBrowsingContextGroup *)pageGroup.wrapper();
+}
+
+}
+
+@interface WKBrowsingContextGroup () <WKObject>
+@end
+
+#endif // WK_API_ENABLED
Modified: trunk/Source/WebKit2/UIProcess/WebPageGroup.cpp (159823 => 159824)
--- trunk/Source/WebKit2/UIProcess/WebPageGroup.cpp 2013-11-27 21:03:51 UTC (rev 159823)
+++ trunk/Source/WebKit2/UIProcess/WebPageGroup.cpp 2013-11-27 22:48:32 UTC (rev 159824)
@@ -51,11 +51,7 @@
PassRefPtr<WebPageGroup> WebPageGroup::create(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient)
{
- RefPtr<WebPageGroup> pageGroup = adoptRef(new WebPageGroup(identifier, visibleToInjectedBundle, visibleToHistoryClient));
-
- webPageGroupMap().set(pageGroup->pageGroupID(), pageGroup.get());
-
- return pageGroup.release();
+ return adoptRef(new WebPageGroup(identifier, visibleToInjectedBundle, visibleToHistoryClient));
}
WebPageGroup* WebPageGroup::get(uint64_t pageGroupID)
@@ -74,6 +70,8 @@
m_data.visibleToInjectedBundle = visibleToInjectedBundle;
m_data.visibleToHistoryClient = visibleToHistoryClient;
+
+ webPageGroupMap().set(m_data.pageGroupID, this);
}
WebPageGroup::~WebPageGroup()
Modified: trunk/Source/WebKit2/UIProcess/WebPageGroup.h (159823 => 159824)
--- trunk/Source/WebKit2/UIProcess/WebPageGroup.h 2013-11-27 21:03:51 UTC (rev 159823)
+++ trunk/Source/WebKit2/UIProcess/WebPageGroup.h 2013-11-27 22:48:32 UTC (rev 159824)
@@ -40,6 +40,7 @@
class WebPageGroup : public API::TypedObject<API::Object::Type::PageGroup> {
public:
+ WebPageGroup(const String& identifier = String(), bool visibleToInjectedBundle = true, bool visibleToHistoryClient = true);
static PassRefPtr<WebPageGroup> create(const String& identifier = String(), bool visibleToInjectedBundle = true, bool visibleToHistoryClient = true);
static WebPageGroup* get(uint64_t pageGroupID);
@@ -64,8 +65,6 @@
void removeAllUserContent();
private:
- WebPageGroup(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient);
-
template<typename T> void sendToAllProcessesInGroup(const T&, uint64_t destinationID);
WebPageGroupData m_data;
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (159823 => 159824)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2013-11-27 21:03:51 UTC (rev 159823)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2013-11-27 22:48:32 UTC (rev 159824)
@@ -691,6 +691,7 @@
7C3F8C90173AF52D007B7F39 /* PluginInformation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3F8C8E173AF52D007B7F39 /* PluginInformation.cpp */; };
7C3F8C91173AF52D007B7F39 /* PluginInformation.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3F8C8F173AF52D007B7F39 /* PluginInformation.h */; };
7C6D37FC172F555F009D2847 /* PageBannerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C6D37FA172F555F009D2847 /* PageBannerMac.mm */; };
+ 7C9D1537184584DA009D3918 /* WKBrowsingContextGroupInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C9D1536184584DA009D3918 /* WKBrowsingContextGroupInternal.h */; };
7CA254EB182993CE00FC8A41 /* WKBrowsingContextPolicyDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CA254EA182993CE00FC8A41 /* WKBrowsingContextPolicyDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
7CB16FEF1724BA23007A0A95 /* com.apple.ist.ds.appleconnect.webplugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 7CB16FE21724B9B5007A0A95 /* com.apple.ist.ds.appleconnect.webplugin.sb */; };
7CB16FF01724BA24007A0A95 /* com.apple.QuickTime Plugin.plugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 7CB16FE31724B9B5007A0A95 /* com.apple.QuickTime Plugin.plugin.sb */; };
@@ -2241,6 +2242,7 @@
7C3F8C8E173AF52D007B7F39 /* PluginInformation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginInformation.cpp; sourceTree = "<group>"; };
7C3F8C8F173AF52D007B7F39 /* PluginInformation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginInformation.h; sourceTree = "<group>"; };
7C6D37FA172F555F009D2847 /* PageBannerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageBannerMac.mm; sourceTree = "<group>"; };
+ 7C9D1536184584DA009D3918 /* WKBrowsingContextGroupInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowsingContextGroupInternal.h; sourceTree = "<group>"; };
7CA254EA182993CE00FC8A41 /* WKBrowsingContextPolicyDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowsingContextPolicyDelegate.h; sourceTree = "<group>"; };
7CB16FE21724B9B5007A0A95 /* com.apple.ist.ds.appleconnect.webplugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.ist.ds.appleconnect.webplugin.sb; sourceTree = "<group>"; };
7CB16FE31724B9B5007A0A95 /* com.apple.QuickTime Plugin.plugin.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "com.apple.QuickTime Plugin.plugin.sb"; sourceTree = "<group>"; };
@@ -4640,6 +4642,7 @@
3788A05B14743C90006319E5 /* WKBrowsingContextControllerPrivate.h */,
BCBAACEE145232430053F82F /* WKBrowsingContextGroup.h */,
BCBAACEF145232440053F82F /* WKBrowsingContextGroup.mm */,
+ 7C9D1536184584DA009D3918 /* WKBrowsingContextGroupInternal.h */,
BCBAACF0145232480053F82F /* WKBrowsingContextGroupPrivate.h */,
BCBAAD0A14560A430053F82F /* WKBrowsingContextLoadDelegate.h */,
7CA254EA182993CE00FC8A41 /* WKBrowsingContextPolicyDelegate.h */,
@@ -6078,6 +6081,7 @@
F67DD7BA125E40D9007BDCB8 /* WKSerializedScriptValuePrivate.h in Headers */,
BCDDB32B124EC2AB0048D13C /* WKSharedAPICast.h in Headers */,
BC407606124FF0270068F20A /* WKString.h in Headers */,
+ 7C9D1537184584DA009D3918 /* WKBrowsingContextGroupInternal.h in Headers */,
BC40761A124FF0370068F20A /* WKStringCF.h in Headers */,
759CCD591808F1690078E8A8 /* WebOriginDataManagerProxyChangeClient.h in Headers */,
BC9099801256A98200083756 /* WKStringPrivate.h in Headers */,