Experimental features should toggle runtime flags
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 May 2016 22:29:18 +0000 (22:29 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 May 2016 22:29:18 +0000 (22:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=157353
<rdar://problem/23621603>

Reviewed by Anders Carlsson.

Hook up the experimental WebPreferences to RuntimeEnabledFeatures.
In the process I removed the general preference for WebGL 2 (we
already had an experimental feature for it) and moved Custom
Elements and Shadow DOM to experimental.

I also removed the C versions of the preferences, since experimental
features only need the ObjC API (which is generated automatically).

* Shared/WebPreferencesDefinitions.h: Move/remove some features and
make the experimental section more clear.
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetWebGL2Enabled): Deleted.
(WKPreferencesGetWebGL2Enabled): Deleted.
(WKPreferencesSetShadowDOMEnabled): Deleted.
(WKPreferencesGetShadowDOMEnabled): Deleted.
(WKPreferencesSetCustomElementsEnabled): Deleted.
(WKPreferencesGetCustomElementsEnabled): Deleted.
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* UIProcess/WebPreferences.cpp:
(WebKit::WebPreferences::updateBoolValueForExperimentalFeatureKey): A
version of updateBoolValueForKey that doesn't call the platform
function (e.g. doesn't save to NSUserDefaults).
* UIProcess/WebPreferences.h:
* UIProcess/mac/WebPreferencesMac.mm:
(WebKit::WebPreferences::platformInitializeStore): Deleted.
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200437 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesDefinitions.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit2/UIProcess/WebPreferences.cpp
Source/WebKit2/UIProcess/WebPreferences.h
Source/WebKit2/UIProcess/mac/WebPreferencesMac.mm
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index f07aee2..fad798d 100644 (file)
@@ -1,5 +1,43 @@
 2016-05-04  Dean Jackson  <dino@apple.com>
 
+        Experimental features should toggle runtime flags
+        https://bugs.webkit.org/show_bug.cgi?id=157353
+        <rdar://problem/23621603>
+
+        Reviewed by Anders Carlsson.
+
+        Hook up the experimental WebPreferences to RuntimeEnabledFeatures.
+        In the process I removed the general preference for WebGL 2 (we
+        already had an experimental feature for it) and moved Custom
+        Elements and Shadow DOM to experimental.
+
+        I also removed the C versions of the preferences, since experimental
+        features only need the ObjC API (which is generated automatically).
+
+        * Shared/WebPreferencesDefinitions.h: Move/remove some features and
+        make the experimental section more clear.
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetWebGL2Enabled): Deleted.
+        (WKPreferencesGetWebGL2Enabled): Deleted.
+        (WKPreferencesSetShadowDOMEnabled): Deleted.
+        (WKPreferencesGetShadowDOMEnabled): Deleted.
+        (WKPreferencesSetCustomElementsEnabled): Deleted.
+        (WKPreferencesGetCustomElementsEnabled): Deleted.
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * UIProcess/WebPreferences.cpp:
+        (WebKit::WebPreferences::updateBoolValueForExperimentalFeatureKey): A
+        version of updateBoolValueForKey that doesn't call the platform
+        function (e.g. doesn't save to NSUserDefaults).
+        * UIProcess/WebPreferences.h:
+        * UIProcess/mac/WebPreferencesMac.mm:
+        (WebKit::WebPreferences::platformInitializeStore): Deleted.
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
+2016-05-04  Dean Jackson  <dino@apple.com>
+
         TestRunner should always enable all the experimental features
         https://bugs.webkit.org/show_bug.cgi?id=157360
         <rdar://problem/26099748>
index 4e54b86..1cd2c8d 100644 (file)
     macro(NewBlockInsideInlineModelEnabled, newBlockInsideInlineModelEnabled, Bool, bool, false, "", "") \
     macro(HTTPEquivEnabled, httpEquivEnabled, Bool, bool, true, "", "") \
     macro(MockCaptureDevicesEnabled, mockCaptureDevicesEnabled, Bool, bool, false, "", "") \
-    macro(ShadowDOMEnabled, shadowDOMEnabled, Bool, bool, true, "", "") \
-    macro(CustomElementsEnabled, customElementsEnabled, Bool, bool, false, "", "") \
     macro(FetchAPIEnabled, fetchAPIEnabled, Bool, bool, false, "", "") \
-    macro(WebGL2Enabled, webGL2Enabled, Bool, bool, false, "", "") \
     macro(DownloadAttributeEnabled, downloadAttributeEnabled, Bool, bool, false, "", "") \
     macro(SelectionPaintingWithoutSelectionGapsEnabled, selectionPaintingWithoutSelectionGapsEnabled, Bool, bool, DEFAULT_SELECTION_PAINTING_WITHOUT_SELECTION_GAPS_ENABLED, "", "") \
     FOR_EACH_ADDITIONAL_WEBKIT_BOOL_PREFERENCE(macro) \
 #define FOR_EACH_WEBKIT_DEBUG_UINT32_PREFERENCE(macro) \
     macro(VisibleDebugOverlayRegions, visibleDebugOverlayRegions, UInt32, uint32_t, 0, "", "")
 
-// Remember to provide the last two parameters for all experimental features. They
-// are the text exposed to the user from the WebKit client. Also note that the key
-// should be prefixed with "experimental" so that it doesn't clash if/when the feature
-// becomes stable.
+// For experimental features:
+// - The type should be boolean.
+// - You must provide the last two parameters for all experimental features. They
+//   are the text exposed to the user from the WebKit client.
+// - They should be alphabetically ordered by the human readable text.
+// - The key should be prefixed with "experimental" so that it doesn't clash if/when the feature
+//   becomes stable.
+// - They should be false by default. The client is responsible for enabling them.
 
 #define FOR_EACH_WEBKIT_EXPERIMENTAL_FEATURE_PREFERENCE(macro) \
-    macro(ExperimentalShadowDOMEnabled, experimentalShadowDOMEnabled, Bool, bool, false, "Shadow DOM", "Support for the Shadow DOM feature") \
-    macro(ExperimentalWebGL2Enabled, experimentalWebGL2Enabled, Bool, bool, false, "WebGL 2.0", "Prototype WebGL 2 Support") \
-    macro(ExperimentalCSSGridLayoutEnabled, experimentalCSSGridLayoutEnabled, Bool, bool, true, "CSS Grid Layout", "CSS Grid Layout") \
+    macro(ExperimentalCSSGridLayoutEnabled, experimentalCSSGridLayoutEnabled, Bool, bool, false, "CSS Grid", "CSS Grid Layout Module support") \
+    macro(ExperimentalCustomElementsEnabled, experimentalCustomElementsEnabled, Bool, bool, false, "Custom Elements", "HTML Custom Elements prototype") \
+    macro(ExperimentalShadowDOMEnabled, experimentalShadowDOMEnabled, Bool, bool, false, "Shadow DOM", "HTML Shadow DOM prototype") \
+    macro(ExperimentalWebGL2Enabled, experimentalWebGL2Enabled, Bool, bool, false, "WebGL 2.0", "WebGL 2 prototype") \
     \
 
 #if PLATFORM(COCOA)
index 3ce8618..31d4b16 100644 (file)
@@ -468,16 +468,6 @@ bool WKPreferencesGetWebGLEnabled(WKPreferencesRef preferencesRef)
     return toImpl(preferencesRef)->webGLEnabled();
 }
 
-void WKPreferencesSetWebGL2Enabled(WKPreferencesRef preferencesRef, bool flag)
-{
-    toImpl(preferencesRef)->setWebGL2Enabled(flag);
-}
-
-bool WKPreferencesGetWebGL2Enabled(WKPreferencesRef preferencesRef)
-{
-    return toImpl(preferencesRef)->webGL2Enabled();
-}
-
 void WKPreferencesSetForceSoftwareWebGLRendering(WKPreferencesRef preferencesRef, bool flag)
 {
     toImpl(preferencesRef)->setForceSoftwareWebGLRendering(flag);
@@ -1506,26 +1496,6 @@ bool WKPreferencesGetMockCaptureDevicesEnabled(WKPreferencesRef preferencesRef)
     return toImpl(preferencesRef)->mockCaptureDevicesEnabled();
 }
 
-void WKPreferencesSetShadowDOMEnabled(WKPreferencesRef preferencesRef, bool flag)
-{
-    toImpl(preferencesRef)->setShadowDOMEnabled(flag);
-}
-
-bool WKPreferencesGetShadowDOMEnabled(WKPreferencesRef preferencesRef)
-{
-    return toImpl(preferencesRef)->shadowDOMEnabled();
-}
-
-void WKPreferencesSetCustomElementsEnabled(WKPreferencesRef preferencesRef, bool flag)
-{
-    toImpl(preferencesRef)->setCustomElementsEnabled(flag);
-}
-
-bool WKPreferencesGetCustomElementsEnabled(WKPreferencesRef preferencesRef)
-{
-    return toImpl(preferencesRef)->customElementsEnabled();
-}
-
 void WKPreferencesSetFetchAPIEnabled(WKPreferencesRef preferencesRef, bool flag)
 {
     toImpl(preferencesRef)->setFetchAPIEnabled(flag);
index 23bed99..b51c88f 100644 (file)
@@ -100,10 +100,6 @@ WK_EXPORT void WKPreferencesSetWebGLEnabled(WKPreferencesRef, bool);
 WK_EXPORT bool WKPreferencesGetWebGLEnabled(WKPreferencesRef);
 
 // Defaults to false.
-WK_EXPORT void WKPreferencesSetWebGL2Enabled(WKPreferencesRef, bool);
-WK_EXPORT bool WKPreferencesGetWebGL2Enabled(WKPreferencesRef);
-
-// Defaults to false.
 WK_EXPORT void WKPreferencesSetForceSoftwareWebGLRendering(WKPreferencesRef, bool);
 WK_EXPORT bool WKPreferencesGetForceSoftwareWebGLRendering(WKPreferencesRef);
 
@@ -417,14 +413,6 @@ WK_EXPORT bool WKPreferencesGetResourceUsageOverlayVisible(WKPreferencesRef);
 WK_EXPORT void WKPreferencesSetMockCaptureDevicesEnabled(WKPreferencesRef, bool);
 WK_EXPORT bool WKPreferencesGetMockCaptureDevicesEnabled(WKPreferencesRef);
     
-// Defaults to true
-WK_EXPORT void WKPreferencesSetShadowDOMEnabled(WKPreferencesRef, bool flag);
-WK_EXPORT bool WKPreferencesGetShadowDOMEnabled(WKPreferencesRef);
-
-// Defaults to false
-WK_EXPORT void WKPreferencesSetCustomElementsEnabled(WKPreferencesRef, bool flag);
-WK_EXPORT bool WKPreferencesGetCustomElementsEnabled(WKPreferencesRef);
-
 // Defaults to false
 WK_EXPORT void WKPreferencesSetFetchAPIEnabled(WKPreferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetFetchAPIEnabled(WKPreferencesRef);
index 1f175d1..44b3633 100644 (file)
@@ -129,6 +129,11 @@ void WebPreferences::updateBoolValueForKey(const String& key, bool value)
     update(); // FIXME: Only send over the changed key and value.
 }
 
+void WebPreferences::updateBoolValueForExperimentalFeatureKey(const String& key, bool value)
+{
+    update(); // FIXME: Only send over the changed key and value.
+}
+
 void WebPreferences::updateUInt32ValueForKey(const String& key, uint32_t value)
 {
     platformUpdateUInt32ValueForKey(key, value);
@@ -187,10 +192,27 @@ void WebPreferences::updatePrivateBrowsingValue(bool value)
 
 FOR_EACH_WEBKIT_PREFERENCE(DEFINE_PREFERENCE_GETTER_AND_SETTERS)
 FOR_EACH_WEBKIT_DEBUG_PREFERENCE(DEFINE_PREFERENCE_GETTER_AND_SETTERS)
-FOR_EACH_WEBKIT_EXPERIMENTAL_FEATURE_PREFERENCE(DEFINE_PREFERENCE_GETTER_AND_SETTERS)
 
 #undef DEFINE_PREFERENCE_GETTER_AND_SETTERS
 
+#define DEFINE_EXPERIMENTAL_PREFERENCE_GETTER_AND_SETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue, HumanReadableName, HumanReadableDescription) \
+    void WebPreferences::set##KeyUpper(const Type& value) \
+    { \
+        if (!m_store.set##TypeName##ValueForKey(WebPreferencesKey::KeyLower##Key(), value)) \
+            return; \
+        update##TypeName##ValueForExperimentalFeatureKey(WebPreferencesKey::KeyLower##Key(), value); \
+    \
+    } \
+    \
+    Type WebPreferences::KeyLower() const \
+    { \
+        return m_store.get##TypeName##ValueForKey(WebPreferencesKey::KeyLower##Key()); \
+    } \
+
+FOR_EACH_WEBKIT_EXPERIMENTAL_FEATURE_PREFERENCE(DEFINE_EXPERIMENTAL_PREFERENCE_GETTER_AND_SETTERS)
+
+#undef DEFINE_EXPERIMENTAL_PREFERENCE_GETTER_AND_SETTERS
+
 static Vector<RefPtr<API::Object>> createExperimentalFeaturesVector()
 {
     Vector<RefPtr<API::Object>> features;
index d47447c..c4c4217 100644 (file)
@@ -81,6 +81,7 @@ private:
 
     void updateStringValueForKey(const String& key, const String& value);
     void updateBoolValueForKey(const String& key, bool value);
+    void updateBoolValueForExperimentalFeatureKey(const String& key, bool value);
     void updateUInt32ValueForKey(const String& key, uint32_t value);
     void updateDoubleValueForKey(const String& key, double value);
     void updateFloatValueForKey(const String& key, float value);
index 9ad8095..fa49212 100644 (file)
@@ -147,7 +147,6 @@ void WebPreferences::platformInitializeStore()
 #define INITIALIZE_DEBUG_PREFERENCE_FROM_NSUSERDEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue, HumanReadableName, HumanReadableDescription) \
     setDebug##TypeName##ValueIfInUserDefaults(m_identifier, m_keyPrefix, m_globalDebugKeyPrefix, WebPreferencesKey::KeyLower##Key(), m_store);
 
-    FOR_EACH_WEBKIT_EXPERIMENTAL_FEATURE_PREFERENCE(INITIALIZE_DEBUG_PREFERENCE_FROM_NSUSERDEFAULTS)
     FOR_EACH_WEBKIT_DEBUG_PREFERENCE(INITIALIZE_DEBUG_PREFERENCE_FROM_NSUSERDEFAULTS)
 
 #undef INITIALIZE_DEBUG_PREFERENCE_FROM_NSUSERDEFAULTS
index 726c896..c1a33c7 100644 (file)
@@ -193,21 +193,6 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page
         RuntimeEnabledFeatures::sharedFeatures().setCSSCompositingEnabled(enabled);
 #endif
     
-#if ENABLE(SHADOW_DOM)
-    if (preference == "WebKitShadowDOMEnabled")
-        RuntimeEnabledFeatures::sharedFeatures().setShadowDOMEnabled(enabled);
-#endif
-
-#if ENABLE(CUSTOM_ELEMENTS)
-    if (preference == "WebKitCustomElementsEnabled")
-        RuntimeEnabledFeatures::sharedFeatures().setCustomElementsEnabled(enabled);
-#endif
-
-#if ENABLE(WEBGL2)
-    if (preference == "WebKitWebGL2Enabled")
-        RuntimeEnabledFeatures::sharedFeatures().setWebGL2Enabled(enabled);
-#endif
-
 #if ENABLE(FETCH_API)
     if (preference == "WebKitFetchAPIEnabled")
         RuntimeEnabledFeatures::sharedFeatures().setFetchAPIEnabled(enabled);
@@ -223,6 +208,21 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page
         RuntimeEnabledFeatures::sharedFeatures().setCSSGridLayoutEnabled(enabled);
 #endif
 
+#if ENABLE(CUSTOM_ELEMENTS)
+    if (preference == "WebKitExperimentalCustomElementsEnabled")
+        RuntimeEnabledFeatures::sharedFeatures().setCustomElementsEnabled(enabled);
+#endif
+
+#if ENABLE(SHADOW_DOM)
+    if (preference == "WebKitExperimentalShadowDOMEnabled")
+        RuntimeEnabledFeatures::sharedFeatures().setShadowDOMEnabled(enabled);
+#endif
+
+#if ENABLE(WEBGL2)
+    if (preference == "WebKitExperimentalWebGL2Enabled")
+        RuntimeEnabledFeatures::sharedFeatures().setWebGL2Enabled(enabled);
+#endif
+
     // Map the names used in LayoutTests with the names used in WebCore::Settings and WebPreferencesStore.
 #define FOR_EACH_OVERRIDE_BOOL_PREFERENCE(macro) \
     macro(WebKitAcceleratedCompositingEnabled, AcceleratedCompositingEnabled, acceleratedCompositingEnabled) \
index c8c50ad..8058e30 100644 (file)
@@ -3100,18 +3100,6 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     settings.setServiceControlsEnabled(store.getBoolValueForKey(WebPreferencesKey::serviceControlsEnabledKey()));
 #endif
 
-#if ENABLE(SHADOW_DOM)
-    RuntimeEnabledFeatures::sharedFeatures().setShadowDOMEnabled(store.getBoolValueForKey(WebPreferencesKey::shadowDOMEnabledKey()));
-#endif
-
-#if ENABLE(CUSTOM_ELEMENTS)
-    RuntimeEnabledFeatures::sharedFeatures().setCustomElementsEnabled(store.getBoolValueForKey(WebPreferencesKey::customElementsEnabledKey()));
-#endif
-
-#if ENABLE(WEBGL2)
-    RuntimeEnabledFeatures::sharedFeatures().setWebGL2Enabled(store.getBoolValueForKey(WebPreferencesKey::webGL2EnabledKey()));
-#endif
-
 #if ENABLE(FETCH_API)
     RuntimeEnabledFeatures::sharedFeatures().setFetchAPIEnabled(store.getBoolValueForKey(WebPreferencesKey::fetchAPIEnabledKey()));
 #endif
@@ -3120,10 +3108,24 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     RuntimeEnabledFeatures::sharedFeatures().setDownloadAttributeEnabled(store.getBoolValueForKey(WebPreferencesKey::downloadAttributeEnabledKey()));
 #endif
 
+    // Experimental Features.
+
 #if ENABLE(CSS_GRID_LAYOUT)
     RuntimeEnabledFeatures::sharedFeatures().setCSSGridLayoutEnabled(store.getBoolValueForKey(WebPreferencesKey::experimentalCSSGridLayoutEnabledKey()));
 #endif
 
+#if ENABLE(CUSTOM_ELEMENTS)
+    RuntimeEnabledFeatures::sharedFeatures().setCustomElementsEnabled(store.getBoolValueForKey(WebPreferencesKey::experimentalCustomElementsEnabledKey()));
+#endif
+
+#if ENABLE(SHADOW_DOM)
+    RuntimeEnabledFeatures::sharedFeatures().setShadowDOMEnabled(store.getBoolValueForKey(WebPreferencesKey::experimentalShadowDOMEnabledKey()));
+#endif
+
+#if ENABLE(WEBGL2)
+    RuntimeEnabledFeatures::sharedFeatures().setWebGL2Enabled(store.getBoolValueForKey(WebPreferencesKey::experimentalWebGL2EnabledKey()));
+#endif
+
     bool processSuppressionEnabled = store.getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey());
     if (m_processSuppressionEnabled != processSuppressionEnabled) {
         m_processSuppressionEnabled = processSuppressionEnabled;