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

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

Issue 2234193002: DevTools: migrate some of the sources panel sidebar panes to view management, allow view toolbars. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/Toolbar.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 /** 5 /**
6 * @interface 6 * @interface
7 */ 7 */
8 WebInspector.View = function() 8 WebInspector.View = function()
9 { 9 {
10 } 10 }
(...skipping 23 matching lines...) Expand all
34 * @return {!Promise<!Array<!WebInspector.ToolbarItem>>} 34 * @return {!Promise<!Array<!WebInspector.ToolbarItem>>}
35 */ 35 */
36 toolbarItems: function() { }, 36 toolbarItems: function() { },
37 37
38 /** 38 /**
39 * @return {!Promise<!WebInspector.Widget>} 39 * @return {!Promise<!WebInspector.Widget>}
40 */ 40 */
41 widget: function() { } 41 widget: function() { }
42 } 42 }
43 43
44 WebInspector.View._symbol = Symbol("view");
45
44 /** 46 /**
45 * @constructor 47 * @constructor
46 * @extends {WebInspector.VBox} 48 * @extends {WebInspector.VBox}
47 * @implements {WebInspector.View} 49 * @implements {WebInspector.View}
48 * @param {string} title 50 * @param {string} title
49 * @param {boolean=} isWebComponent 51 * @param {boolean=} isWebComponent
50 */ 52 */
51 WebInspector.SimpleView = function(title, isWebComponent) 53 WebInspector.SimpleView = function(title, isWebComponent)
52 { 54 {
53 WebInspector.VBox.call(this, isWebComponent); 55 WebInspector.VBox.call(this, isWebComponent);
54 this._title = title; 56 this._title = title;
55 /** @type {!Array<!WebInspector.ToolbarItem>} */ 57 /** @type {!Array<!WebInspector.ToolbarItem>} */
56 this._toolbarItems = []; 58 this._toolbarItems = [];
59 this[WebInspector.View._symbol] = this;
57 } 60 }
58 61
59 WebInspector.SimpleView.prototype = { 62 WebInspector.SimpleView.prototype = {
60 /** 63 /**
61 * @override 64 * @override
62 * @return {string} 65 * @return {string}
63 */ 66 */
64 viewId: function() 67 viewId: function()
65 { 68 {
66 return this._title; 69 return this._title;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 { 187 {
185 return this._extension.descriptor()["persistence"] === "transient"; 188 return this._extension.descriptor()["persistence"] === "transient";
186 }, 189 },
187 190
188 /** 191 /**
189 * @override 192 * @override
190 * @return {!Promise<!Array<!WebInspector.ToolbarItem>>} 193 * @return {!Promise<!Array<!WebInspector.ToolbarItem>>}
191 */ 194 */
192 toolbarItems: function() 195 toolbarItems: function()
193 { 196 {
197 var actionIds = this._extension.descriptor()["actionIds"];
198 if (actionIds) {
199 var result = []
200 for (var id of actionIds.split(",")) {
201 var item = WebInspector.Toolbar.createActionButtonForId(id.trim( ));
202 if (item)
203 result.push(item);
204 }
205 return Promise.resolve(result);
206 }
207
208 if (this._extension.descriptor()["hasToolbar"])
209 return this.widget().then(widget => /** @type {!WebInspector.Toolbar Item.ItemsProvider} */ (widget).toolbarItems());
194 return Promise.resolve([]); 210 return Promise.resolve([]);
195 }, 211 },
196 212
197 /** 213 /**
198 * @override 214 * @override
199 * @return {!Promise<!WebInspector.Widget>} 215 * @return {!Promise<!WebInspector.Widget>}
200 */ 216 */
201 widget: function() 217 widget: function()
202 { 218 {
203 return /** @type {!Promise<!WebInspector.Widget>} */ (this._extension.i nstance()); 219 return this._extension.instance().then(widget => {
220 if (!(widget instanceof WebInspector.Widget))
221 throw new Error("view className should point to a WebInspector.W idget");
222 widget[WebInspector.View._symbol] = this;
223 return /** @type {!WebInspector.Widget} */ (widget);
224 });
204 } 225 }
205 } 226 }
206 227
207 /** 228 /**
208 * @interface 229 * @interface
209 */ 230 */
210 WebInspector.ViewLocation = function() { } 231 WebInspector.ViewLocation = function() { }
211 232
212 WebInspector.ViewLocation.prototype = { 233 WebInspector.ViewLocation.prototype = {
213 /** 234 /**
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 295
275 for (var extension of self.runtime.extensions("view")) { 296 for (var extension of self.runtime.extensions("view")) {
276 var descriptor = extension.descriptor(); 297 var descriptor = extension.descriptor();
277 this._views.set(descriptor["id"], new WebInspector.ProvidedView(extensio n)); 298 this._views.set(descriptor["id"], new WebInspector.ProvidedView(extensio n));
278 this._locationNameByViewId.set(descriptor["id"], descriptor["location"]) ; 299 this._locationNameByViewId.set(descriptor["id"], descriptor["location"]) ;
279 } 300 }
280 } 301 }
281 302
282 WebInspector.ViewManager.prototype = { 303 WebInspector.ViewManager.prototype = {
283 /** 304 /**
305 * @param {!WebInspector.Widget} widget
306 */
307 revealViewWithWidget: function(widget)
308 {
309 var view = widget[WebInspector.View._symbol];
310 if (view)
311 this.revealView(view);
312 },
313
314 /**
284 * @param {!WebInspector.View} view 315 * @param {!WebInspector.View} view
285 * @return {!Promise} 316 * @return {!Promise}
286 */ 317 */
287 revealView: function(view) 318 revealView: function(view)
288 { 319 {
289 var location = /** @type {?WebInspector.ViewManager._Location} */ (view[ WebInspector.ViewManager._Location.symbol]); 320 var location = /** @type {?WebInspector.ViewManager._Location} */ (view[ WebInspector.ViewManager._Location.symbol]);
290 if (!location) 321 if (!location)
291 return Promise.resolve(); 322 return Promise.resolve();
292 location._reveal(); 323 location._reveal();
293 return location.showView(view); 324 return location.showView(view);
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 this.appendView(view); 806 this.appendView(view);
776 }, 807 },
777 808
778 __proto__: WebInspector.ViewManager._Location.prototype 809 __proto__: WebInspector.ViewManager._Location.prototype
779 } 810 }
780 811
781 /** 812 /**
782 * @type {!WebInspector.ViewManager} 813 * @type {!WebInspector.ViewManager}
783 */ 814 */
784 WebInspector.viewManager; 815 WebInspector.viewManager;
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/Toolbar.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698