| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 83 // element. | 83 // element. |
| 84 KURL icon_url = KURL(menu_item->baseURI(), icon); | 84 KURL icon_url = KURL(menu_item->baseURI(), icon); |
| 85 icon = icon_url.GetString(); | 85 icon = icon_url.GetString(); |
| 86 } | 86 } |
| 87 ContextMenuAction action = static_cast<ContextMenuAction>( | 87 ContextMenuAction action = static_cast<ContextMenuAction>( |
| 88 kContextMenuItemBaseCustomTag + menu_items_.size() - 1); | 88 kContextMenuItemBaseCustomTag + menu_items_.size() - 1); |
| 89 if (EqualIgnoringCase(menu_item->FastGetAttribute(typeAttr), "checkbox") || | 89 if (DeprecatedEqualIgnoringCase(menu_item->FastGetAttribute(typeAttr), |
| 90 EqualIgnoringCase(menu_item->FastGetAttribute(typeAttr), "radio")) | 90 "checkbox") || |
| 91 DeprecatedEqualIgnoringCase(menu_item->FastGetAttribute(typeAttr), |
| 92 "radio")) |
| 91 context_menu.AppendItem( | 93 context_menu.AppendItem( |
| 92 ContextMenuItem(kCheckableActionType, action, label_string, icon, | 94 ContextMenuItem(kCheckableActionType, action, label_string, icon, |
| 93 enabled, menu_item->FastHasAttribute(checkedAttr))); | 95 enabled, menu_item->FastHasAttribute(checkedAttr))); |
| 94 else | 96 else |
| 95 context_menu.AppendItem(ContextMenuItem(kActionType, action, label_string, | 97 context_menu.AppendItem(ContextMenuItem(kActionType, action, label_string, |
| 96 icon, enabled, false)); | 98 icon, enabled, false)); |
| 97 } | 99 } |
| 98 | 100 |
| 99 void CustomContextMenuProvider::PopulateContextMenuItems( | 101 void CustomContextMenuProvider::PopulateContextMenuItems( |
| 100 const HTMLMenuElement& menu, | 102 const HTMLMenuElement& menu, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 140 |
| 139 HTMLElement* CustomContextMenuProvider::MenuItemAt(unsigned menu_id) { | 141 HTMLElement* CustomContextMenuProvider::MenuItemAt(unsigned menu_id) { |
| 140 int item_index = menu_id - kContextMenuItemBaseCustomTag; | 142 int item_index = menu_id - kContextMenuItemBaseCustomTag; |
| 141 if (item_index < 0 || | 143 if (item_index < 0 || |
| 142 static_cast<unsigned long>(item_index) >= menu_items_.size()) | 144 static_cast<unsigned long>(item_index) >= menu_items_.size()) |
| 143 return nullptr; | 145 return nullptr; |
| 144 return menu_items_[item_index].Get(); | 146 return menu_items_[item_index].Get(); |
| 145 } | 147 } |
| 146 | 148 |
| 147 } // namespace blink | 149 } // namespace blink |
| OLD | NEW |