<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[169321] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/169321">169321</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2014-05-25 11:59:41 -0700 (Sun, 25 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WebKit2] Rework WebPreferencesStore to allow easier overriding of defaults
https://bugs.webkit.org/show_bug.cgi?id=133258

Reviewed by Anders Carlsson.

To support changing default values of preferences based on which API you are using (either
the legacy C-SPI or the Objective-C API), overhaul the WebPreferencesStore to use a single
HashMap of String -&gt; Value (where Value is new type that can be a String, bool, uint32_t or double)
instead of four HashMaps.  This allows us to use two of these new HashMaps, one for the actual
set values, and one for overridden defaults. This new Value class will also allow easier incremental
updating of preferences in the future.
        
Other notable changes:
- Removed Float kind of preferences. There were none.
- Move StorageBlockingPolicy preference to the correct group, it's a uint32_t, not bool.

* Shared/WebPreferencesStore.cpp:
* Shared/WebPreferencesStore.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPreferencesStorecpp">trunk/Source/WebKit2/Shared/WebPreferencesStore.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPreferencesStoreh">trunk/Source/WebKit2/Shared/WebPreferencesStore.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKPreferencesh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (169320 => 169321)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-05-25 18:09:16 UTC (rev 169320)
+++ trunk/Source/WebKit2/ChangeLog        2014-05-25 18:59:41 UTC (rev 169321)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2014-05-24  Sam Weinig  &lt;sam@webkit.org&gt;
+
+        [WebKit2] Rework WebPreferencesStore to allow easier overriding of defaults
+        https://bugs.webkit.org/show_bug.cgi?id=133258
+
+        Reviewed by Anders Carlsson.
+
+        To support changing default values of preferences based on which API you are using (either
+        the legacy C-SPI or the Objective-C API), overhaul the WebPreferencesStore to use a single
+        HashMap of String -&gt; Value (where Value is new type that can be a String, bool, uint32_t or double)
+        instead of four HashMaps.  This allows us to use two of these new HashMaps, one for the actual
+        set values, and one for overridden defaults. This new Value class will also allow easier incremental
+        updating of preferences in the future.
+        
+        Other notable changes:
+        - Removed Float kind of preferences. There were none.
+        - Move StorageBlockingPolicy preference to the correct group, it's a uint32_t, not bool.
+
+        * Shared/WebPreferencesStore.cpp:
+        * Shared/WebPreferencesStore.h:
+
</ins><span class="cx"> 2014-05-25  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add type-checked casts for TransformOperations
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPreferencesStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPreferencesStore.cpp (169320 => 169321)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebPreferencesStore.cpp        2014-05-25 18:09:16 UTC (rev 169320)
+++ trunk/Source/WebKit2/Shared/WebPreferencesStore.cpp        2014-05-25 18:59:41 UTC (rev 169321)
</span><span class="lines">@@ -60,31 +60,88 @@
</span><span class="cx">     return map;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPreferencesStore::Value::encode(IPC::ArgumentEncoder&amp; encoder) const
+{
+    encoder.encodeEnum(m_type);
+    
+    switch (m_type) {
+    case Type::None:
+        break;
+    case Type::String:
+        encoder &lt;&lt; m_string;
+        break;
+    case Type::Bool:
+        encoder &lt;&lt; m_bool;
+        break;
+    case Type::UInt32:
+        encoder &lt;&lt; m_uint32;
+        break;
+    case Type::Double:
+        encoder &lt;&lt; m_double;
+        break;
+    }
+}
+
+bool WebPreferencesStore::Value::decode(IPC::ArgumentDecoder&amp; decoder, Value&amp; result)
+{
+    Value::Type type;
+    if (!decoder.decodeEnum(type))
+        return false;
+    
+    switch (type) {
+    case Type::None:
+        break;
+    case Type::String: {
+        String value;
+        if (!decoder.decode(value))
+            return false;
+        result = Value(value);
+        break;
+    }
+    case Type::Bool: {
+        bool value;
+        if (!decoder.decode(value))
+            return false;
+        result = Value(value);
+        break;
+    }
+    case Type::UInt32: {
+        uint32_t value;
+        if (!decoder.decode(value))
+            return false;
+        result = Value(value);
+        break;
+    }
+    case Type::Double: {
+        double value;
+        if (!decoder.decode(value))
+            return false;
+        result = Value(value);
+        break;
+    }
+    default:
+        return false;
+    }
+
+    return true;
+}
+
</ins><span class="cx"> WebPreferencesStore::WebPreferencesStore()
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPreferencesStore::encode(IPC::ArgumentEncoder&amp; encoder) const
</span><span class="cx"> {
</span><del>-    encoder &lt;&lt; m_stringValues;
-    encoder &lt;&lt; m_boolValues;
-    encoder &lt;&lt; m_uint32Values;
-    encoder &lt;&lt; m_doubleValues;
-    encoder &lt;&lt; m_floatValues;
</del><ins>+    encoder &lt;&lt; m_values;
+    encoder &lt;&lt; m_overridenDefaults;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebPreferencesStore::decode(IPC::ArgumentDecoder&amp; decoder, WebPreferencesStore&amp; result)
</span><span class="cx"> {
</span><del>-    if (!decoder.decode(result.m_stringValues))
</del><ins>+    if (!decoder.decode(result.m_values))
</ins><span class="cx">         return false;
</span><del>-    if (!decoder.decode(result.m_boolValues))
</del><ins>+    if (!decoder.decode(result.m_overridenDefaults))
</ins><span class="cx">         return false;
</span><del>-    if (!decoder.decode(result.m_uint32Values))
-        return false;
-    if (!decoder.decode(result.m_doubleValues))
-        return false;
-    if (!decoder.decode(result.m_floatValues))
-        return false;
</del><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -98,149 +155,129 @@
</span><span class="cx">     boolTestRunnerOverridesMap().clear();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template &lt;typename T&gt; struct ToType { };
</ins><span class="cx"> 
</span><del>-template&lt;typename MappedType&gt;
-MappedType defaultValueForKey(const String&amp;);
</del><ins>+template&lt;&gt; struct ToType&lt;String&gt; { static const auto value = WebPreferencesStore::Value::Type::String; };
+template&lt;&gt; struct ToType&lt;bool&gt; { static const auto value = WebPreferencesStore::Value::Type::Bool; };
+template&lt;&gt; struct ToType&lt;uint32_t&gt; { static const auto value = WebPreferencesStore::Value::Type::UInt32; };
+template&lt;&gt; struct ToType&lt;double&gt; { static const auto value = WebPreferencesStore::Value::Type::Double; };
</ins><span class="cx"> 
</span><del>-template&lt;&gt;
-String defaultValueForKey(const String&amp; key)
-{
-    static HashMap&lt;String, String&gt;&amp; defaults = *new HashMap&lt;String, String&gt;;
-    if (defaults.isEmpty()) {
-#define DEFINE_STRING_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
-        FOR_EACH_WEBKIT_STRING_PREFERENCE(DEFINE_STRING_DEFAULTS)
-        FOR_EACH_WEBKIT_STRING_PREFERENCE_NOT_IN_WEBCORE(DEFINE_STRING_DEFAULTS)
-#undef DEFINE_STRING_DEFAULTS
-    }
</del><span class="cx"> 
</span><del>-    return defaults.get(key);
-}
</del><ins>+template&lt;typename MappedType&gt; MappedType as(const WebPreferencesStore::Value&amp;);
</ins><span class="cx"> 
</span><del>-template&lt;&gt;
-bool defaultValueForKey(const String&amp; key)
-{
-    static HashMap&lt;String, bool&gt;&amp; defaults = *new HashMap&lt;String, bool&gt;;
-    if (defaults.isEmpty()) {
-#define DEFINE_BOOL_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
-        FOR_EACH_WEBKIT_BOOL_PREFERENCE(DEFINE_BOOL_DEFAULTS)
-#undef DEFINE_BOOL_DEFAULTS
-    }
</del><ins>+template&lt;&gt; String as&lt;String&gt;(const WebPreferencesStore::Value&amp; value) { return value.asString(); }
+template&lt;&gt; bool as&lt;bool&gt;(const WebPreferencesStore::Value&amp; value) { return value.asBool(); }
+template&lt;&gt; uint32_t as&lt;uint32_t&gt;(const WebPreferencesStore::Value&amp; value) { return value.asUInt32(); }
+template&lt;&gt; double as&lt;double&gt;(const WebPreferencesStore::Value&amp; value) { return value.asDouble(); }
</ins><span class="cx"> 
</span><del>-    return defaults.get(key);
-}
</del><span class="cx"> 
</span><del>-template&lt;&gt;
-uint32_t defaultValueForKey(const String&amp; key)
</del><ins>+static WebPreferencesStore::ValueMap&amp; defaults()
</ins><span class="cx"> {
</span><del>-    static HashMap&lt;String, uint32_t&gt;&amp; defaults = *new HashMap&lt;String, uint32_t&gt;;
-    if (defaults.isEmpty()) {
-#define DEFINE_UINT32_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
-        FOR_EACH_WEBKIT_UINT32_PREFERENCE(DEFINE_UINT32_DEFAULTS)
-#undef DEFINE_UINT32_DEFAULTS
</del><ins>+    static NeverDestroyed&lt;WebPreferencesStore::ValueMap&gt; defaults;
+    if (defaults.get().isEmpty()) {
+#define DEFINE_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.get().set(WebPreferencesKey::KeyLower##Key(), WebPreferencesStore::Value((Type)DefaultValue));
+        FOR_EACH_WEBKIT_PREFERENCE(DEFINE_DEFAULTS)
+#undef DEFINE_DEFAULTS
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return defaults.get(key);
</del><ins>+    return defaults;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-template&lt;&gt;
-double defaultValueForKey(const String&amp; key)
</del><ins>+template&lt;typename MappedType&gt;
+static MappedType valueForKey(const WebPreferencesStore::ValueMap&amp; values, const WebPreferencesStore::ValueMap&amp; overridenDefaults, const String&amp; key)
</ins><span class="cx"> {
</span><del>-    static HashMap&lt;String, double&gt;&amp; defaults = *new HashMap&lt;String, double&gt;;
-    if (defaults.isEmpty()) {
-#define DEFINE_DOUBLE_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
-        FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(DEFINE_DOUBLE_DEFAULTS)
-#undef DEFINE_DOUBLE_DEFAULTS
-    }
</del><ins>+    auto valuesIt = values.find(key);
+    if (valuesIt != values.end() &amp;&amp; valuesIt-&gt;value.type() == ToType&lt;MappedType&gt;::value)
+        return as&lt;MappedType&gt;(valuesIt-&gt;value);
</ins><span class="cx"> 
</span><del>-    return defaults.get(key);
-}
</del><ins>+    auto overridenDefaultsIt = overridenDefaults.find(key);
+    if (overridenDefaultsIt != overridenDefaults.end() &amp;&amp; overridenDefaultsIt-&gt;value.type() == ToType&lt;MappedType&gt;::value)
+        return as&lt;MappedType&gt;(overridenDefaultsIt-&gt;value);
</ins><span class="cx"> 
</span><del>-template&lt;&gt;
-float defaultValueForKey(const String&amp; key)
-{
-    static HashMap&lt;String, float&gt;&amp; defaults = *new HashMap&lt;String, float&gt;;
-    if (defaults.isEmpty()) {
-#define DEFINE_FLOAT_DEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) defaults.set(WebPreferencesKey::KeyLower##Key(), DefaultValue);
-        FOR_EACH_WEBKIT_FLOAT_PREFERENCE(DEFINE_FLOAT_DEFAULTS)
-#undef DEFINE_FLOAT_DEFAULTS
-    }
</del><ins>+    auto defaultsMap = defaults();
+    auto defaultsIt = defaultsMap.find(key);
+    if (defaultsIt != defaultsMap.end() &amp;&amp; defaultsIt-&gt;value.type() == ToType&lt;MappedType&gt;::value)
+        return as&lt;MappedType&gt;(defaultsIt-&gt;value);
</ins><span class="cx"> 
</span><del>-    return defaults.get(key);
</del><ins>+    return MappedType();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-template&lt;typename MapType&gt;
-static typename MapType::MappedType valueForKey(const MapType&amp; map, const typename MapType::KeyType&amp; key)
</del><ins>+template&lt;typename MappedType&gt;
+static bool setValueForKey(WebPreferencesStore::ValueMap&amp; map, const WebPreferencesStore::ValueMap&amp; overridenDefaults, const String&amp; key, const MappedType&amp; value)
</ins><span class="cx"> {
</span><del>-    typename MapType::const_iterator it = map.find(key);
-    if (it != map.end())
-        return it-&gt;value;
-
-    return defaultValueForKey&lt;typename MapType::MappedType&gt;(key);
-}
-
-template&lt;typename MapType&gt;
-static bool setValueForKey(MapType&amp; map, const typename MapType::KeyType&amp; key, const typename MapType::MappedType&amp; value)
-{
-    typename MapType::MappedType existingValue = valueForKey(map, key);
</del><ins>+    MappedType existingValue = valueForKey&lt;MappedType&gt;(map, overridenDefaults, key);
</ins><span class="cx">     if (existingValue == value)
</span><span class="cx">         return false;
</span><del>-    
-    map.set(key, value);
</del><ins>+
+    map.set(key, WebPreferencesStore::Value(value));
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebPreferencesStore::setStringValueForKey(const String&amp; key, const String&amp; value)
</span><span class="cx"> {
</span><del>-    return setValueForKey(m_stringValues, key, value);
</del><ins>+    return setValueForKey&lt;String&gt;(m_values, m_overridenDefaults, key, value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String WebPreferencesStore::getStringValueForKey(const String&amp; key) const
</span><span class="cx"> {
</span><del>-    return valueForKey(m_stringValues, key);
</del><ins>+    return valueForKey&lt;String&gt;(m_values, m_overridenDefaults, key);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebPreferencesStore::setBoolValueForKey(const String&amp; key, bool value)
</span><span class="cx"> {
</span><del>-    return setValueForKey(m_boolValues, key, value);
</del><ins>+    return setValueForKey&lt;bool&gt;(m_values, m_overridenDefaults, key, value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebPreferencesStore::getBoolValueForKey(const String&amp; key) const
</span><span class="cx"> {
</span><span class="cx">     // FIXME: Extend overriding to other key types used from TestRunner.
</span><del>-    BoolOverridesMap::const_iterator it = boolTestRunnerOverridesMap().find(key);
</del><ins>+    auto it = boolTestRunnerOverridesMap().find(key);
</ins><span class="cx">     if (it != boolTestRunnerOverridesMap().end())
</span><span class="cx">         return it-&gt;value;
</span><del>-    return valueForKey(m_boolValues, key);
</del><ins>+
+    return valueForKey&lt;bool&gt;(m_values, m_overridenDefaults, key);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebPreferencesStore::setUInt32ValueForKey(const String&amp; key, uint32_t value) 
</span><span class="cx"> {
</span><del>-    return setValueForKey(m_uint32Values, key, value);
</del><ins>+    return setValueForKey&lt;uint32_t&gt;(m_values, m_overridenDefaults, key, value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> uint32_t WebPreferencesStore::getUInt32ValueForKey(const String&amp; key) const
</span><span class="cx"> {
</span><del>-    return valueForKey(m_uint32Values, key);
</del><ins>+    return valueForKey&lt;uint32_t&gt;(m_values, m_overridenDefaults, key);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebPreferencesStore::setDoubleValueForKey(const String&amp; key, double value) 
</span><span class="cx"> {
</span><del>-    return setValueForKey(m_doubleValues, key, value);
</del><ins>+    return setValueForKey&lt;double&gt;(m_values, m_overridenDefaults, key, value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> double WebPreferencesStore::getDoubleValueForKey(const String&amp; key) const
</span><span class="cx"> {
</span><del>-    return valueForKey(m_doubleValues, key);
</del><ins>+    return valueForKey&lt;double&gt;(m_values, m_overridenDefaults, key);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool WebPreferencesStore::setFloatValueForKey(const String&amp; key, float value) 
</del><ins>+// Overriden Defaults
+
+void WebPreferencesStore::setOverrideDefaultsStringValueForKey(const String&amp; key, String value)
</ins><span class="cx"> {
</span><del>-    return setValueForKey(m_floatValues, key, value);
</del><ins>+    m_overridenDefaults.set(key, Value(value));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-float WebPreferencesStore::getFloatValueForKey(const String&amp; key) const
</del><ins>+void WebPreferencesStore::setOverrideDefaultsBoolValueForKey(const String&amp; key, bool value)
</ins><span class="cx"> {
</span><del>-    return valueForKey(m_floatValues, key);
</del><ins>+    m_overridenDefaults.set(key, Value(value));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPreferencesStore::setOverrideDefaultsUInt32ValueForKey(const String&amp; key, uint32_t value)
+{
+    m_overridenDefaults.set(key, Value(value));
+}
+
+void WebPreferencesStore::setOverrideDefaultsDoubleValueForKey(const String&amp; key, double value)
+{
+    m_overridenDefaults.set(key, Value(value));
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPreferencesStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPreferencesStore.h (169320 => 169321)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebPreferencesStore.h        2014-05-25 18:09:16 UTC (rev 169320)
+++ trunk/Source/WebKit2/Shared/WebPreferencesStore.h        2014-05-25 18:59:41 UTC (rev 169321)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ArgumentDecoder.h&quot;
</span><span class="cx"> #include &quot;ArgumentEncoder.h&quot;
</span><ins>+#include &lt;WebCore/SecurityOrigin.h&gt;
</ins><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringHash.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="lines">@@ -176,7 +177,6 @@
</span><span class="cx">     macro(TabToLinksEnabled, tabToLinksEnabled, Bool, bool, false) \
</span><span class="cx">     macro(InteractiveFormValidationEnabled, interactiveFormValidationEnabled, Bool, bool, false) \
</span><span class="cx">     macro(ScrollingPerformanceLoggingEnabled, scrollingPerformanceLoggingEnabled, Bool, bool, false) \
</span><del>-    macro(StorageBlockingPolicy, storageBlockingPolicy, UInt32, uint32_t, 0) \
</del><span class="cx">     macro(ScrollAnimatorEnabled, scrollAnimatorEnabled, Bool, bool, DEFAULT_WEBKIT_SCROLL_ANIMATOR_ENABLED) \
</span><span class="cx">     macro(ScreenFontSubstitutionEnabled, screenFontSubstitutionEnabled, Bool, bool, DEFAULT_SCREEN_FONT_SUBSTITUTION_ENABLED) \
</span><span class="cx">     macro(CookieEnabled, cookieEnabled, Bool, bool, true) \
</span><span class="lines">@@ -233,9 +233,6 @@
</span><span class="cx">     macro(PasswordEchoDuration, passwordEchoDuration, Double, double, 2) \
</span><span class="cx">     \
</span><span class="cx"> 
</span><del>-#define FOR_EACH_WEBKIT_FLOAT_PREFERENCE(macro) \
-    \
-
</del><span class="cx"> #define FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
</span><span class="cx">     macro(FontSmoothingLevel, fontSmoothingLevel, UInt32, uint32_t, FontSmoothingLevelMedium) \
</span><span class="cx">     macro(LayoutFallbackWidth, layoutFallbackWidth, UInt32, uint32_t, 980) \
</span><span class="lines">@@ -246,6 +243,7 @@
</span><span class="cx">     macro(InspectorAttachedHeight, inspectorAttachedHeight, UInt32, uint32_t, 300) \
</span><span class="cx">     macro(InspectorAttachedWidth, inspectorAttachedWidth, UInt32, uint32_t, 750) \
</span><span class="cx">     macro(InspectorAttachmentSide, inspectorAttachmentSide, UInt32, uint32_t, 0) \
</span><ins>+    macro(StorageBlockingPolicy, storageBlockingPolicy, UInt32, uint32_t, WebCore::SecurityOrigin::AllowAllStorage) \
</ins><span class="cx">     \
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="lines">@@ -296,7 +294,6 @@
</span><span class="cx"> #define FOR_EACH_WEBKIT_PREFERENCE(macro) \
</span><span class="cx">     FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
</span><span class="cx">     FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
</span><del>-    FOR_EACH_WEBKIT_FLOAT_PREFERENCE(macro) \
</del><span class="cx">     FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
</span><span class="cx">     FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
</span><span class="cx">     FOR_EACH_WEBKIT_STRING_PREFERENCE_NOT_IN_WEBCORE(macro) \
</span><span class="lines">@@ -332,18 +329,132 @@
</span><span class="cx">     bool setDoubleValueForKey(const String&amp; key, double value);
</span><span class="cx">     double getDoubleValueForKey(const String&amp; key) const;
</span><span class="cx"> 
</span><del>-    bool setFloatValueForKey(const String&amp; key, float value);
-    float getFloatValueForKey(const String&amp; key) const;
</del><ins>+    void setOverrideDefaultsStringValueForKey(const String&amp; key, String value);
+    void setOverrideDefaultsBoolValueForKey(const String&amp; key, bool value);
+    void setOverrideDefaultsUInt32ValueForKey(const String&amp; key, uint32_t value);
+    void setOverrideDefaultsDoubleValueForKey(const String&amp; key, double value);
</ins><span class="cx"> 
</span><span class="cx">     // For WebKitTestRunner usage.
</span><span class="cx">     static void overrideBoolValueForKey(const String&amp; key, bool value);
</span><span class="cx">     static void removeTestRunnerOverrides();
</span><span class="cx"> 
</span><del>-    HashMap&lt;String, String&gt; m_stringValues;
-    HashMap&lt;String, bool&gt; m_boolValues;
-    HashMap&lt;String, uint32_t&gt; m_uint32Values;
-    HashMap&lt;String, double&gt; m_doubleValues;
-    HashMap&lt;String, float&gt; m_floatValues;
</del><ins>+    struct Value {
+        enum class Type {
+            None,
+            String,
+            Bool,
+            UInt32,
+            Double,
+        };
+
+        void encode(IPC::ArgumentEncoder&amp;) const;
+        static bool decode(IPC::ArgumentDecoder&amp;, Value&amp;);
+
+        explicit Value() : m_type(Type::None) { }
+        explicit Value(const String&amp; value) : m_type(Type::String), m_string(value) { }
+        explicit Value(bool value) : m_type(Type::Bool), m_bool(value) { }
+        explicit Value(uint32_t value) : m_type(Type::UInt32), m_uint32(value) { }
+        explicit Value(double value) : m_type(Type::Double), m_double(value) { }
+
+        Value(Value&amp;&amp; value)
+            : m_type(value.m_type)
+        {
+            switch (m_type) {
+            case Type::None:
+                break;
+            case Type::String:
+                new (&amp;m_string) String(std::move(value.m_string));
+                break;
+            case Type::Bool:
+                m_bool = value.m_bool;
+                break;
+            case Type::UInt32:
+                m_uint32 = value.m_uint32;
+                break;
+            case Type::Double:
+                m_double = value.m_double;
+                break;
+            }
+        }
+
+        Value&amp; operator=(const Value&amp; other)
+        {
+            if (this == &amp;other)
+                return *this;
+                
+            destroy();
+
+            m_type = other.m_type;
+            switch (m_type) {
+            case Type::None:
+                break;
+            case Type::String:
+                new (&amp;m_string) String(other.m_string);
+                break;
+            case Type::Bool:
+                m_bool = other.m_bool;
+                break;
+            case Type::UInt32:
+                m_uint32 = other.m_uint32;
+                break;
+            case Type::Double:
+                m_double = other.m_double;
+                break;
+            }
+    
+            return *this;
+        }
+
+        ~Value()
+        {
+            destroy();
+        }
+
+        Type type() const { return m_type; }
+
+        String asString() const
+        {
+            ASSERT(m_type == Type::String);
+            return m_string;
+        }
+
+        bool asBool() const
+        {
+            ASSERT(m_type == Type::Bool);
+            return m_bool;
+        }
+
+        uint32_t asUInt32() const
+        {
+            ASSERT(m_type == Type::UInt32);
+            return m_uint32;
+        }
+
+        double asDouble() const
+        {
+            ASSERT(m_type == Type::Double);
+            return m_double;
+        }
+
+    private:
+        void destroy()
+        {
+            if (m_type == Type::String)
+                m_string.~String();
+        }
+
+        Type m_type;
+        union {
+            String m_string;
+            bool m_bool;
+            uint32_t m_uint32;
+            double m_double;
+        };
+    };
+
+    typedef HashMap&lt;String, Value&gt; ValueMap;
+    ValueMap m_values;
+    ValueMap m_overridenDefaults;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKPreferencesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.h (169320 => 169321)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.h        2014-05-25 18:09:16 UTC (rev 169320)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKPreferences.h        2014-05-25 18:59:41 UTC (rev 169321)
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx">  A @link WKWebView @/link can specify which WKPreferences object it uses through its @link WKWebViewConfiguration @/link.
</span><span class="cx">  */
</span><span class="cx"> WK_CLASS_AVAILABLE(10_10, 8_0)
</span><del>-@interface WKPreferences : NSObject
</del><ins>+@interface      : NSObject
</ins><span class="cx"> 
</span><span class="cx"> /*! @abstract Returns an initialized WKPreferences object.
</span><span class="cx">  @param userDefaultsKeyPrefix The user defaults key prefix.
</span></span></pre>
</div>
</div>

</body>
</html>