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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/Toolbar.js

Issue 2353033004: [DevTools] Expose left and right toolbar in TabbedPane. (Closed)
Patch Set: review comment Created 4 years, 2 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 if (this._items[i].visible()) { 166 if (this._items[i].visible()) {
167 previousIsSeparator = false; 167 previousIsSeparator = false;
168 lastSeparator = null; 168 lastSeparator = null;
169 nonSeparatorVisible = true; 169 nonSeparatorVisible = true;
170 } 170 }
171 } 171 }
172 if (lastSeparator && lastSeparator !== this._items.peekLast()) 172 if (lastSeparator && lastSeparator !== this._items.peekLast())
173 lastSeparator.setVisible(false); 173 lastSeparator.setVisible(false);
174 174
175 this.element.classList.toggle("hidden", !!lastSeparator && lastSeparator .visible() && !nonSeparatorVisible); 175 this.element.classList.toggle("hidden", !!lastSeparator && lastSeparator .visible() && !nonSeparatorVisible);
176 },
177
178 /**
179 * @param {string} location
180 */
181 appendLocationItems: function(location)
182 {
183 var extensions = self.runtime.extensions(WebInspector.ToolbarItem.Provid er);
184 var promises = [];
185 for (var i = 0; i < extensions.length; ++i) {
186 if (extensions[i].descriptor()["location"] === location)
187 promises.push(resolveItem(extensions[i]));
188 }
189 Promise.all(promises).then(appendItemsInOrder.bind(this));
190
191 /**
192 * @param {!Runtime.Extension} extension
193 * @return {!Promise.<?WebInspector.ToolbarItem>}
194 */
195 function resolveItem(extension)
196 {
197 var descriptor = extension.descriptor();
198 if (descriptor["separator"])
199 return Promise.resolve(/** @type {?WebInspector.ToolbarItem} */( new WebInspector.ToolbarSeparator()));
200 if (descriptor["actionId"])
201 return Promise.resolve(WebInspector.Toolbar.createActionButtonFo rId(descriptor["actionId"]));
202 return extension.instance().then(fetchItemFromProvider);
203
204 /**
205 * @param {!Object} provider
206 */
207 function fetchItemFromProvider(provider)
208 {
209 return /** @type {!WebInspector.ToolbarItem.Provider} */ (provid er).item();
210 }
211 }
212
213 /**
214 * @param {!Array.<?WebInspector.ToolbarItem>} items
215 * @this {WebInspector.Toolbar}
216 */
217 function appendItemsInOrder(items)
218 {
219 for (var i = 0; i < items.length; ++i) {
220 var item = items[i];
221 if (item)
222 this.appendToolbarItem(item);
223 }
224 }
176 } 225 }
177 } 226 }
178 227
179 /** 228 /**
180 * @constructor 229 * @constructor
181 * @extends {WebInspector.Object} 230 * @extends {WebInspector.Object}
182 * @param {!Element} element 231 * @param {!Element} element
183 */ 232 */
184 WebInspector.ToolbarItem = function(element) 233 WebInspector.ToolbarItem = function(element)
185 { 234 {
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 * @param {boolean} value 987 * @param {boolean} value
939 */ 988 */
940 setChecked: function(value) 989 setChecked: function(value)
941 { 990 {
942 this.inputElement.checked = value; 991 this.inputElement.checked = value;
943 }, 992 },
944 993
945 __proto__: WebInspector.ToolbarItem.prototype 994 __proto__: WebInspector.ToolbarItem.prototype
946 } 995 }
947 996
948 /**
949 * @constructor
950 * @extends {WebInspector.Toolbar}
951 * @param {string} location
952 * @param {!Element=} parentElement
953 */
954 WebInspector.ExtensibleToolbar = function(location, parentElement)
955 {
956 WebInspector.Toolbar.call(this, "", parentElement);
957 this._loadItems(location);
958 }
959
960 WebInspector.ExtensibleToolbar.prototype = {
961 /**
962 * @param {string} location
963 */
964 _loadItems: function(location)
965 {
966 var extensions = self.runtime.extensions(WebInspector.ToolbarItem.Provid er);
967 var promises = [];
968 for (var i = 0; i < extensions.length; ++i) {
969 if (extensions[i].descriptor()["location"] === location)
970 promises.push(resolveItem(extensions[i]));
971 }
972 Promise.all(promises).then(appendItemsInOrder.bind(this));
973
974 /**
975 * @param {!Runtime.Extension} extension
976 * @return {!Promise.<?WebInspector.ToolbarItem>}
977 */
978 function resolveItem(extension)
979 {
980 var descriptor = extension.descriptor();
981 if (descriptor["separator"])
982 return Promise.resolve(/** @type {?WebInspector.ToolbarItem} */( new WebInspector.ToolbarSeparator()));
983 if (descriptor["actionId"])
984 return Promise.resolve(WebInspector.Toolbar.createActionButtonFo rId(descriptor["actionId"]));
985 return extension.instance().then(fetchItemFromProvider);
986
987 /**
988 * @param {!Object} provider
989 */
990 function fetchItemFromProvider(provider)
991 {
992 return /** @type {!WebInspector.ToolbarItem.Provider} */ (provid er).item();
993 }
994 }
995
996 /**
997 * @param {!Array.<?WebInspector.ToolbarItem>} items
998 * @this {WebInspector.ExtensibleToolbar}
999 */
1000 function appendItemsInOrder(items)
1001 {
1002 for (var i = 0; i < items.length; ++i) {
1003 var item = items[i];
1004 if (item)
1005 this.appendToolbarItem(item);
1006 }
1007 }
1008 },
1009
1010 __proto__: WebInspector.Toolbar.prototype
1011 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/TabbedPane.js ('k') | third_party/WebKit/Source/devtools/front_end/ui/View.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698