Title: [147545] trunk
Revision
147545
Author
[email protected]
Date
2013-04-03 05:44:36 -0700 (Wed, 03 Apr 2013)

Log Message

[Qt] Switch ContextMenu implementation to CROSS_PLATFORM_CONTEXT_MENU
https://bugs.webkit.org/show_bug.cgi?id=113535

Reviewed by Simon Hausmann.

Source/WebCore:

Now Qt uses the CROSS_PLATFORM_CONTEXT_MENUS
USE flag. This flag provides a full cross-platform
representation of a ContextMenu and a ContextMenuItem.
The embedder can then decide how to show this, so neither
WebCore nor WebCore/platform need to know any platform
specifics about menus.

No new tests, no behavior changes.

* Target.pri:
* platform/ContextMenu.h:
(ContextMenu):
* platform/ContextMenuItem.h:
* platform/qt/ContextMenuItemQt.cpp:
(WebCore::ContextMenuItem::platformContextMenuItem):
* platform/qt/ContextMenuQt.cpp:
(WebCore::ContextMenu::ContextMenu):
(WebCore::ContextMenu::getContextMenuItems):
(WebCore::ContextMenu::createPlatformContextMenuFromItems):
(WebCore::ContextMenu::platformContextMenu):

Source/WebKit/qt:

Adjust ContextMenuClientQt and QWebPageAdapter to use CROSS_PLATFORM_CONTEXT_MENUS
USE flag by implementing customizeMenu() instead of getCustomMenuFromDefaultItems()
and by calling menu->items() instead of menu->platformDescription().

* WebCoreSupport/ContextMenuClientQt.cpp:
(WebCore::ContextMenuClientQt::customizeMenu):
* WebCoreSupport/ContextMenuClientQt.h:
(ContextMenuClientQt):
* WebCoreSupport/QWebPageAdapter.cpp:
(descriptionForPlatformMenu):
(QWebPageAdapter::updatePositionDependentMenuActions):

Tools:

Adding USE_CROSS_PLATFORM_CONTEXT_MENUS to WEBKIT_CONFIG.

* qmake/mkspecs/features/features.prf:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (147544 => 147545)


--- trunk/Source/WebCore/ChangeLog	2013-04-03 12:35:36 UTC (rev 147544)
+++ trunk/Source/WebCore/ChangeLog	2013-04-03 12:44:36 UTC (rev 147545)
@@ -1,3 +1,31 @@
+2013-03-28  Jesus Sanchez-Palencia  <[email protected]>
+
+        [Qt] Switch ContextMenu implementation to CROSS_PLATFORM_CONTEXT_MENU
+        https://bugs.webkit.org/show_bug.cgi?id=113535
+
+        Reviewed by Simon Hausmann.
+
+        Now Qt uses the CROSS_PLATFORM_CONTEXT_MENUS
+        USE flag. This flag provides a full cross-platform
+        representation of a ContextMenu and a ContextMenuItem.
+        The embedder can then decide how to show this, so neither
+        WebCore nor WebCore/platform need to know any platform
+        specifics about menus.
+
+        No new tests, no behavior changes.
+
+        * Target.pri:
+        * platform/ContextMenu.h:
+        (ContextMenu):
+        * platform/ContextMenuItem.h:
+        * platform/qt/ContextMenuItemQt.cpp:
+        (WebCore::ContextMenuItem::platformContextMenuItem):
+        * platform/qt/ContextMenuQt.cpp:
+        (WebCore::ContextMenu::ContextMenu):
+        (WebCore::ContextMenu::getContextMenuItems):
+        (WebCore::ContextMenu::createPlatformContextMenuFromItems):
+        (WebCore::ContextMenu::platformContextMenu):
+
 2013-04-03  Allan Sandfeld Jensen  <[email protected]>
 
         [Qt] Monospace font does not render in proper sizes

Modified: trunk/Source/WebCore/Target.pri (147544 => 147545)


--- trunk/Source/WebCore/Target.pri	2013-04-03 12:35:36 UTC (rev 147544)
+++ trunk/Source/WebCore/Target.pri	2013-04-03 12:44:36 UTC (rev 147545)
@@ -2173,6 +2173,7 @@
     platform/ClockGeneric.h \
     platform/ContentType.h \
     platform/ContextMenu.h \
+    platform/ContextMenuItem.h \
     platform/CrossThreadCopier.h \
     platform/DateComponents.h \
     platform/Decimal.h \
@@ -2953,6 +2954,8 @@
     platform/network/qt/QNetworkReplyHandler.cpp \
     editing/qt/EditorQt.cpp \
     platform/Cursor.cpp \
+    platform/ContextMenu.cpp \
+    platform/ContextMenuItem.cpp \
     platform/qt/ClipboardQt.cpp \
     platform/qt/ContextMenuItemQt.cpp \
     platform/qt/ContextMenuQt.cpp \

Modified: trunk/Source/WebCore/platform/ContextMenu.h (147544 => 147545)


--- trunk/Source/WebCore/platform/ContextMenu.h	2013-04-03 12:35:36 UTC (rev 147544)
+++ trunk/Source/WebCore/platform/ContextMenu.h	2013-04-03 12:44:36 UTC (rev 147545)
@@ -95,8 +95,6 @@
 #if PLATFORM(MAC)
         // Keep this in sync with the PlatformMenuDescription typedef
         RetainPtr<NSMutableArray> m_platformDescription;
-#elif PLATFORM(QT)
-        QList<ContextMenuItem> m_items;
 #elif PLATFORM(CHROMIUM)
         Vector<ContextMenuItem> m_items;
 #else

Modified: trunk/Source/WebCore/platform/ContextMenuItem.h (147544 => 147545)


--- trunk/Source/WebCore/platform/ContextMenuItem.h	2013-04-03 12:35:36 UTC (rev 147544)
+++ trunk/Source/WebCore/platform/ContextMenuItem.h	2013-04-03 12:44:36 UTC (rev 147545)
@@ -181,22 +181,6 @@
 #if ENABLE(CONTEXT_MENUS)
 #if PLATFORM(MAC)
     typedef NSMenuItem* PlatformMenuItemDescription;
-#elif PLATFORM(QT)
-    struct PlatformMenuItemDescription {
-        PlatformMenuItemDescription()
-            : type(ActionType),
-              action(ContextMenuItemTagNoAction),
-              checked(false),
-              enabled(true)
-        {}
-
-        ContextMenuItemType type;
-        ContextMenuAction action;
-        String title;
-        QList<ContextMenuItem> subMenuItems;
-        bool checked;
-        bool enabled;
-    };
 #elif PLATFORM(GTK)
     typedef GtkMenuItem* PlatformMenuItemDescription;
 #elif PLATFORM(WX)

Modified: trunk/Source/WebCore/platform/qt/ContextMenuItemQt.cpp (147544 => 147545)


--- trunk/Source/WebCore/platform/qt/ContextMenuItemQt.cpp	2013-04-03 12:35:36 UTC (rev 147544)
+++ trunk/Source/WebCore/platform/qt/ContextMenuItemQt.cpp	2013-04-03 12:44:36 UTC (rev 147545)
@@ -27,113 +27,15 @@
 #include "config.h"
 #include "ContextMenuItem.h"
 
-#include "ContextMenu.h"
+#include "NotImplemented.h"
 
 namespace WebCore {
 
-ContextMenuItem::ContextMenuItem(ContextMenu* subMenu)
+void* ContextMenuItem::platformContextMenuItem() const
 {
-    m_platformDescription.type = SubmenuType;
-    m_platformDescription.action = ""
-    if (subMenu)
-        setSubMenu(subMenu);
+    notImplemented();
+    return 0;
 }
 
-ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action,
-                                 const String& title, ContextMenu* subMenu)
-{
-    m_platformDescription.type = type;
-    m_platformDescription.action = ""
-    m_platformDescription.title = title;
-    if (subMenu)
-        setSubMenu(subMenu);
 }
-
-ContextMenuItem::ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, bool, bool)
-{
-    // FIXME: Implement
-}
-
-ContextMenuItem::ContextMenuItem(ContextMenuAction, const String&, bool, bool, Vector<ContextMenuItem>&)
-{
-    // FIXME: Implement
-}
-
-ContextMenuItem::~ContextMenuItem()
-{
-}
-
-PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription()
-{
-    return m_platformDescription;
-}
-
-ContextMenuItemType ContextMenuItem::type() const
-{
-    return m_platformDescription.type;
-}
-
-void ContextMenuItem::setType(ContextMenuItemType type)
-{
-    m_platformDescription.type = type;
-}
-
-ContextMenuAction ContextMenuItem::action() const
-{
-    return m_platformDescription.action;
-}
-
-void ContextMenuItem::setAction(ContextMenuAction action)
-{
-    m_platformDescription.action = ""
-}
-
-String ContextMenuItem::title() const
-{
-    return m_platformDescription.title;
-}
-
-void ContextMenuItem::setTitle(const String& title)
-{
-    m_platformDescription.title = title;
-}
-
-
-PlatformMenuDescription ContextMenuItem::platformSubMenu() const
-{
-    return &m_platformDescription.subMenuItems;
-}
-
-void ContextMenuItem::setSubMenu(ContextMenu* menu)
-{
-    m_platformDescription.subMenuItems = *menu->platformDescription();
-}
-
-void ContextMenuItem::setSubMenu(Vector<ContextMenuItem>&)
-{
-    // FIXME: Implement
-}
-
-void ContextMenuItem::setChecked(bool on)
-{
-    m_platformDescription.checked = on;
-}
-
-bool ContextMenuItem::checked() const
-{
-    // FIXME - Implement
-    return false;
-}
-
-void ContextMenuItem::setEnabled(bool on)
-{
-    m_platformDescription.enabled = on;
-}
-
-bool ContextMenuItem::enabled() const
-{
-    return m_platformDescription.enabled;
-}
-
-}
 // vim: ts=4 sw=4 et

Modified: trunk/Source/WebCore/platform/qt/ContextMenuQt.cpp (147544 => 147545)


--- trunk/Source/WebCore/platform/qt/ContextMenuQt.cpp	2013-04-03 12:35:36 UTC (rev 147544)
+++ trunk/Source/WebCore/platform/qt/ContextMenuQt.cpp	2013-04-03 12:44:36 UTC (rev 147545)
@@ -27,65 +27,30 @@
 #include "config.h"
 #include "ContextMenu.h"
 
-#include <Document.h>
-#include <Frame.h>
-#include <FrameView.h>
-#include <wtf/Assertions.h>
+#include "NotImplemented.h"
 
 namespace WebCore {
 
-ContextMenu::ContextMenu()
+ContextMenu::ContextMenu(PlatformContextMenu menu)
 {
+    getContextMenuItems(menu, m_items);
 }
 
-ContextMenu::~ContextMenu()
+void ContextMenu::getContextMenuItems(PlatformContextMenu, Vector<ContextMenuItem>&)
 {
+    notImplemented();
 }
 
-void ContextMenu::appendItem(ContextMenuItem& item)
+PlatformContextMenu ContextMenu::createPlatformContextMenuFromItems(const Vector<ContextMenuItem>&)
 {
-    m_items.append(item);
+    notImplemented();
+    return 0;
 }
 
-unsigned ContextMenu::itemCount() const
+PlatformContextMenu ContextMenu::platformContextMenu() const
 {
-    return m_items.count();
+    return createPlatformContextMenuFromItems(m_items);
 }
 
-void ContextMenu::insertItem(unsigned position, ContextMenuItem& item)
-{
-    m_items.insert(position, item);
 }
-
-void ContextMenu::setPlatformDescription(PlatformMenuDescription)
-{
-    // doesn't make sense
-}
-
-PlatformMenuDescription ContextMenu::platformDescription() const
-{
-    return &m_items;
-}
-
-PlatformMenuDescription ContextMenu::releasePlatformDescription()
-{
-    return PlatformMenuDescription();
-}
-
-Vector<ContextMenuItem> contextMenuItemVector(const QList<ContextMenuItem>* items)
-{
-    int itemCount = items->size();
-    Vector<ContextMenuItem> menuItemVector(itemCount);
-    for (int i = 0; i < itemCount; ++i)
-        menuItemVector.append(items->at(i));
-    return menuItemVector;
-}
-
-PlatformMenuDescription platformMenuDescription(Vector<ContextMenuItem>& menuItemVector)
-{
-    // FIXME - Implement    
-    return 0;
-}
-
-}
 // vim: ts=4 sw=4 et

Modified: trunk/Source/WebKit/qt/ChangeLog (147544 => 147545)


--- trunk/Source/WebKit/qt/ChangeLog	2013-04-03 12:35:36 UTC (rev 147544)
+++ trunk/Source/WebKit/qt/ChangeLog	2013-04-03 12:44:36 UTC (rev 147545)
@@ -1,3 +1,22 @@
+2013-03-28  Jesus Sanchez-Palencia  <[email protected]>
+
+        [Qt] Switch ContextMenu implementation to CROSS_PLATFORM_CONTEXT_MENU
+        https://bugs.webkit.org/show_bug.cgi?id=113535
+
+        Reviewed by Simon Hausmann.
+
+        Adjust ContextMenuClientQt and QWebPageAdapter to use CROSS_PLATFORM_CONTEXT_MENUS
+        USE flag by implementing customizeMenu() instead of getCustomMenuFromDefaultItems()
+        and by calling menu->items() instead of menu->platformDescription().
+
+        * WebCoreSupport/ContextMenuClientQt.cpp:
+        (WebCore::ContextMenuClientQt::customizeMenu):
+        * WebCoreSupport/ContextMenuClientQt.h:
+        (ContextMenuClientQt):
+        * WebCoreSupport/QWebPageAdapter.cpp:
+        (descriptionForPlatformMenu):
+        (QWebPageAdapter::updatePositionDependentMenuActions):
+
 2013-03-27  Timothy Hatcher  <[email protected]>
 
         Add support for dock-to-right of the Web Inspector in the Mac port.

Modified: trunk/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp (147544 => 147545)


--- trunk/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp	2013-04-03 12:35:36 UTC (rev 147544)
+++ trunk/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp	2013-04-03 12:44:36 UTC (rev 147545)
@@ -40,10 +40,9 @@
     delete this;
 }
 
-PlatformMenuDescription ContextMenuClientQt::getCustomMenuFromDefaultItems(ContextMenu* menu)
+PassOwnPtr<ContextMenu> ContextMenuClientQt::customizeMenu(PassOwnPtr<ContextMenu> menu)
 {
-    // warning: this transfers the ownership to the caller
-    return menu->releasePlatformDescription();
+    return menu;
 }
 
 void ContextMenuClientQt::contextMenuItemSelected(ContextMenuItem*, const ContextMenu*)

Modified: trunk/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h (147544 => 147545)


--- trunk/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h	2013-04-03 12:35:36 UTC (rev 147544)
+++ trunk/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h	2013-04-03 12:44:36 UTC (rev 147545)
@@ -37,7 +37,7 @@
 public:
     virtual void contextMenuDestroyed();
 
-    virtual PlatformMenuDescription getCustomMenuFromDefaultItems(ContextMenu*);
+    virtual PassOwnPtr<ContextMenu> customizeMenu(PassOwnPtr<ContextMenu>);
     virtual void contextMenuItemSelected(ContextMenuItem*, const ContextMenu*);
 
     virtual void downloadURL(const KURL&);

Modified: trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp (147544 => 147545)


--- trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp	2013-04-03 12:35:36 UTC (rev 147544)
+++ trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp	2013-04-03 12:44:36 UTC (rev 147545)
@@ -802,13 +802,13 @@
     return QWebPageAdapter::NoAction;
 }
 
-QList<MenuItem> descriptionForPlatformMenu(const QList<ContextMenuItem>* items, Page* page)
+QList<MenuItem> descriptionForPlatformMenu(const Vector<ContextMenuItem>& items, Page* page)
 {
     QList<MenuItem> itemDescriptions;
-    if (!items)
+    if (!items.size())
         return itemDescriptions;
-    for (int i = 0; i < items->count(); ++i) {
-        const ContextMenuItem &item = items->at(i);
+    for (int i = 0; i < items.size(); ++i) {
+        const ContextMenuItem &item = items.at(i);
         MenuItem description;
         switch (item.type()) {
         case WebCore::CheckableActionType: /* fall through */
@@ -819,12 +819,11 @@
                 description.action = ""
                 ContextMenuItem it(item);
                 page->contextMenuController()->checkOrEnableIfNeeded(it);
-                PlatformMenuItemDescription desc = it.releasePlatformDescription();
-                if (desc.enabled)
+                if (it.enabled())
                     description.traits |= MenuItem::Enabled;
                 if (item.type() == WebCore::CheckableActionType) {
                     description.traits |= MenuItem::Checkable;
-                    if (desc.checked)
+                    if (it.checked())
                         description.traits |= MenuItem::Checked;
                 }
             }
@@ -835,7 +834,7 @@
             break;
         case WebCore::SubmenuType: {
             description.type = MenuItem::SubMenu;
-            description.subMenu = descriptionForPlatformMenu(item.platformSubMenu(), page);
+            description.subMenu = descriptionForPlatformMenu(item.subMenuItems(), page);
             description.subMenuTitle = item.title();
             // Don't append empty submenu descriptions.
             if (description.subMenu.isEmpty())
@@ -863,7 +862,7 @@
     WebCore::ContextMenu* webcoreMenu = page->contextMenuController()->contextMenu();
     QList<MenuItem> itemDescriptions;
     if (client && webcoreMenu)
-        itemDescriptions = descriptionForPlatformMenu(webcoreMenu->platformDescription(), page);
+        itemDescriptions = descriptionForPlatformMenu(webcoreMenu->items(), page);
     createAndSetCurrentContextMenu(itemDescriptions, visitedWebActions);
     if (result.scrollbar())
         return 0;

Modified: trunk/Tools/ChangeLog (147544 => 147545)


--- trunk/Tools/ChangeLog	2013-04-03 12:35:36 UTC (rev 147544)
+++ trunk/Tools/ChangeLog	2013-04-03 12:44:36 UTC (rev 147545)
@@ -1,3 +1,14 @@
+2013-03-28  Jesus Sanchez-Palencia  <[email protected]>
+
+        [Qt] Switch ContextMenu implementation to CROSS_PLATFORM_CONTEXT_MENU
+        https://bugs.webkit.org/show_bug.cgi?id=113535
+
+        Reviewed by Simon Hausmann.
+
+        Adding USE_CROSS_PLATFORM_CONTEXT_MENUS to WEBKIT_CONFIG.
+
+        * qmake/mkspecs/features/features.prf:
+
 2013-04-03  Zeno Albisser  <[email protected]>
 
         [Qt] Move logic of simple forwarding functions to TestRunner.

Modified: trunk/Tools/qmake/mkspecs/features/features.prf (147544 => 147545)


--- trunk/Tools/qmake/mkspecs/features/features.prf	2013-04-03 12:35:36 UTC (rev 147544)
+++ trunk/Tools/qmake/mkspecs/features/features.prf	2013-04-03 12:44:36 UTC (rev 147545)
@@ -22,6 +22,7 @@
     }
 
     WEBKIT_CONFIG += use_tiled_backing_store
+    WEBKIT_CONFIG += use_cross_platform_context_menus
 
     # ------------- Prepare for feature detection -------------
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to