| OLD | NEW |
| 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 WebInspector.View = function() {}; | 7 UI.View = function() {}; |
| 8 | 8 |
| 9 WebInspector.View.prototype = { | 9 UI.View.prototype = { |
| 10 /** | 10 /** |
| 11 * @return {string} | 11 * @return {string} |
| 12 */ | 12 */ |
| 13 viewId: function() {}, | 13 viewId: function() {}, |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * @return {string} | 16 * @return {string} |
| 17 */ | 17 */ |
| 18 title: function() {}, | 18 title: function() {}, |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * @return {boolean} | 21 * @return {boolean} |
| 22 */ | 22 */ |
| 23 isCloseable: function() {}, | 23 isCloseable: function() {}, |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * @return {boolean} | 26 * @return {boolean} |
| 27 */ | 27 */ |
| 28 isTransient: function() {}, | 28 isTransient: function() {}, |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * @return {!Promise<!Array<!WebInspector.ToolbarItem>>} | 31 * @return {!Promise<!Array<!UI.ToolbarItem>>} |
| 32 */ | 32 */ |
| 33 toolbarItems: function() {}, | 33 toolbarItems: function() {}, |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * @return {!Promise<!WebInspector.Widget>} | 36 * @return {!Promise<!UI.Widget>} |
| 37 */ | 37 */ |
| 38 widget: function() {} | 38 widget: function() {} |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 WebInspector.View._symbol = Symbol('view'); | 41 UI.View._symbol = Symbol('view'); |
| 42 WebInspector.View._widgetSymbol = Symbol('widget'); | 42 UI.View._widgetSymbol = Symbol('widget'); |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * @implements {WebInspector.View} | 45 * @implements {UI.View} |
| 46 * @unrestricted | 46 * @unrestricted |
| 47 */ | 47 */ |
| 48 WebInspector.SimpleView = class extends WebInspector.VBox { | 48 UI.SimpleView = class extends UI.VBox { |
| 49 /** | 49 /** |
| 50 * @param {string} title | 50 * @param {string} title |
| 51 * @param {boolean=} isWebComponent | 51 * @param {boolean=} isWebComponent |
| 52 */ | 52 */ |
| 53 constructor(title, isWebComponent) { | 53 constructor(title, isWebComponent) { |
| 54 super(isWebComponent); | 54 super(isWebComponent); |
| 55 this._title = title; | 55 this._title = title; |
| 56 /** @type {!Array<!WebInspector.ToolbarItem>} */ | 56 /** @type {!Array<!UI.ToolbarItem>} */ |
| 57 this._toolbarItems = []; | 57 this._toolbarItems = []; |
| 58 this[WebInspector.View._symbol] = this; | 58 this[UI.View._symbol] = this; |
| 59 } | 59 } |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * @override | 62 * @override |
| 63 * @return {string} | 63 * @return {string} |
| 64 */ | 64 */ |
| 65 viewId() { | 65 viewId() { |
| 66 return this._title; | 66 return this._title; |
| 67 } | 67 } |
| 68 | 68 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 85 /** | 85 /** |
| 86 * @override | 86 * @override |
| 87 * @return {boolean} | 87 * @return {boolean} |
| 88 */ | 88 */ |
| 89 isTransient() { | 89 isTransient() { |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * @override | 94 * @override |
| 95 * @return {!Promise<!Array<!WebInspector.ToolbarItem>>} | 95 * @return {!Promise<!Array<!UI.ToolbarItem>>} |
| 96 */ | 96 */ |
| 97 toolbarItems() { | 97 toolbarItems() { |
| 98 return Promise.resolve(this.syncToolbarItems()); | 98 return Promise.resolve(this.syncToolbarItems()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 /** | 101 /** |
| 102 * @return {!Array<!WebInspector.ToolbarItem>} | 102 * @return {!Array<!UI.ToolbarItem>} |
| 103 */ | 103 */ |
| 104 syncToolbarItems() { | 104 syncToolbarItems() { |
| 105 return this._toolbarItems; | 105 return this._toolbarItems; |
| 106 } | 106 } |
| 107 | 107 |
| 108 /** | 108 /** |
| 109 * @override | 109 * @override |
| 110 * @return {!Promise<!WebInspector.Widget>} | 110 * @return {!Promise<!UI.Widget>} |
| 111 */ | 111 */ |
| 112 widget() { | 112 widget() { |
| 113 return /** @type {!Promise<!WebInspector.Widget>} */ (Promise.resolve(this))
; | 113 return /** @type {!Promise<!UI.Widget>} */ (Promise.resolve(this)); |
| 114 } | 114 } |
| 115 | 115 |
| 116 /** | 116 /** |
| 117 * @param {!WebInspector.ToolbarItem} item | 117 * @param {!UI.ToolbarItem} item |
| 118 */ | 118 */ |
| 119 addToolbarItem(item) { | 119 addToolbarItem(item) { |
| 120 this._toolbarItems.push(item); | 120 this._toolbarItems.push(item); |
| 121 } | 121 } |
| 122 | 122 |
| 123 /** | 123 /** |
| 124 * @return {!Promise} | 124 * @return {!Promise} |
| 125 */ | 125 */ |
| 126 revealView() { | 126 revealView() { |
| 127 return WebInspector.viewManager.revealView(this); | 127 return UI.viewManager.revealView(this); |
| 128 } | 128 } |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 /** | 131 /** |
| 132 * @implements {WebInspector.View} | 132 * @implements {UI.View} |
| 133 * @unrestricted | 133 * @unrestricted |
| 134 */ | 134 */ |
| 135 WebInspector.ProvidedView = class { | 135 UI.ProvidedView = class { |
| 136 /** | 136 /** |
| 137 * @param {!Runtime.Extension} extension | 137 * @param {!Runtime.Extension} extension |
| 138 */ | 138 */ |
| 139 constructor(extension) { | 139 constructor(extension) { |
| 140 this._extension = extension; | 140 this._extension = extension; |
| 141 } | 141 } |
| 142 | 142 |
| 143 /** | 143 /** |
| 144 * @override | 144 * @override |
| 145 * @return {string} | 145 * @return {string} |
| (...skipping 21 matching lines...) Expand all Loading... |
| 167 /** | 167 /** |
| 168 * @override | 168 * @override |
| 169 * @return {boolean} | 169 * @return {boolean} |
| 170 */ | 170 */ |
| 171 isTransient() { | 171 isTransient() { |
| 172 return this._extension.descriptor()['persistence'] === 'transient'; | 172 return this._extension.descriptor()['persistence'] === 'transient'; |
| 173 } | 173 } |
| 174 | 174 |
| 175 /** | 175 /** |
| 176 * @override | 176 * @override |
| 177 * @return {!Promise<!Array<!WebInspector.ToolbarItem>>} | 177 * @return {!Promise<!Array<!UI.ToolbarItem>>} |
| 178 */ | 178 */ |
| 179 toolbarItems() { | 179 toolbarItems() { |
| 180 var actionIds = this._extension.descriptor()['actionIds']; | 180 var actionIds = this._extension.descriptor()['actionIds']; |
| 181 if (actionIds) { | 181 if (actionIds) { |
| 182 var result = []; | 182 var result = []; |
| 183 for (var id of actionIds.split(',')) { | 183 for (var id of actionIds.split(',')) { |
| 184 var item = WebInspector.Toolbar.createActionButtonForId(id.trim()); | 184 var item = UI.Toolbar.createActionButtonForId(id.trim()); |
| 185 if (item) | 185 if (item) |
| 186 result.push(item); | 186 result.push(item); |
| 187 } | 187 } |
| 188 return Promise.resolve(result); | 188 return Promise.resolve(result); |
| 189 } | 189 } |
| 190 | 190 |
| 191 if (this._extension.descriptor()['hasToolbar']) | 191 if (this._extension.descriptor()['hasToolbar']) |
| 192 return this.widget().then( | 192 return this.widget().then( |
| 193 widget => /** @type {!WebInspector.ToolbarItem.ItemsProvider} */ (widg
et).toolbarItems()); | 193 widget => /** @type {!UI.ToolbarItem.ItemsProvider} */ (widget).toolba
rItems()); |
| 194 return Promise.resolve([]); | 194 return Promise.resolve([]); |
| 195 } | 195 } |
| 196 | 196 |
| 197 /** | 197 /** |
| 198 * @override | 198 * @override |
| 199 * @return {!Promise<!WebInspector.Widget>} | 199 * @return {!Promise<!UI.Widget>} |
| 200 */ | 200 */ |
| 201 widget() { | 201 widget() { |
| 202 return this._extension.instance().then(widget => { | 202 return this._extension.instance().then(widget => { |
| 203 if (!(widget instanceof WebInspector.Widget)) | 203 if (!(widget instanceof UI.Widget)) |
| 204 throw new Error('view className should point to a WebInspector.Widget'); | 204 throw new Error('view className should point to a UI.Widget'); |
| 205 widget[WebInspector.View._symbol] = this; | 205 widget[UI.View._symbol] = this; |
| 206 return /** @type {!WebInspector.Widget} */ (widget); | 206 return /** @type {!UI.Widget} */ (widget); |
| 207 }); | 207 }); |
| 208 } | 208 } |
| 209 }; | 209 }; |
| 210 | 210 |
| 211 /** | 211 /** |
| 212 * @interface | 212 * @interface |
| 213 */ | 213 */ |
| 214 WebInspector.ViewLocation = function() {}; | 214 UI.ViewLocation = function() {}; |
| 215 | 215 |
| 216 WebInspector.ViewLocation.prototype = { | 216 UI.ViewLocation.prototype = { |
| 217 /** | 217 /** |
| 218 * @param {string} locationName | 218 * @param {string} locationName |
| 219 */ | 219 */ |
| 220 appendApplicableItems: function(locationName) {}, | 220 appendApplicableItems: function(locationName) {}, |
| 221 | 221 |
| 222 /** | 222 /** |
| 223 * @param {!WebInspector.View} view | 223 * @param {!UI.View} view |
| 224 * @param {?WebInspector.View=} insertBefore | 224 * @param {?UI.View=} insertBefore |
| 225 */ | 225 */ |
| 226 appendView: function(view, insertBefore) {}, | 226 appendView: function(view, insertBefore) {}, |
| 227 | 227 |
| 228 /** | 228 /** |
| 229 * @param {!WebInspector.View} view | 229 * @param {!UI.View} view |
| 230 * @param {?WebInspector.View=} insertBefore | 230 * @param {?UI.View=} insertBefore |
| 231 * @return {!Promise} | 231 * @return {!Promise} |
| 232 */ | 232 */ |
| 233 showView: function(view, insertBefore) {}, | 233 showView: function(view, insertBefore) {}, |
| 234 | 234 |
| 235 /** | 235 /** |
| 236 * @param {!WebInspector.View} view | 236 * @param {!UI.View} view |
| 237 */ | 237 */ |
| 238 removeView: function(view) {}, | 238 removeView: function(view) {}, |
| 239 | 239 |
| 240 /** | 240 /** |
| 241 * @return {!WebInspector.Widget} | 241 * @return {!UI.Widget} |
| 242 */ | 242 */ |
| 243 widget: function() {} | 243 widget: function() {} |
| 244 }; | 244 }; |
| 245 | 245 |
| 246 /** | 246 /** |
| 247 * @interface | 247 * @interface |
| 248 * @extends {WebInspector.ViewLocation} | 248 * @extends {UI.ViewLocation} |
| 249 */ | 249 */ |
| 250 WebInspector.TabbedViewLocation = function() {}; | 250 UI.TabbedViewLocation = function() {}; |
| 251 | 251 |
| 252 WebInspector.TabbedViewLocation.prototype = { | 252 UI.TabbedViewLocation.prototype = { |
| 253 /** | 253 /** |
| 254 * @return {!WebInspector.TabbedPane} | 254 * @return {!UI.TabbedPane} |
| 255 */ | 255 */ |
| 256 tabbedPane: function() {}, | 256 tabbedPane: function() {}, |
| 257 | 257 |
| 258 enableMoreTabsButton: function() {} | 258 enableMoreTabsButton: function() {} |
| 259 }; | 259 }; |
| 260 | 260 |
| 261 /** | 261 /** |
| 262 * @interface | 262 * @interface |
| 263 */ | 263 */ |
| 264 WebInspector.ViewLocationResolver = function() {}; | 264 UI.ViewLocationResolver = function() {}; |
| 265 | 265 |
| 266 WebInspector.ViewLocationResolver.prototype = { | 266 UI.ViewLocationResolver.prototype = { |
| 267 /** | 267 /** |
| 268 * @param {string} location | 268 * @param {string} location |
| 269 * @return {?WebInspector.ViewLocation} | 269 * @return {?UI.ViewLocation} |
| 270 */ | 270 */ |
| 271 resolveLocation: function(location) {} | 271 resolveLocation: function(location) {} |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 /** | 274 /** |
| 275 * @unrestricted | 275 * @unrestricted |
| 276 */ | 276 */ |
| 277 WebInspector.ViewManager = class { | 277 UI.ViewManager = class { |
| 278 constructor() { | 278 constructor() { |
| 279 /** @type {!Map<string, !WebInspector.View>} */ | 279 /** @type {!Map<string, !UI.View>} */ |
| 280 this._views = new Map(); | 280 this._views = new Map(); |
| 281 /** @type {!Map<string, string>} */ | 281 /** @type {!Map<string, string>} */ |
| 282 this._locationNameByViewId = new Map(); | 282 this._locationNameByViewId = new Map(); |
| 283 | 283 |
| 284 for (var extension of self.runtime.extensions('view')) { | 284 for (var extension of self.runtime.extensions('view')) { |
| 285 var descriptor = extension.descriptor(); | 285 var descriptor = extension.descriptor(); |
| 286 this._views.set(descriptor['id'], new WebInspector.ProvidedView(extension)
); | 286 this._views.set(descriptor['id'], new UI.ProvidedView(extension)); |
| 287 this._locationNameByViewId.set(descriptor['id'], descriptor['location']); | 287 this._locationNameByViewId.set(descriptor['id'], descriptor['location']); |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 | 290 |
| 291 /** | 291 /** |
| 292 * @param {!Element} element | 292 * @param {!Element} element |
| 293 * @param {!Array<!WebInspector.ToolbarItem>} toolbarItems | 293 * @param {!Array<!UI.ToolbarItem>} toolbarItems |
| 294 */ | 294 */ |
| 295 static _populateToolbar(element, toolbarItems) { | 295 static _populateToolbar(element, toolbarItems) { |
| 296 if (!toolbarItems.length) | 296 if (!toolbarItems.length) |
| 297 return; | 297 return; |
| 298 var toolbar = new WebInspector.Toolbar(''); | 298 var toolbar = new UI.Toolbar(''); |
| 299 element.insertBefore(toolbar.element, element.firstChild); | 299 element.insertBefore(toolbar.element, element.firstChild); |
| 300 for (var item of toolbarItems) | 300 for (var item of toolbarItems) |
| 301 toolbar.appendToolbarItem(item); | 301 toolbar.appendToolbarItem(item); |
| 302 } | 302 } |
| 303 | 303 |
| 304 /** | 304 /** |
| 305 * @param {!WebInspector.View} view | 305 * @param {!UI.View} view |
| 306 * @return {!Promise} | 306 * @return {!Promise} |
| 307 */ | 307 */ |
| 308 revealView(view) { | 308 revealView(view) { |
| 309 var location = /** @type {?WebInspector.ViewManager._Location} */ (view[WebI
nspector.ViewManager._Location.symbol]); | 309 var location = /** @type {?UI.ViewManager._Location} */ (view[UI.ViewManager
._Location.symbol]); |
| 310 if (!location) | 310 if (!location) |
| 311 return Promise.resolve(); | 311 return Promise.resolve(); |
| 312 location._reveal(); | 312 location._reveal(); |
| 313 return location.showView(view); | 313 return location.showView(view); |
| 314 } | 314 } |
| 315 | 315 |
| 316 /** | 316 /** |
| 317 * @param {string} viewId | 317 * @param {string} viewId |
| 318 * @return {?WebInspector.View} | 318 * @return {?UI.View} |
| 319 */ | 319 */ |
| 320 view(viewId) { | 320 view(viewId) { |
| 321 return this._views.get(viewId); | 321 return this._views.get(viewId); |
| 322 } | 322 } |
| 323 | 323 |
| 324 /** | 324 /** |
| 325 * @param {string} viewId | 325 * @param {string} viewId |
| 326 * @return {?WebInspector.Widget} | 326 * @return {?UI.Widget} |
| 327 */ | 327 */ |
| 328 materializedWidget(viewId) { | 328 materializedWidget(viewId) { |
| 329 var view = this.view(viewId); | 329 var view = this.view(viewId); |
| 330 return view ? view[WebInspector.View._widgetSymbol] : null; | 330 return view ? view[UI.View._widgetSymbol] : null; |
| 331 } | 331 } |
| 332 | 332 |
| 333 /** | 333 /** |
| 334 * @param {string} viewId | 334 * @param {string} viewId |
| 335 * @return {!Promise} | 335 * @return {!Promise} |
| 336 */ | 336 */ |
| 337 showView(viewId) { | 337 showView(viewId) { |
| 338 var view = this._views.get(viewId); | 338 var view = this._views.get(viewId); |
| 339 if (!view) { | 339 if (!view) { |
| 340 console.error('Could not find view for id: \'' + viewId + '\' ' + new Erro
r().stack); | 340 console.error('Could not find view for id: \'' + viewId + '\' ' + new Erro
r().stack); |
| 341 return Promise.resolve(); | 341 return Promise.resolve(); |
| 342 } | 342 } |
| 343 | 343 |
| 344 var locationName = this._locationNameByViewId.get(viewId); | 344 var locationName = this._locationNameByViewId.get(viewId); |
| 345 if (locationName === 'drawer-view') | 345 if (locationName === 'drawer-view') |
| 346 WebInspector.userMetrics.drawerShown(viewId); | 346 Host.userMetrics.drawerShown(viewId); |
| 347 | 347 |
| 348 var location = view[WebInspector.ViewManager._Location.symbol]; | 348 var location = view[UI.ViewManager._Location.symbol]; |
| 349 if (location) { | 349 if (location) { |
| 350 location._reveal(); | 350 location._reveal(); |
| 351 return location.showView(view); | 351 return location.showView(view); |
| 352 } | 352 } |
| 353 | 353 |
| 354 return this._resolveLocation(locationName).then(location => { | 354 return this._resolveLocation(locationName).then(location => { |
| 355 if (!location) | 355 if (!location) |
| 356 throw new Error('Could not resolve location for view: ' + viewId); | 356 throw new Error('Could not resolve location for view: ' + viewId); |
| 357 location._reveal(); | 357 location._reveal(); |
| 358 return location.showView(view); | 358 return location.showView(view); |
| 359 }); | 359 }); |
| 360 } | 360 } |
| 361 | 361 |
| 362 /** | 362 /** |
| 363 * @param {string=} location | 363 * @param {string=} location |
| 364 * @return {!Promise<?WebInspector.ViewManager._Location>} | 364 * @return {!Promise<?UI.ViewManager._Location>} |
| 365 */ | 365 */ |
| 366 _resolveLocation(location) { | 366 _resolveLocation(location) { |
| 367 if (!location) | 367 if (!location) |
| 368 return /** @type {!Promise<?WebInspector.ViewManager._Location>} */ (Promi
se.resolve(null)); | 368 return /** @type {!Promise<?UI.ViewManager._Location>} */ (Promise.resolve
(null)); |
| 369 | 369 |
| 370 var resolverExtensions = self.runtime.extensions(WebInspector.ViewLocationRe
solver) | 370 var resolverExtensions = self.runtime.extensions(UI.ViewLocationResolver) |
| 371 .filter(extension => extension.descriptor()['na
me'] === location); | 371 .filter(extension => extension.descriptor()['na
me'] === location); |
| 372 if (!resolverExtensions.length) | 372 if (!resolverExtensions.length) |
| 373 throw new Error('Unresolved location: ' + location); | 373 throw new Error('Unresolved location: ' + location); |
| 374 var resolverExtension = resolverExtensions[0]; | 374 var resolverExtension = resolverExtensions[0]; |
| 375 return resolverExtension.instance().then( | 375 return resolverExtension.instance().then( |
| 376 resolver => /** @type {?WebInspector.ViewManager._Location} */ (resolver
.resolveLocation(location))); | 376 resolver => /** @type {?UI.ViewManager._Location} */ (resolver.resolveLo
cation(location))); |
| 377 } | 377 } |
| 378 | 378 |
| 379 /** | 379 /** |
| 380 * @param {function()=} revealCallback | 380 * @param {function()=} revealCallback |
| 381 * @param {string=} location | 381 * @param {string=} location |
| 382 * @param {boolean=} restoreSelection | 382 * @param {boolean=} restoreSelection |
| 383 * @param {boolean=} allowReorder | 383 * @param {boolean=} allowReorder |
| 384 * @return {!WebInspector.TabbedViewLocation} | 384 * @return {!UI.TabbedViewLocation} |
| 385 */ | 385 */ |
| 386 createTabbedLocation(revealCallback, location, restoreSelection, allowReorder)
{ | 386 createTabbedLocation(revealCallback, location, restoreSelection, allowReorder)
{ |
| 387 return new WebInspector.ViewManager._TabbedLocation(this, revealCallback, lo
cation, restoreSelection, allowReorder); | 387 return new UI.ViewManager._TabbedLocation(this, revealCallback, location, re
storeSelection, allowReorder); |
| 388 } | 388 } |
| 389 | 389 |
| 390 /** | 390 /** |
| 391 * @param {function()=} revealCallback | 391 * @param {function()=} revealCallback |
| 392 * @param {string=} location | 392 * @param {string=} location |
| 393 * @return {!WebInspector.ViewLocation} | 393 * @return {!UI.ViewLocation} |
| 394 */ | 394 */ |
| 395 createStackLocation(revealCallback, location) { | 395 createStackLocation(revealCallback, location) { |
| 396 return new WebInspector.ViewManager._StackLocation(this, revealCallback, loc
ation); | 396 return new UI.ViewManager._StackLocation(this, revealCallback, location); |
| 397 } | 397 } |
| 398 | 398 |
| 399 /** | 399 /** |
| 400 * @param {string} location | 400 * @param {string} location |
| 401 * @return {!Array<!WebInspector.View>} | 401 * @return {!Array<!UI.View>} |
| 402 */ | 402 */ |
| 403 _viewsForLocation(location) { | 403 _viewsForLocation(location) { |
| 404 var result = []; | 404 var result = []; |
| 405 for (var id of this._views.keys()) { | 405 for (var id of this._views.keys()) { |
| 406 if (this._locationNameByViewId.get(id) === location) | 406 if (this._locationNameByViewId.get(id) === location) |
| 407 result.push(this._views.get(id)); | 407 result.push(this._views.get(id)); |
| 408 } | 408 } |
| 409 return result; | 409 return result; |
| 410 } | 410 } |
| 411 }; | 411 }; |
| 412 | 412 |
| 413 | 413 |
| 414 /** | 414 /** |
| 415 * @unrestricted | 415 * @unrestricted |
| 416 */ | 416 */ |
| 417 WebInspector.ViewManager._ContainerWidget = class extends WebInspector.VBox { | 417 UI.ViewManager._ContainerWidget = class extends UI.VBox { |
| 418 /** | 418 /** |
| 419 * @param {!WebInspector.View} view | 419 * @param {!UI.View} view |
| 420 */ | 420 */ |
| 421 constructor(view) { | 421 constructor(view) { |
| 422 super(); | 422 super(); |
| 423 this.element.classList.add('flex-auto', 'view-container', 'overflow-auto'); | 423 this.element.classList.add('flex-auto', 'view-container', 'overflow-auto'); |
| 424 this._view = view; | 424 this._view = view; |
| 425 this.element.tabIndex = 0; | 425 this.element.tabIndex = 0; |
| 426 this.setDefaultFocusedElement(this.element); | 426 this.setDefaultFocusedElement(this.element); |
| 427 } | 427 } |
| 428 | 428 |
| 429 /** | 429 /** |
| 430 * @return {!Promise} | 430 * @return {!Promise} |
| 431 */ | 431 */ |
| 432 _materialize() { | 432 _materialize() { |
| 433 if (this._materializePromise) | 433 if (this._materializePromise) |
| 434 return this._materializePromise; | 434 return this._materializePromise; |
| 435 var promises = []; | 435 var promises = []; |
| 436 promises.push(this._view.toolbarItems().then( | 436 promises.push(this._view.toolbarItems().then( |
| 437 WebInspector.ViewManager._populateToolbar.bind(WebInspector.ViewManager,
this.element))); | 437 UI.ViewManager._populateToolbar.bind(UI.ViewManager, this.element))); |
| 438 promises.push(this._view.widget().then(widget => { | 438 promises.push(this._view.widget().then(widget => { |
| 439 // Move focus from |this| to loaded |widget| if any. | 439 // Move focus from |this| to loaded |widget| if any. |
| 440 var shouldFocus = this.element.hasFocus(); | 440 var shouldFocus = this.element.hasFocus(); |
| 441 this.setDefaultFocusedElement(null); | 441 this.setDefaultFocusedElement(null); |
| 442 this._view[WebInspector.View._widgetSymbol] = widget; | 442 this._view[UI.View._widgetSymbol] = widget; |
| 443 widget.show(this.element); | 443 widget.show(this.element); |
| 444 if (shouldFocus) | 444 if (shouldFocus) |
| 445 widget.focus(); | 445 widget.focus(); |
| 446 })); | 446 })); |
| 447 this._materializePromise = Promise.all(promises); | 447 this._materializePromise = Promise.all(promises); |
| 448 return this._materializePromise; | 448 return this._materializePromise; |
| 449 } | 449 } |
| 450 }; | 450 }; |
| 451 | 451 |
| 452 /** | 452 /** |
| 453 * @unrestricted | 453 * @unrestricted |
| 454 */ | 454 */ |
| 455 WebInspector.ViewManager._ExpandableContainerWidget = class extends WebInspector
.VBox { | 455 UI.ViewManager._ExpandableContainerWidget = class extends UI.VBox { |
| 456 /** | 456 /** |
| 457 * @param {!WebInspector.View} view | 457 * @param {!UI.View} view |
| 458 */ | 458 */ |
| 459 constructor(view) { | 459 constructor(view) { |
| 460 super(true); | 460 super(true); |
| 461 this.element.classList.add('flex-none'); | 461 this.element.classList.add('flex-none'); |
| 462 this.registerRequiredCSS('ui/viewContainers.css'); | 462 this.registerRequiredCSS('ui/viewContainers.css'); |
| 463 | 463 |
| 464 this._titleElement = createElementWithClass('div', 'expandable-view-title'); | 464 this._titleElement = createElementWithClass('div', 'expandable-view-title'); |
| 465 this._titleElement.textContent = view.title(); | 465 this._titleElement.textContent = view.title(); |
| 466 this._titleElement.tabIndex = 0; | 466 this._titleElement.tabIndex = 0; |
| 467 this._titleElement.addEventListener('click', this._toggleExpanded.bind(this)
, false); | 467 this._titleElement.addEventListener('click', this._toggleExpanded.bind(this)
, false); |
| 468 this._titleElement.addEventListener('keydown', this._onTitleKeyDown.bind(thi
s), false); | 468 this._titleElement.addEventListener('keydown', this._onTitleKeyDown.bind(thi
s), false); |
| 469 this.contentElement.insertBefore(this._titleElement, this.contentElement.fir
stChild); | 469 this.contentElement.insertBefore(this._titleElement, this.contentElement.fir
stChild); |
| 470 | 470 |
| 471 this.contentElement.createChild('content'); | 471 this.contentElement.createChild('content'); |
| 472 this._view = view; | 472 this._view = view; |
| 473 view[WebInspector.ViewManager._ExpandableContainerWidget._symbol] = this; | 473 view[UI.ViewManager._ExpandableContainerWidget._symbol] = this; |
| 474 } | 474 } |
| 475 | 475 |
| 476 /** | 476 /** |
| 477 * @return {!Promise} | 477 * @return {!Promise} |
| 478 */ | 478 */ |
| 479 _materialize() { | 479 _materialize() { |
| 480 if (this._materializePromise) | 480 if (this._materializePromise) |
| 481 return this._materializePromise; | 481 return this._materializePromise; |
| 482 var promises = []; | 482 var promises = []; |
| 483 promises.push(this._view.toolbarItems().then( | 483 promises.push(this._view.toolbarItems().then( |
| 484 WebInspector.ViewManager._populateToolbar.bind(WebInspector.ViewManager,
this._titleElement))); | 484 UI.ViewManager._populateToolbar.bind(UI.ViewManager, this._titleElement)
)); |
| 485 promises.push(this._view.widget().then(widget => { | 485 promises.push(this._view.widget().then(widget => { |
| 486 this._widget = widget; | 486 this._widget = widget; |
| 487 this._view[WebInspector.View._widgetSymbol] = widget; | 487 this._view[UI.View._widgetSymbol] = widget; |
| 488 widget.show(this.element); | 488 widget.show(this.element); |
| 489 })); | 489 })); |
| 490 this._materializePromise = Promise.all(promises); | 490 this._materializePromise = Promise.all(promises); |
| 491 return this._materializePromise; | 491 return this._materializePromise; |
| 492 } | 492 } |
| 493 | 493 |
| 494 /** | 494 /** |
| 495 * @return {!Promise} | 495 * @return {!Promise} |
| 496 */ | 496 */ |
| 497 _expand() { | 497 _expand() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 512 if (this._titleElement.classList.contains('expanded')) | 512 if (this._titleElement.classList.contains('expanded')) |
| 513 this._collapse(); | 513 this._collapse(); |
| 514 else | 514 else |
| 515 this._expand(); | 515 this._expand(); |
| 516 } | 516 } |
| 517 | 517 |
| 518 /** | 518 /** |
| 519 * @param {!Event} event | 519 * @param {!Event} event |
| 520 */ | 520 */ |
| 521 _onTitleKeyDown(event) { | 521 _onTitleKeyDown(event) { |
| 522 if (isEnterKey(event) || event.keyCode === WebInspector.KeyboardShortcut.Key
s.Space.code) | 522 if (isEnterKey(event) || event.keyCode === UI.KeyboardShortcut.Keys.Space.co
de) |
| 523 this._toggleExpanded(); | 523 this._toggleExpanded(); |
| 524 } | 524 } |
| 525 }; | 525 }; |
| 526 | 526 |
| 527 WebInspector.ViewManager._ExpandableContainerWidget._symbol = Symbol('container'
); | 527 UI.ViewManager._ExpandableContainerWidget._symbol = Symbol('container'); |
| 528 | 528 |
| 529 /** | 529 /** |
| 530 * @unrestricted | 530 * @unrestricted |
| 531 */ | 531 */ |
| 532 WebInspector.ViewManager._Location = class { | 532 UI.ViewManager._Location = class { |
| 533 /** | 533 /** |
| 534 * @param {!WebInspector.ViewManager} manager | 534 * @param {!UI.ViewManager} manager |
| 535 * @param {!WebInspector.Widget} widget | 535 * @param {!UI.Widget} widget |
| 536 * @param {function()=} revealCallback | 536 * @param {function()=} revealCallback |
| 537 */ | 537 */ |
| 538 constructor(manager, widget, revealCallback) { | 538 constructor(manager, widget, revealCallback) { |
| 539 this._manager = manager; | 539 this._manager = manager; |
| 540 this._revealCallback = revealCallback; | 540 this._revealCallback = revealCallback; |
| 541 this._widget = widget; | 541 this._widget = widget; |
| 542 } | 542 } |
| 543 | 543 |
| 544 /** | 544 /** |
| 545 * @return {!WebInspector.Widget} | 545 * @return {!UI.Widget} |
| 546 */ | 546 */ |
| 547 widget() { | 547 widget() { |
| 548 return this._widget; | 548 return this._widget; |
| 549 } | 549 } |
| 550 | 550 |
| 551 _reveal() { | 551 _reveal() { |
| 552 if (this._revealCallback) | 552 if (this._revealCallback) |
| 553 this._revealCallback(); | 553 this._revealCallback(); |
| 554 } | 554 } |
| 555 }; | 555 }; |
| 556 | 556 |
| 557 WebInspector.ViewManager._Location.symbol = Symbol('location'); | 557 UI.ViewManager._Location.symbol = Symbol('location'); |
| 558 | 558 |
| 559 /** | 559 /** |
| 560 * @implements {WebInspector.TabbedViewLocation} | 560 * @implements {UI.TabbedViewLocation} |
| 561 * @unrestricted | 561 * @unrestricted |
| 562 */ | 562 */ |
| 563 WebInspector.ViewManager._TabbedLocation = class extends WebInspector.ViewManage
r._Location { | 563 UI.ViewManager._TabbedLocation = class extends UI.ViewManager._Location { |
| 564 /** | 564 /** |
| 565 * @param {!WebInspector.ViewManager} manager | 565 * @param {!UI.ViewManager} manager |
| 566 * @param {function()=} revealCallback | 566 * @param {function()=} revealCallback |
| 567 * @param {string=} location | 567 * @param {string=} location |
| 568 * @param {boolean=} restoreSelection | 568 * @param {boolean=} restoreSelection |
| 569 * @param {boolean=} allowReorder | 569 * @param {boolean=} allowReorder |
| 570 */ | 570 */ |
| 571 constructor(manager, revealCallback, location, restoreSelection, allowReorder)
{ | 571 constructor(manager, revealCallback, location, restoreSelection, allowReorder)
{ |
| 572 var tabbedPane = new WebInspector.TabbedPane(); | 572 var tabbedPane = new UI.TabbedPane(); |
| 573 if (allowReorder) | 573 if (allowReorder) |
| 574 tabbedPane.setAllowTabReorder(true); | 574 tabbedPane.setAllowTabReorder(true); |
| 575 | 575 |
| 576 super(manager, tabbedPane, revealCallback); | 576 super(manager, tabbedPane, revealCallback); |
| 577 this._tabbedPane = tabbedPane; | 577 this._tabbedPane = tabbedPane; |
| 578 this._allowReorder = allowReorder; | 578 this._allowReorder = allowReorder; |
| 579 | 579 |
| 580 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabSelected
, this._tabSelected, this); | 580 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta
bSelected, this); |
| 581 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabClosed,
this._tabClosed, this); | 581 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabClosed, this._tabC
losed, this); |
| 582 this._closeableTabSetting = WebInspector.settings.createSetting(location + '
-closeableTabs', {}); | 582 this._closeableTabSetting = Common.settings.createSetting(location + '-close
ableTabs', {}); |
| 583 this._tabOrderSetting = WebInspector.settings.createSetting(location + '-tab
Order', {}); | 583 this._tabOrderSetting = Common.settings.createSetting(location + '-tabOrder'
, {}); |
| 584 this._tabbedPane.addEventListener(WebInspector.TabbedPane.Events.TabOrderCha
nged, this._persistTabOrder, this); | 584 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabOrderChanged, this
._persistTabOrder, this); |
| 585 if (restoreSelection) | 585 if (restoreSelection) |
| 586 this._lastSelectedTabSetting = WebInspector.settings.createSetting(locatio
n + '-selectedTab', ''); | 586 this._lastSelectedTabSetting = Common.settings.createSetting(location + '-
selectedTab', ''); |
| 587 | 587 |
| 588 /** @type {!Map.<string, !WebInspector.View>} */ | 588 /** @type {!Map.<string, !UI.View>} */ |
| 589 this._views = new Map(); | 589 this._views = new Map(); |
| 590 | 590 |
| 591 if (location) | 591 if (location) |
| 592 this.appendApplicableItems(location); | 592 this.appendApplicableItems(location); |
| 593 } | 593 } |
| 594 | 594 |
| 595 /** | 595 /** |
| 596 * @override | 596 * @override |
| 597 * @return {!WebInspector.Widget} | 597 * @return {!UI.Widget} |
| 598 */ | 598 */ |
| 599 widget() { | 599 widget() { |
| 600 return this._tabbedPane; | 600 return this._tabbedPane; |
| 601 } | 601 } |
| 602 | 602 |
| 603 /** | 603 /** |
| 604 * @override | 604 * @override |
| 605 * @return {!WebInspector.TabbedPane} | 605 * @return {!UI.TabbedPane} |
| 606 */ | 606 */ |
| 607 tabbedPane() { | 607 tabbedPane() { |
| 608 return this._tabbedPane; | 608 return this._tabbedPane; |
| 609 } | 609 } |
| 610 | 610 |
| 611 /** | 611 /** |
| 612 * @override | 612 * @override |
| 613 */ | 613 */ |
| 614 enableMoreTabsButton() { | 614 enableMoreTabsButton() { |
| 615 this._tabbedPane.leftToolbar().appendToolbarItem( | 615 this._tabbedPane.leftToolbar().appendToolbarItem( |
| 616 new WebInspector.ToolbarMenuButton(this._appendTabsToMenu.bind(this))); | 616 new UI.ToolbarMenuButton(this._appendTabsToMenu.bind(this))); |
| 617 this._tabbedPane.disableOverflowMenu(); | 617 this._tabbedPane.disableOverflowMenu(); |
| 618 } | 618 } |
| 619 | 619 |
| 620 /** | 620 /** |
| 621 * @override | 621 * @override |
| 622 * @param {string} locationName | 622 * @param {string} locationName |
| 623 */ | 623 */ |
| 624 appendApplicableItems(locationName) { | 624 appendApplicableItems(locationName) { |
| 625 var views = this._manager._viewsForLocation(locationName); | 625 var views = this._manager._viewsForLocation(locationName); |
| 626 if (this._allowReorder) { | 626 if (this._allowReorder) { |
| 627 var i = 0; | 627 var i = 0; |
| 628 var persistedOrders = this._tabOrderSetting.get(); | 628 var persistedOrders = this._tabOrderSetting.get(); |
| 629 var orders = new Map(); | 629 var orders = new Map(); |
| 630 for (var view of views) | 630 for (var view of views) |
| 631 orders.set( | 631 orders.set( |
| 632 view.viewId(), | 632 view.viewId(), |
| 633 persistedOrders[view.viewId()] || (++i) * WebInspector.ViewManager._
TabbedLocation.orderStep); | 633 persistedOrders[view.viewId()] || (++i) * UI.ViewManager._TabbedLoca
tion.orderStep); |
| 634 views.sort((a, b) => orders.get(a.viewId()) - orders.get(b.viewId())); | 634 views.sort((a, b) => orders.get(a.viewId()) - orders.get(b.viewId())); |
| 635 } | 635 } |
| 636 | 636 |
| 637 for (var view of views) { | 637 for (var view of views) { |
| 638 var id = view.viewId(); | 638 var id = view.viewId(); |
| 639 this._views.set(id, view); | 639 this._views.set(id, view); |
| 640 view[WebInspector.ViewManager._Location.symbol] = this; | 640 view[UI.ViewManager._Location.symbol] = this; |
| 641 if (view.isTransient()) | 641 if (view.isTransient()) |
| 642 continue; | 642 continue; |
| 643 if (!view.isCloseable()) | 643 if (!view.isCloseable()) |
| 644 this._appendTab(view); | 644 this._appendTab(view); |
| 645 else if (this._closeableTabSetting.get()[id]) | 645 else if (this._closeableTabSetting.get()[id]) |
| 646 this._appendTab(view); | 646 this._appendTab(view); |
| 647 } | 647 } |
| 648 if (this._lastSelectedTabSetting && this._tabbedPane.hasTab(this._lastSelect
edTabSetting.get())) | 648 if (this._lastSelectedTabSetting && this._tabbedPane.hasTab(this._lastSelect
edTabSetting.get())) |
| 649 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); | 649 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); |
| 650 } | 650 } |
| 651 | 651 |
| 652 /** | 652 /** |
| 653 * @param {!WebInspector.ContextMenu} contextMenu | 653 * @param {!UI.ContextMenu} contextMenu |
| 654 */ | 654 */ |
| 655 _appendTabsToMenu(contextMenu) { | 655 _appendTabsToMenu(contextMenu) { |
| 656 for (var view of this._views.values()) { | 656 for (var view of this._views.values()) { |
| 657 var title = WebInspector.UIString(view.title()); | 657 var title = Common.UIString(view.title()); |
| 658 contextMenu.appendItem(title, this.showView.bind(this, view)); | 658 contextMenu.appendItem(title, this.showView.bind(this, view)); |
| 659 } | 659 } |
| 660 } | 660 } |
| 661 | 661 |
| 662 /** | 662 /** |
| 663 * @param {!WebInspector.View} view | 663 * @param {!UI.View} view |
| 664 * @param {number=} index | 664 * @param {number=} index |
| 665 */ | 665 */ |
| 666 _appendTab(view, index) { | 666 _appendTab(view, index) { |
| 667 this._tabbedPane.appendTab( | 667 this._tabbedPane.appendTab( |
| 668 view.viewId(), view.title(), new WebInspector.ViewManager._ContainerWidg
et(view), undefined, false, | 668 view.viewId(), view.title(), new UI.ViewManager._ContainerWidget(view),
undefined, false, |
| 669 view.isCloseable() || view.isTransient(), index); | 669 view.isCloseable() || view.isTransient(), index); |
| 670 } | 670 } |
| 671 | 671 |
| 672 /** | 672 /** |
| 673 * @override | 673 * @override |
| 674 * @param {!WebInspector.View} view | 674 * @param {!UI.View} view |
| 675 * @param {?WebInspector.View=} insertBefore | 675 * @param {?UI.View=} insertBefore |
| 676 */ | 676 */ |
| 677 appendView(view, insertBefore) { | 677 appendView(view, insertBefore) { |
| 678 if (this._tabbedPane.hasTab(view.viewId())) | 678 if (this._tabbedPane.hasTab(view.viewId())) |
| 679 return; | 679 return; |
| 680 view[WebInspector.ViewManager._Location.symbol] = this; | 680 view[UI.ViewManager._Location.symbol] = this; |
| 681 this._manager._views.set(view.viewId(), view); | 681 this._manager._views.set(view.viewId(), view); |
| 682 this._views.set(view.viewId(), view); | 682 this._views.set(view.viewId(), view); |
| 683 | 683 |
| 684 var index = undefined; | 684 var index = undefined; |
| 685 var tabIds = this._tabbedPane.tabIds(); | 685 var tabIds = this._tabbedPane.tabIds(); |
| 686 if (this._allowReorder) { | 686 if (this._allowReorder) { |
| 687 var orderSetting = this._tabOrderSetting.get(); | 687 var orderSetting = this._tabOrderSetting.get(); |
| 688 var order = orderSetting[view.viewId()]; | 688 var order = orderSetting[view.viewId()]; |
| 689 for (var i = 0; order && i < tabIds.length; ++i) { | 689 for (var i = 0; order && i < tabIds.length; ++i) { |
| 690 if (orderSetting[tabIds[i]] && orderSetting[tabIds[i]] > order) { | 690 if (orderSetting[tabIds[i]] && orderSetting[tabIds[i]] > order) { |
| 691 index = i; | 691 index = i; |
| 692 break; | 692 break; |
| 693 } | 693 } |
| 694 } | 694 } |
| 695 } else if (insertBefore) { | 695 } else if (insertBefore) { |
| 696 for (var i = 0; i < tabIds.length; ++i) { | 696 for (var i = 0; i < tabIds.length; ++i) { |
| 697 if (tabIds[i] === insertBefore.viewId()) { | 697 if (tabIds[i] === insertBefore.viewId()) { |
| 698 index = i; | 698 index = i; |
| 699 break; | 699 break; |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 } | 702 } |
| 703 this._appendTab(view, index); | 703 this._appendTab(view, index); |
| 704 } | 704 } |
| 705 | 705 |
| 706 /** | 706 /** |
| 707 * @override | 707 * @override |
| 708 * @param {!WebInspector.View} view | 708 * @param {!UI.View} view |
| 709 * @param {?WebInspector.View=} insertBefore | 709 * @param {?UI.View=} insertBefore |
| 710 * @return {!Promise} | 710 * @return {!Promise} |
| 711 */ | 711 */ |
| 712 showView(view, insertBefore) { | 712 showView(view, insertBefore) { |
| 713 this.appendView(view, insertBefore); | 713 this.appendView(view, insertBefore); |
| 714 this._tabbedPane.selectTab(view.viewId()); | 714 this._tabbedPane.selectTab(view.viewId()); |
| 715 this._tabbedPane.focus(); | 715 this._tabbedPane.focus(); |
| 716 return this._materializeWidget(view); | 716 return this._materializeWidget(view); |
| 717 } | 717 } |
| 718 | 718 |
| 719 /** | 719 /** |
| 720 * @param {!WebInspector.View} view | 720 * @param {!UI.View} view |
| 721 * @override | 721 * @override |
| 722 */ | 722 */ |
| 723 removeView(view) { | 723 removeView(view) { |
| 724 if (!this._tabbedPane.hasTab(view.viewId())) | 724 if (!this._tabbedPane.hasTab(view.viewId())) |
| 725 return; | 725 return; |
| 726 | 726 |
| 727 delete view[WebInspector.ViewManager._Location.symbol]; | 727 delete view[UI.ViewManager._Location.symbol]; |
| 728 this._manager._views.delete(view.viewId()); | 728 this._manager._views.delete(view.viewId()); |
| 729 this._views.delete(view.viewId()); | 729 this._views.delete(view.viewId()); |
| 730 this._tabbedPane.closeTab(view.viewId()); | 730 this._tabbedPane.closeTab(view.viewId()); |
| 731 } | 731 } |
| 732 | 732 |
| 733 /** | 733 /** |
| 734 * @param {!WebInspector.Event} event | 734 * @param {!Common.Event} event |
| 735 */ | 735 */ |
| 736 _tabSelected(event) { | 736 _tabSelected(event) { |
| 737 var tabId = /** @type {string} */ (event.data.tabId); | 737 var tabId = /** @type {string} */ (event.data.tabId); |
| 738 if (this._lastSelectedTabSetting && event.data['isUserGesture']) | 738 if (this._lastSelectedTabSetting && event.data['isUserGesture']) |
| 739 this._lastSelectedTabSetting.set(tabId); | 739 this._lastSelectedTabSetting.set(tabId); |
| 740 var view = this._views.get(tabId); | 740 var view = this._views.get(tabId); |
| 741 if (!view) | 741 if (!view) |
| 742 return; | 742 return; |
| 743 | 743 |
| 744 this._materializeWidget(view); | 744 this._materializeWidget(view); |
| 745 | 745 |
| 746 if (view.isCloseable()) { | 746 if (view.isCloseable()) { |
| 747 var tabs = this._closeableTabSetting.get(); | 747 var tabs = this._closeableTabSetting.get(); |
| 748 if (!tabs[tabId]) { | 748 if (!tabs[tabId]) { |
| 749 tabs[tabId] = true; | 749 tabs[tabId] = true; |
| 750 this._closeableTabSetting.set(tabs); | 750 this._closeableTabSetting.set(tabs); |
| 751 } | 751 } |
| 752 } | 752 } |
| 753 } | 753 } |
| 754 | 754 |
| 755 /** | 755 /** |
| 756 * @param {!WebInspector.Event} event | 756 * @param {!Common.Event} event |
| 757 */ | 757 */ |
| 758 _tabClosed(event) { | 758 _tabClosed(event) { |
| 759 var id = /** @type {string} */ (event.data['tabId']); | 759 var id = /** @type {string} */ (event.data['tabId']); |
| 760 var tabs = this._closeableTabSetting.get(); | 760 var tabs = this._closeableTabSetting.get(); |
| 761 if (tabs[id]) { | 761 if (tabs[id]) { |
| 762 delete tabs[id]; | 762 delete tabs[id]; |
| 763 this._closeableTabSetting.set(tabs); | 763 this._closeableTabSetting.set(tabs); |
| 764 } | 764 } |
| 765 } | 765 } |
| 766 | 766 |
| 767 /** | 767 /** |
| 768 * @param {!WebInspector.View} view | 768 * @param {!UI.View} view |
| 769 * @return {!Promise} | 769 * @return {!Promise} |
| 770 */ | 770 */ |
| 771 _materializeWidget(view) { | 771 _materializeWidget(view) { |
| 772 var widget = /** @type {!WebInspector.ViewManager._ContainerWidget} */ (this
._tabbedPane.tabView(view.viewId())); | 772 var widget = /** @type {!UI.ViewManager._ContainerWidget} */ (this._tabbedPa
ne.tabView(view.viewId())); |
| 773 return widget._materialize(); | 773 return widget._materialize(); |
| 774 } | 774 } |
| 775 | 775 |
| 776 /** | 776 /** |
| 777 * @param {!WebInspector.Event} event | 777 * @param {!Common.Event} event |
| 778 */ | 778 */ |
| 779 _persistTabOrder(event) { | 779 _persistTabOrder(event) { |
| 780 var tabIds = this._tabbedPane.tabIds(); | 780 var tabIds = this._tabbedPane.tabIds(); |
| 781 var tabOrders = {}; | 781 var tabOrders = {}; |
| 782 for (var i = 0; i < tabIds.length; i++) | 782 for (var i = 0; i < tabIds.length; i++) |
| 783 tabOrders[tabIds[i]] = (i + 1) * WebInspector.ViewManager._TabbedLocation.
orderStep; | 783 tabOrders[tabIds[i]] = (i + 1) * UI.ViewManager._TabbedLocation.orderStep; |
| 784 this._tabOrderSetting.set(tabOrders); | 784 this._tabOrderSetting.set(tabOrders); |
| 785 } | 785 } |
| 786 }; | 786 }; |
| 787 | 787 |
| 788 WebInspector.ViewManager._TabbedLocation.orderStep = 10; // Keep in sync with d
escriptors. | 788 UI.ViewManager._TabbedLocation.orderStep = 10; // Keep in sync with descriptors
. |
| 789 | 789 |
| 790 /** | 790 /** |
| 791 * @implements {WebInspector.ViewLocation} | 791 * @implements {UI.ViewLocation} |
| 792 * @unrestricted | 792 * @unrestricted |
| 793 */ | 793 */ |
| 794 WebInspector.ViewManager._StackLocation = class extends WebInspector.ViewManager
._Location { | 794 UI.ViewManager._StackLocation = class extends UI.ViewManager._Location { |
| 795 /** | 795 /** |
| 796 * @param {!WebInspector.ViewManager} manager | 796 * @param {!UI.ViewManager} manager |
| 797 * @param {function()=} revealCallback | 797 * @param {function()=} revealCallback |
| 798 * @param {string=} location | 798 * @param {string=} location |
| 799 */ | 799 */ |
| 800 constructor(manager, revealCallback, location) { | 800 constructor(manager, revealCallback, location) { |
| 801 var vbox = new WebInspector.VBox(); | 801 var vbox = new UI.VBox(); |
| 802 super(manager, vbox, revealCallback); | 802 super(manager, vbox, revealCallback); |
| 803 this._vbox = vbox; | 803 this._vbox = vbox; |
| 804 | 804 |
| 805 /** @type {!Map<string, !WebInspector.ViewManager._ExpandableContainerWidget
>} */ | 805 /** @type {!Map<string, !UI.ViewManager._ExpandableContainerWidget>} */ |
| 806 this._expandableContainers = new Map(); | 806 this._expandableContainers = new Map(); |
| 807 | 807 |
| 808 if (location) | 808 if (location) |
| 809 this.appendApplicableItems(location); | 809 this.appendApplicableItems(location); |
| 810 } | 810 } |
| 811 | 811 |
| 812 /** | 812 /** |
| 813 * @override | 813 * @override |
| 814 * @param {!WebInspector.View} view | 814 * @param {!UI.View} view |
| 815 * @param {?WebInspector.View=} insertBefore | 815 * @param {?UI.View=} insertBefore |
| 816 */ | 816 */ |
| 817 appendView(view, insertBefore) { | 817 appendView(view, insertBefore) { |
| 818 var container = this._expandableContainers.get(view.viewId()); | 818 var container = this._expandableContainers.get(view.viewId()); |
| 819 if (!container) { | 819 if (!container) { |
| 820 view[WebInspector.ViewManager._Location.symbol] = this; | 820 view[UI.ViewManager._Location.symbol] = this; |
| 821 this._manager._views.set(view.viewId(), view); | 821 this._manager._views.set(view.viewId(), view); |
| 822 container = new WebInspector.ViewManager._ExpandableContainerWidget(view); | 822 container = new UI.ViewManager._ExpandableContainerWidget(view); |
| 823 var beforeElement = null; | 823 var beforeElement = null; |
| 824 if (insertBefore) { | 824 if (insertBefore) { |
| 825 var beforeContainer = insertBefore[WebInspector.ViewManager._ExpandableC
ontainerWidget._symbol]; | 825 var beforeContainer = insertBefore[UI.ViewManager._ExpandableContainerWi
dget._symbol]; |
| 826 beforeElement = beforeContainer ? beforeContainer.element : null; | 826 beforeElement = beforeContainer ? beforeContainer.element : null; |
| 827 } | 827 } |
| 828 container.show(this._vbox.contentElement, beforeElement); | 828 container.show(this._vbox.contentElement, beforeElement); |
| 829 this._expandableContainers.set(view.viewId(), container); | 829 this._expandableContainers.set(view.viewId(), container); |
| 830 } | 830 } |
| 831 } | 831 } |
| 832 | 832 |
| 833 /** | 833 /** |
| 834 * @override | 834 * @override |
| 835 * @param {!WebInspector.View} view | 835 * @param {!UI.View} view |
| 836 * @param {?WebInspector.View=} insertBefore | 836 * @param {?UI.View=} insertBefore |
| 837 * @return {!Promise} | 837 * @return {!Promise} |
| 838 */ | 838 */ |
| 839 showView(view, insertBefore) { | 839 showView(view, insertBefore) { |
| 840 this.appendView(view, insertBefore); | 840 this.appendView(view, insertBefore); |
| 841 var container = this._expandableContainers.get(view.viewId()); | 841 var container = this._expandableContainers.get(view.viewId()); |
| 842 return container._expand(); | 842 return container._expand(); |
| 843 } | 843 } |
| 844 | 844 |
| 845 /** | 845 /** |
| 846 * @param {!WebInspector.View} view | 846 * @param {!UI.View} view |
| 847 * @override | 847 * @override |
| 848 */ | 848 */ |
| 849 removeView(view) { | 849 removeView(view) { |
| 850 var container = this._expandableContainers.get(view.viewId()); | 850 var container = this._expandableContainers.get(view.viewId()); |
| 851 if (!container) | 851 if (!container) |
| 852 return; | 852 return; |
| 853 | 853 |
| 854 container.detach(); | 854 container.detach(); |
| 855 this._expandableContainers.delete(view.viewId()); | 855 this._expandableContainers.delete(view.viewId()); |
| 856 delete view[WebInspector.ViewManager._Location.symbol]; | 856 delete view[UI.ViewManager._Location.symbol]; |
| 857 this._manager._views.delete(view.viewId()); | 857 this._manager._views.delete(view.viewId()); |
| 858 } | 858 } |
| 859 | 859 |
| 860 /** | 860 /** |
| 861 * @override | 861 * @override |
| 862 * @param {string} locationName | 862 * @param {string} locationName |
| 863 */ | 863 */ |
| 864 appendApplicableItems(locationName) { | 864 appendApplicableItems(locationName) { |
| 865 for (var view of this._manager._viewsForLocation(locationName)) | 865 for (var view of this._manager._viewsForLocation(locationName)) |
| 866 this.appendView(view); | 866 this.appendView(view); |
| 867 } | 867 } |
| 868 }; | 868 }; |
| 869 | 869 |
| 870 /** | 870 /** |
| 871 * @type {!WebInspector.ViewManager} | 871 * @type {!UI.ViewManager} |
| 872 */ | 872 */ |
| 873 WebInspector.viewManager; | 873 UI.viewManager; |
| OLD | NEW |