Diff
Modified: trunk/Source/WebKit2/ChangeLog (183408 => 183409)
--- trunk/Source/WebKit2/ChangeLog 2015-04-27 19:36:25 UTC (rev 183408)
+++ trunk/Source/WebKit2/ChangeLog 2015-04-27 20:05:14 UTC (rev 183409)
@@ -1,3 +1,59 @@
+2015-04-27 Zan Dobersek <[email protected]>
+
+ [WK2] API::String creation functions should return Ref<>
+ https://bugs.webkit.org/show_bug.cgi?id=144218
+
+ Reviewed by Darin Adler.
+
+ Have API::String creation functions return Ref<>.
+ The call-sites are also updated, using and operating on the returned
+ Ref<> object, where possible.
+
+ * Shared/API/APIString.h:
+ * Shared/API/c/WKPluginInformation.cpp:
+ (WKPluginInformationBundleIdentifierKey):
+ (WKPluginInformationBundleVersionKey):
+ (WKPluginInformationBundleShortVersionKey):
+ (WKPluginInformationPathKey):
+ (WKPluginInformationDisplayNameKey):
+ (WKPluginInformationDefaultLoadPolicyKey):
+ (WKPluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey):
+ (WKPluginInformationHasSandboxProfileKey):
+ (WKPluginInformationFrameURLKey):
+ (WKPluginInformationMIMETypeKey):
+ (WKPluginInformationPageURLKey):
+ (WKPluginInformationPluginspageAttributeURLKey):
+ (WKPluginInformationPluginURLKey):
+ (WKPlugInInformationReplacementObscuredKey):
+ * Shared/API/c/WKSharedAPICast.h:
+ (WebKit::ProxyingRefPtr::ProxyingRefPtr):
+ (WebKit::toCopiedAPI):
+ * Shared/API/c/WKString.cpp:
+ (WKStringCreateWithUTF8CString):
+ (WKStringCreateWithJSString):
+ * UIProcess/API/C/WKDatabaseManager.cpp:
+ (WKDatabaseManagerGetOriginKey):
+ (WKDatabaseManagerGetOriginQuotaKey):
+ (WKDatabaseManagerGetOriginUsageKey):
+ (WKDatabaseManagerGetDatabaseDetailsKey):
+ (WKDatabaseManagerGetDatabaseDetailsNameKey):
+ (WKDatabaseManagerGetDatabaseDetailsDisplayNameKey):
+ (WKDatabaseManagerGetDatabaseDetailsExpectedUsageKey):
+ (WKDatabaseManagerGetDatabaseDetailsCurrentUsageKey):
+ (WKDatabaseManagerGetDatabaseDetailsCreationTimeKey):
+ (WKDatabaseManagerGetDatabaseDetailsModificationTimeKey):
+ * UIProcess/API/C/WKKeyValueStorageManager.cpp:
+ (WKKeyValueStorageManagerGetOriginKey):
+ (WKKeyValueStorageManagerGetCreationTimeKey):
+ (WKKeyValueStorageManagerGetModificationTimeKey):
+ * UIProcess/API/C/WKPage.cpp:
+ (WKPageGetSessionHistoryURLValueType):
+ (WKPageGetSessionBackForwardListItemValueType):
+ (toGenericCallbackFunction):
+ (WKPageValidateCommand):
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::didReceiveInvalidMessage):
+
2015-04-27 Brady Eidson <[email protected]>
Make 'enum NavigationType' be an enum class
Modified: trunk/Source/WebKit2/Shared/API/APIString.h (183408 => 183409)
--- trunk/Source/WebKit2/Shared/API/APIString.h 2015-04-27 19:36:25 UTC (rev 183408)
+++ trunk/Source/WebKit2/Shared/API/APIString.h 2015-04-27 20:05:14 UTC (rev 183409)
@@ -27,7 +27,7 @@
#define APIString_h
#include "APIObject.h"
-#include <wtf/PassRefPtr.h>
+#include <wtf/Ref.h>
#include <wtf/text/StringView.h>
#include <wtf/text/WTFString.h>
#include <wtf/unicode/UTF8.h>
@@ -36,17 +36,17 @@
class String final : public ObjectImpl<Object::Type::String> {
public:
- static RefPtr<String> createNull()
+ static Ref<String> createNull()
{
- return adoptRef(new String);
+ return adoptRef(*new String);
}
- static RefPtr<String> create(WTF::String&& string)
+ static Ref<String> create(WTF::String&& string)
{
- return adoptRef(new String(string.isNull() ? WTF::String(StringImpl::empty()) : string.isolatedCopy()));
+ return adoptRef(*new String(string.isNull() ? WTF::String(StringImpl::empty()) : string.isolatedCopy()));
}
- static RefPtr<String> create(const WTF::String& string)
+ static Ref<String> create(const WTF::String& string)
{
return create(string.isolatedCopy());
}
Modified: trunk/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp (183408 => 183409)
--- trunk/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp 2015-04-27 19:36:25 UTC (rev 183408)
+++ trunk/Source/WebKit2/Shared/API/c/WKPluginInformation.cpp 2015-04-27 20:05:14 UTC (rev 183409)
@@ -35,8 +35,8 @@
WKStringRef WKPluginInformationBundleIdentifierKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationBundleIdentifierKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationBundleIdentifierKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -45,8 +45,8 @@
WKStringRef WKPluginInformationBundleVersionKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationBundleVersionKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationBundleVersionKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -55,8 +55,8 @@
WKStringRef WKPluginInformationBundleShortVersionKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationBundleShortVersionKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationBundleShortVersionKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -65,8 +65,8 @@
WKStringRef WKPluginInformationPathKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationPathKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationPathKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -75,8 +75,8 @@
WKStringRef WKPluginInformationDisplayNameKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationDisplayNameKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationDisplayNameKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -85,8 +85,8 @@
WKStringRef WKPluginInformationDefaultLoadPolicyKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationDefaultLoadPolicyKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationDefaultLoadPolicyKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -95,8 +95,8 @@
WKStringRef WKPluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationUpdatePastLastBlockedVersionIsKnownAvailableKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -105,8 +105,8 @@
WKStringRef WKPluginInformationHasSandboxProfileKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationHasSandboxProfileKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationHasSandboxProfileKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -115,8 +115,8 @@
WKStringRef WKPluginInformationFrameURLKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationFrameURLKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationFrameURLKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -125,8 +125,8 @@
WKStringRef WKPluginInformationMIMETypeKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationMIMETypeKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationMIMETypeKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -135,8 +135,8 @@
WKStringRef WKPluginInformationPageURLKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationPageURLKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationPageURLKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -145,8 +145,8 @@
WKStringRef WKPluginInformationPluginspageAttributeURLKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationPluginspageAttributeURLKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationPluginspageAttributeURLKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -155,8 +155,8 @@
WKStringRef WKPluginInformationPluginURLKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(pluginInformationPluginURLKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(pluginInformationPluginURLKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
@@ -165,8 +165,8 @@
WKStringRef WKPlugInInformationReplacementObscuredKey()
{
#if ENABLE(NETSCAPE_PLUGIN_API)
- static API::String* key = API::String::create(plugInInformationReplacementObscuredKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(plugInInformationReplacementObscuredKey()).leakRef();
+ return toAPI(&key);
#else
return 0;
#endif
Modified: trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h (183408 => 183409)
--- trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h 2015-04-27 19:36:25 UTC (rev 183408)
+++ trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h 2015-04-27 20:05:14 UTC (rev 183409)
@@ -145,6 +145,11 @@
{
}
+ ProxyingRefPtr(Ref<ImplType>&& impl)
+ : m_impl(WTF::move(impl))
+ {
+ }
+
operator APIType() { return toAPI(m_impl.get()); }
private:
@@ -160,8 +165,7 @@
inline WKStringRef toCopiedAPI(const String& string)
{
- RefPtr<API::String> apiString = API::String::create(string);
- return toAPI(apiString.release().leakRef());
+ return toAPI(&API::String::create(string).leakRef());
}
inline ProxyingRefPtr<API::URL> toURLRef(StringImpl* string)
Modified: trunk/Source/WebKit2/Shared/API/c/WKString.cpp (183408 => 183409)
--- trunk/Source/WebKit2/Shared/API/c/WKString.cpp 2015-04-27 19:36:25 UTC (rev 183408)
+++ trunk/Source/WebKit2/Shared/API/c/WKString.cpp 2015-04-27 20:05:14 UTC (rev 183409)
@@ -41,8 +41,7 @@
WKStringRef WKStringCreateWithUTF8CString(const char* string)
{
- auto apiString = API::String::create(WTF::String::fromUTF8(string));
- return toAPI(apiString.release().leakRef());
+ return toAPI(&API::String::create(WTF::String::fromUTF8(string)).leakRef());
}
bool WKStringIsEmpty(WKStringRef stringRef)
@@ -116,7 +115,7 @@
{
auto apiString = jsStringRef ? API::String::create(jsStringRef->string()) : API::String::createNull();
- return toAPI(apiString.release().leakRef());
+ return toAPI(&apiString.leakRef());
}
JSStringRef WKStringCopyJSString(WKStringRef stringRef)
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp (183408 => 183409)
--- trunk/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp 2015-04-27 19:36:25 UTC (rev 183408)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp 2015-04-27 20:05:14 UTC (rev 183409)
@@ -38,62 +38,62 @@
WKStringRef WKDatabaseManagerGetOriginKey()
{
- static API::String* key = API::String::create(WebDatabaseManagerProxy::originKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebDatabaseManagerProxy::originKey()).leakRef();
+ return toAPI(&key);
}
WKStringRef WKDatabaseManagerGetOriginQuotaKey()
{
- static API::String* key = API::String::create(WebDatabaseManagerProxy::originQuotaKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebDatabaseManagerProxy::originQuotaKey()).leakRef();
+ return toAPI(&key);
}
WKStringRef WKDatabaseManagerGetOriginUsageKey()
{
- static API::String* key = API::String::create(WebDatabaseManagerProxy::originUsageKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebDatabaseManagerProxy::originUsageKey()).leakRef();
+ return toAPI(&key);
}
WKStringRef WKDatabaseManagerGetDatabaseDetailsKey()
{
- static API::String* key = API::String::create(WebDatabaseManagerProxy::databaseDetailsKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebDatabaseManagerProxy::databaseDetailsKey()).leakRef();
+ return toAPI(&key);
}
WKStringRef WKDatabaseManagerGetDatabaseDetailsNameKey()
{
- static API::String* key = API::String::create(WebDatabaseManagerProxy::databaseDetailsNameKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebDatabaseManagerProxy::databaseDetailsNameKey()).leakRef();
+ return toAPI(&key);
}
WKStringRef WKDatabaseManagerGetDatabaseDetailsDisplayNameKey()
{
- static API::String* key = API::String::create(WebDatabaseManagerProxy::databaseDetailsDisplayNameKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebDatabaseManagerProxy::databaseDetailsDisplayNameKey()).leakRef();
+ return toAPI(&key);
}
WKStringRef WKDatabaseManagerGetDatabaseDetailsExpectedUsageKey()
{
- static API::String* key = API::String::create(WebDatabaseManagerProxy::databaseDetailsExpectedUsageKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebDatabaseManagerProxy::databaseDetailsExpectedUsageKey()).leakRef();
+ return toAPI(&key);
}
WKStringRef WKDatabaseManagerGetDatabaseDetailsCurrentUsageKey()
{
- static API::String* key = API::String::create(WebDatabaseManagerProxy::databaseDetailsCurrentUsageKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebDatabaseManagerProxy::databaseDetailsCurrentUsageKey()).leakRef();
+ return toAPI(&key);
}
WKStringRef WKDatabaseManagerGetDatabaseDetailsCreationTimeKey()
{
- static API::String* key = API::String::create(WebDatabaseManagerProxy::databaseDetailsCreationTimeKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebDatabaseManagerProxy::databaseDetailsCreationTimeKey()).leakRef();
+ return toAPI(&key);
}
WKStringRef WKDatabaseManagerGetDatabaseDetailsModificationTimeKey()
{
- static API::String* key = API::String::create(WebDatabaseManagerProxy::databaseDetailsModificationTimeKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebDatabaseManagerProxy::databaseDetailsModificationTimeKey()).leakRef();
+ return toAPI(&key);
}
void WKDatabaseManagerSetClient(WKDatabaseManagerRef databaseManagerRef, const WKDatabaseManagerClientBase* wkClient)
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.cpp (183408 => 183409)
--- trunk/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.cpp 2015-04-27 19:36:25 UTC (rev 183408)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.cpp 2015-04-27 20:05:14 UTC (rev 183409)
@@ -38,20 +38,20 @@
WKStringRef WKKeyValueStorageManagerGetOriginKey()
{
- static API::String* key = API::String::create(WebKeyValueStorageManager::originKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebKeyValueStorageManager::originKey()).leakRef();
+ return toAPI(&key);
}
WKStringRef WKKeyValueStorageManagerGetCreationTimeKey()
{
- static API::String* key = API::String::create(WebKeyValueStorageManager::creationTimeKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebKeyValueStorageManager::creationTimeKey()).leakRef();
+ return toAPI(&key);
}
WKStringRef WKKeyValueStorageManagerGetModificationTimeKey()
{
- static API::String* key = API::String::create(WebKeyValueStorageManager::modificationTimeKey()).leakRef();
- return toAPI(key);
+ static API::String& key = API::String::create(WebKeyValueStorageManager::modificationTimeKey()).leakRef();
+ return toAPI(&key);
}
void WKKeyValueStorageManagerGetKeyValueStorageOrigins(WKKeyValueStorageManagerRef keyValueStorageManagerRef, void* context, WKKeyValueStorageManagerGetKeyValueStorageOriginsFunction callback)
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (183408 => 183409)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2015-04-27 19:36:25 UTC (rev 183408)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2015-04-27 20:05:14 UTC (rev 183409)
@@ -363,14 +363,14 @@
WKStringRef WKPageGetSessionHistoryURLValueType()
{
- static API::String* sessionHistoryURLValueType = API::String::create("SessionHistoryURL").leakRef();
- return toAPI(sessionHistoryURLValueType);
+ static API::String& sessionHistoryURLValueType = API::String::create("SessionHistoryURL").leakRef();
+ return toAPI(&sessionHistoryURLValueType);
}
WKStringRef WKPageGetSessionBackForwardListItemValueType()
{
- static API::String* sessionBackForwardListValueType = API::String::create("SessionBackForwardListItem").leakRef();
- return toAPI(sessionBackForwardListValueType);
+ static API::String& sessionBackForwardListValueType = API::String::create("SessionBackForwardListItem").leakRef();
+ return toAPI(&sessionBackForwardListValueType);
}
WKTypeRef WKPageCopySessionState(WKPageRef pageRef, void* context, WKPageSessionStateFilterCallback filter)
@@ -1954,7 +1954,7 @@
static std::function<void (const String&, WebKit::CallbackBase::Error)> toGenericCallbackFunction(void* context, void (*callback)(WKStringRef, WKErrorRef, void*))
{
return [context, callback](const String& returnValue, WebKit::CallbackBase::Error error) {
- callback(toAPI(API::String::create(returnValue).get()), error != WebKit::CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
+ callback(toAPI(API::String::create(returnValue).ptr()), error != WebKit::CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
};
}
@@ -2035,7 +2035,7 @@
void WKPageValidateCommand(WKPageRef pageRef, WKStringRef command, void* context, WKPageValidateCommandCallback callback)
{
toImpl(pageRef)->validateCommand(toImpl(command)->string(), [context, callback](const String& commandName, bool isEnabled, int32_t state, WebKit::CallbackBase::Error error) {
- callback(toAPI(API::String::create(commandName).get()), isEnabled, state, error != WebKit::CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
+ callback(toAPI(API::String::create(commandName).ptr()), isEnabled, state, error != WebKit::CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
});
}
Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (183408 => 183409)
--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp 2015-04-27 19:36:25 UTC (rev 183408)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp 2015-04-27 20:05:14 UTC (rev 183409)
@@ -565,7 +565,7 @@
messageNameStringBuilder.append('.');
messageNameStringBuilder.append(messageName.data(), messageName.size());
- s_invalidMessageCallback(toAPI(API::String::create(messageNameStringBuilder.toString()).get()));
+ s_invalidMessageCallback(toAPI(API::String::create(messageNameStringBuilder.toString()).ptr()));
}
void WebProcessPool::processDidCachePage(WebProcessProxy* process)