Index: Source/core/html/HTMLMenuElement.h |
diff --git a/Source/core/html/HTMLMenuElement.h b/Source/core/html/HTMLMenuElement.h |
index b1fdab64b05e94ccf65ca7f2aaf05946f61ac46b..674ed92b73cdb0e4c4711b609db02b1ee10b04bc 100644 |
--- a/Source/core/html/HTMLMenuElement.h |
+++ b/Source/core/html/HTMLMenuElement.h |
@@ -24,17 +24,76 @@ |
#define HTMLMenuElement_h |
#include "core/html/HTMLElement.h" |
+#include "core/page/ContextMenuProvider.h" |
+#include "platform/ContextMenu.h" |
+#include "platform/ContextMenuItem.h" |
namespace WebCore { |
+class HTMLMenuElement; |
+class CustomContextMenuProvider; |
+ |
class HTMLMenuElement FINAL : public HTMLElement { |
public: |
static PassRefPtr<HTMLMenuElement> create(Document&); |
+ void buildCustomProvider(); |
+ PassRefPtr<CustomContextMenuProvider> getCustomProvider() { return m_menuProvider; } |
esprehn
2014/05/20 05:51:34
Getters don't start with "get". Instead you want c
pals
2014/05/21 07:55:12
Done.
|
+ void populateContextMenuItems(HTMLMenuElement* menu, ContextMenu& contextMenu); |
esprehn
2014/05/20 05:51:34
You don't need the argument names, they don't add
pals
2014/05/21 07:55:12
Done.
|
+ HTMLElement* getSelectedMenuItem(unsigned menuId); |
esprehn
2014/05/20 05:51:34
Getters don't start with "get", selectedMenuItem(m
pals
2014/05/21 07:55:12
Done.
|
private: |
explicit HTMLMenuElement(Document&); |
+ RefPtr<CustomContextMenuProvider> m_menuProvider; |
+ Vector<HTMLElement*> m_menuItems; |
}; |
+class CustomContextMenuProvider FINAL : public ContextMenuProvider { |
esprehn
2014/05/20 05:51:34
This doesn't need to be all inline. Give it its ow
pals
2014/05/21 07:55:12
Done.
|
+public: |
+ static PassRefPtr<CustomContextMenuProvider> create(HTMLMenuElement* menu, const Vector<ContextMenuItem>& items) |
+ { |
+ return adoptRef(new CustomContextMenuProvider(menu, items)); |
+ } |
+ |
+ void disconnect() |
esprehn
2014/05/20 05:51:34
What is this for?
pals
2014/05/21 07:55:12
Done. Removed.
|
+ { |
+ } |
+ |
+private: |
+ CustomContextMenuProvider(HTMLMenuElement* menu, const Vector<ContextMenuItem>& items) |
+ : m_menu(menu) |
+ , m_items(items) |
+ { |
+ } |
+ |
+ virtual ~CustomContextMenuProvider() |
esprehn
2014/05/20 05:51:34
These don't need to be inline.
pals
2014/05/21 07:55:12
Done.
|
+ { |
+ contextMenuCleared(); |
+ } |
+ |
+ virtual void populateContextMenu(ContextMenu* menu) OVERRIDE |
+ { |
+ for (size_t i = 0; i < m_items.size(); ++i) |
+ menu->appendItem(m_items[i]); |
+ } |
+ |
+ virtual void contextMenuItemSelected(const ContextMenuItem* item) OVERRIDE |
+ { |
+ if (m_menu) { |
+ if (HTMLElement* element = m_menu->getSelectedMenuItem(item->action())) |
+ element->click(); |
+ } |
+ } |
+ |
+ virtual void contextMenuCleared() OVERRIDE |
+ { |
+ m_items.clear(); |
+ } |
+ |
+ HTMLMenuElement* m_menu; |
esprehn
2014/05/20 05:51:34
Does this need to be a ref ptr? What keeps m_menu
pals
2014/05/21 07:55:12
Done.
|
+ Vector<ContextMenuItem> m_items; |
+}; |
+ |
+ |
} //namespace |
#endif |