Diff
Modified: trunk/Source/WebKit2/ChangeLog (160503 => 160504)
--- trunk/Source/WebKit2/ChangeLog 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/ChangeLog 2013-12-12 20:28:47 UTC (rev 160504)
@@ -1,3 +1,46 @@
+2013-12-12 Anders Carlsson <[email protected]>
+
+ Clean up dictionary handling a little
+ https://bugs.webkit.org/show_bug.cgi?id=125644
+
+ Reviewed by Dan Bernstein.
+
+ Add a WKDictionaryCreate function as a first step towards eliminating WKMutableDictionaryRef,
+ (in the same way we've eliminated WKMutableArrayRef). Also, rename adopt to create and make it take a Map by value
+ so we can use std::move where appropriate.
+
+ * Shared/API/c/WKDictionary.cpp:
+ (WKDictionaryCreate):
+ * Shared/API/c/WKDictionary.h:
+ * Shared/Cocoa/WKNSDictionary.mm:
+ (-[WKNSDictionary copyWithZone:]):
+ * Shared/ImmutableDictionary.cpp:
+ (WebKit::ImmutableDictionary::create):
+ (WebKit::ImmutableDictionary::ImmutableDictionary):
+ * Shared/ImmutableDictionary.h:
+ * Shared/MutableDictionary.cpp:
+ (WebKit::MutableDictionary::MutableDictionary):
+ * Shared/Plugins/Netscape/PluginInformation.cpp:
+ (WebKit::createPluginInformationDictionary):
+ * Shared/UserData.cpp:
+ (WebKit::UserData::transform):
+ (WebKit::UserData::decode):
+ * Shared/UserMessageCoders.h:
+ (WebKit::UserMessageDecoder::baseDecode):
+ * UIProcess/Plugins/PlugInAutoStartProvider.cpp:
+ (WebKit::PlugInAutoStartProvider::autoStartOriginsTableCopy):
+ * UIProcess/WebContext.cpp:
+ (WebKit::WebContext::pluginInfoStoreDidLoadPlugins):
+ * UIProcess/WebDatabaseManagerProxy.cpp:
+ (WebKit::WebDatabaseManagerProxy::didGetDatabasesByOrigin):
+ * UIProcess/WebFormClient.cpp:
+ (WebKit::WebFormClient::willSubmitForm):
+ * UIProcess/WebUIClient.cpp:
+ (WebKit::WebUIClient::createNewPage):
+ * WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp:
+ (WebKit::InjectedBundlePageFormClient::willSendSubmitEvent):
+ (WebKit::InjectedBundlePageFormClient::willSubmitForm):
+
2013-12-12 Dan Bernstein <[email protected]>
[Cocoa] Navigation action information for policy decisions is missing the original request
Modified: trunk/Source/WebKit2/Shared/API/c/WKDictionary.cpp (160503 => 160504)
--- trunk/Source/WebKit2/Shared/API/c/WKDictionary.cpp 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/Shared/API/c/WKDictionary.cpp 2013-12-12 20:28:47 UTC (rev 160504)
@@ -37,6 +37,15 @@
return toAPI(ImmutableDictionary::APIType);
}
+WK_EXPORT WKDictionaryRef WKDictionaryCreate(const WKStringRef* keys, const WKTypeRef* values, size_t numberOfValues)
+{
+ ImmutableDictionary::MapType map;
+ for (size_t i = 0; i < numberOfValues; ++i)
+ map.add(toImpl(keys[i])->string(), toImpl(values[i]));
+
+ return toAPI(ImmutableDictionary::create(std::move(map)).release().leakRef());
+}
+
WKTypeRef WKDictionaryGetItemForKey(WKDictionaryRef dictionaryRef, WKStringRef key)
{
return toImpl(dictionaryRef)->get(toImpl(key)->string());
Modified: trunk/Source/WebKit2/Shared/API/c/WKDictionary.h (160503 => 160504)
--- trunk/Source/WebKit2/Shared/API/c/WKDictionary.h 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/Shared/API/c/WKDictionary.h 2013-12-12 20:28:47 UTC (rev 160504)
@@ -36,6 +36,8 @@
WK_EXPORT WKTypeID WKDictionaryGetTypeID();
+WK_EXPORT WKDictionaryRef WKDictionaryCreate(const WKStringRef* keys, const WKTypeRef* values, size_t numberOfValues);
+
WK_EXPORT WKTypeRef WKDictionaryGetItemForKey(WKDictionaryRef dictionary, WKStringRef key);
WK_EXPORT size_t WKDictionaryGetSize(WKDictionaryRef dictionary);
Modified: trunk/Source/WebKit2/Shared/Cocoa/WKNSDictionary.mm (160503 => 160504)
--- trunk/Source/WebKit2/Shared/Cocoa/WKNSDictionary.mm 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKNSDictionary.mm 2013-12-12 20:28:47 UTC (rev 160504)
@@ -82,7 +82,7 @@
return [self retain];
auto map = _dictionary->map();
- return ImmutableDictionary::adopt(map).leakRef()->wrapper();
+ return ImmutableDictionary::create(std::move(map)).release().leakRef()->wrapper();
}
#pragma mark WKObject protocol implementation
Modified: trunk/Source/WebKit2/Shared/ImmutableDictionary.cpp (160503 => 160504)
--- trunk/Source/WebKit2/Shared/ImmutableDictionary.cpp 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/Shared/ImmutableDictionary.cpp 2013-12-12 20:28:47 UTC (rev 160504)
@@ -31,15 +31,21 @@
namespace WebKit {
-ImmutableDictionary::ImmutableDictionary()
+RefPtr<ImmutableDictionary> ImmutableDictionary::create()
{
+ return create({ });
}
-ImmutableDictionary::ImmutableDictionary(MapType& map)
+RefPtr<ImmutableDictionary> ImmutableDictionary::create(MapType map)
{
- m_map.swap(map);
+ return adoptRef(new ImmutableDictionary(std::move(map)));
}
+ImmutableDictionary::ImmutableDictionary(MapType map)
+ : m_map(std::move(map))
+{
+}
+
ImmutableDictionary::~ImmutableDictionary()
{
}
Modified: trunk/Source/WebKit2/Shared/ImmutableDictionary.h (160503 => 160504)
--- trunk/Source/WebKit2/Shared/ImmutableDictionary.h 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/Shared/ImmutableDictionary.h 2013-12-12 20:28:47 UTC (rev 160504)
@@ -44,14 +44,8 @@
public:
typedef HashMap<String, RefPtr<API::Object>> MapType;
- static PassRefPtr<ImmutableDictionary> create()
- {
- return adoptRef(new ImmutableDictionary);
- }
- static PassRefPtr<ImmutableDictionary> adopt(MapType& map)
- {
- return adoptRef(new ImmutableDictionary(map));
- }
+ static RefPtr<ImmutableDictionary> create();
+ static RefPtr<ImmutableDictionary> create(MapType);
virtual ~ImmutableDictionary();
@@ -89,8 +83,7 @@
const MapType& map() const { return m_map; }
protected:
- ImmutableDictionary();
- explicit ImmutableDictionary(MapType&);
+ explicit ImmutableDictionary(MapType);
MapType m_map;
};
Modified: trunk/Source/WebKit2/Shared/MutableDictionary.cpp (160503 => 160504)
--- trunk/Source/WebKit2/Shared/MutableDictionary.cpp 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/Shared/MutableDictionary.cpp 2013-12-12 20:28:47 UTC (rev 160504)
@@ -29,6 +29,7 @@
namespace WebKit {
MutableDictionary::MutableDictionary()
+ : ImmutableDictionary({ })
{
}
Modified: trunk/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.cpp (160503 => 160504)
--- trunk/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.cpp 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/Shared/Plugins/Netscape/PluginInformation.cpp 2013-12-12 20:28:47 UTC (rev 160504)
@@ -127,7 +127,7 @@
ImmutableDictionary::MapType map;
getPluginModuleInformation(plugin, map);
- return ImmutableDictionary::adopt(map);
+ return ImmutableDictionary::create(std::move(map));
}
PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const PluginModuleInfo& plugin, const String& frameURLString, const String& mimeType, const String& pageURLString, const String& pluginspageAttributeURLString, const String& pluginURLString, bool replacementObscured)
@@ -147,7 +147,7 @@
map.set(pluginInformationPluginURLKey(), WebURL::create(pluginURLString));
map.set(plugInInformationReplacementObscuredKey(), API::Boolean::create(replacementObscured));
- return ImmutableDictionary::adopt(map);
+ return ImmutableDictionary::create(std::move(map));
}
PassRefPtr<ImmutableDictionary> createPluginInformationDictionary(const String& mimeType, const String& frameURLString, const String& pageURLString)
@@ -161,7 +161,7 @@
if (!pageURLString.isEmpty())
map.set(pluginInformationPageURLKey(), WebURL::create(pageURLString));
- return ImmutableDictionary::adopt(map);
+ return ImmutableDictionary::create(std::move(map));
}
#if !PLATFORM(MAC)
Modified: trunk/Source/WebKit2/Shared/UserData.cpp (160503 => 160504)
--- trunk/Source/WebKit2/Shared/UserData.cpp 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/Shared/UserData.cpp 2013-12-12 20:28:47 UTC (rev 160504)
@@ -71,7 +71,7 @@
for (const auto& keyValuePair : dictionary.map())
map.add(keyValuePair.key, transform(keyValuePair.value.get(), transformer));
- return ImmutableDictionary::adopt(map);
+ return ImmutableDictionary::create(std::move(map));
}
if (auto transformedObject = transformer(*object))
@@ -222,7 +222,7 @@
return false;
}
- result = ImmutableDictionary::adopt(map);
+ result = ImmutableDictionary::create(std::move(map));
break;
}
Modified: trunk/Source/WebKit2/Shared/UserMessageCoders.h (160503 => 160504)
--- trunk/Source/WebKit2/Shared/UserMessageCoders.h 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/Shared/UserMessageCoders.h 2013-12-12 20:28:47 UTC (rev 160504)
@@ -307,7 +307,7 @@
return false;
}
- coder.m_root = ImmutableDictionary::adopt(map);
+ coder.m_root = ImmutableDictionary::create(std::move(map));
break;
}
case API::Object::Type::String: {
Modified: trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp (160503 => 160504)
--- trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp 2013-12-12 20:28:47 UTC (rev 160504)
@@ -93,10 +93,10 @@
}
if (hashMap.size())
- map.set(it->key, ImmutableDictionary::adopt(hashMap));
+ map.set(it->key, ImmutableDictionary::create(std::move(hashMap)));
}
- return ImmutableDictionary::adopt(map);
+ return ImmutableDictionary::create(std::move(map));
}
void PlugInAutoStartProvider::setAutoStartOriginsTable(ImmutableDictionary& table)
Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (160503 => 160504)
--- trunk/Source/WebKit2/UIProcess/WebContext.cpp 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp 2013-12-12 20:28:47 UTC (rev 160504)
@@ -1293,7 +1293,7 @@
map.set(ASCIILiteral("version"), WebString::create(pluginModule.versionString));
#endif
- plugins.uncheckedAppend(ImmutableDictionary::adopt(map));
+ plugins.uncheckedAppend(ImmutableDictionary::create(std::move(map)));
}
m_client.plugInInformationBecameAvailable(this, API::Array::create(std::move(plugins)).get());
Modified: trunk/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp (160503 => 160504)
--- trunk/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp 2013-12-12 20:28:47 UTC (rev 160504)
@@ -173,7 +173,7 @@
detailsMap.set(databaseDetailsExpectedUsageKey(), API::UInt64::create(databaseDetails.expectedUsage()));
detailsMap.set(databaseDetailsCurrentUsageKey(), API::UInt64::create(databaseDetails.currentUsage()));
- databases.uncheckedAppend(ImmutableDictionary::adopt(detailsMap));
+ databases.uncheckedAppend(ImmutableDictionary::create(std::move(detailsMap)));
}
HashMap<String, RefPtr<API::Object>> originAndDatabasesMap;
@@ -182,7 +182,7 @@
originAndDatabasesMap.set(originUsageKey(), API::UInt64::create(originAndDatabases.originUsage));
originAndDatabasesMap.set(databaseDetailsKey(), API::Array::create(std::move(databases)));
- result.uncheckedAppend(ImmutableDictionary::adopt(originAndDatabasesMap));
+ result.uncheckedAppend(ImmutableDictionary::create(std::move(originAndDatabasesMap)));
}
callback->performCallbackWithReturnValue(API::Array::create(std::move(result)).get());
Modified: trunk/Source/WebKit2/UIProcess/WebFormClient.cpp (160503 => 160504)
--- trunk/Source/WebKit2/UIProcess/WebFormClient.cpp 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/UIProcess/WebFormClient.cpp 2013-12-12 20:28:47 UTC (rev 160504)
@@ -41,7 +41,7 @@
ImmutableDictionary::MapType map;
for (size_t i = 0; i < textFieldValues.size(); ++i)
map.set(textFieldValues[i].first, WebString::create(textFieldValues[i].second));
- RefPtr<ImmutableDictionary> textFieldsMap = ImmutableDictionary::adopt(map);
+ RefPtr<ImmutableDictionary> textFieldsMap = ImmutableDictionary::create(std::move(map));
m_client.willSubmitForm(toAPI(page), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.get()), toAPI(userData), toAPI(listener), m_client.base.clientInfo);
return true;
Modified: trunk/Source/WebKit2/UIProcess/WebUIClient.cpp (160503 => 160504)
--- trunk/Source/WebKit2/UIProcess/WebUIClient.cpp 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/UIProcess/WebUIClient.cpp 2013-12-12 20:28:47 UTC (rev 160504)
@@ -71,7 +71,7 @@
map.set("resizable", API::Boolean::create(windowFeatures.resizable));
map.set("fullscreen", API::Boolean::create(windowFeatures.fullscreen));
map.set("dialog", API::Boolean::create(windowFeatures.dialog));
- RefPtr<ImmutableDictionary> featuresMap = ImmutableDictionary::adopt(map);
+ RefPtr<ImmutableDictionary> featuresMap = ImmutableDictionary::create(std::move(map));
if (!m_client.base.version)
return adoptRef(toImpl(m_client.createNewPage_deprecatedForUseWithV0(toAPI(page), toAPI(featuresMap.get()), toAPI(modifiers), toAPI(button), m_client.base.clientInfo)));
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp (160503 => 160504)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp 2013-12-12 20:18:45 UTC (rev 160503)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageFormClient.cpp 2013-12-12 20:28:47 UTC (rev 160504)
@@ -103,7 +103,7 @@
ImmutableDictionary::MapType map;
for (size_t i = 0; i < values.size(); ++i)
map.set(values[i].first, WebString::create(values[i].second));
- RefPtr<ImmutableDictionary> textFieldsMap = ImmutableDictionary::adopt(map);
+ auto textFieldsMap = ImmutableDictionary::create(std::move(map));
m_client.willSendSubmitEvent(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.get()), m_client.base.clientInfo);
}
@@ -118,7 +118,7 @@
ImmutableDictionary::MapType map;
for (size_t i = 0; i < values.size(); ++i)
map.set(values[i].first, WebString::create(values[i].second));
- RefPtr<ImmutableDictionary> textFieldsMap = ImmutableDictionary::adopt(map);
+ auto textFieldsMap = ImmutableDictionary::create(std::move(map));
WKTypeRef userDataToPass = 0;
m_client.willSubmitForm(toAPI(page), toAPI(nodeHandle.get()), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.get()), &userDataToPass, m_client.base.clientInfo);