OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "core/html/CustomContextMenuProvider.h" | |
7 | |
8 #include "core/dom/Document.h" | |
9 #include "core/events/EventDispatcher.h" | |
10 #include "core/events/MouseEvent.h" | |
11 #include "core/html/HTMLMenuElement.h" | |
12 #include "core/html/HTMLMenuItemElement.h" | |
13 #include "platform/ContextMenu.h" | |
14 | |
15 namespace blink { | |
16 | |
17 CustomContextMenuProvider::CustomContextMenuProvider(HTMLMenuElement* menu, cons t Vector<ContextMenuItem>& items) | |
18 : m_menu(menu) | |
19 , m_items(items) | |
20 { | |
21 } | |
22 | |
23 CustomContextMenuProvider::~CustomContextMenuProvider() | |
24 { | |
25 } | |
26 | |
27 void CustomContextMenuProvider::populateContextMenu(ContextMenu* menu) | |
28 { | |
29 for (size_t i = 0; i < m_items.size(); ++i) | |
30 menu->appendItem(m_items[i]); | |
31 } | |
32 | |
33 void CustomContextMenuProvider::contextMenuItemSelected(const ContextMenuItem* i tem) | |
34 { | |
35 if (!m_menu) | |
tkent
2014/07/25 04:42:37
This check is unnecessary. m_menu is always non-nu
pals
2014/07/30 09:47:43
This can happen if user has been shown context men
| |
36 return; | |
37 | |
38 if (HTMLMenuItemElement* element = m_menu->menuItemAt(item->action())) { | |
39 RefPtrWillBeRawPtr<SimulatedMouseEvent> click = SimulatedMouseEvent::cre ate(EventTypeNames::click, m_menu->document().domWindow(), Event::create()); | |
tkent
2014/07/25 04:42:37
Why do you dispatch 'click' event even though the
pals
2014/07/30 09:47:43
Selection is done on menu shown by platform contex
tkent
2014/07/31 06:10:47
I'm asking why 'click'. We should not dispatch 'c
| |
40 click->setRelatedTarget(m_menu->subjectElement()); | |
41 EventDispatcher::dispatchEvent(element, EventDispatchMediator::create(cl ick.release())); | |
tkent
2014/07/25 04:42:37
Why don't you use element->dispatchEvent(click.rel
pals
2014/07/30 09:47:43
Done.
| |
42 } | |
43 } | |
44 | |
45 } // namespace blink | |
OLD | NEW |