[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

kov at webkit.org kov at webkit.org
Thu Apr 8 00:35:07 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit e9988485dff07219c23b25f99d4fec51bb5de8f1
Author: kov at webkit.org <kov at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Dec 14 10:51:29 2009 +0000

            Reviewed by Xan Lopez.
    
            New setting to allow applications to completely supress the
            default context menu that is generated by WebKit. This allows them
            to still pass the vent to the default handler without needing to
            use ugly hacks such as handling populate-popup, and removing all
            the items from the default context menu.
    
            * webkit/webkitwebsettings.cpp:
            (webkit_web_settings_class_init):
            (webkit_web_settings_set_property):
            (webkit_web_settings_get_property):
            (webkit_web_settings_copy):
            * webkit/webkitwebview.cpp:
            (webkit_web_view_forward_context_menu_event):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52087 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index f4a81e9..e06b2a7 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,21 @@
+2009-12-14  Gustavo Noronha Silva  <gustavo.noronha at collabora.co.uk>
+
+        Reviewed by Xan Lopez.
+
+        New setting to allow applications to completely supress the
+        default context menu that is generated by WebKit. This allows them
+        to still pass the vent to the default handler without needing to
+        use ugly hacks such as handling populate-popup, and removing all
+        the items from the default context menu.
+
+        * webkit/webkitwebsettings.cpp:
+        (webkit_web_settings_class_init):
+        (webkit_web_settings_set_property):
+        (webkit_web_settings_get_property):
+        (webkit_web_settings_copy):
+        * webkit/webkitwebview.cpp:
+        (webkit_web_view_forward_context_menu_event):
+
 2009-12-13  Gustavo Noronha Silva  <gustavo.noronha at collabora.co.uk>
 
         Reviewed by Xan Lopez.
diff --git a/WebKit/gtk/webkit/webkitwebsettings.cpp b/WebKit/gtk/webkit/webkitwebsettings.cpp
index 143ae06..f565841 100644
--- a/WebKit/gtk/webkit/webkitwebsettings.cpp
+++ b/WebKit/gtk/webkit/webkitwebsettings.cpp
@@ -98,6 +98,7 @@ struct _WebKitWebSettingsPrivate {
     gboolean enable_universal_access_from_file_uris;
     gboolean enable_dom_paste;
     gboolean tab_key_cycles_through_elements;
+    gboolean enable_default_context_menu;
 };
 
 #define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate))
@@ -139,7 +140,8 @@ enum {
     PROP_EDITING_BEHAVIOR,
     PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS,
     PROP_ENABLE_DOM_PASTE,
-    PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS
+    PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS,
+    PROP_ENABLE_DEFAULT_CONTEXT_MENU
 };
 
 // Create a default user agent string
@@ -686,6 +688,27 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
                                                          TRUE,
                                                          flags));
 
+    /**
+     * WebKitWebSettings:enable-default-context-menu:
+     *
+     * Whether right-clicks should be handled automatically to create,
+     * and display the context menu. Turning this off will make
+     * WebKitGTK+ not emit the populate-popup signal. Notice that the
+     * default button press event handler may still handle right
+     * clicks for other reasons, such as in-page context menus, or
+     * right-clicks that are handled by the page itself.
+     *
+     * Since: 1.1.18
+     */
+    g_object_class_install_property(gobject_class,
+                                    PROP_ENABLE_DEFAULT_CONTEXT_MENU,
+                                    g_param_spec_boolean(
+                                    "enable-default-context-menu",
+                                    _("Enable Default Context Menu"),
+                                    _("Enables the handling of right-clicks for the creation of the default context menu"),
+                                    TRUE,
+                                    flags));
+
     g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate));
 }
 
@@ -885,6 +908,9 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con
     case PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS:
         priv->tab_key_cycles_through_elements =  g_value_get_boolean(value);
         break;
+    case PROP_ENABLE_DEFAULT_CONTEXT_MENU:
+        priv->enable_default_context_menu =  g_value_get_boolean(value);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
         break;
@@ -1002,6 +1028,9 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa
     case PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS:
         g_value_set_boolean(value, priv->tab_key_cycles_through_elements);
         break;
+    case PROP_ENABLE_DEFAULT_CONTEXT_MENU:
+        g_value_set_boolean(value, priv->enable_default_context_menu);
+        break;
    default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
         break;
@@ -1067,6 +1096,7 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings)
                  "editing-behavior", priv->editing_behavior,
                  "enable-universal-access-from-file-uris", priv->enable_universal_access_from_file_uris,
                  "enable-dom-paste", priv->enable_dom_paste,
+                 "enable-default-context-menu", priv->enable_default_context_menu,
                  NULL));
 
     return copy;
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index 58fffc5..0447c9c 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -207,6 +207,11 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie
     if (!handledEvent)
         return FALSE;
 
+    // If coreMenu is NULL, this means WebCore decided to not create
+    // the default context menu; this may still mean that the frame
+    // wants to consume the event - this happens when the page is
+    // handling the right-click for reasons other than a context menu,
+    // so we give it to it.
     ContextMenu* coreMenu = page->contextMenuController()->contextMenu();
     if (!coreMenu) {
         Frame* frame = core(webView)->mainFrame();
@@ -216,6 +221,16 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie
         return FALSE;
     }
 
+    // If we reach here, it's because WebCore is going to show the
+    // default context menu. We check our setting to figure out
+    // whether we want it or not.
+    WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
+    gboolean enableDefaultContextMenu;
+    g_object_get(settings, "enable-default-context-menu", &enableDefaultContextMenu, NULL);
+
+    if (!enableDefaultContextMenu)
+        return FALSE;
+
     GtkMenu* menu = GTK_MENU(coreMenu->platformDescription());
     if (!menu)
         return FALSE;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list