Changeset 147545 in webkit
- Timestamp:
- Apr 3, 2013 5:44:36 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r147544 r147545 1 2013-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 1 29 2013-04-03 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 30 -
trunk/Source/WebCore/Target.pri
r147020 r147545 2174 2174 platform/ContentType.h \ 2175 2175 platform/ContextMenu.h \ 2176 platform/ContextMenuItem.h \ 2176 2177 platform/CrossThreadCopier.h \ 2177 2178 platform/DateComponents.h \ … … 2954 2955 editing/qt/EditorQt.cpp \ 2955 2956 platform/Cursor.cpp \ 2957 platform/ContextMenu.cpp \ 2958 platform/ContextMenuItem.cpp \ 2956 2959 platform/qt/ClipboardQt.cpp \ 2957 2960 platform/qt/ContextMenuItemQt.cpp \ -
trunk/Source/WebCore/platform/ContextMenu.h
r145841 r147545 96 96 // Keep this in sync with the PlatformMenuDescription typedef 97 97 RetainPtr<NSMutableArray> m_platformDescription; 98 #elif PLATFORM(QT)99 QList<ContextMenuItem> m_items;100 98 #elif PLATFORM(CHROMIUM) 101 99 Vector<ContextMenuItem> m_items; -
trunk/Source/WebCore/platform/ContextMenuItem.h
r145841 r147545 182 182 #if PLATFORM(MAC) 183 183 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 };200 184 #elif PLATFORM(GTK) 201 185 typedef GtkMenuItem* PlatformMenuItemDescription; -
trunk/Source/WebCore/platform/qt/ContextMenuItemQt.cpp
r71682 r147545 28 28 #include "ContextMenuItem.h" 29 29 30 #include " ContextMenu.h"30 #include "NotImplemented.h" 31 31 32 32 namespace WebCore { 33 33 34 ContextMenuItem::ContextMenuItem(ContextMenu* subMenu) 34 void* ContextMenuItem::platformContextMenuItem() const 35 35 { 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; 136 38 } 137 39 -
trunk/Source/WebCore/platform/qt/ContextMenuQt.cpp
r107811 r147545 28 28 #include "ContextMenu.h" 29 29 30 #include <Document.h> 31 #include <Frame.h> 32 #include <FrameView.h> 33 #include <wtf/Assertions.h> 30 #include "NotImplemented.h" 34 31 35 32 namespace WebCore { 36 33 37 ContextMenu::ContextMenu( )34 ContextMenu::ContextMenu(PlatformContextMenu menu) 38 35 { 36 getContextMenuItems(menu, m_items); 39 37 } 40 38 41 ContextMenu::~ContextMenu()39 void ContextMenu::getContextMenuItems(PlatformContextMenu, Vector<ContextMenuItem>&) 42 40 { 41 notImplemented(); 43 42 } 44 43 45 void ContextMenu::appendItem(ContextMenuItem& item)44 PlatformContextMenu ContextMenu::createPlatformContextMenuFromItems(const Vector<ContextMenuItem>&) 46 45 { 47 m_items.append(item); 46 notImplemented(); 47 return 0; 48 48 } 49 49 50 unsigned ContextMenu::itemCount() const50 PlatformContextMenu ContextMenu::platformContextMenu() const 51 51 { 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); 88 53 } 89 54 -
trunk/Source/WebKit/qt/ChangeLog
r147004 r147545 1 2013-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 1 20 2013-03-27 Timothy Hatcher <timothy@apple.com> 2 21 -
trunk/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.cpp
r135515 r147545 41 41 } 42 42 43 P latformMenuDescription ContextMenuClientQt::getCustomMenuFromDefaultItems(ContextMenu*menu)43 PassOwnPtr<ContextMenu> ContextMenuClientQt::customizeMenu(PassOwnPtr<ContextMenu> menu) 44 44 { 45 // warning: this transfers the ownership to the caller 46 return menu->releasePlatformDescription(); 45 return menu; 47 46 } 48 47 -
trunk/Source/WebKit/qt/WebCoreSupport/ContextMenuClientQt.h
r135515 r147545 38 38 virtual void contextMenuDestroyed(); 39 39 40 virtual P latformMenuDescription getCustomMenuFromDefaultItems(ContextMenu*);40 virtual PassOwnPtr<ContextMenu> customizeMenu(PassOwnPtr<ContextMenu>); 41 41 virtual void contextMenuItemSelected(ContextMenuItem*, const ContextMenu*); 42 42 -
trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
r145895 r147545 803 803 } 804 804 805 QList<MenuItem> descriptionForPlatformMenu(const QList<ContextMenuItem>*items, Page* page)805 QList<MenuItem> descriptionForPlatformMenu(const Vector<ContextMenuItem>& items, Page* page) 806 806 { 807 807 QList<MenuItem> itemDescriptions; 808 if (!items )808 if (!items.size()) 809 809 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); 812 812 MenuItem description; 813 813 switch (item.type()) { … … 820 820 ContextMenuItem it(item); 821 821 page->contextMenuController()->checkOrEnableIfNeeded(it); 822 PlatformMenuItemDescription desc = it.releasePlatformDescription(); 823 if (desc.enabled) 822 if (it.enabled()) 824 823 description.traits |= MenuItem::Enabled; 825 824 if (item.type() == WebCore::CheckableActionType) { 826 825 description.traits |= MenuItem::Checkable; 827 if ( desc.checked)826 if (it.checked()) 828 827 description.traits |= MenuItem::Checked; 829 828 } … … 836 835 case WebCore::SubmenuType: { 837 836 description.type = MenuItem::SubMenu; 838 description.subMenu = descriptionForPlatformMenu(item. platformSubMenu(), page);837 description.subMenu = descriptionForPlatformMenu(item.subMenuItems(), page); 839 838 description.subMenuTitle = item.title(); 840 839 // Don't append empty submenu descriptions. … … 864 863 QList<MenuItem> itemDescriptions; 865 864 if (client && webcoreMenu) 866 itemDescriptions = descriptionForPlatformMenu(webcoreMenu-> platformDescription(), page);865 itemDescriptions = descriptionForPlatformMenu(webcoreMenu->items(), page); 867 866 createAndSetCurrentContextMenu(itemDescriptions, visitedWebActions); 868 867 if (result.scrollbar()) -
trunk/Tools/ChangeLog
r147543 r147545 1 2013-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 1 12 2013-04-03 Zeno Albisser <zeno@webkit.org> 2 13 -
trunk/Tools/qmake/mkspecs/features/features.prf
r147540 r147545 23 23 24 24 WEBKIT_CONFIG += use_tiled_backing_store 25 WEBKIT_CONFIG += use_cross_platform_context_menus 25 26 26 27 # ------------- Prepare for feature detection -------------
Note: See TracChangeset
for help on using the changeset viewer.