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

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

Issue 2733493002: DevTools: fix bug with persisting drawer selection (Closed)
Patch Set: fix Created 3 years, 9 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 * @interface 5 * @interface
6 */ 6 */
7 UI.View = function() {}; 7 UI.View = function() {};
8 8
9 UI.View.prototype = { 9 UI.View.prototype = {
10 /** 10 /**
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 /** 216 /**
217 * @param {!UI.View} view 217 * @param {!UI.View} view
218 * @param {?UI.View=} insertBefore 218 * @param {?UI.View=} insertBefore
219 */ 219 */
220 appendView(view, insertBefore) {}, 220 appendView(view, insertBefore) {},
221 221
222 /** 222 /**
223 * @param {!UI.View} view 223 * @param {!UI.View} view
224 * @param {?UI.View=} insertBefore 224 * @param {?UI.View=} insertBefore
225 * @param {boolean=} userGesture
225 * @return {!Promise} 226 * @return {!Promise}
226 */ 227 */
227 showView(view, insertBefore) {}, 228 showView(view, insertBefore, userGesture) {},
228 229
229 /** 230 /**
230 * @param {!UI.View} view 231 * @param {!UI.View} view
231 */ 232 */
232 removeView(view) {}, 233 removeView(view) {},
233 234
234 /** 235 /**
235 * @return {!UI.Widget} 236 * @return {!UI.Widget}
236 */ 237 */
237 widget() {} 238 widget() {}
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 * @param {string} viewId 320 * @param {string} viewId
320 * @return {?UI.Widget} 321 * @return {?UI.Widget}
321 */ 322 */
322 materializedWidget(viewId) { 323 materializedWidget(viewId) {
323 var view = this.view(viewId); 324 var view = this.view(viewId);
324 return view ? view[UI.View._widgetSymbol] : null; 325 return view ? view[UI.View._widgetSymbol] : null;
325 } 326 }
326 327
327 /** 328 /**
328 * @param {string} viewId 329 * @param {string} viewId
330 * @param {boolean=} userGesture
329 * @return {!Promise} 331 * @return {!Promise}
330 */ 332 */
331 showView(viewId) { 333 showView(viewId, userGesture) {
332 var view = this._views.get(viewId); 334 var view = this._views.get(viewId);
333 if (!view) { 335 if (!view) {
334 console.error('Could not find view for id: \'' + viewId + '\' ' + new Erro r().stack); 336 console.error('Could not find view for id: \'' + viewId + '\' ' + new Erro r().stack);
335 return Promise.resolve(); 337 return Promise.resolve();
336 } 338 }
337 339
338 var locationName = this._locationNameByViewId.get(viewId); 340 var locationName = this._locationNameByViewId.get(viewId);
339 if (locationName === 'drawer-view') 341 if (locationName === 'drawer-view')
340 Host.userMetrics.drawerShown(viewId); 342 Host.userMetrics.drawerShown(viewId);
341 343
342 var location = view[UI.ViewManager._Location.symbol]; 344 var location = view[UI.ViewManager._Location.symbol];
343 if (location) { 345 if (location) {
344 location._reveal(); 346 location._reveal();
345 return location.showView(view); 347 return location.showView(view, undefined, userGesture);
346 } 348 }
347 349
348 return this._resolveLocation(locationName).then(location => { 350 return this._resolveLocation(locationName).then(location => {
349 if (!location) 351 if (!location)
350 throw new Error('Could not resolve location for view: ' + viewId); 352 throw new Error('Could not resolve location for view: ' + viewId);
351 location._reveal(); 353 location._reveal();
352 return location.showView(view); 354 return location.showView(view, undefined, userGesture);
353 }); 355 });
354 } 356 }
355 357
356 /** 358 /**
357 * @param {string=} location 359 * @param {string=} location
358 * @return {!Promise<?UI.ViewManager._Location>} 360 * @return {!Promise<?UI.ViewManager._Location>}
359 */ 361 */
360 _resolveLocation(location) { 362 _resolveLocation(location) {
361 if (!location) 363 if (!location)
362 return /** @type {!Promise<?UI.ViewManager._Location>} */ (Promise.resolve (null)); 364 return /** @type {!Promise<?UI.ViewManager._Location>} */ (Promise.resolve (null));
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 else if (this._lastSelectedTabSetting && this._tabbedPane.hasTab(this._lastS electedTabSetting.get())) 657 else if (this._lastSelectedTabSetting && this._tabbedPane.hasTab(this._lastS electedTabSetting.get()))
656 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); 658 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get());
657 } 659 }
658 660
659 /** 661 /**
660 * @param {!UI.ContextMenu} contextMenu 662 * @param {!UI.ContextMenu} contextMenu
661 */ 663 */
662 _appendTabsToMenu(contextMenu) { 664 _appendTabsToMenu(contextMenu) {
663 for (var view of this._views.values()) { 665 for (var view of this._views.values()) {
664 var title = Common.UIString(view.title()); 666 var title = Common.UIString(view.title());
665 contextMenu.appendItem(title, this.showView.bind(this, view)); 667 contextMenu.appendItem(title, this.showView.bind(this, view, undefined, tr ue));
666 } 668 }
667 } 669 }
668 670
669 /** 671 /**
670 * @param {!UI.View} view 672 * @param {!UI.View} view
671 * @param {number=} index 673 * @param {number=} index
672 */ 674 */
673 _appendTab(view, index) { 675 _appendTab(view, index) {
674 this._tabbedPane.appendTab( 676 this._tabbedPane.appendTab(
675 view.viewId(), view.title(), new UI.ViewManager._ContainerWidget(view), undefined, false, 677 view.viewId(), view.title(), new UI.ViewManager._ContainerWidget(view), undefined, false,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 } 709 }
708 } 710 }
709 } 711 }
710 this._appendTab(view, index); 712 this._appendTab(view, index);
711 } 713 }
712 714
713 /** 715 /**
714 * @override 716 * @override
715 * @param {!UI.View} view 717 * @param {!UI.View} view
716 * @param {?UI.View=} insertBefore 718 * @param {?UI.View=} insertBefore
719 * @param {boolean=} userGesture
717 * @return {!Promise} 720 * @return {!Promise}
718 */ 721 */
719 showView(view, insertBefore) { 722 showView(view, insertBefore, userGesture) {
720 this.appendView(view, insertBefore); 723 this.appendView(view, insertBefore);
721 this._tabbedPane.selectTab(view.viewId()); 724 this._tabbedPane.selectTab(view.viewId(), userGesture);
722 this._tabbedPane.focus(); 725 this._tabbedPane.focus();
723 var widget = /** @type {!UI.ViewManager._ContainerWidget} */ (this._tabbedPa ne.tabView(view.viewId())); 726 var widget = /** @type {!UI.ViewManager._ContainerWidget} */ (this._tabbedPa ne.tabView(view.viewId()));
724 return widget._materialize(); 727 return widget._materialize();
725 } 728 }
726 729
727 /** 730 /**
728 * @param {!UI.View} view 731 * @param {!UI.View} view
729 * @override 732 * @override
730 */ 733 */
731 removeView(view) { 734 removeView(view) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 appendApplicableItems(locationName) { 864 appendApplicableItems(locationName) {
862 for (var view of this._manager._viewsForLocation(locationName)) 865 for (var view of this._manager._viewsForLocation(locationName))
863 this.appendView(view); 866 this.appendView(view);
864 } 867 }
865 }; 868 };
866 869
867 /** 870 /**
868 * @type {!UI.ViewManager} 871 * @type {!UI.ViewManager}
869 */ 872 */
870 UI.viewManager; 873 UI.viewManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698