Chromium Code Reviews| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 if (last_item.GetType() == kSeparatorType) | 62 if (last_item.GetType() == kSeparatorType) |
| 63 return; | 63 return; |
| 64 | 64 |
| 65 context_menu.AppendItem(ContextMenuItem( | 65 context_menu.AppendItem(ContextMenuItem( |
| 66 kSeparatorType, kContextMenuItemCustomTagNoAction, String(), String())); | 66 kSeparatorType, kContextMenuItemCustomTagNoAction, String(), String())); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void CustomContextMenuProvider::AppendMenuItem(HTMLMenuItemElement* menu_item, | 69 void CustomContextMenuProvider::AppendMenuItem(HTMLMenuItemElement* menu_item, |
| 70 ContextMenu& context_menu) { | 70 ContextMenu& context_menu) { |
| 71 // Avoid menuitems with no label. | 71 // Avoid menuitems with no label. |
| 72 String label_string = menu_item->FastGetAttribute(labelAttr); | 72 String label_string = menu_item->label(); |
|
tkent
2017/04/26 08:59:58
Can you check Firefox behavior for <menuitem label
yuzuchan
2017/04/26 10:28:30
Firefox does not render the menuitem when label is
| |
| 73 if (label_string.IsEmpty()) | 73 if (label_string.IsEmpty()) |
| 74 return; | 74 return; |
| 75 | 75 |
| 76 menu_items_.push_back(menu_item); | 76 menu_items_.push_back(menu_item); |
| 77 | 77 |
| 78 bool enabled = !menu_item->FastHasAttribute(disabledAttr); | 78 bool enabled = !menu_item->FastHasAttribute(disabledAttr); |
| 79 String icon = menu_item->FastGetAttribute(iconAttr); | 79 String icon = menu_item->FastGetAttribute(iconAttr); |
| 80 if (!icon.IsEmpty()) { | 80 if (!icon.IsEmpty()) { |
| 81 // To obtain the absolute URL of the icon when the attribute's value is not | 81 // To obtain the absolute URL of the icon when the attribute's value is not |
| 82 // the empty string, the attribute's value must be resolved relative to the | 82 // the empty string, the attribute's value must be resolved relative to the |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 | 140 |
| 141 HTMLElement* CustomContextMenuProvider::MenuItemAt(unsigned menu_id) { | 141 HTMLElement* CustomContextMenuProvider::MenuItemAt(unsigned menu_id) { |
| 142 int item_index = menu_id - kContextMenuItemBaseCustomTag; | 142 int item_index = menu_id - kContextMenuItemBaseCustomTag; |
| 143 if (item_index < 0 || | 143 if (item_index < 0 || |
| 144 static_cast<unsigned long>(item_index) >= menu_items_.size()) | 144 static_cast<unsigned long>(item_index) >= menu_items_.size()) |
| 145 return nullptr; | 145 return nullptr; |
| 146 return menu_items_[item_index].Get(); | 146 return menu_items_[item_index].Get(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace blink | 149 } // namespace blink |
| OLD | NEW |