Title: [107593] trunk/Source/WebCore
Revision
107593
Author
[email protected]
Date
2012-02-13 12:14:58 -0800 (Mon, 13 Feb 2012)

Log Message

Don't include a separator before the "Inspect Element" context menu item when the context menu is empty.

https://webkit.org/b/78312

Reviewed by Brian Weinstein.

* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::addInspectElementItem): Check itemCount before appending the separator.
* platform/gtk/ContextMenuGtk.cpp:
(WebCore::ContextMenu::itemCount): Added. Implement so this builds on GTK.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (107592 => 107593)


--- trunk/Source/WebCore/ChangeLog	2012-02-13 19:54:31 UTC (rev 107592)
+++ trunk/Source/WebCore/ChangeLog	2012-02-13 20:14:58 UTC (rev 107593)
@@ -1,3 +1,16 @@
+2012-02-13  Timothy Hatcher  <[email protected]>
+
+        Don't include a separator before the "Inspect Element" context menu item when the context menu is empty.
+
+        https://webkit.org/b/78312
+
+        Reviewed by Brian Weinstein.
+
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::addInspectElementItem): Check itemCount before appending the separator.
+        * platform/gtk/ContextMenuGtk.cpp:
+        (WebCore::ContextMenu::itemCount): Added. Implement so this builds on GTK.
+
 2012-02-13  Patrick Gansterer  <[email protected]>
 
         [WIN] Define HWND_MESSAGE if not done already

Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (107592 => 107593)


--- trunk/Source/WebCore/page/ContextMenuController.cpp	2012-02-13 19:54:31 UTC (rev 107592)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp	2012-02-13 20:14:58 UTC (rev 107593)
@@ -983,7 +983,12 @@
         return;
 
     ContextMenuItem InspectElementItem(ActionType, ContextMenuItemTagInspectElement, contextMenuItemTagInspectElement());
-    appendItem(*separatorItem(), m_contextMenu.get());
+#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
+    if (!m_contextMenu->items().isEmpty())
+#else
+    if (m_contextMenu->itemCount())
+#endif
+        appendItem(*separatorItem(), m_contextMenu.get());
     appendItem(InspectElementItem, m_contextMenu.get());
 }
 #endif // ENABLE(INSPECTOR)

Modified: trunk/Source/WebCore/platform/gtk/ContextMenuGtk.cpp (107592 => 107593)


--- trunk/Source/WebCore/platform/gtk/ContextMenuGtk.cpp	2012-02-13 19:54:31 UTC (rev 107592)
+++ trunk/Source/WebCore/platform/gtk/ContextMenuGtk.cpp	2012-02-13 20:14:58 UTC (rev 107593)
@@ -75,6 +75,14 @@
     return description;
 }
 
+unsigned ContextMenu::itemCount() const
+{
+    ASSERT(m_platformDescription);
+
+    GOwnPtr<GList> children(gtk_container_get_children(GTK_CONTAINER(m_platformDescription)));
+    return g_list_length(children.get());
+}
+
 Vector<ContextMenuItem> contextMenuItemVector(const PlatformMenuDescription menu)
 {
     Vector<ContextMenuItem> menuItemVector;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to