[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

weinig at apple.com weinig at apple.com
Wed Dec 22 17:55:08 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit df25d143557829e7fbfe2bc328d93653bb23224a
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 2 18:30:05 2010 +0000

    https://bugs.webkit.org/show_bug.cgi?id=50368
    Overhaul WebKit2 preferences code
    
    Reviewed by Anders Carlsson.
    
    - Reduces the number of places you have to touch to add a new preference
      (From 9 down to 4, but with a bit of elbow grease, we should get that
       down to 2 or 3).
    - Add hooks so that platforms can initialize the preferences based on an
      identifier. This is currently only used on the Mac to initialize a
      preference store from NSUserDefaults and autosave the changes to disk.
      It is not yet enabled due to no way to set the identifier from client
      code.
    
    * Shared/WebPageCreationParameters.cpp:
    Add necessary #include of WebCoreArgumentCoders.h which is now needed
    due to cleanup in WebPreferencesStore.h.
    
    * Shared/WebPreferencesStore.cpp:
    (WebKit::WebPreferencesStore::WebPreferencesStore):
    (WebKit::WebPreferencesStore::encode):
    (WebKit::WebPreferencesStore::decode):
    (WebKit::defaultValueForKey):
    (WebKit::setValueForKey):
    (WebKit::valueForKey):
    (WebKit::WebPreferencesStore::setStringValueForKey):
    (WebKit::WebPreferencesStore::getStringValueForKey):
    (WebKit::WebPreferencesStore::setBoolValueForKey):
    (WebKit::WebPreferencesStore::getBoolValueForKey):
    (WebKit::WebPreferencesStore::setUInt32ValueForKey):
    (WebKit::WebPreferencesStore::getUInt32ValueForKey):
    * Shared/WebPreferencesStore.h:
    Complete overhaul of this class to store the preferences as
    a set of HashMaps and use macros to define the keys and default
    values.
    
    * UIProcess/API/C/WKPreferences.cpp:
    (WKPreferencesGetFontSmoothingLevel):
    Add cast to keep conversion function working.
    
    * UIProcess/WebPreferences.cpp:
    (WebKit::WebPreferences::WebPreferences): Add identifier constructor.
    (WebKit::WebPreferences::updateStringValueForKey):
    (WebKit::WebPreferences::updateBoolValueForKey):
    (WebKit::WebPreferences::updateUInt32ValueForKey):
    Add type based updaters. These currently give hooks to the platform and
    call the generic update, but in the future, we can use this to optimize
    updating preferences to not send the entire store for each change.
    
    * UIProcess/WebPreferences.h:
    Generate the getters and setters via macro instantiation.
    
    * UIProcess/cf/WebPreferencesCF.cpp: Added.
    (WebKit::WebPreferences::platformInitializeStore):
    (WebKit::WebPreferences::platformUpdateStringValueForKey):
    (WebKit::WebPreferences::platformUpdateBoolValueForKey):
    (WebKit::WebPreferences::platformUpdateUInt32ValueForKey):
    Stubbed out.
    
    * UIProcess/mac/WebPreferencesMac.mm: Added.
    (WebKit::makeKey):
    (WebKit::setStringValueIfInUserDefaults):
    (WebKit::setBoolValueIfInUserDefaults):
    (WebKit::setUInt32ValueIfInUserDefaults):
    (WebKit::WebPreferences::platformInitializeStore):
    (WebKit::WebPreferences::platformUpdateStringValueForKey):
    (WebKit::WebPreferences::platformUpdateBoolValueForKey):
    (WebKit::WebPreferences::platformUpdateUInt32ValueForKey):
    Use the platform hooks to initialize and update the store from
    NSUserDefaults.
    
    * UIProcess/qt/WebPreferencesQt.cpp: Added.
    (WebKit::WebPreferences::platformInitializeStore):
    (WebKit::WebPreferences::platformUpdateStringValueForKey):
    (WebKit::WebPreferences::platformUpdateBoolValueForKey):
    (WebKit::WebPreferences::platformUpdateUInt32ValueForKey):
    Stubbed out.
    
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::updatePreferences):
    * WebProcess/WebPage/win/WebPageWin.cpp:
    (WebKit::WebPage::platformPreferencesDidChange):
    Update to pull the value using the new type based getters.
    
    * WebKit2.pro:
    * WebKit2.xcodeproj/project.pbxproj:
    * win/WebKit2.vcproj:
    Add new files.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73154 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index ab344d7..fc0584f 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,94 @@
+2010-12-02  Sam Weinig  <sam at webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        https://bugs.webkit.org/show_bug.cgi?id=50368
+        Overhaul WebKit2 preferences code
+
+        - Reduces the number of places you have to touch to add a new preference
+          (From 9 down to 4, but with a bit of elbow grease, we should get that
+           down to 2 or 3).
+        - Add hooks so that platforms can initialize the preferences based on an
+          identifier. This is currently only used on the Mac to initialize a
+          preference store from NSUserDefaults and autosave the changes to disk.
+          It is not yet enabled due to no way to set the identifier from client
+          code.
+
+        * Shared/WebPageCreationParameters.cpp:
+        Add necessary #include of WebCoreArgumentCoders.h which is now needed
+        due to cleanup in WebPreferencesStore.h.
+
+        * Shared/WebPreferencesStore.cpp:
+        (WebKit::WebPreferencesStore::WebPreferencesStore):
+        (WebKit::WebPreferencesStore::encode):
+        (WebKit::WebPreferencesStore::decode):
+        (WebKit::defaultValueForKey):
+        (WebKit::setValueForKey):
+        (WebKit::valueForKey):
+        (WebKit::WebPreferencesStore::setStringValueForKey):
+        (WebKit::WebPreferencesStore::getStringValueForKey):
+        (WebKit::WebPreferencesStore::setBoolValueForKey):
+        (WebKit::WebPreferencesStore::getBoolValueForKey):
+        (WebKit::WebPreferencesStore::setUInt32ValueForKey):
+        (WebKit::WebPreferencesStore::getUInt32ValueForKey):
+        * Shared/WebPreferencesStore.h:
+        Complete overhaul of this class to store the preferences as
+        a set of HashMaps and use macros to define the keys and default
+        values.
+
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesGetFontSmoothingLevel):
+        Add cast to keep conversion function working.
+
+        * UIProcess/WebPreferences.cpp:
+        (WebKit::WebPreferences::WebPreferences): Add identifier constructor.
+        (WebKit::WebPreferences::updateStringValueForKey):
+        (WebKit::WebPreferences::updateBoolValueForKey):
+        (WebKit::WebPreferences::updateUInt32ValueForKey):
+        Add type based updaters. These currently give hooks to the platform and
+        call the generic update, but in the future, we can use this to optimize
+        updating preferences to not send the entire store for each change.
+
+        * UIProcess/WebPreferences.h:
+        Generate the getters and setters via macro instantiation.
+
+        * UIProcess/cf/WebPreferencesCF.cpp: Added.
+        (WebKit::WebPreferences::platformInitializeStore):
+        (WebKit::WebPreferences::platformUpdateStringValueForKey):
+        (WebKit::WebPreferences::platformUpdateBoolValueForKey):
+        (WebKit::WebPreferences::platformUpdateUInt32ValueForKey):
+        Stubbed out.
+
+        * UIProcess/mac/WebPreferencesMac.mm: Added.
+        (WebKit::makeKey):
+        (WebKit::setStringValueIfInUserDefaults):
+        (WebKit::setBoolValueIfInUserDefaults):
+        (WebKit::setUInt32ValueIfInUserDefaults):
+        (WebKit::WebPreferences::platformInitializeStore):
+        (WebKit::WebPreferences::platformUpdateStringValueForKey):
+        (WebKit::WebPreferences::platformUpdateBoolValueForKey):
+        (WebKit::WebPreferences::platformUpdateUInt32ValueForKey):
+        Use the platform hooks to initialize and update the store from
+        NSUserDefaults.
+        
+        * UIProcess/qt/WebPreferencesQt.cpp: Added.
+        (WebKit::WebPreferences::platformInitializeStore):
+        (WebKit::WebPreferences::platformUpdateStringValueForKey):
+        (WebKit::WebPreferences::platformUpdateBoolValueForKey):
+        (WebKit::WebPreferences::platformUpdateUInt32ValueForKey):
+        Stubbed out.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+        * WebProcess/WebPage/win/WebPageWin.cpp:
+        (WebKit::WebPage::platformPreferencesDidChange):
+        Update to pull the value using the new type based getters.
+
+        * WebKit2.pro:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * win/WebKit2.vcproj:
+        Add new files.
+
 2010-12-02  Steve Falkenburg  <sfalken at apple.com>
 
         Mac build fix.
diff --git a/WebKit2/Shared/WebPageCreationParameters.cpp b/WebKit2/Shared/WebPageCreationParameters.cpp
index 3c95863..007a2c3 100644
--- a/WebKit2/Shared/WebPageCreationParameters.cpp
+++ b/WebKit2/Shared/WebPageCreationParameters.cpp
@@ -25,7 +25,7 @@
 
 #include "WebPageCreationParameters.h"
 
-#include "ArgumentCoders.h"
+#include "WebCoreArgumentCoders.h"
 
 namespace WebKit {
 
diff --git a/WebKit2/Shared/WebPreferencesStore.cpp b/WebKit2/Shared/WebPreferencesStore.cpp
index 2e26ffd..bd8f01a 100644
--- a/WebKit2/Shared/WebPreferencesStore.cpp
+++ b/WebKit2/Shared/WebPreferencesStore.cpp
@@ -26,138 +26,45 @@
 #include "WebPreferencesStore.h"
 
 #include "FontSmoothingLevel.h"
+#include "WebCoreArgumentCoders.h"
 
 namespace WebKit {
 
+namespace WebPreferencesKey {
+
+#define DEFINE_KEY_GETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
+        const String& KeyLower##Key() \
+        { \
+            DEFINE_STATIC_LOCAL(String, key, (#KeyUpper)); \
+            return key; \
+        }
+
+    FOR_EACH_WEBKIT_PREFERENCE(DEFINE_KEY_GETTERS)
+
+#undef DEFINE_KEY_GETTERS
+
+} // namespace WebPreferencesKey
+
+
 static bool hasXSSAuditorEnabledTestRunnerOverride;
 static bool xssAuditorEnabledTestRunnerOverride;
 
 WebPreferencesStore::WebPreferencesStore()
-    : javaScriptEnabled(true)
-    , loadsImagesAutomatically(true)
-    , pluginsEnabled(true)
-    , javaEnabled(true)
-    , offlineWebApplicationCacheEnabled(false)
-    , localStorageEnabled(true)
-    , xssAuditorEnabled(true)
-    , frameFlatteningEnabled(false)
-    , developerExtrasEnabled(false)
-    , privateBrowsingEnabled(false)
-    , textAreasAreResizable(true)
-    , needsSiteSpecificQuirks(false)
-    , acceleratedCompositingEnabled(true)
-    , compositingBordersVisible(false)
-    , compositingRepaintCountersVisible(false)
-    , fontSmoothingLevel(FontSmoothingLevelMedium)
-    , minimumFontSize(0)
-    , minimumLogicalFontSize(9)
-    , defaultFontSize(16)
-    , defaultFixedFontSize(13)
-#if PLATFORM(WIN)
-    , standardFontFamily("Times New Roman")
-    , cursiveFontFamily("Comic Sans MS")
-    , fantasyFontFamily("Comic Sans MS")
-    , fixedFontFamily("Courier New")
-    , sansSerifFontFamily("Arial")
-    , serifFontFamily("Times New Roman")
-#else
-    , standardFontFamily("Times")
-    , cursiveFontFamily("Apple Chancery")
-    , fantasyFontFamily("Papyrus")
-    , fixedFontFamily("Courier")
-    , sansSerifFontFamily("Helvetica")
-    , serifFontFamily("Times")
-#endif
 {
 }
 
 void WebPreferencesStore::encode(CoreIPC::ArgumentEncoder* encoder) const
 {
-    encoder->encode(javaScriptEnabled);
-    encoder->encode(loadsImagesAutomatically);
-    encoder->encode(pluginsEnabled);
-    encoder->encode(javaEnabled);
-    encoder->encode(offlineWebApplicationCacheEnabled);
-    encoder->encode(localStorageEnabled);
-    encoder->encode(xssAuditorEnabled);
-    encoder->encode(frameFlatteningEnabled);
-    encoder->encode(privateBrowsingEnabled);
-    encoder->encode(textAreasAreResizable);
-    encoder->encode(developerExtrasEnabled);
-    encoder->encode(fontSmoothingLevel);
-    encoder->encode(minimumFontSize);
-    encoder->encode(minimumLogicalFontSize);
-    encoder->encode(defaultFontSize);
-    encoder->encode(defaultFixedFontSize);
-    encoder->encode(standardFontFamily);
-    encoder->encode(cursiveFontFamily);
-    encoder->encode(fantasyFontFamily);
-    encoder->encode(fixedFontFamily);
-    encoder->encode(sansSerifFontFamily);
-    encoder->encode(serifFontFamily);
-    encoder->encode(acceleratedCompositingEnabled);
-    encoder->encode(compositingBordersVisible);
-    encoder->encode(compositingRepaintCountersVisible);
-    encoder->encode(needsSiteSpecificQuirks);
+    encoder->encode(CoreIPC::In(m_stringValues, m_boolValues, m_uint32Values));
 }
 
 bool WebPreferencesStore::decode(CoreIPC::ArgumentDecoder* decoder, WebPreferencesStore& s)
 {
-    if (!decoder->decode(s.javaScriptEnabled))
-        return false;
-    if (!decoder->decode(s.loadsImagesAutomatically))
-        return false;
-    if (!decoder->decode(s.pluginsEnabled))
-        return false;
-    if (!decoder->decode(s.javaEnabled))
-        return false;
-    if (!decoder->decode(s.offlineWebApplicationCacheEnabled))
-        return false;
-    if (!decoder->decode(s.localStorageEnabled))
-        return false;
-    if (!decoder->decode(s.xssAuditorEnabled))
-        return false;
-    if (!decoder->decode(s.frameFlatteningEnabled))
-        return false;
-    if (!decoder->decode(s.privateBrowsingEnabled))
-        return false;
-    if (!decoder->decode(s.textAreasAreResizable))
-        return false;
-    if (!decoder->decode(s.developerExtrasEnabled))
-        return false;
-    if (!decoder->decode(s.fontSmoothingLevel))
-        return false;
-    if (!decoder->decode(s.minimumFontSize))
-        return false;
-    if (!decoder->decode(s.minimumLogicalFontSize))
-        return false;
-    if (!decoder->decode(s.defaultFontSize))
-        return false;
-    if (!decoder->decode(s.defaultFixedFontSize))
-        return false;
-    if (!decoder->decode(s.standardFontFamily))
-        return false;
-    if (!decoder->decode(s.cursiveFontFamily))
-        return false;
-    if (!decoder->decode(s.fantasyFontFamily))
-        return false;
-    if (!decoder->decode(s.fixedFontFamily))
-        return false;
-    if (!decoder->decode(s.sansSerifFontFamily))
-        return false;
-    if (!decoder->decode(s.serifFontFamily))
-        return false;
-    if (!decoder->decode(s.acceleratedCompositingEnabled))
-        return false;
-    if (!decoder->decode(s.compositingBordersVisible))
-        return false;
-    if (!decoder->decode(s.compositingRepaintCountersVisible))
-        return false;
-    if (!decoder->decode(s.needsSiteSpecificQuirks))
+    if (!decoder->decode(CoreIPC::Out(s.m_stringValues, s.m_boolValues, s.m_uint32Values)))
         return false;
 
     if (hasXSSAuditorEnabledTestRunnerOverride)
-        s.xssAuditorEnabled = xssAuditorEnabledTestRunnerOverride;
+        s.m_boolValues.set(WebPreferencesKey::xssAuditorEnabledKey(), xssAuditorEnabledTestRunnerOverride);
 
     return true;
 }
@@ -173,4 +80,99 @@ void WebPreferencesStore::removeTestRunnerOverrides()
     hasXSSAuditorEnabledTestRunnerOverride = false;
 }
 
+
+template<typename MappedType>
+MappedType defaultValueForKey(const String&);
+
+template<>
+String defaultValueForKey(const String& key)
+{
+    static HashMap<String, String>& defaults = *new HashMap<String, String>;
+    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)
+#undef DEFINE_STRING_DEFAULTS
+    }
+
+    return defaults.get(key);
+}
+
+template<>
+bool defaultValueForKey(const String& key)
+{
+    static HashMap<String, bool>& defaults = *new HashMap<String, bool>;
+    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
+    }
+
+    return defaults.get(key);
+}
+
+template<>
+uint32_t defaultValueForKey(const String& key)
+{
+    static HashMap<String, uint32_t>& defaults = *new HashMap<String, uint32_t>;
+    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
+    }
+
+    return defaults.get(key);
+}
+
+
+template<typename MapType>
+static bool setValueForKey(MapType& map, const typename MapType::KeyType& key, const typename MapType::MappedType& value)
+{
+    typename MapType::MappedType existingValue = valueForKey(map, key);
+    if (existingValue == value)
+        return false;
+    
+    map.set(key, value);
+    return true;
+}
+
+template<typename MapType>
+static typename MapType::MappedType valueForKey(const MapType& map, const typename MapType::KeyType& key)
+{
+    typename MapType::const_iterator it = map.find(key);
+    if (it != map.end())
+        return it->second;
+
+    return defaultValueForKey<typename MapType::MappedType>(key);
+}
+
+bool WebPreferencesStore::setStringValueForKey(const String& key, const String& value)
+{
+    return setValueForKey(m_stringValues, key, value);
+}
+
+String WebPreferencesStore::getStringValueForKey(const String& key) const
+{
+    return valueForKey(m_stringValues, key);
+}
+
+bool WebPreferencesStore::setBoolValueForKey(const String& key, bool value)
+{
+    return setValueForKey(m_boolValues, key, value);
+}
+
+bool WebPreferencesStore::getBoolValueForKey(const String& key) const
+{
+    return valueForKey(m_boolValues, key);
+}
+
+bool WebPreferencesStore::setUInt32ValueForKey(const String& key, uint32_t value) 
+{
+    return setValueForKey(m_uint32Values, key, value);
+}
+
+uint32_t WebPreferencesStore::getUInt32ValueForKey(const String& key) const
+{
+    return valueForKey(m_uint32Values, key);
+}
+
 } // namespace WebKit
diff --git a/WebKit2/Shared/WebPreferencesStore.h b/WebKit2/Shared/WebPreferencesStore.h
index 329f4c1..a562d9d 100644
--- a/WebKit2/Shared/WebPreferencesStore.h
+++ b/WebKit2/Shared/WebPreferencesStore.h
@@ -28,46 +28,103 @@
 
 #include "ArgumentDecoder.h"
 #include "ArgumentEncoder.h"
-#include "WebCoreArgumentCoders.h"
+#include <wtf/HashMap.h>
+#include <wtf/text/StringHash.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebKit {
 
+// macro(KeyUpper, KeyLower, TypeNameUpper, TypeName, DefaultValue) 
+
+#define FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
+    macro(JavaScriptEnabled, javaScriptEnabled, Bool, bool, true) \
+    macro(LoadsImagesAutomatically, loadsImagesAutomatically, Bool, bool, true) \
+    macro(PluginsEnabled, pluginsEnabled, Bool, bool, true) \
+    macro(JavaEnabled, javaEnabled, Bool, bool, true) \
+    macro(OfflineWebApplicationCacheEnabled, offlineWebApplicationCacheEnabled, Bool, bool, false) \
+    macro(LocalStorageEnabled, localStorageEnabled, Bool, bool, true) \
+    macro(XSSAuditorEnabled, xssAuditorEnabled, Bool, bool, true) \
+    macro(FrameFlatteningEnabled, frameFlatteningEnabled, Bool, bool, false) \
+    macro(DeveloperExtrasEnabled, developerExtrasEnabled, Bool, bool, false) \
+    macro(PrivateBrowsingEnabled, privateBrowsingEnabled, Bool, bool, false) \
+    macro(TextAreasAreResizable, textAreasAreResizable, Bool, bool, true) \
+    macro(NeedsSiteSpecificQuirks, needsSiteSpecificQuirks, Bool, bool, false) \
+    macro(AcceleratedCompositingEnabled, acceleratedCompositingEnabled, Bool, bool, true) \
+    macro(CompositingBordersVisible, compositingBordersVisible, Bool, bool, false) \
+    macro(CompositingRepaintCountersVisible, compositingRepaintCountersVisible, Bool, bool, false) \
+    \
+
+#define FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
+    macro(FontSmoothingLevel, fontSmoothingLevel, UInt32, uint32_t, FontSmoothingLevelMedium) \
+    macro(MinimumFontSize, minimumFontSize, UInt32, uint32_t, 0) \
+    macro(MinimumLogicalFontSize, minimumLogicalFontSize, UInt32, uint32_t, 9) \
+    macro(DefaultFontSize, defaultFontSize, UInt32, uint32_t, 16) \
+    macro(DefaultFixedFontSize, defaultFixedFontSize, UInt32, uint32_t, 13) \
+    \
+
+#if PLATFORM(WIN)
+
+#define FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
+    macro(StandardFontFamily, standardFontFamily, String, String, "Times New Roman") \
+    macro(CursiveFontFamily, cursiveFontFamily, String, String, "Comic Sans MS") \
+    macro(FantasyFontFamily, fantasyFontFamily, String, String, "Comic Sans MS") \
+    macro(FixedFontFamily, fixedFontFamily, String, String, "Courier New") \
+    macro(SansSerifFontFamily, sansSerifFontFamily, String, String, "Arial") \
+    macro(SerifFontFamily, serifFontFamily, String, String, "Times New Roman") \
+    \
+
+#else
+
+#define FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
+    macro(StandardFontFamily, standardFontFamily, String, String, "Times") \
+    macro(CursiveFontFamily, cursiveFontFamily, String, String, "Apple Chancery") \
+    macro(FantasyFontFamily, fantasyFontFamily, String, String, "Papyrus") \
+    macro(FixedFontFamily, fixedFontFamily, String, String, "Courier") \
+    macro(SansSerifFontFamily, sansSerifFontFamily, String, String, "Courier") \
+    macro(SerifFontFamily, serifFontFamily, String, String, "Times") \
+    \
+
+#endif
+
+#define FOR_EACH_WEBKIT_PREFERENCE(macro) \
+    FOR_EACH_WEBKIT_BOOL_PREFERENCE(macro) \
+    FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
+    FOR_EACH_WEBKIT_STRING_PREFERENCE(macro) \
+    \
+
+namespace WebPreferencesKey {
+
+#define DECLARE_KEY_GETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) const String& KeyLower##Key();
+
+    FOR_EACH_WEBKIT_PREFERENCE(DECLARE_KEY_GETTERS)
+
+#undef DECLARE_KEY_GETTERS
+
+} // namespace WebPreferencesKey
+
 struct WebPreferencesStore {
     WebPreferencesStore();
 
     void encode(CoreIPC::ArgumentEncoder* encoder) const;
     static bool decode(CoreIPC::ArgumentDecoder*, WebPreferencesStore&);
 
+    // NOTE: The getters in this class have non-standard names to aid in the use of the preference macros.
+
+    bool setStringValueForKey(const String& key, const String& value);
+    String getStringValueForKey(const String& key) const;
+
+    bool setBoolValueForKey(const String& key, bool value);
+    bool getBoolValueForKey(const String& key) const;
+
+    bool setUInt32ValueForKey(const String& key, uint32_t value);
+    uint32_t getUInt32ValueForKey(const String& key) const;
+
     static void overrideXSSAuditorEnabledForTestRunner(bool);
     static void removeTestRunnerOverrides();
 
-    bool javaScriptEnabled;
-    bool loadsImagesAutomatically;
-    bool pluginsEnabled;
-    bool javaEnabled;
-    bool offlineWebApplicationCacheEnabled;
-    bool localStorageEnabled;
-    bool xssAuditorEnabled;
-    bool frameFlatteningEnabled;
-    bool developerExtrasEnabled;
-    bool privateBrowsingEnabled;
-    bool textAreasAreResizable;
-    bool needsSiteSpecificQuirks;
-    bool acceleratedCompositingEnabled;
-    bool compositingBordersVisible;
-    bool compositingRepaintCountersVisible;
-    uint32_t fontSmoothingLevel;
-    uint32_t minimumFontSize;
-    uint32_t minimumLogicalFontSize;
-    uint32_t defaultFontSize;
-    uint32_t defaultFixedFontSize;
-    String standardFontFamily;
-    String cursiveFontFamily;
-    String fantasyFontFamily;
-    String fixedFontFamily;
-    String sansSerifFontFamily;
-    String serifFontFamily;
+    HashMap<String, String> m_stringValues;
+    HashMap<String, bool> m_boolValues;
+    HashMap<String, uint32_t> m_uint32Values;
 };
 
 } // namespace WebKit
diff --git a/WebKit2/UIProcess/API/C/WKPreferences.cpp b/WebKit2/UIProcess/API/C/WKPreferences.cpp
index 73956ea..c89a3e4 100644
--- a/WebKit2/UIProcess/API/C/WKPreferences.cpp
+++ b/WebKit2/UIProcess/API/C/WKPreferences.cpp
@@ -237,7 +237,7 @@ void WKPreferencesSetFontSmoothingLevel(WKPreferencesRef preferencesRef, WKFontS
 
 WKFontSmoothingLevel WKPreferencesGetFontSmoothingLevel(WKPreferencesRef preferencesRef)
 {
-    return toAPI(toImpl(preferencesRef)->fontSmoothingLevel());
+    return toAPI(static_cast<FontSmoothingLevel>(toImpl(preferencesRef)->fontSmoothingLevel()));
 }
 
 void WKPreferencesSetAcceleratedCompositingEnabled(WKPreferencesRef preferencesRef, bool flag)
diff --git a/WebKit2/UIProcess/WebPreferences.cpp b/WebKit2/UIProcess/WebPreferences.cpp
index 6da80df..f02c860 100644
--- a/WebKit2/UIProcess/WebPreferences.cpp
+++ b/WebKit2/UIProcess/WebPreferences.cpp
@@ -44,6 +44,12 @@ WebPreferences::WebPreferences(WebPreferences* preferences)
 {
 }
 
+WebPreferences::WebPreferences(const String& identifier)
+    : m_identifier(identifier)
+{
+    platformInitializeStore();
+}
+
 WebPreferences::~WebPreferences()
 {
 }
@@ -64,258 +70,40 @@ void WebPreferences::update()
         (*it)->preferencesDidChange();
 }
 
-void WebPreferences::setJavaScriptEnabled(bool b)
-{
-    m_store.javaScriptEnabled = b;
-    update();
-}
-
-bool WebPreferences::javaScriptEnabled() const
-{
-    return m_store.javaScriptEnabled;
-}
-
-void WebPreferences::setLoadsImagesAutomatically(bool b)
-{
-    m_store.loadsImagesAutomatically = b;
-    update();
-}
-
-bool WebPreferences::loadsImagesAutomatically() const
-{
-    return m_store.loadsImagesAutomatically;
-}
-
-void WebPreferences::setOfflineWebApplicationCacheEnabled(bool b)
-{
-    m_store.offlineWebApplicationCacheEnabled = b;
-    update();
-}
-
-bool WebPreferences::offlineWebApplicationCacheEnabled() const
-{
-    return m_store.offlineWebApplicationCacheEnabled;
-}
-
-void WebPreferences::setLocalStorageEnabled(bool b)
-{
-    m_store.localStorageEnabled = b;
-    update();
-}
-
-bool WebPreferences::localStorageEnabled() const
-{
-    return m_store.localStorageEnabled;
-}
-
-void WebPreferences::setXSSAuditorEnabled(bool b)
-{
-    m_store.xssAuditorEnabled = b;
-    update();
-}
-
-bool WebPreferences::xssAuditorEnabled() const
-{
-    return m_store.xssAuditorEnabled;
-}
-
-void WebPreferences::setFrameFlatteningEnabled(bool b)
-{
-    m_store.frameFlatteningEnabled = b;
-    update();
-}
-
-bool WebPreferences::frameFlatteningEnabled() const
-{
-    return m_store.frameFlatteningEnabled;
-}
-
-void WebPreferences::setPrivateBrowsingEnabled(bool b)
-{
-    m_store.privateBrowsingEnabled = b;
-    update();
-}
-
-bool WebPreferences::privateBrowsingEnabled() const
-{
-    return m_store.privateBrowsingEnabled;
-}
-
-void WebPreferences::setDeveloperExtrasEnabled(bool b)
-{
-    m_store.developerExtrasEnabled = b;
-    update();
-}
-
-bool WebPreferences::developerExtrasEnabled() const
-{
-    return m_store.developerExtrasEnabled;
-}
-
-void WebPreferences::setTextAreasAreResizable(bool r)
-{
-    m_store.textAreasAreResizable = r;
-    update();
-}
-
-bool WebPreferences::textAreasAreResizable() const
-{
-    return m_store.textAreasAreResizable;
-}
-
-void WebPreferences::setNeedsSiteSpecificQuirks(bool b)
-{
-    m_store.needsSiteSpecificQuirks = b;
-    update();
-}
-
-bool WebPreferences::needsSiteSpecificQuirks() const
-{
-    return m_store.needsSiteSpecificQuirks;
-}
-
-void WebPreferences::setPluginsEnabled(bool b)
-{
-    m_store.pluginsEnabled = b;
-    update();
-}
-
-bool WebPreferences::pluginsEnabled() const
+void WebPreferences::updateStringValueForKey(const String& key, const String& value)
 {
-    return m_store.pluginsEnabled;
+    platformUpdateStringValueForKey(key, value);
+    update(); // FIXME: Only send over the changed key and value.
 }
 
-void WebPreferences::setJavaEnabled(bool b)
+void WebPreferences::updateBoolValueForKey(const String& key, bool value)
 {
-    m_store.javaEnabled = b;
-    update();
+    platformUpdateBoolValueForKey(key, value);
+    update(); // FIXME: Only send over the changed key and value.
 }
 
-bool WebPreferences::javaEnabled() const
+void WebPreferences::updateUInt32ValueForKey(const String& key, uint32_t value)
 {
-    return m_store.javaEnabled;
+    platformUpdateUInt32ValueForKey(key, value);
+    update(); // FIXME: Only send over the changed key and value.
 }
 
-void WebPreferences::setFontSmoothingLevel(FontSmoothingLevel level)
-{
-    m_store.fontSmoothingLevel = level;
-    update();
-}
+#define DEFINE_PREFERENCE_GETTER_AND_SETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
+    void WebPreferences::set##KeyUpper(const Type& value) \
+    { \
+        if (!m_store.set##TypeName##ValueForKey(WebPreferencesKey::KeyLower##Key(), value)) \
+            return; \
+        update##TypeName##ValueForKey(WebPreferencesKey::KeyLower##Key(), value); \
+        \
+    } \
+    \
+    Type WebPreferences::KeyLower() const \
+    { \
+        return m_store.get##TypeName##ValueForKey(WebPreferencesKey::KeyLower##Key()); \
+    } \
 
-FontSmoothingLevel WebPreferences::fontSmoothingLevel() const
-{
-    return static_cast<FontSmoothingLevel>(m_store.fontSmoothingLevel);
-}
+FOR_EACH_WEBKIT_PREFERENCE(DEFINE_PREFERENCE_GETTER_AND_SETTERS)
 
-void WebPreferences::setStandardFontFamily(const String& family)
-{
-    m_store.standardFontFamily = family;
-    update();
-}
-
-const String& WebPreferences::standardFontFamily() const
-{
-    return m_store.standardFontFamily;
-}
-
-void WebPreferences::setFixedFontFamily(const String& family)
-{
-    m_store.fixedFontFamily = family;
-    update();
-}
-
-const String& WebPreferences::fixedFontFamily() const
-{
-    return m_store.fixedFontFamily;
-}
-
-void WebPreferences::setSerifFontFamily(const String& family)
-{
-    m_store.serifFontFamily = family;
-    update();
-}
-
-const String& WebPreferences::serifFontFamily() const
-{
-    return m_store.serifFontFamily;
-}
-
-void WebPreferences::setSansSerifFontFamily(const String& family)
-{
-    m_store.sansSerifFontFamily = family;
-    update();
-}
-
-const String& WebPreferences::sansSerifFontFamily() const
-{
-    return m_store.sansSerifFontFamily;
-}
-
-void WebPreferences::setCursiveFontFamily(const String& family)
-{
-    m_store.cursiveFontFamily = family;
-    update();
-}
-
-const String& WebPreferences::cursiveFontFamily() const
-{
-    return m_store.cursiveFontFamily;
-}
-
-void WebPreferences::setFantasyFontFamily(const String& family)
-{
-    m_store.fantasyFontFamily = family;
-    update();
-}
-
-const String& WebPreferences::fantasyFontFamily() const
-{
-    return m_store.fantasyFontFamily;
-}
-
-void WebPreferences::setMinimumFontSize(uint32_t size)
-{
-    m_store.minimumFontSize = size;
-    update();
-}
-
-uint32_t WebPreferences::minimumFontSize() const
-{
-    return m_store.minimumFontSize;
-}
-
-void WebPreferences::setAcceleratedCompositingEnabled(bool flag)
-{
-    m_store.acceleratedCompositingEnabled = flag;
-    update();
-}
-
-bool WebPreferences::acceleratedCompositingEnabled() const
-{
-    return m_store.acceleratedCompositingEnabled;
-}
-
-void WebPreferences::setCompositingBordersVisible(bool flag)
-{
-    m_store.compositingBordersVisible = flag;
-    update();
-}
-
-bool WebPreferences::compositingBordersVisible() const
-{
-    return m_store.compositingBordersVisible;
-}
-
-void WebPreferences::setCompositingRepaintCountersVisible(bool flag)
-{
-    m_store.compositingRepaintCountersVisible = flag;
-    update();
-}
-
-bool WebPreferences::compositingRepaintCountersVisible() const
-{
-    return m_store.compositingRepaintCountersVisible;
-}
+#undef DEFINE_PREFERENCE_GETTER_AND_SETTERS
 
 } // namespace WebKit
-
diff --git a/WebKit2/UIProcess/WebPreferences.h b/WebKit2/UIProcess/WebPreferences.h
index f7e0a0f..5deb382 100644
--- a/WebKit2/UIProcess/WebPreferences.h
+++ b/WebKit2/UIProcess/WebPreferences.h
@@ -33,6 +33,10 @@
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 
+#define DECLARE_PREFERENCE_GETTER_AND_SETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
+    void set##KeyUpper(const Type& value); \
+    Type KeyLower() const;
+
 namespace WebKit {
 
 class WebContext;
@@ -59,85 +63,36 @@ public:
 
     const WebPreferencesStore& store() const { return m_store; }
 
-    void setJavaScriptEnabled(bool);
-    bool javaScriptEnabled() const;
-
-    void setLoadsImagesAutomatically(bool);
-    bool loadsImagesAutomatically() const;
-
-    void setOfflineWebApplicationCacheEnabled(bool);
-    bool offlineWebApplicationCacheEnabled() const;
-
-    void setLocalStorageEnabled(bool);
-    bool localStorageEnabled() const;
-
-    void setXSSAuditorEnabled(bool);
-    bool xssAuditorEnabled() const;
-
-    void setFrameFlatteningEnabled(bool);
-    bool frameFlatteningEnabled() const;
-
-    void setPluginsEnabled(bool);
-    bool pluginsEnabled() const;
-
-    void setJavaEnabled(bool);
-    bool javaEnabled() const;
-
-    void setFontSmoothingLevel(FontSmoothingLevel);
-    FontSmoothingLevel fontSmoothingLevel() const;
-
-    void setStandardFontFamily(const String&);
-    const String& standardFontFamily() const;
-
-    void setFixedFontFamily(const String&);
-    const String& fixedFontFamily() const;
 
-    void setSerifFontFamily(const String&);
-    const String& serifFontFamily() const;
+#define DECLARE_PREFERENCE_GETTER_AND_SETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
+    void set##KeyUpper(const Type& value); \
+    Type KeyLower() const; \
 
-    void setSansSerifFontFamily(const String&);
-    const String& sansSerifFontFamily() const;
+    FOR_EACH_WEBKIT_PREFERENCE(DECLARE_PREFERENCE_GETTER_AND_SETTERS)
 
-    void setCursiveFontFamily(const String&);
-    const String& cursiveFontFamily() const;
-
-    void setFantasyFontFamily(const String&);
-    const String& fantasyFontFamily() const;
-    
-    void setMinimumFontSize(uint32_t);
-    uint32_t minimumFontSize() const;
-
-    void setAcceleratedCompositingEnabled(bool);
-    bool acceleratedCompositingEnabled() const;
-
-    void setCompositingBordersVisible(bool);
-    bool compositingBordersVisible() const;
-
-    void setCompositingRepaintCountersVisible(bool);
-    bool compositingRepaintCountersVisible() const;
-
-    void setPrivateBrowsingEnabled(bool);
-    bool privateBrowsingEnabled() const;
-
-    void setDeveloperExtrasEnabled(bool);
-    bool developerExtrasEnabled() const;
-
-    void setTextAreasAreResizable(bool);
-    bool textAreasAreResizable() const;
-
-    void setNeedsSiteSpecificQuirks(bool);
-    bool needsSiteSpecificQuirks() const;
+#undef DECLARE_PREFERENCE_GETTER_AND_SETTERS
 
 private:
     WebPreferences();
     WebPreferences(WebPreferences*);
+    WebPreferences(const String& identifier);
+
+    void platformInitializeStore();
 
     virtual Type type() const { return APIType; }
 
     void update();
 
+    void updateStringValueForKey(const String& key, const String& value);
+    void updateBoolValueForKey(const String& key, bool value);
+    void updateUInt32ValueForKey(const String& key, uint32_t value);
+    void platformUpdateStringValueForKey(const String& key, const String& value);
+    void platformUpdateBoolValueForKey(const String& key, bool value);
+    void platformUpdateUInt32ValueForKey(const String& key, uint32_t value);
+
     HashSet<WebContext*> m_contexts;
     WebPreferencesStore m_store;
+    String m_identifier;
 };
 
 } // namespace WebKit
diff --git a/WebKit2/UIProcess/cf/WebPreferencesCF.cpp b/WebKit2/UIProcess/cf/WebPreferencesCF.cpp
new file mode 100644
index 0000000..c93d96e
--- /dev/null
+++ b/WebKit2/UIProcess/cf/WebPreferencesCF.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "WebPreferences.h"
+
+#if !PLATFORM(MAC)
+
+namespace WebKit {
+
+void WebPreferences::platformInitializeStore()
+{
+}
+
+void WebPreferences::platformUpdateStringValueForKey(const String&, const String&)
+{
+}
+
+void WebPreferences::platformUpdateBoolValueForKey(const String&, bool)
+{
+}
+
+void WebPreferences::platformUpdateUInt32ValueForKey(const String&, uint32_t)
+{
+}
+
+} // namespace WebKit
+
+#endif // !PLATFORM(MAC)
diff --git a/WebKit2/UIProcess/mac/WebPreferencesMac.mm b/WebKit2/UIProcess/mac/WebPreferencesMac.mm
new file mode 100644
index 0000000..92d87fd
--- /dev/null
+++ b/WebKit2/UIProcess/mac/WebPreferencesMac.mm
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "WebPreferences.h"
+
+#include "PageClientImpl.h"
+#include <wtf/text/StringConcatenate.h>
+
+namespace WebKit {
+
+static inline NSString* makeKey(const String& identifier, const String& baseKey)
+{
+    return nsStringFromWebCoreString(makeString(identifier, baseKey));
+}
+
+static void setStringValueIfInUserDefaults(const String& identifier, const String& key, WebPreferencesStore& store)
+{
+    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, key)];
+    if (!object)
+        return;
+    if (![object isKindOfClass:[NSString class]])
+        return;
+
+    store.setStringValueForKey(key, (NSString *)object);
+}
+
+static void setBoolValueIfInUserDefaults(const String& identifier, const String& key, WebPreferencesStore& store)
+{
+    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, key)];
+    if (!object)
+        return;
+    if (![object respondsToSelector:@selector(boolValue)])
+        return;
+
+    store.setBoolValueForKey(key, [object boolValue]);
+}
+
+static void setUInt32ValueIfInUserDefaults(const String& identifier, const String& key, WebPreferencesStore& store)
+{
+    id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, key)];
+    if (!object)
+        return;
+    if (![object respondsToSelector:@selector(intValue)])
+        return;
+
+    store.setUInt32ValueForKey(key, [object intValue]);
+}
+
+void WebPreferences::platformInitializeStore()
+{
+    if (!m_identifier)
+        return;
+
+#define INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
+    set##TypeName##ValueIfInUserDefaults(m_identifier, WebPreferencesKey::KeyLower##Key(), m_store);
+
+    FOR_EACH_WEBKIT_PREFERENCE(INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS)
+
+#undef INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS
+}
+
+void WebPreferences::platformUpdateStringValueForKey(const String& key, const String& value)
+{
+    if (!m_identifier)
+        return;
+
+    [[NSUserDefaults standardUserDefaults] setObject:nsStringFromWebCoreString(value) forKey:makeKey(m_identifier, key)];
+}
+
+void WebPreferences::platformUpdateBoolValueForKey(const String& key, bool value)
+{
+    if (!m_identifier)
+        return;
+
+    [[NSUserDefaults standardUserDefaults] setBool:value forKey:makeKey(m_identifier, key)];
+}
+
+void WebPreferences::platformUpdateUInt32ValueForKey(const String& key, uint32_t value)
+{
+    if (!m_identifier)
+        return;
+
+    [[NSUserDefaults standardUserDefaults] setInteger:value forKey:makeKey(m_identifier, key)];
+}
+
+} // namespace WebKit
+
diff --git a/WebKit2/UIProcess/qt/WebPreferencesQt.cpp b/WebKit2/UIProcess/qt/WebPreferencesQt.cpp
new file mode 100644
index 0000000..c2fd76e
--- /dev/null
+++ b/WebKit2/UIProcess/qt/WebPreferencesQt.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "WebPreferences.h"
+
+namespace WebKit {
+
+void WebPreferences::platformInitializeStore()
+{
+}
+
+void WebPreferences::platformUpdateStringValueForKey(const String&, const String&)
+{
+}
+
+void WebPreferences::platformUpdateBoolValueForKey(const String&, bool)
+{
+}
+
+void WebPreferences::platformUpdateUInt32ValueForKey(const String&, uint32_t)
+{
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebKit2.pro b/WebKit2/WebKit2.pro
index 50e88cd..d5e48da 100644
--- a/WebKit2/WebKit2.pro
+++ b/WebKit2/WebKit2.pro
@@ -511,6 +511,7 @@ SOURCES += \
     UIProcess/qt/WebContextQt.cpp \
     UIProcess/qt/WebInspectorProxyQt.cpp \
     UIProcess/qt/WebPopupMenuProxyQt.cpp \
+    UIProcess/qt/WebPreferencesQt.cpp \
     WebProcess/Downloads/Download.cpp \
     WebProcess/Downloads/DownloadManager.cpp \
     WebProcess/Downloads/qt/DownloadQt.cpp \
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 9be6f3e..f487b6e 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -306,6 +306,7 @@
 		BC2652171182608100243E12 /* DrawingAreaProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2652131182608100243E12 /* DrawingAreaProxy.h */; };
 		BC2652181182608100243E12 /* ChunkedUpdateDrawingAreaProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2652141182608100243E12 /* ChunkedUpdateDrawingAreaProxy.cpp */; };
 		BC2652191182608100243E12 /* ChunkedUpdateDrawingAreaProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2652151182608100243E12 /* ChunkedUpdateDrawingAreaProxy.h */; };
+		BC2DFBA312A761A500E732A3 /* WebPreferencesCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2DFBA212A761A500E732A3 /* WebPreferencesCF.cpp */; };
 		BC2E6E871141971500A63B1E /* RunLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC2E6E771141970C00A63B1E /* RunLoop.cpp */; };
 		BC2E6E881141971500A63B1E /* RunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2E6E781141970C00A63B1E /* RunLoop.h */; };
 		BC2E6E8C1141971500A63B1E /* WorkItem.h in Headers */ = {isa = PBXBuildFile; fileRef = BC2E6E7C1141970C00A63B1E /* WorkItem.h */; };
@@ -407,6 +408,7 @@
 		BC7B633E12A45D1200D174A4 /* WKBundlePageGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC7B633C12A45D1200D174A4 /* WKBundlePageGroup.cpp */; };
 		BC8452A71162C80900CAB9B5 /* DrawingArea.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8452A51162C80900CAB9B5 /* DrawingArea.cpp */; };
 		BC8452A81162C80900CAB9B5 /* DrawingArea.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8452A61162C80900CAB9B5 /* DrawingArea.h */; };
+		BC84EB1812A7100C0083F2DA /* WebPreferencesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC84EB1712A7100C0083F2DA /* WebPreferencesMac.mm */; };
 		BC8699B5116AADAA002A925B /* WKView.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8699B2116AADAA002A925B /* WKView.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		BC8699B6116AADAA002A925B /* WKView.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC8699B3116AADAA002A925B /* WKView.mm */; };
 		BC8699B7116AADAA002A925B /* WKViewInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8699B4116AADAA002A925B /* WKViewInternal.h */; };
@@ -910,6 +912,7 @@
 		BC2652131182608100243E12 /* DrawingAreaProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawingAreaProxy.h; sourceTree = "<group>"; };
 		BC2652141182608100243E12 /* ChunkedUpdateDrawingAreaProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ChunkedUpdateDrawingAreaProxy.cpp; sourceTree = "<group>"; };
 		BC2652151182608100243E12 /* ChunkedUpdateDrawingAreaProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChunkedUpdateDrawingAreaProxy.h; sourceTree = "<group>"; };
+		BC2DFBA212A761A500E732A3 /* WebPreferencesCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebPreferencesCF.cpp; path = cf/WebPreferencesCF.cpp; sourceTree = "<group>"; };
 		BC2E6E771141970C00A63B1E /* RunLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoop.cpp; sourceTree = "<group>"; };
 		BC2E6E781141970C00A63B1E /* RunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunLoop.h; sourceTree = "<group>"; };
 		BC2E6E7C1141970C00A63B1E /* WorkItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkItem.h; sourceTree = "<group>"; };
@@ -1011,6 +1014,7 @@
 		BC7B633C12A45D1200D174A4 /* WKBundlePageGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundlePageGroup.cpp; sourceTree = "<group>"; };
 		BC8452A51162C80900CAB9B5 /* DrawingArea.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DrawingArea.cpp; sourceTree = "<group>"; };
 		BC8452A61162C80900CAB9B5 /* DrawingArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawingArea.h; sourceTree = "<group>"; };
+		BC84EB1712A7100C0083F2DA /* WebPreferencesMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPreferencesMac.mm; sourceTree = "<group>"; };
 		BC8699B2116AADAA002A925B /* WKView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKView.h; sourceTree = "<group>"; };
 		BC8699B3116AADAA002A925B /* WKView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKView.mm; sourceTree = "<group>"; };
 		BC8699B4116AADAA002A925B /* WKViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKViewInternal.h; sourceTree = "<group>"; };
@@ -1607,6 +1611,7 @@
 			children = (
 				51B3004E12529D0E000B5CA0 /* WebBackForwardListCF.cpp */,
 				51B3004F12529D0E000B5CA0 /* WebPageProxyCF.cpp */,
+				BC2DFBA212A761A500E732A3 /* WebPreferencesCF.cpp */,
 			);
 			name = cf;
 			sourceTree = "<group>";
@@ -2107,6 +2112,7 @@
 				1CA8B935127C774E00576C2B /* WebInspectorProxyMac.mm */,
 				BC5750951268F3C6006F0F12 /* WebPopupMenuProxyMac.h */,
 				BC5750961268F3C6006F0F12 /* WebPopupMenuProxyMac.mm */,
+				BC84EB1712A7100C0083F2DA /* WebPreferencesMac.mm */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -2906,6 +2912,8 @@
 				BC7B633812A45ABA00D174A4 /* WKPageGroup.cpp in Sources */,
 				BC7B633E12A45D1200D174A4 /* WKBundlePageGroup.cpp in Sources */,
 				1AA4792312A59FD9008236C3 /* PluginProcessMac.mm in Sources */,
+				BC84EB1812A7100C0083F2DA /* WebPreferencesMac.mm in Sources */,
+				BC2DFBA312A761A500E732A3 /* WebPreferencesCF.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebKit2/WebProcess/WebPage/WebPage.cpp b/WebKit2/WebProcess/WebPage/WebPage.cpp
index 255ef69..1434174 100644
--- a/WebKit2/WebProcess/WebPage/WebPage.cpp
+++ b/WebKit2/WebProcess/WebPage/WebPage.cpp
@@ -880,38 +880,42 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
 {
     Settings* settings = m_page->settings();
     
-    settings->setJavaScriptEnabled(store.javaScriptEnabled);
-    settings->setLoadsImagesAutomatically(store.loadsImagesAutomatically);
-    settings->setPluginsEnabled(store.pluginsEnabled);
-    settings->setJavaEnabled(store.javaEnabled);
-    settings->setOfflineWebApplicationCacheEnabled(store.offlineWebApplicationCacheEnabled);
-    settings->setLocalStorageEnabled(store.localStorageEnabled);
-    settings->setXSSAuditorEnabled(store.xssAuditorEnabled);
-    settings->setFrameFlatteningEnabled(store.frameFlatteningEnabled);
-    settings->setPrivateBrowsingEnabled(store.privateBrowsingEnabled);
-    settings->setDeveloperExtrasEnabled(store.developerExtrasEnabled);
-    settings->setTextAreasAreResizable(store.textAreasAreResizable);
-    settings->setNeedsSiteSpecificQuirks(store.needsSiteSpecificQuirks);
-    settings->setMinimumFontSize(store.minimumFontSize);
-    settings->setMinimumLogicalFontSize(store.minimumLogicalFontSize);
-    settings->setDefaultFontSize(store.defaultFontSize);
-    settings->setDefaultFixedFontSize(store.defaultFixedFontSize);
-    settings->setStandardFontFamily(store.standardFontFamily);
-    settings->setCursiveFontFamily(store.cursiveFontFamily);
-    settings->setFantasyFontFamily(store.fantasyFontFamily);
-    settings->setFixedFontFamily(store.fixedFontFamily);
-    settings->setSansSerifFontFamily(store.sansSerifFontFamily);
-    settings->setSerifFontFamily(store.serifFontFamily);
+    // FIXME: This should be generated from macro expansion for all preferences,
+    // but we currently don't match the naming of WebCore exactly so we are
+    // handrolling the boolean and integer preferences until that is fixed.
+
+#define INITIALIZE_SETTINGS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) settings->set##KeyUpper(store.get##TypeName##ValueForKey(WebPreferencesKey::KeyLower##Key()));
+
+    FOR_EACH_WEBKIT_STRING_PREFERENCE(INITIALIZE_SETTINGS)
+
+#undef INITIALIZE_SETTINGS
+
+    settings->setJavaScriptEnabled(store.getBoolValueForKey(WebPreferencesKey::javaScriptEnabledKey()));
+    settings->setLoadsImagesAutomatically(store.getBoolValueForKey(WebPreferencesKey::loadsImagesAutomaticallyKey()));
+    settings->setPluginsEnabled(store.getBoolValueForKey(WebPreferencesKey::pluginsEnabledKey()));
+    settings->setJavaEnabled(store.getBoolValueForKey(WebPreferencesKey::javaEnabledKey()));
+    settings->setOfflineWebApplicationCacheEnabled(store.getBoolValueForKey(WebPreferencesKey::offlineWebApplicationCacheEnabledKey()));
+    settings->setLocalStorageEnabled(store.getBoolValueForKey(WebPreferencesKey::localStorageEnabledKey()));
+    settings->setXSSAuditorEnabled(store.getBoolValueForKey(WebPreferencesKey::xssAuditorEnabledKey()));
+    settings->setFrameFlatteningEnabled(store.getBoolValueForKey(WebPreferencesKey::frameFlatteningEnabledKey()));
+    settings->setPrivateBrowsingEnabled(store.getBoolValueForKey(WebPreferencesKey::privateBrowsingEnabledKey()));
+    settings->setDeveloperExtrasEnabled(store.getBoolValueForKey(WebPreferencesKey::developerExtrasEnabledKey()));
+    settings->setTextAreasAreResizable(store.getBoolValueForKey(WebPreferencesKey::textAreasAreResizableKey()));
+    settings->setNeedsSiteSpecificQuirks(store.getBoolValueForKey(WebPreferencesKey::needsSiteSpecificQuirksKey()));
+    settings->setMinimumFontSize(store.getUInt32ValueForKey(WebPreferencesKey::minimumFontSizeKey()));
+    settings->setMinimumLogicalFontSize(store.getUInt32ValueForKey(WebPreferencesKey::minimumLogicalFontSizeKey()));
+    settings->setDefaultFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFontSizeKey()));
+    settings->setDefaultFixedFontSize(store.getUInt32ValueForKey(WebPreferencesKey::defaultFixedFontSizeKey()));
     settings->setJavaScriptCanOpenWindowsAutomatically(true);
 
 #if PLATFORM(WIN)
     // Temporarily turn off accelerated compositing until we have a good solution for rendering it.
     settings->setAcceleratedCompositingEnabled(false);
 #else
-    settings->setAcceleratedCompositingEnabled(store.acceleratedCompositingEnabled);
+    settings->setAcceleratedCompositingEnabled(store.getBoolValueForKey(WebPreferencesKey::acceleratedCompositingEnabledKey()));
 #endif
-    settings->setShowDebugBorders(store.compositingBordersVisible);
-    settings->setShowRepaintCounter(store.compositingRepaintCountersVisible);
+    settings->setShowDebugBorders(store.getBoolValueForKey(WebPreferencesKey::compositingBordersVisibleKey()));
+    settings->setShowRepaintCounter(store.getBoolValueForKey(WebPreferencesKey::compositingRepaintCountersVisibleKey()));
     
     platformPreferencesDidChange(store);
 }
diff --git a/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp b/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
index d0c9935..0e4a047 100644
--- a/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
+++ b/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
@@ -51,14 +51,16 @@ void WebPage::platformInitialize()
 
 void WebPage::platformPreferencesDidChange(const WebPreferencesStore& store)
 {
+    FontSmoothingLevel fontSmoothingLevel = static_cast<FontSmoothingLevel>(store.getUInt32ValueForKey(WebPreferencesKey::fontSmoothingLevelKey()));
+
 #if PLATFORM(CG)
-    FontSmoothingLevel adjustedLevel = static_cast<FontSmoothingLevel>(store.fontSmoothingLevel);
+    FontSmoothingLevel adjustedLevel = fontSmoothingLevel;
     if (adjustedLevel == FontSmoothingLevelWindows)
         adjustedLevel = FontSmoothingLevelMedium;
     wkSetFontSmoothingLevel(adjustedLevel);
 #endif
 
-    m_page->settings()->setFontRenderingMode(store.fontSmoothingLevel == FontSmoothingLevelWindows ? AlternateRenderingMode : NormalRenderingMode);
+    m_page->settings()->setFontRenderingMode(fontSmoothingLevel == FontSmoothingLevelWindows ? AlternateRenderingMode : NormalRenderingMode);
 }
 
 static const unsigned CtrlKey = 1 << 0;
diff --git a/WebKit2/win/WebKit2.vcproj b/WebKit2/win/WebKit2.vcproj
index b0cc48f..69c4faa 100755
--- a/WebKit2/win/WebKit2.vcproj
+++ b/WebKit2/win/WebKit2.vcproj
@@ -2193,6 +2193,10 @@
 					RelativePath="..\UIProcess\cf\WebPageProxyCF.cpp"
 					>
 				</File>
+				<File
+					RelativePath="..\UIProcess\cf\WebPreferencesCF.cpp"
+					>
+				</File>
 			</Filter>
 			<Filter
 				Name="Downloads"

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list