Title: [152922] trunk/Source/WebKit2
Revision
152922
Author
[email protected]
Date
2013-07-19 13:04:59 -0700 (Fri, 19 Jul 2013)

Log Message

[GTK] Need a way to enable region based columns from the command line
https://bugs.webkit.org/show_bug.cgi?id=116611

Patch by Morten Stenshorne <[email protected]> on 2013-07-19
Reviewed by Martin Robinson.

Add an environment variable to enable experimental features.

This provides a means to enable experimental features without polluting
the public API.

Environment variable name: WEBKITGTK_EXPERIMENTAL_FEATURES

Format: WEBKITGTK_EXPERIMENTAL_FEATURES="<feature1>=1,<feature2>=1,..."
Or, to enable all experimental features: WEBKITGTK_EXPERIMENTAL_FEATURES=all

So far the only feature is region based columns (implement multicol using
the CSS regions implementation rather than ColumnInfo & co) - REGION_BASED_COLUMNS.

Example: WEBKITGTK_EXPERIMENTAL_FEATURES="REGION_BASED_COLUMNS=1"

* GNUmakefile.list.am:
* PlatformGTK.cmake:
* UIProcess/API/gtk/WebKitSettings.cpp:
(webKitSettingsConstructed):
(webkit_settings_class_init):
* UIProcess/gtk/ExperimentalFeatures.cpp: Added.
(WebKit):
(Setting):
(WebKit::ExperimentalFeatures::ExperimentalFeatures):
(WebKit::ExperimentalFeatures::isEnabled):
(WebKit::ExperimentalFeatures::setEnableByName):
(WebKit::ExperimentalFeatures::parseEnvironment):
* UIProcess/gtk/ExperimentalFeatures.h: Added.
(WebKit):
(ExperimentalFeatures):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (152921 => 152922)


--- trunk/Source/WebKit2/ChangeLog	2013-07-19 19:43:21 UTC (rev 152921)
+++ trunk/Source/WebKit2/ChangeLog	2013-07-19 20:04:59 UTC (rev 152922)
@@ -1,3 +1,41 @@
+2013-07-19  Morten Stenshorne  <[email protected]>
+
+        [GTK] Need a way to enable region based columns from the command line
+        https://bugs.webkit.org/show_bug.cgi?id=116611
+
+        Reviewed by Martin Robinson.
+
+        Add an environment variable to enable experimental features.
+
+        This provides a means to enable experimental features without polluting
+        the public API.
+
+        Environment variable name: WEBKITGTK_EXPERIMENTAL_FEATURES
+
+        Format: WEBKITGTK_EXPERIMENTAL_FEATURES="<feature1>=1,<feature2>=1,..."
+        Or, to enable all experimental features: WEBKITGTK_EXPERIMENTAL_FEATURES=all
+
+        So far the only feature is region based columns (implement multicol using
+        the CSS regions implementation rather than ColumnInfo & co) - REGION_BASED_COLUMNS.
+
+        Example: WEBKITGTK_EXPERIMENTAL_FEATURES="REGION_BASED_COLUMNS=1"
+
+        * GNUmakefile.list.am:
+        * PlatformGTK.cmake:
+        * UIProcess/API/gtk/WebKitSettings.cpp:
+        (webKitSettingsConstructed):
+        (webkit_settings_class_init):
+        * UIProcess/gtk/ExperimentalFeatures.cpp: Added.
+        (WebKit):
+        (Setting):
+        (WebKit::ExperimentalFeatures::ExperimentalFeatures):
+        (WebKit::ExperimentalFeatures::isEnabled):
+        (WebKit::ExperimentalFeatures::setEnableByName):
+        (WebKit::ExperimentalFeatures::parseEnvironment):
+        * UIProcess/gtk/ExperimentalFeatures.h: Added.
+        (WebKit):
+        (ExperimentalFeatures):
+
 2013-07-18  Eunmi Lee  <[email protected]>
 
         [WK2] Share Qt port's codes to find zoomable area with CoordinatedGraphics.

Modified: trunk/Source/WebKit2/GNUmakefile.list.am (152921 => 152922)


--- trunk/Source/WebKit2/GNUmakefile.list.am	2013-07-19 19:43:21 UTC (rev 152921)
+++ trunk/Source/WebKit2/GNUmakefile.list.am	2013-07-19 20:04:59 UTC (rev 152922)
@@ -814,6 +814,7 @@
 	Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.cpp \
 	Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.h \
 	Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp \
+	Source/WebKit2/UIProcess/gtk/ExperimentalFeatures.cpp \
 	Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp \
 	Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp \
 	Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp \

Modified: trunk/Source/WebKit2/PlatformGTK.cmake (152921 => 152922)


--- trunk/Source/WebKit2/PlatformGTK.cmake	2013-07-19 19:43:21 UTC (rev 152921)
+++ trunk/Source/WebKit2/PlatformGTK.cmake	2013-07-19 20:04:59 UTC (rev 152922)
@@ -32,6 +32,7 @@
     WebProcess/InjectedBundle/gtk/InjectedBundleGtk.cpp
     UIProcess/API/C/gtk/WKFullScreenClientGtk.cpp
     UIProcess/API/C/gtk/WKInspectorClientGtk.cpp
+    UIProcess/gtk/ExperimentalFeatures.cpp
     UIProcess/gtk/WebContextMenuProxyGtk.cpp
     UIProcess/gtk/WebContextGtk.cpp
     UIProcess/gtk/WebPageProxyGtk.cpp

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp (152921 => 152922)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp	2013-07-19 19:43:21 UTC (rev 152921)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp	2013-07-19 20:04:59 UTC (rev 152922)
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "WebKitSettings.h"
 
+#include "ExperimentalFeatures.h"
 #include "WebKitPrivate.h"
 #include "WebKitSettingsPrivate.h"
 #include <WebCore/UserAgentGtk.h>
@@ -137,6 +138,17 @@
     PROP_ENABLE_WRITE_CONSOLE_MESSAGES_TO_STDOUT
 };
 
+static void webKitSettingsConstructed(GObject* object)
+{
+    G_OBJECT_CLASS(webkit_settings_parent_class)->constructed(object);
+
+    WebPreferences* prefs = WEBKIT_SETTINGS(object)->priv->preferences.get();
+    ExperimentalFeatures features;
+    bool regionBasedColumnsEnabled = features.isEnabled(ExperimentalFeatures::RegionBasedColumns);
+    if (prefs->regionBasedColumnsEnabled() != regionBasedColumnsEnabled)
+        prefs->setRegionBasedColumnsEnabled(regionBasedColumnsEnabled);
+}
+
 static void webKitSettingsSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
 {
     WebKitSettings* settings = WEBKIT_SETTINGS(object);
@@ -438,6 +450,7 @@
 static void webkit_settings_class_init(WebKitSettingsClass* klass)
 {
     GObjectClass* gObjectClass = G_OBJECT_CLASS(klass);
+    gObjectClass->constructed = webKitSettingsConstructed;
     gObjectClass->set_property = webKitSettingsSetProperty;
     gObjectClass->get_property = webKitSettingsGetProperty;
 

Added: trunk/Source/WebKit2/UIProcess/gtk/ExperimentalFeatures.cpp (0 => 152922)


--- trunk/Source/WebKit2/UIProcess/gtk/ExperimentalFeatures.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/ExperimentalFeatures.cpp	2013-07-19 20:04:59 UTC (rev 152922)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013, Opera Software ASA. 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.
+ * 3. Neither the name of Opera Software ASA nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE
+ * COPYRIGHT HOLDER OR 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 "config.h"
+#include "ExperimentalFeatures.h"
+
+namespace WebKit {
+
+struct Setting {
+    ExperimentalFeatures::Feature feature;
+    const char* featureName;
+    bool enabled;
+};
+
+static Setting settings[] = {
+    { ExperimentalFeatures::RegionBasedColumns, "REGION_BASED_COLUMNS", false }
+};
+
+ExperimentalFeatures::ExperimentalFeatures()
+{
+    parseEnvironment();
+}
+
+bool ExperimentalFeatures::isEnabled(Feature feature)
+{
+    return settings[feature].enabled;
+}
+
+void ExperimentalFeatures::setEnableByName(const String& key, bool enable)
+{
+    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(settings); i++) {
+        if (key == settings[i].featureName) {
+            settings[i].enabled = enable;
+            break;
+        }
+    }
+}
+
+void ExperimentalFeatures::parseEnvironment()
+{
+    const char* data = ""
+    if (!data)
+        return;
+    if (!strcmp(data, "all")) {
+        for (unsigned i = 0; i < WTF_ARRAY_LENGTH(settings); i++)
+            settings[i].enabled = true;
+    } else {
+        Vector<String> variables;
+        String(data).split(',', false, variables);
+        for (unsigned i = 0; i < variables.size(); i++) {
+            Vector<String> keyAndValue;
+            variables[i].split('=', false, keyAndValue);
+            if (keyAndValue.size() != 2)
+                continue;
+            setEnableByName(keyAndValue[0], keyAndValue[1][0] - '0');
+        }
+    }
+}
+
+} // namespace WebKit

Added: trunk/Source/WebKit2/UIProcess/gtk/ExperimentalFeatures.h (0 => 152922)


--- trunk/Source/WebKit2/UIProcess/gtk/ExperimentalFeatures.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/ExperimentalFeatures.h	2013-07-19 20:04:59 UTC (rev 152922)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013, Opera Software ASA. 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.
+ * 3. Neither the name of Opera Software ASA nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE
+ * COPYRIGHT HOLDER OR 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.
+ */
+
+#ifndef ExperimentalFeatures_h
+#define ExperimentalFeatures_h
+
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+class ExperimentalFeatures {
+public:
+    enum Feature {
+        RegionBasedColumns
+    };
+
+    ExperimentalFeatures();
+
+    bool isEnabled(Feature);
+
+private:
+    void setEnableByName(const String& key, bool enable);
+    void parseEnvironment();
+};
+
+} // namespace WebKit
+
+#endif // ExperimentalFeatures_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to