OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2010 Igalia S.L | 3 * Copyright (C) 2010 Igalia S.L |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 10 matching lines...) Expand all Loading... | |
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/page/ContextMenuController.h" | 28 #include "core/page/ContextMenuController.h" |
29 | 29 |
30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
31 #include "core/dom/Node.h" | |
31 #include "core/events/Event.h" | 32 #include "core/events/Event.h" |
33 #include "core/events/EventDispatchMediator.h" | |
34 #include "core/events/EventDispatcher.h" | |
32 #include "core/events/MouseEvent.h" | 35 #include "core/events/MouseEvent.h" |
33 #include "core/dom/Node.h" | 36 #include "core/events/RelatedEvent.h" |
34 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
38 #include "core/html/HTMLMenuElement.h" | |
35 #include "core/page/ContextMenuClient.h" | 39 #include "core/page/ContextMenuClient.h" |
36 #include "core/page/ContextMenuProvider.h" | 40 #include "core/page/ContextMenuProvider.h" |
37 #include "core/page/EventHandler.h" | 41 #include "core/page/EventHandler.h" |
38 #include "platform/ContextMenu.h" | 42 #include "platform/ContextMenu.h" |
39 #include "platform/ContextMenuItem.h" | 43 #include "platform/ContextMenuItem.h" |
40 | 44 |
41 namespace WebCore { | 45 namespace WebCore { |
42 | 46 |
47 using namespace HTMLNames; | |
48 | |
43 ContextMenuController::ContextMenuController(Page*, ContextMenuClient* client) | 49 ContextMenuController::ContextMenuController(Page*, ContextMenuClient* client) |
44 : m_client(client) | 50 : m_client(client) |
45 { | 51 { |
46 ASSERT_ARG(client, client); | 52 ASSERT_ARG(client, client); |
47 } | 53 } |
48 | 54 |
49 ContextMenuController::~ContextMenuController() | 55 ContextMenuController::~ContextMenuController() |
50 { | 56 { |
51 } | 57 } |
52 | 58 |
(...skipping 20 matching lines...) Expand all Loading... | |
73 clearContextMenu(); | 79 clearContextMenu(); |
74 } | 80 } |
75 } | 81 } |
76 | 82 |
77 void ContextMenuController::handleContextMenuEvent(Event* event) | 83 void ContextMenuController::handleContextMenuEvent(Event* event) |
78 { | 84 { |
79 m_contextMenu = createContextMenu(event); | 85 m_contextMenu = createContextMenu(event); |
80 if (!m_contextMenu) | 86 if (!m_contextMenu) |
81 return; | 87 return; |
82 | 88 |
89 Node* node = event->target()->toNode(); | |
90 if (node && node->isHTMLElement()) { | |
esprehn
2014/07/14 08:57:51
This needs to be guarded by the RuntimeEnabledFeat
pals
2014/07/14 13:10:41
Done.
| |
91 const HTMLElement& element = toHTMLElement(*event->target()->toNode()); | |
92 if (RefPtr<HTMLMenuElement> menuElement = element.menuElement()) { | |
93 RefPtr<RelatedEvent> relatedEvent = RelatedEvent::create(EventTypeNa mes::show); | |
94 relatedEvent->setRelatedTarget(node); | |
95 EventDispatcher::dispatchEvent(menuElement.get(), EventDispatchMedia tor::create(relatedEvent.release())); | |
96 m_menuProvider = menuElement->menuProvider(); | |
97 m_menuProvider->populateContextMenu(m_contextMenu.get()); | |
98 } | |
99 } | |
83 showContextMenu(event); | 100 showContextMenu(event); |
84 } | 101 } |
85 | 102 |
86 void ContextMenuController::showContextMenu(Event* event, PassRefPtr<ContextMenu Provider> menuProvider) | 103 void ContextMenuController::showContextMenu(Event* event, PassRefPtr<ContextMenu Provider> menuProvider) |
87 { | 104 { |
88 m_menuProvider = menuProvider; | 105 m_menuProvider = menuProvider; |
89 | 106 |
90 m_contextMenu = createContextMenu(event); | 107 m_contextMenu = createContextMenu(event); |
91 if (!m_contextMenu) { | 108 if (!m_contextMenu) { |
92 clearContextMenu(); | 109 clearContextMenu(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 ASSERT(item->type() == ActionType || item->type() == CheckableActionType); | 146 ASSERT(item->type() == ActionType || item->type() == CheckableActionType); |
130 | 147 |
131 if (item->action() < ContextMenuItemBaseCustomTag || item->action() > Contex tMenuItemLastCustomTag) | 148 if (item->action() < ContextMenuItemBaseCustomTag || item->action() > Contex tMenuItemLastCustomTag) |
132 return; | 149 return; |
133 | 150 |
134 ASSERT(m_menuProvider); | 151 ASSERT(m_menuProvider); |
135 m_menuProvider->contextMenuItemSelected(item); | 152 m_menuProvider->contextMenuItemSelected(item); |
136 } | 153 } |
137 | 154 |
138 } // namespace WebCore | 155 } // namespace WebCore |
OLD | NEW |