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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/custom/V8DevToolsHostCustom.cpp

Issue 2905763003: Rollback ContextMenu (Closed)
Patch Set: Rebase Created 3 years, 6 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
1 /* 1 /*
2 * Copyright (C) 2007-2009 Google Inc. All rights reserved. 2 * Copyright (C) 2007-2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 .ToLocal(&enabled) || 75 .ToLocal(&enabled) ||
76 !item->Get(context, V8AtomicString(isolate, "checked")) 76 !item->Get(context, V8AtomicString(isolate, "checked"))
77 .ToLocal(&checked) || 77 .ToLocal(&checked) ||
78 !item->Get(context, V8AtomicString(isolate, "subItems")) 78 !item->Get(context, V8AtomicString(isolate, "subItems"))
79 .ToLocal(&sub_items)) 79 .ToLocal(&sub_items))
80 return false; 80 return false;
81 if (!type->IsString()) 81 if (!type->IsString())
82 continue; 82 continue;
83 String type_string = ToCoreStringWithNullCheck(type.As<v8::String>()); 83 String type_string = ToCoreStringWithNullCheck(type.As<v8::String>());
84 if (type_string == "separator") { 84 if (type_string == "separator") {
85 ContextMenuItem item(ContextMenuItem(kSeparatorType, 85 ContextMenuItem item(ContextMenuItem(
86 kContextMenuItemCustomTagNoAction, 86 kSeparatorType, kContextMenuItemCustomTagNoAction, String()));
87 String(), String()));
88 menu.AppendItem(item); 87 menu.AppendItem(item);
89 } else if (type_string == "subMenu" && sub_items->IsArray()) { 88 } else if (type_string == "subMenu" && sub_items->IsArray()) {
90 ContextMenu sub_menu; 89 ContextMenu sub_menu;
91 v8::Local<v8::Array> sub_items_array = 90 v8::Local<v8::Array> sub_items_array =
92 v8::Local<v8::Array>::Cast(sub_items); 91 v8::Local<v8::Array>::Cast(sub_items);
93 if (!PopulateContextMenuItems(isolate, sub_items_array, sub_menu)) 92 if (!PopulateContextMenuItems(isolate, sub_items_array, sub_menu))
94 return false; 93 return false;
95 TOSTRING_DEFAULT(V8StringResource<kTreatNullAsNullString>, label_string, 94 TOSTRING_DEFAULT(V8StringResource<kTreatNullAsNullString>, label_string,
96 label, false); 95 label, false);
97 ContextMenuItem item(kSubmenuType, kContextMenuItemCustomTagNoAction, 96 ContextMenuItem item(kSubmenuType, kContextMenuItemCustomTagNoAction,
98 label_string, String(), &sub_menu); 97 label_string, &sub_menu);
99 menu.AppendItem(item); 98 menu.AppendItem(item);
100 } else { 99 } else {
101 int32_t int32_id; 100 int32_t int32_id;
102 if (!id->Int32Value(context).To(&int32_id)) 101 if (!id->Int32Value(context).To(&int32_id))
103 return false; 102 return false;
104 ContextMenuAction typed_id = static_cast<ContextMenuAction>( 103 ContextMenuAction typed_id = static_cast<ContextMenuAction>(
105 kContextMenuItemBaseCustomTag + int32_id); 104 kContextMenuItemBaseCustomTag + int32_id);
106 TOSTRING_DEFAULT(V8StringResource<kTreatNullAsNullString>, label_string, 105 TOSTRING_DEFAULT(V8StringResource<kTreatNullAsNullString>, label_string,
107 label, false); 106 label, false);
108 ContextMenuItem menu_item( 107 ContextMenuItem menu_item(
109 (type_string == "checkbox" ? kCheckableActionType : kActionType), 108 (type_string == "checkbox" ? kCheckableActionType : kActionType),
110 typed_id, label_string, String()); 109 typed_id, label_string);
111 if (checked->IsBoolean()) 110 if (checked->IsBoolean())
112 menu_item.SetChecked(checked.As<v8::Boolean>()->Value()); 111 menu_item.SetChecked(checked.As<v8::Boolean>()->Value());
113 if (enabled->IsBoolean()) 112 if (enabled->IsBoolean())
114 menu_item.SetEnabled(enabled.As<v8::Boolean>()->Value()); 113 menu_item.SetEnabled(enabled.As<v8::Boolean>()->Value());
115 menu.AppendItem(menu_item); 114 menu.AppendItem(menu_item);
116 } 115 }
117 } 116 }
118 return true; 117 return true;
119 } 118 }
120 119
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 161 }
163 if (!document || !document->GetFrame()) 162 if (!document || !document->GetFrame())
164 return; 163 return;
165 164
166 DevToolsHost* devtools_host = V8DevToolsHost::toImpl(info.Holder()); 165 DevToolsHost* devtools_host = V8DevToolsHost::toImpl(info.Holder());
167 Vector<ContextMenuItem> items = menu.Items(); 166 Vector<ContextMenuItem> items = menu.Items();
168 devtools_host->ShowContextMenu(document->GetFrame(), x, y, items); 167 devtools_host->ShowContextMenu(document->GetFrame(), x, y, items);
169 } 168 }
170 169
171 } // namespace blink 170 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/BUILD.gn ('k') | third_party/WebKit/Source/core/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698