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

mrobinson at webkit.org mrobinson at webkit.org
Wed Dec 22 18:25:14 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 38d49040c5be1e1f5f36fb89f82ba935dbcc2bce
Author: mrobinson at webkit.org <mrobinson at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Dec 10 19:10:29 2010 +0000

    2010-12-10  Martin Robinson  <mrobinson at igalia.com>
    
            Unreviewed, rolling out r73703.
            http://trac.webkit.org/changeset/73703
            https://bugs.webkit.org/show_bug.cgi?id=49658
    
            This patch is causing crashes on the GTK+ bots.
    
            * wtf/PlatformRefPtr.h:
    2010-12-10  Martin Robinson  <mrobinson at igalia.com>
    
            Unreviewed, rolling out r73703.
            http://trac.webkit.org/changeset/73703
            https://bugs.webkit.org/show_bug.cgi?id=49658
    
            This patch is causing crashes on the GTK+ bots.
    
            * platform/ContextMenuItem.h:
            (WebCore::PlatformMenuItemDescription::PlatformMenuItemDescription):
            * platform/gtk/ContextMenuGtk.cpp:
            (WebCore::ContextMenu::appendItem):
            * platform/gtk/ContextMenuItemGtk.cpp:
            (WebCore::ContextMenuItem::ContextMenuItem):
            (WebCore::ContextMenuItem::~ContextMenuItem):
            (WebCore::ContextMenuItem::createNativeMenuItem):
            (WebCore::ContextMenuItem::releasePlatformDescription):
            (WebCore::ContextMenuItem::type):
            (WebCore::ContextMenuItem::setType):
            (WebCore::ContextMenuItem::action):
            (WebCore::ContextMenuItem::setAction):
            (WebCore::ContextMenuItem::title):
            (WebCore::ContextMenuItem::setTitle):
            (WebCore::ContextMenuItem::platformSubMenu):
            (WebCore::ContextMenuItem::setSubMenu):
            (WebCore::ContextMenuItem::setChecked):
            (WebCore::ContextMenuItem::setEnabled):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73746 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 6bac927..db27b8a 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,13 @@
+2010-12-10  Martin Robinson  <mrobinson at igalia.com>
+
+        Unreviewed, rolling out r73703.
+        http://trac.webkit.org/changeset/73703
+        https://bugs.webkit.org/show_bug.cgi?id=49658
+
+        This patch is causing crashes on the GTK+ bots.
+
+        * wtf/PlatformRefPtr.h:
+
 2010-12-10  Patrick Gansterer  <paroga at webkit.org>
 
         Reviewed by Eric Seidel.
diff --git a/JavaScriptCore/wtf/PlatformRefPtr.h b/JavaScriptCore/wtf/PlatformRefPtr.h
index e4f1314..8ac16cb 100644
--- a/JavaScriptCore/wtf/PlatformRefPtr.h
+++ b/JavaScriptCore/wtf/PlatformRefPtr.h
@@ -74,13 +74,6 @@ public:
             derefPlatformPtr(ptr);
     }
 
-    T* leakRef() WARN_UNUSED_RETURN
-    {
-        T* ptr = m_ptr;
-        m_ptr = 0;
-        return ptr;
-    }
-
     // Hash table deleted values, which are only constructed and never copied or destroyed.
     PlatformRefPtr(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { }
     bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedValue(); }
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 90b9457..10879e2 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,31 @@
+2010-12-10  Martin Robinson  <mrobinson at igalia.com>
+
+        Unreviewed, rolling out r73703.
+        http://trac.webkit.org/changeset/73703
+        https://bugs.webkit.org/show_bug.cgi?id=49658
+
+        This patch is causing crashes on the GTK+ bots.
+
+        * platform/ContextMenuItem.h:
+        (WebCore::PlatformMenuItemDescription::PlatformMenuItemDescription):
+        * platform/gtk/ContextMenuGtk.cpp:
+        (WebCore::ContextMenu::appendItem):
+        * platform/gtk/ContextMenuItemGtk.cpp:
+        (WebCore::ContextMenuItem::ContextMenuItem):
+        (WebCore::ContextMenuItem::~ContextMenuItem):
+        (WebCore::ContextMenuItem::createNativeMenuItem):
+        (WebCore::ContextMenuItem::releasePlatformDescription):
+        (WebCore::ContextMenuItem::type):
+        (WebCore::ContextMenuItem::setType):
+        (WebCore::ContextMenuItem::action):
+        (WebCore::ContextMenuItem::setAction):
+        (WebCore::ContextMenuItem::title):
+        (WebCore::ContextMenuItem::setTitle):
+        (WebCore::ContextMenuItem::platformSubMenu):
+        (WebCore::ContextMenuItem::setSubMenu):
+        (WebCore::ContextMenuItem::setChecked):
+        (WebCore::ContextMenuItem::setEnabled):
+
 2010-12-08  Mihai Parparita  <mihaip at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/platform/ContextMenuItem.h b/WebCore/platform/ContextMenuItem.h
index e0a008d..e702921 100644
--- a/WebCore/platform/ContextMenuItem.h
+++ b/WebCore/platform/ContextMenuItem.h
@@ -42,7 +42,6 @@ class NSMenuItem;
 #elif PLATFORM(WIN)
 typedef struct tagMENUITEMINFOW* LPMENUITEMINFO;
 #elif PLATFORM(GTK)
-#include <GRefPtr.h>
 typedef struct _GtkMenuItem GtkMenuItem;
 #elif PLATFORM(QT)
 #include <QAction>
@@ -186,7 +185,22 @@ namespace WebCore {
         bool enabled;
     };
 #elif PLATFORM(GTK)
-    typedef GtkMenuItem* PlatformMenuItemDescription;
+    struct PlatformMenuItemDescription {
+        PlatformMenuItemDescription()
+            : type(ActionType)
+            , action(ContextMenuItemTagNoAction)
+            , subMenu(0)
+            , checked(false)
+            , enabled(true)
+        {}
+
+        ContextMenuItemType type;
+        ContextMenuAction action;
+        String title;
+        GtkMenu* subMenu;
+        bool checked;
+        bool enabled;
+    };
 #elif PLATFORM(WX)
     struct PlatformMenuItemDescription {
         PlatformMenuItemDescription()
@@ -246,7 +260,9 @@ namespace WebCore {
 
         ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, bool enabled, bool checked);
         ContextMenuItem(ContextMenuAction, const String&, bool enabled, bool checked, Vector<ContextMenuItem>& submenuItems);
-
+#if PLATFORM(GTK)
+        ContextMenuItem(GtkMenuItem*);
+#endif
         ~ContextMenuItem();
 
         PlatformMenuItemDescription releasePlatformDescription();
@@ -271,12 +287,13 @@ namespace WebCore {
         bool enabled() const;
 
         // FIXME: Do we need a keyboard accelerator here?
+#if PLATFORM(GTK)
+        static GtkMenuItem* createNativeMenuItem(const PlatformMenuItemDescription&);
+#endif
 
     private:
 #if PLATFORM(MAC)
         RetainPtr<NSMenuItem> m_platformDescription;
-#elif PLATFORM(GTK)
-        PlatformRefPtr<GtkMenuItem> m_platformDescription;
 #else
         PlatformMenuItemDescription m_platformDescription;
 #endif
diff --git a/WebCore/platform/gtk/ContextMenuGtk.cpp b/WebCore/platform/gtk/ContextMenuGtk.cpp
index 423959a..327167e 100644
--- a/WebCore/platform/gtk/ContextMenuGtk.cpp
+++ b/WebCore/platform/gtk/ContextMenuGtk.cpp
@@ -40,7 +40,7 @@ void ContextMenu::appendItem(ContextMenuItem& item)
 {
     ASSERT(m_platformDescription);
 
-    GtkMenuItem* platformItem = item.releasePlatformDescription();
+    GtkMenuItem* platformItem = ContextMenuItem::createNativeMenuItem(item.releasePlatformDescription());
     ASSERT(platformItem);
     gtk_menu_shell_append(GTK_MENU_SHELL(m_platformDescription), GTK_WIDGET(platformItem));
     gtk_widget_show(GTK_WIDGET(platformItem));
diff --git a/WebCore/platform/gtk/ContextMenuItemGtk.cpp b/WebCore/platform/gtk/ContextMenuItemGtk.cpp
index 37c29b5..68d0a9a 100644
--- a/WebCore/platform/gtk/ContextMenuItemGtk.cpp
+++ b/WebCore/platform/gtk/ContextMenuItemGtk.cpp
@@ -18,14 +18,13 @@
  */
 
 #include "config.h"
-#include "ContextMenuItem.h"
-
 #include "ContextMenu.h"
-#include "GOwnPtr.h"
+#include "ContextMenuItem.h"
 #include "NotImplemented.h"
-#include <gtk/gtk.h>
 #include <wtf/text/CString.h>
 
+#include <gtk/gtk.h>
+
 #define WEBKIT_CONTEXT_MENU_ACTION "webkit-context-menu"
 
 namespace WebCore {
@@ -115,9 +114,30 @@ static const char* gtkStockIDFromContextMenuAction(const ContextMenuAction& acti
 }
 
 // Extract the ActionType from the menu item
-ContextMenuItem::ContextMenuItem(PlatformMenuItemDescription item)
-    : m_platformDescription(item)
+ContextMenuItem::ContextMenuItem(GtkMenuItem* item)
+    : m_platformDescription()
 {
+    if (GTK_IS_SEPARATOR_MENU_ITEM(item))
+        m_platformDescription.type = SeparatorType;
+    else if (gtk_menu_item_get_submenu(item))
+        m_platformDescription.type = SubmenuType;
+    else if (GTK_IS_CHECK_MENU_ITEM(item)) {
+        m_platformDescription.type = CheckableActionType;
+        m_platformDescription.checked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item));
+    } else
+        m_platformDescription.type = ActionType;
+#if GTK_CHECK_VERSION (2, 16, 0)
+    m_platformDescription.title = String::fromUTF8(gtk_menu_item_get_label(GTK_MENU_ITEM(item)));
+#else
+    GtkWidget* label = gtk_bin_get_child(GTK_BIN(item));
+    m_platformDescription.title = String::fromUTF8(gtk_label_get_label(GTK_LABEL(label)));
+#endif
+
+    m_platformDescription.action = *static_cast<ContextMenuAction*>(g_object_get_data(G_OBJECT(item), WEBKIT_CONTEXT_MENU_ACTION));
+
+    m_platformDescription.subMenu = GTK_MENU(gtk_menu_item_get_submenu(item));
+    if (m_platformDescription.subMenu)
+        g_object_ref(m_platformDescription.subMenu);
 }
 
 ContextMenuItem::ContextMenuItem(ContextMenu*)
@@ -127,100 +147,114 @@ ContextMenuItem::ContextMenuItem(ContextMenu*)
 
 ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu)
 {
-    if (type == SeparatorType) {
-        m_platformDescription = GTK_MENU_ITEM(gtk_separator_menu_item_new());
-        return;
-    }
+    m_platformDescription.type = type;
+    m_platformDescription.action = action;
+    m_platformDescription.title = title;
+
+    setSubMenu(subMenu);
+}
 
-    GOwnPtr<char> actionName(g_strdup_printf("context-menu-action-%d", action));
-    GtkAction* platformAction = 0;
+ContextMenuItem::~ContextMenuItem()
+{
+    if (m_platformDescription.subMenu)
+        g_object_unref(m_platformDescription.subMenu);
+}
 
-    if (type == ActionType)
-        platformAction = gtk_action_new(actionName.get(), title.utf8().data(), 0, gtkStockIDFromContextMenuAction(action));
-    else if (type == CheckableActionType)
-        platformAction = GTK_ACTION(gtk_toggle_action_new(actionName.get(), title.utf8().data(), 0, gtkStockIDFromContextMenuAction(action)));
+GtkMenuItem* ContextMenuItem::createNativeMenuItem(const PlatformMenuItemDescription& menu)
+{
+    GtkMenuItem* item = 0;
+    if (menu.type == SeparatorType)
+        item = GTK_MENU_ITEM(gtk_separator_menu_item_new());
+    else {
+        if (menu.type == CheckableActionType) {
+            item = GTK_MENU_ITEM(gtk_check_menu_item_new_with_mnemonic(menu.title.utf8().data()));
+            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), menu.checked);
+        } else {
+            if (const gchar* stockID = gtkStockIDFromContextMenuAction(menu.action)) {
+                item = GTK_MENU_ITEM(gtk_image_menu_item_new_with_mnemonic(menu.title.utf8().data()));
+                GtkWidget* image = gtk_image_new_from_stock(stockID, GTK_ICON_SIZE_MENU);
+                gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
+            } else
+                item = GTK_MENU_ITEM(gtk_menu_item_new_with_mnemonic(menu.title.utf8().data()));
+        }
 
-    m_platformDescription = GTK_MENU_ITEM(gtk_action_create_menu_item(platformAction));
-    g_object_unref(platformAction);
+        ContextMenuAction* menuAction = static_cast<ContextMenuAction*>(malloc(sizeof(ContextMenuAction*)));
+        *menuAction = menu.action;
+        g_object_set_data(G_OBJECT(item), WEBKIT_CONTEXT_MENU_ACTION, menuAction);
 
-    g_object_set_data(G_OBJECT(m_platformDescription.get()), WEBKIT_CONTEXT_MENU_ACTION, GINT_TO_POINTER(action));
+        gtk_widget_set_sensitive(GTK_WIDGET(item), menu.enabled);
 
-    if (subMenu)
-        setSubMenu(subMenu);
-}
+        if (menu.subMenu)
+            gtk_menu_item_set_submenu(item, GTK_WIDGET(menu.subMenu));
+    }
 
-ContextMenuItem::~ContextMenuItem()
-{
+    return item;
 }
 
 PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription()
 {
-    return m_platformDescription.leakRef();
+    PlatformMenuItemDescription description = m_platformDescription;
+    m_platformDescription = PlatformMenuItemDescription();
+    return description;
 }
 
 ContextMenuItemType ContextMenuItem::type() const
 {
-    if (GTK_IS_SEPARATOR_MENU_ITEM(m_platformDescription.get()))
-        return SeparatorType;
-    if (GTK_IS_CHECK_MENU_ITEM(m_platformDescription.get()))
-        return CheckableActionType;
-    if (gtk_menu_item_get_submenu(m_platformDescription.get()))
-        return SubmenuType;
-    return ActionType;
+    return m_platformDescription.type;
 }
 
 void ContextMenuItem::setType(ContextMenuItemType type)
 {
-    if (type == SeparatorType)
-        m_platformDescription = GTK_MENU_ITEM(gtk_separator_menu_item_new());
+    m_platformDescription.type = type;
 }
 
 ContextMenuAction ContextMenuItem::action() const
 {
-    return static_cast<ContextMenuAction>(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(m_platformDescription.get()), WEBKIT_CONTEXT_MENU_ACTION)));
+    return m_platformDescription.action;
 }
 
 void ContextMenuItem::setAction(ContextMenuAction action)
 {
-    g_object_set_data(G_OBJECT(m_platformDescription.get()), WEBKIT_CONTEXT_MENU_ACTION, GINT_TO_POINTER(action));
+    m_platformDescription.action = action;
 }
 
 String ContextMenuItem::title() const
 {
-    GtkAction* action = gtk_activatable_get_related_action(GTK_ACTIVATABLE(m_platformDescription.get()));
-    return action ? String(gtk_action_get_label(action)) : String();
+    return m_platformDescription.title;
 }
 
 void ContextMenuItem::setTitle(const String& title)
 {
-    GtkAction* action = gtk_activatable_get_related_action(GTK_ACTIVATABLE(m_platformDescription.get()));
-    if (action)
-        gtk_action_set_label(action, title.utf8().data());
+    m_platformDescription.title = title;
 }
 
 PlatformMenuDescription ContextMenuItem::platformSubMenu() const
 {
-    GtkWidget* subMenu = gtk_menu_item_get_submenu(m_platformDescription.get());
-    return subMenu ? GTK_MENU(subMenu) : 0;
+    return m_platformDescription.subMenu;
 }
 
 void ContextMenuItem::setSubMenu(ContextMenu* menu)
 {
-    gtk_menu_item_set_submenu(m_platformDescription.get(), GTK_WIDGET(menu->platformDescription()));
+    if (m_platformDescription.subMenu)
+        g_object_unref(m_platformDescription.subMenu);
+
+    if (!menu)
+        return;
+
+    m_platformDescription.subMenu = menu->releasePlatformDescription();
+    m_platformDescription.type = SubmenuType;
+
+    g_object_ref_sink(G_OBJECT(m_platformDescription.subMenu));
 }
 
 void ContextMenuItem::setChecked(bool shouldCheck)
 {
-    GtkAction* action = gtk_activatable_get_related_action(GTK_ACTIVATABLE(m_platformDescription.get()));
-    if (action && GTK_IS_TOGGLE_ACTION(action))
-        gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), shouldCheck);
+    m_platformDescription.checked = shouldCheck;
 }
 
 void ContextMenuItem::setEnabled(bool shouldEnable)
 {
-    GtkAction* action = gtk_activatable_get_related_action(GTK_ACTIVATABLE(m_platformDescription.get()));
-    if (action)
-        gtk_action_set_sensitive(action, shouldEnable);
+    m_platformDescription.enabled = shouldEnable;
 }
 
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list