Title: [130642] trunk/Source/WebKit2
Revision
130642
Author
[email protected]
Date
2012-10-08 08:05:53 -0700 (Mon, 08 Oct 2012)

Log Message

[GTK] Add a setting to enable/disable smooth scrolling to WebKit2 GTK+ API
https://bugs.webkit.org/show_bug.cgi?id=98646

Reviewed by Xan Lopez.

* UIProcess/API/gtk/WebKitSettings.cpp:
(webKitSettingsSetProperty): Implement setter for new property.
(webKitSettingsGetProperty): Implement getter for new property.
(webkit_settings_class_init): Add new property
enable-smooth-scrolling.
(webkit_settings_get_enable_smooth_scrolling):
(webkit_settings_set_enable_smooth_scrolling):
* UIProcess/API/gtk/WebKitSettings.h:
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
* UIProcess/API/gtk/tests/TestWebKitSettings.cpp:
(testWebKitSettings): Test smooth scrolling setting API.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (130641 => 130642)


--- trunk/Source/WebKit2/ChangeLog	2012-10-08 15:04:13 UTC (rev 130641)
+++ trunk/Source/WebKit2/ChangeLog	2012-10-08 15:05:53 UTC (rev 130642)
@@ -1,3 +1,22 @@
+2012-10-08  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Add a setting to enable/disable smooth scrolling to WebKit2 GTK+ API
+        https://bugs.webkit.org/show_bug.cgi?id=98646
+
+        Reviewed by Xan Lopez.
+
+        * UIProcess/API/gtk/WebKitSettings.cpp:
+        (webKitSettingsSetProperty): Implement setter for new property.
+        (webKitSettingsGetProperty): Implement getter for new property.
+        (webkit_settings_class_init): Add new property
+        enable-smooth-scrolling.
+        (webkit_settings_get_enable_smooth_scrolling):
+        (webkit_settings_set_enable_smooth_scrolling):
+        * UIProcess/API/gtk/WebKitSettings.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
+        * UIProcess/API/gtk/tests/TestWebKitSettings.cpp:
+        (testWebKitSettings): Test smooth scrolling setting API.
+
 2012-10-08  Christophe Dumez  <[email protected]>
 
         [EFL][WK2] Use URL instead of URI in the API

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


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp	2012-10-08 15:04:13 UTC (rev 130641)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp	2012-10-08 15:05:53 UTC (rev 130642)
@@ -34,6 +34,7 @@
 #include "WebKitPrivate.h"
 #include "WebKitSettingsPrivate.h"
 #include "WebPageProxy.h"
+#include "WebPreferences.h"
 #include <WebCore/UserAgentGtk.h>
 #include <glib/gi18n-lib.h>
 #include <wtf/text/CString.h>
@@ -117,7 +118,8 @@
     PROP_DRAW_COMPOSITING_INDICATORS,
     PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
     PROP_ENABLE_PAGE_CACHE,
-    PROP_USER_AGENT
+    PROP_USER_AGENT,
+    PROP_ENABLE_SMOOTH_SCROLLING
 };
 
 static void webKitSettingsSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
@@ -251,6 +253,9 @@
     case PROP_USER_AGENT:
         webkit_settings_set_user_agent(settings, g_value_get_string(value));
         break;
+    case PROP_ENABLE_SMOOTH_SCROLLING:
+        webkit_settings_set_enable_smooth_scrolling(settings, g_value_get_boolean(value));
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
         break;
@@ -388,6 +393,9 @@
     case PROP_USER_AGENT:
         g_value_set_string(value, webkit_settings_get_user_agent(settings));
         break;
+    case PROP_ENABLE_SMOOTH_SCROLLING:
+        g_value_set_boolean(value, webkit_settings_get_enable_smooth_scrolling(settings));
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
         break;
@@ -1039,6 +1047,19 @@
                                                         0, // A null string forces the standard user agent.
                                                         readWriteConstructParamFlags));
 
+    /**
+     * WebKitSettings:enable-smooth-scrolling:
+     *
+     * Enable or disable smooth scrolling.
+     */
+    g_object_class_install_property(gObjectClass,
+                                    PROP_ENABLE_SMOOTH_SCROLLING,
+                                    g_param_spec_boolean("enable-smooth-scrolling",
+                                                         _("Enable smooth scrolling"),
+                                                         _("Whether to enable smooth scrolling"),
+                                                         FALSE,
+                                                         readWriteConstructParamFlags));
+
     g_type_class_add_private(klass, sizeof(WebKitSettingsPrivate));
 }
 
@@ -2644,3 +2665,38 @@
     CString newUserAgent = WebCore::standardUserAgent(String::fromUTF8(applicationName), String::fromUTF8(applicationVersion)).utf8();
     webkit_settings_set_user_agent(settings, newUserAgent.data());
 }
+
+/**
+ * webkit_settings_get_enable_smooth_scrolling:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-smooth-scrolling property.
+ *
+ * Returns: %TRUE if smooth scrolling is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_smooth_scrolling(WebKitSettings* settings)
+{
+    g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+    return WebKit::toImpl(settings->priv->preferences.get())->scrollAnimatorEnabled();
+}
+
+/**
+ * webkit_settings_set_enable_smooth_scrolling:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-smooth-scrolling property.
+ */
+void webkit_settings_set_enable_smooth_scrolling(WebKitSettings* settings, gboolean enabled)
+{
+    g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+    WebKitSettingsPrivate* priv = settings->priv;
+    bool currentValue = WebKit::toImpl(priv->preferences.get())->scrollAnimatorEnabled();
+    if (currentValue == enabled)
+        return;
+
+    WebKit::toImpl(priv->preferences.get())->setScrollAnimatorEnabled(enabled);
+    g_object_notify(G_OBJECT(settings), "enable-smooth-scrolling");
+}

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h (130641 => 130642)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h	2012-10-08 15:04:13 UTC (rev 130641)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h	2012-10-08 15:05:53 UTC (rev 130642)
@@ -373,6 +373,13 @@
                                                                 const gchar    *application_name,
                                                                 const gchar    *application_version);
 
+WEBKIT_API gboolean
+webkit_settings_get_enable_smooth_scrolling                    (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_smooth_scrolling                    (WebKitSettings *settings,
+                                                                gboolean        enabled);
+
 G_END_DECLS
 
 #endif /* WebKitSettings_h */

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (130641 => 130642)


--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2012-10-08 15:04:13 UTC (rev 130641)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2012-10-08 15:05:53 UTC (rev 130642)
@@ -295,6 +295,8 @@
 webkit_settings_get_user_agent
 webkit_settings_set_user_agent
 webkit_settings_set_user_agent_with_application_details
+webkit_settings_get_enable_smooth_scrolling
+webkit_settings_set_enable_smooth_scrolling
 
 <SUBSECTION Standard>
 WebKitSettingsClass

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp (130641 => 130642)


--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp	2012-10-08 15:04:13 UTC (rev 130641)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp	2012-10-08 15:05:53 UTC (rev 130642)
@@ -243,6 +243,11 @@
     webkit_settings_set_enable_page_cache(settings, FALSE);
     g_assert(!webkit_settings_get_enable_page_cache(settings));
 
+    // By default, smooth scrolling is disabled.
+    g_assert(!webkit_settings_get_enable_smooth_scrolling(settings));
+    webkit_settings_set_enable_smooth_scrolling(settings, TRUE);
+    g_assert(webkit_settings_get_enable_smooth_scrolling(settings));
+
     g_object_unref(G_OBJECT(settings));
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to