| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/page/CustomContextMenuProvider.h" | 5 #include "core/page/CustomContextMenuProvider.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/ElementTraversal.h" | 8 #include "core/dom/ElementTraversal.h" |
| 9 #include "core/events/EventDispatcher.h" | 9 #include "core/events/EventDispatcher.h" |
| 10 #include "core/events/MouseEvent.h" | 10 #include "core/events/MouseEvent.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 | 38 |
| 39 void CustomContextMenuProvider::populateContextMenu(ContextMenu* menu) | 39 void CustomContextMenuProvider::populateContextMenu(ContextMenu* menu) |
| 40 { | 40 { |
| 41 populateContextMenuItems(*m_menu, *menu); | 41 populateContextMenuItems(*m_menu, *menu); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void CustomContextMenuProvider::contextMenuItemSelected(const ContextMenuItem* i
tem) | 44 void CustomContextMenuProvider::contextMenuItemSelected(const ContextMenuItem* i
tem) |
| 45 { | 45 { |
| 46 if (HTMLElement* element = menuItemAt(item->action())) { | 46 if (HTMLElement* element = menuItemAt(item->action())) { |
| 47 RefPtrWillBeRawPtr<MouseEvent> click = MouseEvent::create(EventTypeNames
::click, m_menu->document().domWindow(), Event::create(), SimulatedClickCreation
Scope::FromUserAgent); | 47 RawPtr<MouseEvent> click = MouseEvent::create(EventTypeNames::click, m_m
enu->document().domWindow(), Event::create(), SimulatedClickCreationScope::FromU
serAgent); |
| 48 click->setRelatedTarget(m_subjectElement.get()); | 48 click->setRelatedTarget(m_subjectElement.get()); |
| 49 element->dispatchEvent(click.release()); | 49 element->dispatchEvent(click.release()); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 void CustomContextMenuProvider::contextMenuCleared() | 53 void CustomContextMenuProvider::contextMenuCleared() |
| 54 { | 54 { |
| 55 m_menuItems.clear(); | 55 m_menuItems.clear(); |
| 56 m_subjectElement = nullptr; | 56 m_subjectElement = nullptr; |
| 57 } | 57 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 HTMLElement* CustomContextMenuProvider::menuItemAt(unsigned menuId) | 132 HTMLElement* CustomContextMenuProvider::menuItemAt(unsigned menuId) |
| 133 { | 133 { |
| 134 int itemIndex = menuId - ContextMenuItemBaseCustomTag; | 134 int itemIndex = menuId - ContextMenuItemBaseCustomTag; |
| 135 if (itemIndex < 0 || static_cast<unsigned long>(itemIndex) >= m_menuItems.si
ze()) | 135 if (itemIndex < 0 || static_cast<unsigned long>(itemIndex) >= m_menuItems.si
ze()) |
| 136 return nullptr; | 136 return nullptr; |
| 137 return m_menuItems[itemIndex].get(); | 137 return m_menuItems[itemIndex].get(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 } // namespace blink | 140 } // namespace blink |
| OLD | NEW |