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

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

Issue 2238003002: DevTools: migrate sources panel sidebar to views. (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
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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 for (var extension of self.runtime.extensions("view")) { 296 for (var extension of self.runtime.extensions("view")) {
297 var descriptor = extension.descriptor(); 297 var descriptor = extension.descriptor();
298 this._views.set(descriptor["id"], new WebInspector.ProvidedView(extensio n)); 298 this._views.set(descriptor["id"], new WebInspector.ProvidedView(extensio n));
299 this._locationNameByViewId.set(descriptor["id"], descriptor["location"]) ; 299 this._locationNameByViewId.set(descriptor["id"], descriptor["location"]) ;
300 } 300 }
301 } 301 }
302 302
303 WebInspector.ViewManager.prototype = { 303 WebInspector.ViewManager.prototype = {
304 /** 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 /**
315 * @param {!WebInspector.View} view 305 * @param {!WebInspector.View} view
316 * @return {!Promise} 306 * @return {!Promise}
317 */ 307 */
318 revealView: function(view) 308 revealView: function(view)
319 { 309 {
320 var location = /** @type {?WebInspector.ViewManager._Location} */ (view[ WebInspector.ViewManager._Location.symbol]); 310 var location = /** @type {?WebInspector.ViewManager._Location} */ (view[ WebInspector.ViewManager._Location.symbol]);
321 if (!location) 311 if (!location)
322 return Promise.resolve(); 312 return Promise.resolve();
323 location._reveal(); 313 location._reveal();
324 return location.showView(view); 314 return location.showView(view);
325 }, 315 },
326 316
327 /** 317 /**
328 * @param {string} viewId 318 * @param {string} viewId
319 * @return {?WebInspector.View}
320 */
321 view: function(viewId)
322 {
323 return this._views.get(viewId);
324 },
325
326 /**
327 * @param {string} viewId
329 * @return {!Promise} 328 * @return {!Promise}
330 */ 329 */
331 showView: function(viewId) 330 showView: function(viewId)
332 { 331 {
333 var view = this._views.get(viewId); 332 var view = this._views.get(viewId);
334 if (!view) { 333 if (!view) {
335 console.error("Could not find view for id: '" + viewId + "' " + new Error().stack); 334 console.error("Could not find view for id: '" + viewId + "' " + new Error().stack);
336 return Promise.resolve(); 335 return Promise.resolve();
337 } 336 }
337
338 var locationName = this._locationNameByViewId.get(viewId); 338 var locationName = this._locationNameByViewId.get(viewId);
339 if (locationName === "drawer-view") 339 if (locationName === "drawer-view")
340 WebInspector.userMetrics.drawerShown(viewId); 340 WebInspector.userMetrics.drawerShown(viewId);
341 341
342 var location = view[WebInspector.ViewManager._Location.symbol];
343 if (location) {
344 location._reveal();
345 return location.showView(view);
346 }
347
342 return this._resolveLocation(locationName).then(location => { 348 return this._resolveLocation(locationName).then(location => {
343 if (!location) 349 if (!location)
344 return; 350 throw new Error("Could not resolve location for view: " + viewId );
345 location._reveal(); 351 location._reveal();
346 return location.showView(view); 352 return location.showView(view);
347 }); 353 });
348 }, 354 },
349 355
350 /** 356 /**
351 * @param {string=} location 357 * @param {string=} location
352 * @return {!Promise<?WebInspector.ViewManager._Location>} 358 * @return {!Promise<?WebInspector.ViewManager._Location>}
353 */ 359 */
354 _resolveLocation: function(location) 360 _resolveLocation: function(location)
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 * @override 671 * @override
666 * @param {!WebInspector.View} view 672 * @param {!WebInspector.View} view
667 * @param {?WebInspector.View=} insertBefore 673 * @param {?WebInspector.View=} insertBefore
668 */ 674 */
669 appendView: function(view, insertBefore) 675 appendView: function(view, insertBefore)
670 { 676 {
671 if (insertBefore) 677 if (insertBefore)
672 throw new Error("Insert before in tabbed pane is not supported"); 678 throw new Error("Insert before in tabbed pane is not supported");
673 if (!this._tabbedPane.hasTab(view.viewId())) { 679 if (!this._tabbedPane.hasTab(view.viewId())) {
674 view[WebInspector.ViewManager._Location.symbol] = this; 680 view[WebInspector.ViewManager._Location.symbol] = this;
681 this._manager._views.set(view.viewId(), view);
675 this._views.set(view.viewId(), view); 682 this._views.set(view.viewId(), view);
676 this._appendTab(view); 683 this._appendTab(view);
677 } 684 }
678 }, 685 },
679 686
680 /** 687 /**
681 * @override 688 * @override
682 * @param {!WebInspector.View} view 689 * @param {!WebInspector.View} view
683 * @param {?WebInspector.View=} insertBefore 690 * @param {?WebInspector.View=} insertBefore
684 * @return {!Promise} 691 * @return {!Promise}
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 /** 772 /**
766 * @override 773 * @override
767 * @param {!WebInspector.View} view 774 * @param {!WebInspector.View} view
768 * @param {?WebInspector.View=} insertBefore 775 * @param {?WebInspector.View=} insertBefore
769 */ 776 */
770 appendView: function(view, insertBefore) 777 appendView: function(view, insertBefore)
771 { 778 {
772 var container = this._expandableContainers.get(view.viewId()); 779 var container = this._expandableContainers.get(view.viewId());
773 if (!container) { 780 if (!container) {
774 view[WebInspector.ViewManager._Location.symbol] = this; 781 view[WebInspector.ViewManager._Location.symbol] = this;
782 this._manager._views.set(view.viewId(), view);
775 container = new WebInspector.ViewManager._ExpandableContainerWidget( view); 783 container = new WebInspector.ViewManager._ExpandableContainerWidget( view);
776 var beforeElement = null; 784 var beforeElement = null;
777 if (insertBefore) { 785 if (insertBefore) {
778 var beforeContainer = insertBefore[WebInspector.ViewManager._Exp andableContainerWidget._symbol]; 786 var beforeContainer = insertBefore[WebInspector.ViewManager._Exp andableContainerWidget._symbol];
779 beforeElement = beforeContainer ? beforeContainer.element : null ; 787 beforeElement = beforeContainer ? beforeContainer.element : null ;
780 } 788 }
781 container.show(this._vbox.contentElement, beforeElement); 789 container.show(this._vbox.contentElement, beforeElement);
782 this._expandableContainers.set(view.viewId(), container); 790 this._expandableContainers.set(view.viewId(), container);
783 } 791 }
784 }, 792 },
(...skipping 21 matching lines...) Expand all
806 this.appendView(view); 814 this.appendView(view);
807 }, 815 },
808 816
809 __proto__: WebInspector.ViewManager._Location.prototype 817 __proto__: WebInspector.ViewManager._Location.prototype
810 } 818 }
811 819
812 /** 820 /**
813 * @type {!WebInspector.ViewManager} 821 * @type {!WebInspector.ViewManager}
814 */ 822 */
815 WebInspector.viewManager; 823 WebInspector.viewManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698