Changeset 147545 in webkit


Ignore:
Timestamp:
Apr 3, 2013 5:44:36 AM (11 years ago)
Author:
jesus@webkit.org
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:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r147544 r147545  
     12013-03-28  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
     2
     3        [Qt] Switch ContextMenu implementation to CROSS_PLATFORM_CONTEXT_MENU
     4        https://bugs.webkit.org/show_bug.cgi?id=113535
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Now Qt uses the CROSS_PLATFORM_CONTEXT_MENUS
     9        USE flag. This flag provides a full cross-platform
     10        representation of a ContextMenu and a ContextMenuItem.
     11        The embedder can then decide how to show this, so neither
     12        WebCore nor WebCore/platform need to know any platform
     13        specifics about menus.
     14
     15        No new tests, no behavior changes.
     16
     17        * Target.pri:
     18        * platform/ContextMenu.h:
     19        (ContextMenu):
     20        * platform/ContextMenuItem.h:
     21        * platform/qt/ContextMenuItemQt.cpp:
     22        (WebCore::ContextMenuItem::platformContextMenuItem):
     23        * platform/qt/ContextMenuQt.cpp:
     24        (WebCore::ContextMenu::ContextMenu):
     25        (WebCore::ContextMenu::getContextMenuItems):
     26        (WebCore::ContextMenu::createPlatformContextMenuFromItems):
     27        (WebCore::ContextMenu::platformContextMenu):
     28
    1292013-04-03  Allan Sandfeld Jensen  <allan.jensen@digia.com>
    230
  • trunk/Source/WebCore/Target.pri

    r147020 r147545  
    21742174    platform/ContentType.h \
    21752175    platform/ContextMenu.h \
     2176    platform/ContextMenuItem.h \
    21762177    platform/CrossThreadCopier.h \
    21772178    platform/DateComponents.h \
     
    29542955    editing/qt/EditorQt.cpp \
    29552956    platform/Cursor.cpp \
     2957    platform/ContextMenu.cpp \
     2958    platform/ContextMenuItem.cpp \
    29562959    platform/qt/ClipboardQt.cpp \
    29572960    platform/qt/ContextMenuItemQt.cpp \
  • trunk/Source/WebCore/platform/ContextMenu.h

    r145841 r147545  
    9696        // Keep this in sync with the PlatformMenuDescription typedef
    9797        RetainPtr<NSMutableArray> m_platformDescription;
    98 #elif PLATFORM(QT)
    99         QList<ContextMenuItem> m_items;
    10098#elif PLATFORM(CHROMIUM)
    10199        Vector<ContextMenuItem> m_items;
  • trunk/Source/WebCore/platform/ContextMenuItem.h

    r145841 r147545  
    182182#if PLATFORM(MAC)
    183183    typedef NSMenuItem* PlatformMenuItemDescription;
    184 #elif PLATFORM(QT)
    185     struct PlatformMenuItemDescription {
    186         PlatformMenuItemDescription()
    187             : type(ActionType),
    188               action(ContextMenuItemTagNoAction),
    189               checked(false),
    190               enabled(true)
    191         {}
    192 
    193         ContextMenuItemType type;
    194         ContextMenuAction action;
    195         String title;
    196         QList<ContextMenuItem> subMenuItems;
    197         bool checked;
    198         bool enabled;
    199     };
    200184#elif PLATFORM(GTK)
    201185    typedef GtkMenuItem* PlatformMenuItemDescription;
  • trunk/Source/WebCore/platform/qt/ContextMenuItemQt.cpp

    r71682 r147545  
    2828#include "ContextMenuItem.h"
    2929
    30 #include "ContextMenu.h"
     30#include "NotImplemented.h"
    3131
    3232namespace WebCore {
    3333
    34 ContextMenuItem::ContextMenuItem(ContextMenu* subMenu)
     34void* ContextMenuItem::platformContextMenuItem() const
    3535{
    36     m_platformDescription.type = SubmenuType;
    37     m_platformDescription.action = ContextMenuItemTagNoAction;
    38     if (subMenu)
    39         setSubMenu(subMenu);
    40 }
    41 
    42 ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action,
    43                                  const String& title, ContextMenu* subMenu)
    44 {
    45     m_platformDescription.type = type;
    46     m_platformDescription.action = action;
    47     m_platformDescription.title = title;
    48     if (subMenu)
    49         setSubMenu(subMenu);
    50 }
    51 
    52 ContextMenuItem::ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, bool, bool)
    53 {
    54     // FIXME: Implement
    55 }
    56 
    57 ContextMenuItem::ContextMenuItem(ContextMenuAction, const String&, bool, bool, Vector<ContextMenuItem>&)
    58 {
    59     // FIXME: Implement
    60 }
    61 
    62 ContextMenuItem::~ContextMenuItem()
    63 {
    64 }
    65 
    66 PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription()
    67 {
    68     return m_platformDescription;
    69 }
    70 
    71 ContextMenuItemType ContextMenuItem::type() const
    72 {
    73     return m_platformDescription.type;
    74 }
    75 
    76 void ContextMenuItem::setType(ContextMenuItemType type)
    77 {
    78     m_platformDescription.type = type;
    79 }
    80 
    81 ContextMenuAction ContextMenuItem::action() const
    82 {
    83     return m_platformDescription.action;
    84 }
    85 
    86 void ContextMenuItem::setAction(ContextMenuAction action)
    87 {
    88     m_platformDescription.action = action;
    89 }
    90 
    91 String ContextMenuItem::title() const
    92 {
    93     return m_platformDescription.title;
    94 }
    95 
    96 void ContextMenuItem::setTitle(const String& title)
    97 {
    98     m_platformDescription.title = title;
    99 }
    100 
    101 
    102 PlatformMenuDescription ContextMenuItem::platformSubMenu() const
    103 {
    104     return &m_platformDescription.subMenuItems;
    105 }
    106 
    107 void ContextMenuItem::setSubMenu(ContextMenu* menu)
    108 {
    109     m_platformDescription.subMenuItems = *menu->platformDescription();
    110 }
    111 
    112 void ContextMenuItem::setSubMenu(Vector<ContextMenuItem>&)
    113 {
    114     // FIXME: Implement
    115 }
    116 
    117 void ContextMenuItem::setChecked(bool on)
    118 {
    119     m_platformDescription.checked = on;
    120 }
    121 
    122 bool ContextMenuItem::checked() const
    123 {
    124     // FIXME - Implement
    125     return false;
    126 }
    127 
    128 void ContextMenuItem::setEnabled(bool on)
    129 {
    130     m_platformDescription.enabled = on;
    131 }
    132 
    133 bool ContextMenuItem::enabled() const
    134 {
    135     return m_platformDescription.enabled;
     36    notImplemented();
     37    return 0;
    13638}
    13739
  • trunk/Source/WebCore/platform/qt/ContextMenuQt.cpp

    r107811 r147545  
    2828#include "ContextMenu.h"
    2929
    30 #include <Document.h>
    31 #include <Frame.h>
    32 #include <FrameView.h>
    33 #include <wtf/Assertions.h>
     30#include "NotImplemented.h"
    3431
    3532namespace WebCore {
    3633
    37 ContextMenu::ContextMenu()
     34ContextMenu::ContextMenu(PlatformContextMenu menu)
    3835{
     36    getContextMenuItems(menu, m_items);
    3937}
    4038
    41 ContextMenu::~ContextMenu()
     39void ContextMenu::getContextMenuItems(PlatformContextMenu, Vector<ContextMenuItem>&)
    4240{
     41    notImplemented();
    4342}
    4443
    45 void ContextMenu::appendItem(ContextMenuItem& item)
     44PlatformContextMenu ContextMenu::createPlatformContextMenuFromItems(const Vector<ContextMenuItem>&)
    4645{
    47     m_items.append(item);
     46    notImplemented();
     47    return 0;
    4848}
    4949
    50 unsigned ContextMenu::itemCount() const
     50PlatformContextMenu ContextMenu::platformContextMenu() const
    5151{
    52     return m_items.count();
    53 }
    54 
    55 void ContextMenu::insertItem(unsigned position, ContextMenuItem& item)
    56 {
    57     m_items.insert(position, item);
    58 }
    59 
    60 void ContextMenu::setPlatformDescription(PlatformMenuDescription)
    61 {
    62     // doesn't make sense
    63 }
    64 
    65 PlatformMenuDescription ContextMenu::platformDescription() const
    66 {
    67     return &m_items;
    68 }
    69 
    70 PlatformMenuDescription ContextMenu::releasePlatformDescription()
    71 {
    72     return PlatformMenuDescription();
    73 }
    74 
    75 Vector<ContextMenuItem> contextMenuItemVector(const QList<ContextMenuItem>* items)
    76 {
    77     int itemCount = items->size();
    78     Vector<ContextMenuItem> menuItemVector(itemCount);
    79     for (int i = 0; i < itemCount; ++i)
    80         menuItemVector.append(items->at(i));
    81     return menuItemVector;
    82 }
    83 
    84 PlatformMenuDescription platformMenuDescription(Vector<ContextMenuItem>& menuItemVector)
    85 {
    86     // FIXME - Implement   
    87     return 0;
     52    return createPlatformContextMenuFromItems(m_items);
    8853}
    8954
  • trunk/Source/WebKit/qt/ChangeLog

    r147004 r147545  
     12013-03-28  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
     2
     3        [Qt] Switch ContextMenu implementation to CROSS_PLATFORM_CONTEXT_MENU
     4        https://bugs.webkit.org/show_bug.cgi?id=113535
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Adjust ContextMenuClientQt and QWebPageAdapter to use CROSS_PLATFORM_CONTEXT_MENUS
     9        USE flag by implementing customizeMenu() instead of getCustomMenuFromDefaultItems()
     10        and by calling menu->items() instead of menu->platformDescription().
     11
     12        * WebCoreSupport/ContextMenuClientQt.cpp:
     13        (WebCore::ContextMenuClientQt::customizeMenu):
     14        * WebCoreSupport/ContextMenuClientQt.h:
     15        (ContextMenuClientQt):
     16        * WebCoreSupport/QWebPageAdapter.cpp:
     17        (descriptionForPlatformMenu):
     18        (QWebPageAdapter::updatePositionDependentMenuActions):
     19
    1202013-03-27  Timothy Hatcher  <timothy@apple.com>
    221
  • trunk/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp

    r135515 r147545  
    4141}
    4242
    43 PlatformMenuDescription ContextMenuClientQt::getCustomMenuFromDefaultItems(ContextMenu* menu)
     43PassOwnPtr<ContextMenu> ContextMenuClientQt::customizeMenu(PassOwnPtr<ContextMenu> menu)
    4444{
    45     // warning: this transfers the ownership to the caller
    46     return menu->releasePlatformDescription();
     45    return menu;
    4746}
    4847
  • trunk/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h

    r135515 r147545  
    3838    virtual void contextMenuDestroyed();
    3939
    40     virtual PlatformMenuDescription getCustomMenuFromDefaultItems(ContextMenu*);
     40    virtual PassOwnPtr<ContextMenu> customizeMenu(PassOwnPtr<ContextMenu>);
    4141    virtual void contextMenuItemSelected(ContextMenuItem*, const ContextMenu*);
    4242
  • trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp

    r145895 r147545  
    803803}
    804804
    805 QList<MenuItem> descriptionForPlatformMenu(const QList<ContextMenuItem>* items, Page* page)
     805QList<MenuItem> descriptionForPlatformMenu(const Vector<ContextMenuItem>& items, Page* page)
    806806{
    807807    QList<MenuItem> itemDescriptions;
    808     if (!items)
     808    if (!items.size())
    809809        return itemDescriptions;
    810     for (int i = 0; i < items->count(); ++i) {
    811         const ContextMenuItem &item = items->at(i);
     810    for (int i = 0; i < items.size(); ++i) {
     811        const ContextMenuItem &item = items.at(i);
    812812        MenuItem description;
    813813        switch (item.type()) {
     
    820820                ContextMenuItem it(item);
    821821                page->contextMenuController()->checkOrEnableIfNeeded(it);
    822                 PlatformMenuItemDescription desc = it.releasePlatformDescription();
    823                 if (desc.enabled)
     822                if (it.enabled())
    824823                    description.traits |= MenuItem::Enabled;
    825824                if (item.type() == WebCore::CheckableActionType) {
    826825                    description.traits |= MenuItem::Checkable;
    827                     if (desc.checked)
     826                    if (it.checked())
    828827                        description.traits |= MenuItem::Checked;
    829828                }
     
    836835        case WebCore::SubmenuType: {
    837836            description.type = MenuItem::SubMenu;
    838             description.subMenu = descriptionForPlatformMenu(item.platformSubMenu(), page);
     837            description.subMenu = descriptionForPlatformMenu(item.subMenuItems(), page);
    839838            description.subMenuTitle = item.title();
    840839            // Don't append empty submenu descriptions.
     
    864863    QList<MenuItem> itemDescriptions;
    865864    if (client && webcoreMenu)
    866         itemDescriptions = descriptionForPlatformMenu(webcoreMenu->platformDescription(), page);
     865        itemDescriptions = descriptionForPlatformMenu(webcoreMenu->items(), page);
    867866    createAndSetCurrentContextMenu(itemDescriptions, visitedWebActions);
    868867    if (result.scrollbar())
  • trunk/Tools/ChangeLog

    r147543 r147545  
     12013-03-28  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
     2
     3        [Qt] Switch ContextMenu implementation to CROSS_PLATFORM_CONTEXT_MENU
     4        https://bugs.webkit.org/show_bug.cgi?id=113535
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Adding USE_CROSS_PLATFORM_CONTEXT_MENUS to WEBKIT_CONFIG.
     9
     10        * qmake/mkspecs/features/features.prf:
     11
    1122013-04-03  Zeno Albisser  <zeno@webkit.org>
    213
  • trunk/Tools/qmake/mkspecs/features/features.prf

    r147540 r147545  
    2323
    2424    WEBKIT_CONFIG += use_tiled_backing_store
     25    WEBKIT_CONFIG += use_cross_platform_context_menus
    2526
    2627    # ------------- Prepare for feature detection -------------
Note: See TracChangeset for help on using the changeset viewer.