Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: Source/core/page/CustomContextMenuProvider.cpp

Issue 243403006: Implement contextmenu attribute with basic support of <menu> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed review comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/page/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 "core/page/ContextMenuController.h"
14 #include "core/page/Page.h"
15 #include "platform/ContextMenu.h"
16
17 namespace blink {
18
19 CustomContextMenuProvider::CustomContextMenuProvider(PassRefPtr<Document> docume nt, const Vector<ContextMenuItem>& items)
20 : m_document(document)
21 , m_items(items)
22 {
23 }
24
25 CustomContextMenuProvider::~CustomContextMenuProvider()
26 {
27 }
28
29 void CustomContextMenuProvider::populateContextMenu(ContextMenu* menu)
30 {
31 for (size_t i = 0; i < m_items.size(); ++i)
32 menu->appendItem(m_items[i]);
33 }
34
35 void CustomContextMenuProvider::contextMenuItemSelected(const ContextMenuItem* i tem)
36 {
37 if (HTMLElement* element = m_document->page()->contextMenuController().menuI temAt(item->action())) {
38 RefPtrWillBeRawPtr<SimulatedMouseEvent> click = SimulatedMouseEvent::cre ate(EventTypeNames::click, m_document->domWindow(), Event::create());
39 click->setRelatedTarget(m_document->page()->contextMenuController().subj ectElement());
40 element->dispatchEvent(click.release());
41 }
42 }
43
44 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698