| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 /** | 30 /** |
| 31 * @implements {WebInspector.FlameChartDataProvider} | 31 * @implements {UI.FlameChartDataProvider} |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 WebInspector.TimelineFlameChartDataProviderBase = class { | 34 Timeline.TimelineFlameChartDataProviderBase = class { |
| 35 /** | 35 /** |
| 36 * @param {!WebInspector.TimelineModel} model | 36 * @param {!TimelineModel.TimelineModel} model |
| 37 * @param {!Array<!WebInspector.TimelineModel.Filter>} filters | 37 * @param {!Array<!TimelineModel.TimelineModel.Filter>} filters |
| 38 */ | 38 */ |
| 39 constructor(model, filters) { | 39 constructor(model, filters) { |
| 40 WebInspector.FlameChartDataProvider.call(this); | 40 UI.FlameChartDataProvider.call(this); |
| 41 this.reset(); | 41 this.reset(); |
| 42 this._model = model; | 42 this._model = model; |
| 43 /** @type {?WebInspector.FlameChart.TimelineData} */ | 43 /** @type {?UI.FlameChart.TimelineData} */ |
| 44 this._timelineData; | 44 this._timelineData; |
| 45 this._font = '11px ' + WebInspector.fontFamily(); | 45 this._font = '11px ' + Host.fontFamily(); |
| 46 this._filters = filters; | 46 this._filters = filters; |
| 47 } | 47 } |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * @override | 50 * @override |
| 51 * @return {number} | 51 * @return {number} |
| 52 */ | 52 */ |
| 53 barHeight() { | 53 barHeight() { |
| 54 return 17; | 54 return 17; |
| 55 } | 55 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 * @override | 191 * @override |
| 192 * @param {number} entryIndex | 192 * @param {number} entryIndex |
| 193 * @return {string} | 193 * @return {string} |
| 194 */ | 194 */ |
| 195 textColor(entryIndex) { | 195 textColor(entryIndex) { |
| 196 return '#333'; | 196 return '#333'; |
| 197 } | 197 } |
| 198 | 198 |
| 199 /** | 199 /** |
| 200 * @param {number} entryIndex | 200 * @param {number} entryIndex |
| 201 * @return {?WebInspector.TimelineSelection} | 201 * @return {?Timeline.TimelineSelection} |
| 202 */ | 202 */ |
| 203 createSelection(entryIndex) { | 203 createSelection(entryIndex) { |
| 204 return null; | 204 return null; |
| 205 } | 205 } |
| 206 | 206 |
| 207 /** | 207 /** |
| 208 * @override | 208 * @override |
| 209 * @return {!WebInspector.FlameChart.TimelineData} | 209 * @return {!UI.FlameChart.TimelineData} |
| 210 */ | 210 */ |
| 211 timelineData() { | 211 timelineData() { |
| 212 throw new Error('Not implemented'); | 212 throw new Error('Not implemented'); |
| 213 } | 213 } |
| 214 | 214 |
| 215 /** | 215 /** |
| 216 * @param {!WebInspector.TracingModel.Event} event | 216 * @param {!SDK.TracingModel.Event} event |
| 217 * @return {boolean} | 217 * @return {boolean} |
| 218 */ | 218 */ |
| 219 _isVisible(event) { | 219 _isVisible(event) { |
| 220 return this._filters.every(function(filter) { | 220 return this._filters.every(function(filter) { |
| 221 return filter.accept(event); | 221 return filter.accept(event); |
| 222 }); | 222 }); |
| 223 } | 223 } |
| 224 }; | 224 }; |
| 225 | 225 |
| 226 /** | 226 /** |
| 227 * @enum {symbol} | 227 * @enum {symbol} |
| 228 */ | 228 */ |
| 229 WebInspector.TimelineFlameChartEntryType = { | 229 Timeline.TimelineFlameChartEntryType = { |
| 230 Frame: Symbol('Frame'), | 230 Frame: Symbol('Frame'), |
| 231 Event: Symbol('Event'), | 231 Event: Symbol('Event'), |
| 232 InteractionRecord: Symbol('InteractionRecord'), | 232 InteractionRecord: Symbol('InteractionRecord'), |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 /** | 235 /** |
| 236 * @unrestricted | 236 * @unrestricted |
| 237 */ | 237 */ |
| 238 WebInspector.TimelineFlameChartDataProvider = class extends WebInspector.Timelin
eFlameChartDataProviderBase { | 238 Timeline.TimelineFlameChartDataProvider = class extends Timeline.TimelineFlameCh
artDataProviderBase { |
| 239 /** | 239 /** |
| 240 * @param {!WebInspector.TimelineModel} model | 240 * @param {!TimelineModel.TimelineModel} model |
| 241 * @param {!WebInspector.TimelineFrameModel} frameModel | 241 * @param {!TimelineModel.TimelineFrameModel} frameModel |
| 242 * @param {!WebInspector.TimelineIRModel} irModel | 242 * @param {!TimelineModel.TimelineIRModel} irModel |
| 243 * @param {!Array<!WebInspector.TimelineModel.Filter>} filters | 243 * @param {!Array<!TimelineModel.TimelineModel.Filter>} filters |
| 244 */ | 244 */ |
| 245 constructor(model, frameModel, irModel, filters) { | 245 constructor(model, frameModel, irModel, filters) { |
| 246 super(model, filters); | 246 super(model, filters); |
| 247 this._frameModel = frameModel; | 247 this._frameModel = frameModel; |
| 248 this._irModel = irModel; | 248 this._irModel = irModel; |
| 249 this._consoleColorGenerator = | 249 this._consoleColorGenerator = |
| 250 new WebInspector.FlameChart.ColorGenerator({min: 30, max: 55}, {min: 70,
max: 100, count: 6}, 50, 0.7); | 250 new UI.FlameChart.ColorGenerator({min: 30, max: 55}, {min: 70, max: 100,
count: 6}, 50, 0.7); |
| 251 | 251 |
| 252 this._headerLevel1 = { | 252 this._headerLevel1 = { |
| 253 padding: 4, | 253 padding: 4, |
| 254 height: 17, | 254 height: 17, |
| 255 collapsible: true, | 255 collapsible: true, |
| 256 color: WebInspector.themeSupport.patchColor('#222', WebInspector.ThemeSupp
ort.ColorUsage.Foreground), | 256 color: UI.themeSupport.patchColor('#222', UI.ThemeSupport.ColorUsage.Foreg
round), |
| 257 font: this._font, | 257 font: this._font, |
| 258 backgroundColor: WebInspector.themeSupport.patchColor('white', WebInspecto
r.ThemeSupport.ColorUsage.Background), | 258 backgroundColor: UI.themeSupport.patchColor('white', UI.ThemeSupport.Color
Usage.Background), |
| 259 nestingLevel: 0 | 259 nestingLevel: 0 |
| 260 }; | 260 }; |
| 261 | 261 |
| 262 this._headerLevel2 = { | 262 this._headerLevel2 = { |
| 263 padding: 2, | 263 padding: 2, |
| 264 height: 17, | 264 height: 17, |
| 265 collapsible: false, | 265 collapsible: false, |
| 266 font: this._font, | 266 font: this._font, |
| 267 color: WebInspector.themeSupport.patchColor('#222', WebInspector.ThemeSupp
ort.ColorUsage.Foreground), | 267 color: UI.themeSupport.patchColor('#222', UI.ThemeSupport.ColorUsage.Foreg
round), |
| 268 backgroundColor: WebInspector.themeSupport.patchColor('white', WebInspecto
r.ThemeSupport.ColorUsage.Background), | 268 backgroundColor: UI.themeSupport.patchColor('white', UI.ThemeSupport.Color
Usage.Background), |
| 269 nestingLevel: 1, | 269 nestingLevel: 1, |
| 270 shareHeaderLine: true | 270 shareHeaderLine: true |
| 271 }; | 271 }; |
| 272 | 272 |
| 273 this._interactionsHeaderLevel1 = { | 273 this._interactionsHeaderLevel1 = { |
| 274 padding: 4, | 274 padding: 4, |
| 275 height: 17, | 275 height: 17, |
| 276 collapsible: true, | 276 collapsible: true, |
| 277 color: WebInspector.themeSupport.patchColor('#222', WebInspector.ThemeSupp
ort.ColorUsage.Foreground), | 277 color: UI.themeSupport.patchColor('#222', UI.ThemeSupport.ColorUsage.Foreg
round), |
| 278 font: this._font, | 278 font: this._font, |
| 279 backgroundColor: WebInspector.themeSupport.patchColor('white', WebInspecto
r.ThemeSupport.ColorUsage.Background), | 279 backgroundColor: UI.themeSupport.patchColor('white', UI.ThemeSupport.Color
Usage.Background), |
| 280 nestingLevel: 0, | 280 nestingLevel: 0, |
| 281 useFirstLineForOverview: true, | 281 useFirstLineForOverview: true, |
| 282 shareHeaderLine: true | 282 shareHeaderLine: true |
| 283 }; | 283 }; |
| 284 | 284 |
| 285 this._interactionsHeaderLevel2 = { | 285 this._interactionsHeaderLevel2 = { |
| 286 padding: 2, | 286 padding: 2, |
| 287 height: 17, | 287 height: 17, |
| 288 collapsible: true, | 288 collapsible: true, |
| 289 color: WebInspector.themeSupport.patchColor('#222', WebInspector.ThemeSupp
ort.ColorUsage.Foreground), | 289 color: UI.themeSupport.patchColor('#222', UI.ThemeSupport.ColorUsage.Foreg
round), |
| 290 font: this._font, | 290 font: this._font, |
| 291 backgroundColor: WebInspector.themeSupport.patchColor('white', WebInspecto
r.ThemeSupport.ColorUsage.Background), | 291 backgroundColor: UI.themeSupport.patchColor('white', UI.ThemeSupport.Color
Usage.Background), |
| 292 nestingLevel: 1, | 292 nestingLevel: 1, |
| 293 shareHeaderLine: true | 293 shareHeaderLine: true |
| 294 }; | 294 }; |
| 295 } | 295 } |
| 296 | 296 |
| 297 /** | 297 /** |
| 298 * @override | 298 * @override |
| 299 * @param {number} entryIndex | 299 * @param {number} entryIndex |
| 300 * @return {?string} | 300 * @return {?string} |
| 301 */ | 301 */ |
| 302 entryTitle(entryIndex) { | 302 entryTitle(entryIndex) { |
| 303 var entryType = this._entryType(entryIndex); | 303 var entryType = this._entryType(entryIndex); |
| 304 if (entryType === WebInspector.TimelineFlameChartEntryType.Event) { | 304 if (entryType === Timeline.TimelineFlameChartEntryType.Event) { |
| 305 var event = /** @type {!WebInspector.TracingModel.Event} */ (this._entryDa
ta[entryIndex]); | 305 var event = /** @type {!SDK.TracingModel.Event} */ (this._entryData[entryI
ndex]); |
| 306 if (event.phase === WebInspector.TracingModel.Phase.AsyncStepInto || | 306 if (event.phase === SDK.TracingModel.Phase.AsyncStepInto || |
| 307 event.phase === WebInspector.TracingModel.Phase.AsyncStepPast) | 307 event.phase === SDK.TracingModel.Phase.AsyncStepPast) |
| 308 return event.name + ':' + event.args['step']; | 308 return event.name + ':' + event.args['step']; |
| 309 if (event._blackboxRoot) | 309 if (event._blackboxRoot) |
| 310 return WebInspector.UIString('Blackboxed'); | 310 return Common.UIString('Blackboxed'); |
| 311 var name = WebInspector.TimelineUIUtils.eventStyle(event).title; | 311 var name = Timeline.TimelineUIUtils.eventStyle(event).title; |
| 312 // TODO(yurys): support event dividers | 312 // TODO(yurys): support event dividers |
| 313 var detailsText = | 313 var detailsText = |
| 314 WebInspector.TimelineUIUtils.buildDetailsTextForTraceEvent(event, this
._model.targetByEvent(event)); | 314 Timeline.TimelineUIUtils.buildDetailsTextForTraceEvent(event, this._mo
del.targetByEvent(event)); |
| 315 if (event.name === WebInspector.TimelineModel.RecordType.JSFrame && detail
sText) | 315 if (event.name === TimelineModel.TimelineModel.RecordType.JSFrame && detai
lsText) |
| 316 return detailsText; | 316 return detailsText; |
| 317 return detailsText ? WebInspector.UIString('%s (%s)', name, detailsText) :
name; | 317 return detailsText ? Common.UIString('%s (%s)', name, detailsText) : name; |
| 318 } | 318 } |
| 319 var title = this._entryIndexToTitle[entryIndex]; | 319 var title = this._entryIndexToTitle[entryIndex]; |
| 320 if (!title) { | 320 if (!title) { |
| 321 title = WebInspector.UIString('Unexpected entryIndex %d', entryIndex); | 321 title = Common.UIString('Unexpected entryIndex %d', entryIndex); |
| 322 console.error(title); | 322 console.error(title); |
| 323 } | 323 } |
| 324 return title; | 324 return title; |
| 325 } | 325 } |
| 326 | 326 |
| 327 /** | 327 /** |
| 328 * @override | 328 * @override |
| 329 * @param {number} index | 329 * @param {number} index |
| 330 * @return {string} | 330 * @return {string} |
| 331 */ | 331 */ |
| 332 textColor(index) { | 332 textColor(index) { |
| 333 var event = this._entryData[index]; | 333 var event = this._entryData[index]; |
| 334 if (event && event._blackboxRoot) | 334 if (event && event._blackboxRoot) |
| 335 return '#888'; | 335 return '#888'; |
| 336 else | 336 else |
| 337 return super.textColor(index); | 337 return super.textColor(index); |
| 338 } | 338 } |
| 339 | 339 |
| 340 /** | 340 /** |
| 341 * @override | 341 * @override |
| 342 */ | 342 */ |
| 343 reset() { | 343 reset() { |
| 344 super.reset(); | 344 super.reset(); |
| 345 /** @type {!Array<!WebInspector.TracingModel.Event|!WebInspector.TimelineFra
me|!WebInspector.TimelineIRModel.Phases>} */ | 345 /** @type {!Array<!SDK.TracingModel.Event|!TimelineModel.TimelineFrame|!Time
lineModel.TimelineIRModel.Phases>} */ |
| 346 this._entryData = []; | 346 this._entryData = []; |
| 347 /** @type {!Array<!WebInspector.TimelineFlameChartEntryType>} */ | 347 /** @type {!Array<!Timeline.TimelineFlameChartEntryType>} */ |
| 348 this._entryTypeByLevel = []; | 348 this._entryTypeByLevel = []; |
| 349 /** @type {!Array<string>} */ | 349 /** @type {!Array<string>} */ |
| 350 this._entryIndexToTitle = []; | 350 this._entryIndexToTitle = []; |
| 351 /** @type {!Array<!WebInspector.TimelineFlameChartMarker>} */ | 351 /** @type {!Array<!Timeline.TimelineFlameChartMarker>} */ |
| 352 this._markers = []; | 352 this._markers = []; |
| 353 /** @type {!Map<!WebInspector.TimelineCategory, string>} */ | 353 /** @type {!Map<!Timeline.TimelineCategory, string>} */ |
| 354 this._asyncColorByCategory = new Map(); | 354 this._asyncColorByCategory = new Map(); |
| 355 /** @type {!Map<!WebInspector.TimelineIRModel.Phases, string>} */ | 355 /** @type {!Map<!TimelineModel.TimelineIRModel.Phases, string>} */ |
| 356 this._asyncColorByInteractionPhase = new Map(); | 356 this._asyncColorByInteractionPhase = new Map(); |
| 357 } | 357 } |
| 358 | 358 |
| 359 /** | 359 /** |
| 360 * @override | 360 * @override |
| 361 * @return {!WebInspector.FlameChart.TimelineData} | 361 * @return {!UI.FlameChart.TimelineData} |
| 362 */ | 362 */ |
| 363 timelineData() { | 363 timelineData() { |
| 364 if (this._timelineData) | 364 if (this._timelineData) |
| 365 return this._timelineData; | 365 return this._timelineData; |
| 366 | 366 |
| 367 this._timelineData = new WebInspector.FlameChart.TimelineData([], [], [], []
); | 367 this._timelineData = new UI.FlameChart.TimelineData([], [], [], []); |
| 368 | 368 |
| 369 this._flowEventIndexById = {}; | 369 this._flowEventIndexById = {}; |
| 370 this._minimumBoundary = this._model.minimumRecordTime(); | 370 this._minimumBoundary = this._model.minimumRecordTime(); |
| 371 this._timeSpan = this._model.isEmpty() ? 1000 : this._model.maximumRecordTim
e() - this._minimumBoundary; | 371 this._timeSpan = this._model.isEmpty() ? 1000 : this._model.maximumRecordTim
e() - this._minimumBoundary; |
| 372 this._currentLevel = 0; | 372 this._currentLevel = 0; |
| 373 this._appendFrameBars(this._frameModel.frames()); | 373 this._appendFrameBars(this._frameModel.frames()); |
| 374 | 374 |
| 375 this._appendHeader(WebInspector.UIString('Interactions'), this._interactions
HeaderLevel1); | 375 this._appendHeader(Common.UIString('Interactions'), this._interactionsHeader
Level1); |
| 376 this._appendInteractionRecords(); | 376 this._appendInteractionRecords(); |
| 377 | 377 |
| 378 var asyncEventGroups = WebInspector.TimelineModel.AsyncEventGroup; | 378 var asyncEventGroups = TimelineModel.TimelineModel.AsyncEventGroup; |
| 379 var inputLatencies = this._model.mainThreadAsyncEvents().get(asyncEventGroup
s.input); | 379 var inputLatencies = this._model.mainThreadAsyncEvents().get(asyncEventGroup
s.input); |
| 380 if (inputLatencies && inputLatencies.length) { | 380 if (inputLatencies && inputLatencies.length) { |
| 381 var title = WebInspector.TimelineUIUtils.titleForAsyncEventGroup(asyncEven
tGroups.input); | 381 var title = Timeline.TimelineUIUtils.titleForAsyncEventGroup(asyncEventGro
ups.input); |
| 382 this._appendAsyncEventsGroup(title, inputLatencies, this._interactionsHead
erLevel2); | 382 this._appendAsyncEventsGroup(title, inputLatencies, this._interactionsHead
erLevel2); |
| 383 } | 383 } |
| 384 var animations = this._model.mainThreadAsyncEvents().get(asyncEventGroups.an
imation); | 384 var animations = this._model.mainThreadAsyncEvents().get(asyncEventGroups.an
imation); |
| 385 if (animations && animations.length) { | 385 if (animations && animations.length) { |
| 386 var title = WebInspector.TimelineUIUtils.titleForAsyncEventGroup(asyncEven
tGroups.animation); | 386 var title = Timeline.TimelineUIUtils.titleForAsyncEventGroup(asyncEventGro
ups.animation); |
| 387 this._appendAsyncEventsGroup(title, animations, this._interactionsHeaderLe
vel2); | 387 this._appendAsyncEventsGroup(title, animations, this._interactionsHeaderLe
vel2); |
| 388 } | 388 } |
| 389 var threads = this._model.virtualThreads(); | 389 var threads = this._model.virtualThreads(); |
| 390 if (!Runtime.experiments.isEnabled('timelinePerFrameTrack')) { | 390 if (!Runtime.experiments.isEnabled('timelinePerFrameTrack')) { |
| 391 this._appendThreadTimelineData( | 391 this._appendThreadTimelineData( |
| 392 WebInspector.UIString('Main'), this._model.mainThreadEvents(), this._m
odel.mainThreadAsyncEvents(), true); | 392 Common.UIString('Main'), this._model.mainThreadEvents(), this._model.m
ainThreadAsyncEvents(), true); |
| 393 } else { | 393 } else { |
| 394 this._appendThreadTimelineData( | 394 this._appendThreadTimelineData( |
| 395 WebInspector.UIString('Page'), this._model.eventsForFrame(WebInspector
.TimelineModel.PageFrame.mainFrameId), this._model.mainThreadAsyncEvents(), true
); | 395 Common.UIString('Page'), this._model.eventsForFrame(TimelineModel.Time
lineModel.PageFrame.mainFrameId), this._model.mainThreadAsyncEvents(), true); |
| 396 for (var frame of this._model.rootFrames()) { | 396 for (var frame of this._model.rootFrames()) { |
| 397 // Ignore top frame itself, since it should be part of page events. | 397 // Ignore top frame itself, since it should be part of page events. |
| 398 frame.children.forEach(this._appendFrameEvents.bind(this, 0)); | 398 frame.children.forEach(this._appendFrameEvents.bind(this, 0)); |
| 399 } | 399 } |
| 400 } | 400 } |
| 401 var compositorThreads = threads.filter(thread => thread.name.startsWith('Com
positorTileWorker')); | 401 var compositorThreads = threads.filter(thread => thread.name.startsWith('Com
positorTileWorker')); |
| 402 var otherThreads = threads.filter(thread => !thread.name.startsWith('Composi
torTileWorker')); | 402 var otherThreads = threads.filter(thread => !thread.name.startsWith('Composi
torTileWorker')); |
| 403 if (compositorThreads.length) { | 403 if (compositorThreads.length) { |
| 404 this._appendHeader(WebInspector.UIString('Raster'), this._headerLevel1); | 404 this._appendHeader(Common.UIString('Raster'), this._headerLevel1); |
| 405 for (var i = 0; i < compositorThreads.length; ++i) | 405 for (var i = 0; i < compositorThreads.length; ++i) |
| 406 this._appendSyncEvents( | 406 this._appendSyncEvents( |
| 407 compositorThreads[i].events, WebInspector.UIString('Rasterizer Threa
d %d', i), this._headerLevel2); | 407 compositorThreads[i].events, Common.UIString('Rasterizer Thread %d',
i), this._headerLevel2); |
| 408 } | 408 } |
| 409 this._appendGPUEvents(); | 409 this._appendGPUEvents(); |
| 410 | 410 |
| 411 otherThreads.forEach( | 411 otherThreads.forEach( |
| 412 thread => this._appendThreadTimelineData(thread.name, thread.events, thr
ead.asyncEventsByGroup)); | 412 thread => this._appendThreadTimelineData(thread.name, thread.events, thr
ead.asyncEventsByGroup)); |
| 413 | 413 |
| 414 /** | 414 /** |
| 415 * @param {!WebInspector.TimelineFlameChartMarker} a | 415 * @param {!Timeline.TimelineFlameChartMarker} a |
| 416 * @param {!WebInspector.TimelineFlameChartMarker} b | 416 * @param {!Timeline.TimelineFlameChartMarker} b |
| 417 */ | 417 */ |
| 418 function compareStartTime(a, b) { | 418 function compareStartTime(a, b) { |
| 419 return a.startTime() - b.startTime(); | 419 return a.startTime() - b.startTime(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 this._markers.sort(compareStartTime); | 422 this._markers.sort(compareStartTime); |
| 423 this._timelineData.markers = this._markers; | 423 this._timelineData.markers = this._markers; |
| 424 | 424 |
| 425 this._flowEventIndexById = {}; | 425 this._flowEventIndexById = {}; |
| 426 return this._timelineData; | 426 return this._timelineData; |
| 427 } | 427 } |
| 428 | 428 |
| 429 /** | 429 /** |
| 430 * @param {number} level | 430 * @param {number} level |
| 431 * @param {!WebInspector.TimelineModel.PageFrame} frame | 431 * @param {!TimelineModel.TimelineModel.PageFrame} frame |
| 432 */ | 432 */ |
| 433 _appendFrameEvents(level, frame) { | 433 _appendFrameEvents(level, frame) { |
| 434 var events = this._model.eventsForFrame(frame.id); | 434 var events = this._model.eventsForFrame(frame.id); |
| 435 var clonedHeader = Object.assign({}, this._headerLevel1); | 435 var clonedHeader = Object.assign({}, this._headerLevel1); |
| 436 clonedHeader.nestingLevel = level; | 436 clonedHeader.nestingLevel = level; |
| 437 this._appendSyncEvents(events, WebInspector.TimelineUIUtils.displayNameForFr
ame(frame), | 437 this._appendSyncEvents(events, Timeline.TimelineUIUtils.displayNameForFrame(
frame), |
| 438 /** @type {!WebInspector.FlameChart.GroupStyle} */ (c
lonedHeader)); | 438 /** @type {!UI.FlameChart.GroupStyle} */ (clonedHeade
r)); |
| 439 frame.children.forEach(this._appendFrameEvents.bind(this, level + 1)); | 439 frame.children.forEach(this._appendFrameEvents.bind(this, level + 1)); |
| 440 } | 440 } |
| 441 | 441 |
| 442 /** | 442 /** |
| 443 * @param {string} threadTitle | 443 * @param {string} threadTitle |
| 444 * @param {!Array<!WebInspector.TracingModel.Event>} syncEvents | 444 * @param {!Array<!SDK.TracingModel.Event>} syncEvents |
| 445 * @param {!Map<!WebInspector.TimelineModel.AsyncEventGroup, !Array<!WebInspec
tor.TracingModel.AsyncEvent>>} asyncEvents | 445 * @param {!Map<!TimelineModel.TimelineModel.AsyncEventGroup, !Array<!SDK.Trac
ingModel.AsyncEvent>>} asyncEvents |
| 446 * @param {boolean=} forceExpanded | 446 * @param {boolean=} forceExpanded |
| 447 */ | 447 */ |
| 448 _appendThreadTimelineData(threadTitle, syncEvents, asyncEvents, forceExpanded)
{ | 448 _appendThreadTimelineData(threadTitle, syncEvents, asyncEvents, forceExpanded)
{ |
| 449 this._appendAsyncEvents(asyncEvents); | 449 this._appendAsyncEvents(asyncEvents); |
| 450 this._appendSyncEvents(syncEvents, threadTitle, this._headerLevel1, forceExp
anded); | 450 this._appendSyncEvents(syncEvents, threadTitle, this._headerLevel1, forceExp
anded); |
| 451 } | 451 } |
| 452 | 452 |
| 453 /** | 453 /** |
| 454 * @param {!Array<!WebInspector.TracingModel.Event>} events | 454 * @param {!Array<!SDK.TracingModel.Event>} events |
| 455 * @param {string} title | 455 * @param {string} title |
| 456 * @param {!WebInspector.FlameChart.GroupStyle} style | 456 * @param {!UI.FlameChart.GroupStyle} style |
| 457 * @param {boolean=} forceExpanded | 457 * @param {boolean=} forceExpanded |
| 458 */ | 458 */ |
| 459 _appendSyncEvents(events, title, style, forceExpanded) { | 459 _appendSyncEvents(events, title, style, forceExpanded) { |
| 460 var openEvents = []; | 460 var openEvents = []; |
| 461 var flowEventsEnabled = Runtime.experiments.isEnabled('timelineFlowEvents'); | 461 var flowEventsEnabled = Runtime.experiments.isEnabled('timelineFlowEvents'); |
| 462 var blackboxingEnabled = Runtime.experiments.isEnabled('blackboxJSFramesOnTi
meline'); | 462 var blackboxingEnabled = Runtime.experiments.isEnabled('blackboxJSFramesOnTi
meline'); |
| 463 var maxStackDepth = 0; | 463 var maxStackDepth = 0; |
| 464 for (var i = 0; i < events.length; ++i) { | 464 for (var i = 0; i < events.length; ++i) { |
| 465 var e = events[i]; | 465 var e = events[i]; |
| 466 if (WebInspector.TimelineModel.isMarkerEvent(e)) | 466 if (TimelineModel.TimelineModel.isMarkerEvent(e)) |
| 467 this._markers.push(new WebInspector.TimelineFlameChartMarker( | 467 this._markers.push(new Timeline.TimelineFlameChartMarker( |
| 468 e.startTime, e.startTime - this._model.minimumRecordTime(), | 468 e.startTime, e.startTime - this._model.minimumRecordTime(), |
| 469 WebInspector.TimelineUIUtils.markerStyleForEvent(e))); | 469 Timeline.TimelineUIUtils.markerStyleForEvent(e))); |
| 470 if (!WebInspector.TracingModel.isFlowPhase(e.phase)) { | 470 if (!SDK.TracingModel.isFlowPhase(e.phase)) { |
| 471 if (!e.endTime && e.phase !== WebInspector.TracingModel.Phase.Instant) | 471 if (!e.endTime && e.phase !== SDK.TracingModel.Phase.Instant) |
| 472 continue; | 472 continue; |
| 473 if (WebInspector.TracingModel.isAsyncPhase(e.phase)) | 473 if (SDK.TracingModel.isAsyncPhase(e.phase)) |
| 474 continue; | 474 continue; |
| 475 if (!this._isVisible(e)) | 475 if (!this._isVisible(e)) |
| 476 continue; | 476 continue; |
| 477 } | 477 } |
| 478 while (openEvents.length && openEvents.peekLast().endTime <= e.startTime) | 478 while (openEvents.length && openEvents.peekLast().endTime <= e.startTime) |
| 479 openEvents.pop(); | 479 openEvents.pop(); |
| 480 e._blackboxRoot = false; | 480 e._blackboxRoot = false; |
| 481 if (blackboxingEnabled && this._isBlackboxedEvent(e)) { | 481 if (blackboxingEnabled && this._isBlackboxedEvent(e)) { |
| 482 var parent = openEvents.peekLast(); | 482 var parent = openEvents.peekLast(); |
| 483 if (parent && parent._blackboxRoot) | 483 if (parent && parent._blackboxRoot) |
| 484 continue; | 484 continue; |
| 485 e._blackboxRoot = true; | 485 e._blackboxRoot = true; |
| 486 } | 486 } |
| 487 if (title) { | 487 if (title) { |
| 488 this._appendHeader(title, style, forceExpanded); | 488 this._appendHeader(title, style, forceExpanded); |
| 489 title = ''; | 489 title = ''; |
| 490 } | 490 } |
| 491 | 491 |
| 492 var level = this._currentLevel + openEvents.length; | 492 var level = this._currentLevel + openEvents.length; |
| 493 this._appendEvent(e, level); | 493 this._appendEvent(e, level); |
| 494 if (flowEventsEnabled) | 494 if (flowEventsEnabled) |
| 495 this._appendFlowEvent(e, level); | 495 this._appendFlowEvent(e, level); |
| 496 maxStackDepth = Math.max(maxStackDepth, openEvents.length + 1); | 496 maxStackDepth = Math.max(maxStackDepth, openEvents.length + 1); |
| 497 if (e.endTime) | 497 if (e.endTime) |
| 498 openEvents.push(e); | 498 openEvents.push(e); |
| 499 } | 499 } |
| 500 this._entryTypeByLevel.length = this._currentLevel + maxStackDepth; | 500 this._entryTypeByLevel.length = this._currentLevel + maxStackDepth; |
| 501 this._entryTypeByLevel.fill(WebInspector.TimelineFlameChartEntryType.Event,
this._currentLevel); | 501 this._entryTypeByLevel.fill(Timeline.TimelineFlameChartEntryType.Event, this
._currentLevel); |
| 502 this._currentLevel += maxStackDepth; | 502 this._currentLevel += maxStackDepth; |
| 503 } | 503 } |
| 504 | 504 |
| 505 /** | 505 /** |
| 506 * @param {!WebInspector.TracingModel.Event} event | 506 * @param {!SDK.TracingModel.Event} event |
| 507 * @return {boolean} | 507 * @return {boolean} |
| 508 */ | 508 */ |
| 509 _isBlackboxedEvent(event) { | 509 _isBlackboxedEvent(event) { |
| 510 if (event.name !== WebInspector.TimelineModel.RecordType.JSFrame) | 510 if (event.name !== TimelineModel.TimelineModel.RecordType.JSFrame) |
| 511 return false; | 511 return false; |
| 512 var url = event.args['data']['url']; | 512 var url = event.args['data']['url']; |
| 513 return url && this._isBlackboxedURL(url); | 513 return url && this._isBlackboxedURL(url); |
| 514 } | 514 } |
| 515 | 515 |
| 516 /** | 516 /** |
| 517 * @param {string} url | 517 * @param {string} url |
| 518 * @return {boolean} | 518 * @return {boolean} |
| 519 */ | 519 */ |
| 520 _isBlackboxedURL(url) { | 520 _isBlackboxedURL(url) { |
| 521 return WebInspector.blackboxManager.isBlackboxedURL(url); | 521 return Bindings.blackboxManager.isBlackboxedURL(url); |
| 522 } | 522 } |
| 523 | 523 |
| 524 /** | 524 /** |
| 525 * @param {!Map<!WebInspector.TimelineModel.AsyncEventGroup, !Array<!WebInspec
tor.TracingModel.AsyncEvent>>} asyncEvents | 525 * @param {!Map<!TimelineModel.TimelineModel.AsyncEventGroup, !Array<!SDK.Trac
ingModel.AsyncEvent>>} asyncEvents |
| 526 */ | 526 */ |
| 527 _appendAsyncEvents(asyncEvents) { | 527 _appendAsyncEvents(asyncEvents) { |
| 528 var groups = WebInspector.TimelineModel.AsyncEventGroup; | 528 var groups = TimelineModel.TimelineModel.AsyncEventGroup; |
| 529 var groupArray = Object.keys(groups).map(key => groups[key]); | 529 var groupArray = Object.keys(groups).map(key => groups[key]); |
| 530 | 530 |
| 531 groupArray.remove(groups.animation); | 531 groupArray.remove(groups.animation); |
| 532 groupArray.remove(groups.input); | 532 groupArray.remove(groups.input); |
| 533 | 533 |
| 534 for (var groupIndex = 0; groupIndex < groupArray.length; ++groupIndex) { | 534 for (var groupIndex = 0; groupIndex < groupArray.length; ++groupIndex) { |
| 535 var group = groupArray[groupIndex]; | 535 var group = groupArray[groupIndex]; |
| 536 var events = asyncEvents.get(group); | 536 var events = asyncEvents.get(group); |
| 537 if (!events) | 537 if (!events) |
| 538 continue; | 538 continue; |
| 539 var title = WebInspector.TimelineUIUtils.titleForAsyncEventGroup(group); | 539 var title = Timeline.TimelineUIUtils.titleForAsyncEventGroup(group); |
| 540 this._appendAsyncEventsGroup(title, events, this._headerLevel1); | 540 this._appendAsyncEventsGroup(title, events, this._headerLevel1); |
| 541 } | 541 } |
| 542 } | 542 } |
| 543 | 543 |
| 544 /** | 544 /** |
| 545 * @param {string} header | 545 * @param {string} header |
| 546 * @param {!Array<!WebInspector.TracingModel.AsyncEvent>} events | 546 * @param {!Array<!SDK.TracingModel.AsyncEvent>} events |
| 547 * @param {!WebInspector.FlameChart.GroupStyle} style | 547 * @param {!UI.FlameChart.GroupStyle} style |
| 548 */ | 548 */ |
| 549 _appendAsyncEventsGroup(header, events, style) { | 549 _appendAsyncEventsGroup(header, events, style) { |
| 550 var lastUsedTimeByLevel = []; | 550 var lastUsedTimeByLevel = []; |
| 551 var groupHeaderAppended = false; | 551 var groupHeaderAppended = false; |
| 552 for (var i = 0; i < events.length; ++i) { | 552 for (var i = 0; i < events.length; ++i) { |
| 553 var asyncEvent = events[i]; | 553 var asyncEvent = events[i]; |
| 554 if (!this._isVisible(asyncEvent)) | 554 if (!this._isVisible(asyncEvent)) |
| 555 continue; | 555 continue; |
| 556 if (!groupHeaderAppended) { | 556 if (!groupHeaderAppended) { |
| 557 this._appendHeader(header, style); | 557 this._appendHeader(header, style); |
| 558 groupHeaderAppended = true; | 558 groupHeaderAppended = true; |
| 559 } | 559 } |
| 560 var startTime = asyncEvent.startTime; | 560 var startTime = asyncEvent.startTime; |
| 561 var level; | 561 var level; |
| 562 for (level = 0; level < lastUsedTimeByLevel.length && lastUsedTimeByLevel[
level] > startTime; ++level) { | 562 for (level = 0; level < lastUsedTimeByLevel.length && lastUsedTimeByLevel[
level] > startTime; ++level) { |
| 563 } | 563 } |
| 564 this._appendAsyncEvent(asyncEvent, this._currentLevel + level); | 564 this._appendAsyncEvent(asyncEvent, this._currentLevel + level); |
| 565 lastUsedTimeByLevel[level] = asyncEvent.endTime; | 565 lastUsedTimeByLevel[level] = asyncEvent.endTime; |
| 566 } | 566 } |
| 567 this._entryTypeByLevel.length = this._currentLevel + lastUsedTimeByLevel.len
gth; | 567 this._entryTypeByLevel.length = this._currentLevel + lastUsedTimeByLevel.len
gth; |
| 568 this._entryTypeByLevel.fill(WebInspector.TimelineFlameChartEntryType.Event,
this._currentLevel); | 568 this._entryTypeByLevel.fill(Timeline.TimelineFlameChartEntryType.Event, this
._currentLevel); |
| 569 this._currentLevel += lastUsedTimeByLevel.length; | 569 this._currentLevel += lastUsedTimeByLevel.length; |
| 570 } | 570 } |
| 571 | 571 |
| 572 _appendGPUEvents() { | 572 _appendGPUEvents() { |
| 573 if (this._appendSyncEvents(this._model.gpuEvents(), WebInspector.UIString('G
PU'), this._headerLevel1, false)) | 573 if (this._appendSyncEvents(this._model.gpuEvents(), Common.UIString('GPU'),
this._headerLevel1, false)) |
| 574 ++this._currentLevel; | 574 ++this._currentLevel; |
| 575 } | 575 } |
| 576 | 576 |
| 577 _appendInteractionRecords() { | 577 _appendInteractionRecords() { |
| 578 this._irModel.interactionRecords().forEach(this._appendSegment, this); | 578 this._irModel.interactionRecords().forEach(this._appendSegment, this); |
| 579 this._entryTypeByLevel[this._currentLevel++] = WebInspector.TimelineFlameCha
rtEntryType.InteractionRecord; | 579 this._entryTypeByLevel[this._currentLevel++] = Timeline.TimelineFlameChartEn
tryType.InteractionRecord; |
| 580 } | 580 } |
| 581 | 581 |
| 582 /** | 582 /** |
| 583 * @param {!Array.<!WebInspector.TimelineFrame>} frames | 583 * @param {!Array.<!TimelineModel.TimelineFrame>} frames |
| 584 */ | 584 */ |
| 585 _appendFrameBars(frames) { | 585 _appendFrameBars(frames) { |
| 586 var style = WebInspector.TimelineUIUtils.markerStyleForFrame(); | 586 var style = Timeline.TimelineUIUtils.markerStyleForFrame(); |
| 587 this._entryTypeByLevel[this._currentLevel] = WebInspector.TimelineFlameChart
EntryType.Frame; | 587 this._entryTypeByLevel[this._currentLevel] = Timeline.TimelineFlameChartEntr
yType.Frame; |
| 588 for (var i = 0; i < frames.length; ++i) { | 588 for (var i = 0; i < frames.length; ++i) { |
| 589 this._markers.push(new WebInspector.TimelineFlameChartMarker( | 589 this._markers.push(new Timeline.TimelineFlameChartMarker( |
| 590 frames[i].startTime, frames[i].startTime - this._model.minimumRecordTi
me(), style)); | 590 frames[i].startTime, frames[i].startTime - this._model.minimumRecordTi
me(), style)); |
| 591 this._appendFrame(frames[i]); | 591 this._appendFrame(frames[i]); |
| 592 } | 592 } |
| 593 ++this._currentLevel; | 593 ++this._currentLevel; |
| 594 } | 594 } |
| 595 | 595 |
| 596 /** | 596 /** |
| 597 * @param {number} entryIndex | 597 * @param {number} entryIndex |
| 598 * @return {!WebInspector.TimelineFlameChartEntryType} | 598 * @return {!Timeline.TimelineFlameChartEntryType} |
| 599 */ | 599 */ |
| 600 _entryType(entryIndex) { | 600 _entryType(entryIndex) { |
| 601 return this._entryTypeByLevel[this._timelineData.entryLevels[entryIndex]]; | 601 return this._entryTypeByLevel[this._timelineData.entryLevels[entryIndex]]; |
| 602 } | 602 } |
| 603 | 603 |
| 604 /** | 604 /** |
| 605 * @override | 605 * @override |
| 606 * @param {number} entryIndex | 606 * @param {number} entryIndex |
| 607 * @return {?Element} | 607 * @return {?Element} |
| 608 */ | 608 */ |
| 609 prepareHighlightedEntryInfo(entryIndex) { | 609 prepareHighlightedEntryInfo(entryIndex) { |
| 610 var time = ''; | 610 var time = ''; |
| 611 var title; | 611 var title; |
| 612 var warning; | 612 var warning; |
| 613 var type = this._entryType(entryIndex); | 613 var type = this._entryType(entryIndex); |
| 614 if (type === WebInspector.TimelineFlameChartEntryType.Event) { | 614 if (type === Timeline.TimelineFlameChartEntryType.Event) { |
| 615 var event = /** @type {!WebInspector.TracingModel.Event} */ (this._entryDa
ta[entryIndex]); | 615 var event = /** @type {!SDK.TracingModel.Event} */ (this._entryData[entryI
ndex]); |
| 616 var totalTime = event.duration; | 616 var totalTime = event.duration; |
| 617 var selfTime = event.selfTime; | 617 var selfTime = event.selfTime; |
| 618 var /** @const */ eps = 1e-6; | 618 var /** @const */ eps = 1e-6; |
| 619 if (typeof totalTime === 'number') { | 619 if (typeof totalTime === 'number') { |
| 620 time = Math.abs(totalTime - selfTime) > eps && selfTime > eps ? | 620 time = Math.abs(totalTime - selfTime) > eps && selfTime > eps ? |
| 621 WebInspector.UIString( | 621 Common.UIString( |
| 622 '%s (self %s)', Number.millisToString(totalTime, true), Number.m
illisToString(selfTime, true)) : | 622 '%s (self %s)', Number.millisToString(totalTime, true), Number.m
illisToString(selfTime, true)) : |
| 623 Number.millisToString(totalTime, true); | 623 Number.millisToString(totalTime, true); |
| 624 } | 624 } |
| 625 title = this.entryTitle(entryIndex); | 625 title = this.entryTitle(entryIndex); |
| 626 warning = WebInspector.TimelineUIUtils.eventWarning(event); | 626 warning = Timeline.TimelineUIUtils.eventWarning(event); |
| 627 } else if (type === WebInspector.TimelineFlameChartEntryType.Frame) { | 627 } else if (type === Timeline.TimelineFlameChartEntryType.Frame) { |
| 628 var frame = /** @type {!WebInspector.TimelineFrame} */ (this._entryData[en
tryIndex]); | 628 var frame = /** @type {!TimelineModel.TimelineFrame} */ (this._entryData[e
ntryIndex]); |
| 629 time = WebInspector.UIString( | 629 time = Common.UIString( |
| 630 '%s ~ %.0f\u2009fps', Number.preciseMillisToString(frame.duration, 1),
(1000 / frame.duration)); | 630 '%s ~ %.0f\u2009fps', Number.preciseMillisToString(frame.duration, 1),
(1000 / frame.duration)); |
| 631 title = frame.idle ? WebInspector.UIString('Idle Frame') : WebInspector.UI
String('Frame'); | 631 title = frame.idle ? Common.UIString('Idle Frame') : Common.UIString('Fram
e'); |
| 632 if (frame.hasWarnings()) { | 632 if (frame.hasWarnings()) { |
| 633 warning = createElement('span'); | 633 warning = createElement('span'); |
| 634 warning.textContent = WebInspector.UIString('Long frame'); | 634 warning.textContent = Common.UIString('Long frame'); |
| 635 } | 635 } |
| 636 } else { | 636 } else { |
| 637 return null; | 637 return null; |
| 638 } | 638 } |
| 639 var element = createElement('div'); | 639 var element = createElement('div'); |
| 640 var root = WebInspector.createShadowRootWithCoreStyles(element, 'timeline/ti
melineFlamechartPopover.css'); | 640 var root = UI.createShadowRootWithCoreStyles(element, 'timeline/timelineFlam
echartPopover.css'); |
| 641 var contents = root.createChild('div', 'timeline-flamechart-popover'); | 641 var contents = root.createChild('div', 'timeline-flamechart-popover'); |
| 642 contents.createChild('span', 'timeline-info-time').textContent = time; | 642 contents.createChild('span', 'timeline-info-time').textContent = time; |
| 643 contents.createChild('span', 'timeline-info-title').textContent = title; | 643 contents.createChild('span', 'timeline-info-title').textContent = title; |
| 644 if (warning) { | 644 if (warning) { |
| 645 warning.classList.add('timeline-info-warning'); | 645 warning.classList.add('timeline-info-warning'); |
| 646 contents.appendChild(warning); | 646 contents.appendChild(warning); |
| 647 } | 647 } |
| 648 return element; | 648 return element; |
| 649 } | 649 } |
| 650 | 650 |
| 651 /** | 651 /** |
| 652 * @override | 652 * @override |
| 653 * @param {number} entryIndex | 653 * @param {number} entryIndex |
| 654 * @return {string} | 654 * @return {string} |
| 655 */ | 655 */ |
| 656 entryColor(entryIndex) { | 656 entryColor(entryIndex) { |
| 657 // This is not annotated due to closure compiler failure to properly infer c
ache container's template type. | 657 // This is not annotated due to closure compiler failure to properly infer c
ache container's template type. |
| 658 function patchColorAndCache(cache, key, lookupColor) { | 658 function patchColorAndCache(cache, key, lookupColor) { |
| 659 var color = cache.get(key); | 659 var color = cache.get(key); |
| 660 if (color) | 660 if (color) |
| 661 return color; | 661 return color; |
| 662 var parsedColor = WebInspector.Color.parse(lookupColor(key)); | 662 var parsedColor = Common.Color.parse(lookupColor(key)); |
| 663 color = parsedColor.setAlpha(0.7).asString(WebInspector.Color.Format.RGBA)
|| ''; | 663 color = parsedColor.setAlpha(0.7).asString(Common.Color.Format.RGBA) || ''
; |
| 664 cache.set(key, color); | 664 cache.set(key, color); |
| 665 return color; | 665 return color; |
| 666 } | 666 } |
| 667 | 667 |
| 668 var type = this._entryType(entryIndex); | 668 var type = this._entryType(entryIndex); |
| 669 if (type === WebInspector.TimelineFlameChartEntryType.Event) { | 669 if (type === Timeline.TimelineFlameChartEntryType.Event) { |
| 670 var event = /** @type {!WebInspector.TracingModel.Event} */ (this._entryDa
ta[entryIndex]); | 670 var event = /** @type {!SDK.TracingModel.Event} */ (this._entryData[entryI
ndex]); |
| 671 if (!WebInspector.TracingModel.isAsyncPhase(event.phase)) | 671 if (!SDK.TracingModel.isAsyncPhase(event.phase)) |
| 672 return WebInspector.TimelineUIUtils.eventColor(event); | 672 return Timeline.TimelineUIUtils.eventColor(event); |
| 673 if (event.hasCategory(WebInspector.TimelineModel.Category.Console) || | 673 if (event.hasCategory(TimelineModel.TimelineModel.Category.Console) || |
| 674 event.hasCategory(WebInspector.TimelineModel.Category.UserTiming)) | 674 event.hasCategory(TimelineModel.TimelineModel.Category.UserTiming)) |
| 675 return this._consoleColorGenerator.colorForID(event.name); | 675 return this._consoleColorGenerator.colorForID(event.name); |
| 676 if (event.hasCategory(WebInspector.TimelineModel.Category.LatencyInfo)) { | 676 if (event.hasCategory(TimelineModel.TimelineModel.Category.LatencyInfo)) { |
| 677 var phase = | 677 var phase = |
| 678 WebInspector.TimelineIRModel.phaseForEvent(event) || WebInspector.Ti
melineIRModel.Phases.Uncategorized; | 678 TimelineModel.TimelineIRModel.phaseForEvent(event) || TimelineModel.
TimelineIRModel.Phases.Uncategorized; |
| 679 return patchColorAndCache( | 679 return patchColorAndCache( |
| 680 this._asyncColorByInteractionPhase, phase, WebInspector.TimelineUIUt
ils.interactionPhaseColor); | 680 this._asyncColorByInteractionPhase, phase, Timeline.TimelineUIUtils.
interactionPhaseColor); |
| 681 } | 681 } |
| 682 var category = WebInspector.TimelineUIUtils.eventStyle(event).category; | 682 var category = Timeline.TimelineUIUtils.eventStyle(event).category; |
| 683 return patchColorAndCache(this._asyncColorByCategory, category, () => cate
gory.color); | 683 return patchColorAndCache(this._asyncColorByCategory, category, () => cate
gory.color); |
| 684 } | 684 } |
| 685 if (type === WebInspector.TimelineFlameChartEntryType.Frame) | 685 if (type === Timeline.TimelineFlameChartEntryType.Frame) |
| 686 return 'white'; | 686 return 'white'; |
| 687 if (type === WebInspector.TimelineFlameChartEntryType.InteractionRecord) | 687 if (type === Timeline.TimelineFlameChartEntryType.InteractionRecord) |
| 688 return 'transparent'; | 688 return 'transparent'; |
| 689 return ''; | 689 return ''; |
| 690 } | 690 } |
| 691 | 691 |
| 692 /** | 692 /** |
| 693 * @override | 693 * @override |
| 694 * @param {number} entryIndex | 694 * @param {number} entryIndex |
| 695 * @param {!CanvasRenderingContext2D} context | 695 * @param {!CanvasRenderingContext2D} context |
| 696 * @param {?string} text | 696 * @param {?string} text |
| 697 * @param {number} barX | 697 * @param {number} barX |
| 698 * @param {number} barY | 698 * @param {number} barY |
| 699 * @param {number} barWidth | 699 * @param {number} barWidth |
| 700 * @param {number} barHeight | 700 * @param {number} barHeight |
| 701 * @param {number} unclippedBarX | 701 * @param {number} unclippedBarX |
| 702 * @param {number} timeToPixels | 702 * @param {number} timeToPixels |
| 703 * @return {boolean} | 703 * @return {boolean} |
| 704 */ | 704 */ |
| 705 decorateEntry(entryIndex, context, text, barX, barY, barWidth, barHeight, uncl
ippedBarX, timeToPixels) { | 705 decorateEntry(entryIndex, context, text, barX, barY, barWidth, barHeight, uncl
ippedBarX, timeToPixels) { |
| 706 var data = this._entryData[entryIndex]; | 706 var data = this._entryData[entryIndex]; |
| 707 var type = this._entryType(entryIndex); | 707 var type = this._entryType(entryIndex); |
| 708 if (type === WebInspector.TimelineFlameChartEntryType.Frame) { | 708 if (type === Timeline.TimelineFlameChartEntryType.Frame) { |
| 709 var /** @const */ vPadding = 1; | 709 var /** @const */ vPadding = 1; |
| 710 var /** @const */ hPadding = 1; | 710 var /** @const */ hPadding = 1; |
| 711 var frame = /** {!WebInspector.TimelineFrame} */ (data); | 711 var frame = /** {!TimelineModel.TimelineFrame} */ (data); |
| 712 barX += hPadding; | 712 barX += hPadding; |
| 713 barWidth -= 2 * hPadding; | 713 barWidth -= 2 * hPadding; |
| 714 barY += vPadding; | 714 barY += vPadding; |
| 715 barHeight -= 2 * vPadding + 1; | 715 barHeight -= 2 * vPadding + 1; |
| 716 context.fillStyle = frame.idle ? 'white' : (frame.hasWarnings() ? '#fad1d1
' : '#d7f0d1'); | 716 context.fillStyle = frame.idle ? 'white' : (frame.hasWarnings() ? '#fad1d1
' : '#d7f0d1'); |
| 717 context.fillRect(barX, barY, barWidth, barHeight); | 717 context.fillRect(barX, barY, barWidth, barHeight); |
| 718 var frameDurationText = Number.preciseMillisToString(frame.duration, 1); | 718 var frameDurationText = Number.preciseMillisToString(frame.duration, 1); |
| 719 var textWidth = context.measureText(frameDurationText).width; | 719 var textWidth = context.measureText(frameDurationText).width; |
| 720 if (barWidth >= textWidth) { | 720 if (barWidth >= textWidth) { |
| 721 context.fillStyle = this.textColor(entryIndex); | 721 context.fillStyle = this.textColor(entryIndex); |
| 722 context.fillText(frameDurationText, barX + (barWidth - textWidth) / 2, b
arY + barHeight - 3); | 722 context.fillText(frameDurationText, barX + (barWidth - textWidth) / 2, b
arY + barHeight - 3); |
| 723 } | 723 } |
| 724 return true; | 724 return true; |
| 725 } | 725 } |
| 726 | 726 |
| 727 if (type === WebInspector.TimelineFlameChartEntryType.InteractionRecord) { | 727 if (type === Timeline.TimelineFlameChartEntryType.InteractionRecord) { |
| 728 var color = WebInspector.TimelineUIUtils.interactionPhaseColor( | 728 var color = Timeline.TimelineUIUtils.interactionPhaseColor( |
| 729 /** @type {!WebInspector.TimelineIRModel.Phases} */ (this._entryData[e
ntryIndex])); | 729 /** @type {!TimelineModel.TimelineIRModel.Phases} */ (this._entryData[
entryIndex])); |
| 730 context.fillStyle = color; | 730 context.fillStyle = color; |
| 731 context.fillRect(barX, barY, barWidth - 1, 2); | 731 context.fillRect(barX, barY, barWidth - 1, 2); |
| 732 context.fillRect(barX, barY - 3, 2, 3); | 732 context.fillRect(barX, barY - 3, 2, 3); |
| 733 context.fillRect(barX + barWidth - 3, barY - 3, 2, 3); | 733 context.fillRect(barX + barWidth - 3, barY - 3, 2, 3); |
| 734 return false; | 734 return false; |
| 735 } | 735 } |
| 736 | 736 |
| 737 if (type === WebInspector.TimelineFlameChartEntryType.Event) { | 737 if (type === Timeline.TimelineFlameChartEntryType.Event) { |
| 738 var event = /** @type {!WebInspector.TracingModel.Event} */ (this._entryDa
ta[entryIndex]); | 738 var event = /** @type {!SDK.TracingModel.Event} */ (this._entryData[entryI
ndex]); |
| 739 if (event.hasCategory(WebInspector.TimelineModel.Category.LatencyInfo)) { | 739 if (event.hasCategory(TimelineModel.TimelineModel.Category.LatencyInfo)) { |
| 740 var timeWaitingForMainThread = WebInspector.TimelineData.forEvent(event)
.timeWaitingForMainThread; | 740 var timeWaitingForMainThread = TimelineModel.TimelineData.forEvent(event
).timeWaitingForMainThread; |
| 741 if (timeWaitingForMainThread) { | 741 if (timeWaitingForMainThread) { |
| 742 context.fillStyle = 'hsla(0, 70%, 60%, 1)'; | 742 context.fillStyle = 'hsla(0, 70%, 60%, 1)'; |
| 743 var width = Math.floor(unclippedBarX - barX + timeWaitingForMainThread
* timeToPixels); | 743 var width = Math.floor(unclippedBarX - barX + timeWaitingForMainThread
* timeToPixels); |
| 744 context.fillRect(barX, barY + barHeight - 3, width, 2); | 744 context.fillRect(barX, barY + barHeight - 3, width, 2); |
| 745 } | 745 } |
| 746 } | 746 } |
| 747 if (WebInspector.TimelineData.forEvent(event).warning) | 747 if (TimelineModel.TimelineData.forEvent(event).warning) |
| 748 paintWarningDecoration(barX, barWidth - 1.5); | 748 paintWarningDecoration(barX, barWidth - 1.5); |
| 749 } | 749 } |
| 750 | 750 |
| 751 /** | 751 /** |
| 752 * @param {number} x | 752 * @param {number} x |
| 753 * @param {number} width | 753 * @param {number} width |
| 754 */ | 754 */ |
| 755 function paintWarningDecoration(x, width) { | 755 function paintWarningDecoration(x, width) { |
| 756 var /** @const */ triangleSize = 8; | 756 var /** @const */ triangleSize = 8; |
| 757 context.save(); | 757 context.save(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 770 return false; | 770 return false; |
| 771 } | 771 } |
| 772 | 772 |
| 773 /** | 773 /** |
| 774 * @override | 774 * @override |
| 775 * @param {number} entryIndex | 775 * @param {number} entryIndex |
| 776 * @return {boolean} | 776 * @return {boolean} |
| 777 */ | 777 */ |
| 778 forceDecoration(entryIndex) { | 778 forceDecoration(entryIndex) { |
| 779 var type = this._entryType(entryIndex); | 779 var type = this._entryType(entryIndex); |
| 780 return type === WebInspector.TimelineFlameChartEntryType.Frame || | 780 return type === Timeline.TimelineFlameChartEntryType.Frame || |
| 781 type === WebInspector.TimelineFlameChartEntryType.Event && | 781 type === Timeline.TimelineFlameChartEntryType.Event && |
| 782 !!WebInspector.TimelineData.forEvent(/** @type {!WebInspector.TracingMod
el.Event} */ (this._entryData[entryIndex])).warning; | 782 !!TimelineModel.TimelineData.forEvent(/** @type {!SDK.TracingModel.Event
} */ (this._entryData[entryIndex])).warning; |
| 783 } | 783 } |
| 784 | 784 |
| 785 /** | 785 /** |
| 786 * @param {string} title | 786 * @param {string} title |
| 787 * @param {!WebInspector.FlameChart.GroupStyle} style | 787 * @param {!UI.FlameChart.GroupStyle} style |
| 788 * @param {boolean=} expanded | 788 * @param {boolean=} expanded |
| 789 */ | 789 */ |
| 790 _appendHeader(title, style, expanded) { | 790 _appendHeader(title, style, expanded) { |
| 791 this._timelineData.groups.push({startLevel: this._currentLevel, name: title,
expanded: expanded, style: style}); | 791 this._timelineData.groups.push({startLevel: this._currentLevel, name: title,
expanded: expanded, style: style}); |
| 792 } | 792 } |
| 793 | 793 |
| 794 /** | 794 /** |
| 795 * @param {!WebInspector.TracingModel.Event} event | 795 * @param {!SDK.TracingModel.Event} event |
| 796 * @param {number} level | 796 * @param {number} level |
| 797 */ | 797 */ |
| 798 _appendEvent(event, level) { | 798 _appendEvent(event, level) { |
| 799 var index = this._entryData.length; | 799 var index = this._entryData.length; |
| 800 this._entryData.push(event); | 800 this._entryData.push(event); |
| 801 this._timelineData.entryLevels[index] = level; | 801 this._timelineData.entryLevels[index] = level; |
| 802 var duration; | 802 var duration; |
| 803 if (WebInspector.TimelineModel.isMarkerEvent(event)) | 803 if (TimelineModel.TimelineModel.isMarkerEvent(event)) |
| 804 duration = undefined; | 804 duration = undefined; |
| 805 else | 805 else |
| 806 duration = event.duration || WebInspector.TimelineFlameChartDataProvider.I
nstantEventVisibleDurationMs; | 806 duration = event.duration || Timeline.TimelineFlameChartDataProvider.Insta
ntEventVisibleDurationMs; |
| 807 this._timelineData.entryTotalTimes[index] = duration; | 807 this._timelineData.entryTotalTimes[index] = duration; |
| 808 this._timelineData.entryStartTimes[index] = event.startTime; | 808 this._timelineData.entryStartTimes[index] = event.startTime; |
| 809 } | 809 } |
| 810 | 810 |
| 811 /** | 811 /** |
| 812 * @param {!WebInspector.TracingModel.Event} event | 812 * @param {!SDK.TracingModel.Event} event |
| 813 * @param {number} level | 813 * @param {number} level |
| 814 */ | 814 */ |
| 815 _appendFlowEvent(event, level) { | 815 _appendFlowEvent(event, level) { |
| 816 var timelineData = this._timelineData; | 816 var timelineData = this._timelineData; |
| 817 /** | 817 /** |
| 818 * @param {!WebInspector.TracingModel.Event} event | 818 * @param {!SDK.TracingModel.Event} event |
| 819 * @return {number} | 819 * @return {number} |
| 820 */ | 820 */ |
| 821 function pushStartFlow(event) { | 821 function pushStartFlow(event) { |
| 822 var flowIndex = timelineData.flowStartTimes.length; | 822 var flowIndex = timelineData.flowStartTimes.length; |
| 823 timelineData.flowStartTimes.push(event.startTime); | 823 timelineData.flowStartTimes.push(event.startTime); |
| 824 timelineData.flowStartLevels.push(level); | 824 timelineData.flowStartLevels.push(level); |
| 825 return flowIndex; | 825 return flowIndex; |
| 826 } | 826 } |
| 827 | 827 |
| 828 /** | 828 /** |
| 829 * @param {!WebInspector.TracingModel.Event} event | 829 * @param {!SDK.TracingModel.Event} event |
| 830 * @param {number} flowIndex | 830 * @param {number} flowIndex |
| 831 */ | 831 */ |
| 832 function pushEndFlow(event, flowIndex) { | 832 function pushEndFlow(event, flowIndex) { |
| 833 timelineData.flowEndTimes[flowIndex] = event.startTime; | 833 timelineData.flowEndTimes[flowIndex] = event.startTime; |
| 834 timelineData.flowEndLevels[flowIndex] = level; | 834 timelineData.flowEndLevels[flowIndex] = level; |
| 835 } | 835 } |
| 836 | 836 |
| 837 switch (event.phase) { | 837 switch (event.phase) { |
| 838 case WebInspector.TracingModel.Phase.FlowBegin: | 838 case SDK.TracingModel.Phase.FlowBegin: |
| 839 this._flowEventIndexById[event.id] = pushStartFlow(event); | 839 this._flowEventIndexById[event.id] = pushStartFlow(event); |
| 840 break; | 840 break; |
| 841 case WebInspector.TracingModel.Phase.FlowStep: | 841 case SDK.TracingModel.Phase.FlowStep: |
| 842 pushEndFlow(event, this._flowEventIndexById[event.id]); | 842 pushEndFlow(event, this._flowEventIndexById[event.id]); |
| 843 this._flowEventIndexById[event.id] = pushStartFlow(event); | 843 this._flowEventIndexById[event.id] = pushStartFlow(event); |
| 844 break; | 844 break; |
| 845 case WebInspector.TracingModel.Phase.FlowEnd: | 845 case SDK.TracingModel.Phase.FlowEnd: |
| 846 pushEndFlow(event, this._flowEventIndexById[event.id]); | 846 pushEndFlow(event, this._flowEventIndexById[event.id]); |
| 847 delete this._flowEventIndexById[event.id]; | 847 delete this._flowEventIndexById[event.id]; |
| 848 break; | 848 break; |
| 849 } | 849 } |
| 850 } | 850 } |
| 851 | 851 |
| 852 /** | 852 /** |
| 853 * @param {!WebInspector.TracingModel.AsyncEvent} asyncEvent | 853 * @param {!SDK.TracingModel.AsyncEvent} asyncEvent |
| 854 * @param {number} level | 854 * @param {number} level |
| 855 */ | 855 */ |
| 856 _appendAsyncEvent(asyncEvent, level) { | 856 _appendAsyncEvent(asyncEvent, level) { |
| 857 if (WebInspector.TracingModel.isNestableAsyncPhase(asyncEvent.phase)) { | 857 if (SDK.TracingModel.isNestableAsyncPhase(asyncEvent.phase)) { |
| 858 // FIXME: also add steps once we support event nesting in the FlameChart. | 858 // FIXME: also add steps once we support event nesting in the FlameChart. |
| 859 this._appendEvent(asyncEvent, level); | 859 this._appendEvent(asyncEvent, level); |
| 860 return; | 860 return; |
| 861 } | 861 } |
| 862 var steps = asyncEvent.steps; | 862 var steps = asyncEvent.steps; |
| 863 // If we have past steps, put the end event for each range rather than start
one. | 863 // If we have past steps, put the end event for each range rather than start
one. |
| 864 var eventOffset = steps.length > 1 && steps[1].phase === WebInspector.Tracin
gModel.Phase.AsyncStepPast ? 1 : 0; | 864 var eventOffset = steps.length > 1 && steps[1].phase === SDK.TracingModel.Ph
ase.AsyncStepPast ? 1 : 0; |
| 865 for (var i = 0; i < steps.length - 1; ++i) { | 865 for (var i = 0; i < steps.length - 1; ++i) { |
| 866 var index = this._entryData.length; | 866 var index = this._entryData.length; |
| 867 this._entryData.push(steps[i + eventOffset]); | 867 this._entryData.push(steps[i + eventOffset]); |
| 868 var startTime = steps[i].startTime; | 868 var startTime = steps[i].startTime; |
| 869 this._timelineData.entryLevels[index] = level; | 869 this._timelineData.entryLevels[index] = level; |
| 870 this._timelineData.entryTotalTimes[index] = steps[i + 1].startTime - start
Time; | 870 this._timelineData.entryTotalTimes[index] = steps[i + 1].startTime - start
Time; |
| 871 this._timelineData.entryStartTimes[index] = startTime; | 871 this._timelineData.entryStartTimes[index] = startTime; |
| 872 } | 872 } |
| 873 } | 873 } |
| 874 | 874 |
| 875 /** | 875 /** |
| 876 * @param {!WebInspector.TimelineFrame} frame | 876 * @param {!TimelineModel.TimelineFrame} frame |
| 877 */ | 877 */ |
| 878 _appendFrame(frame) { | 878 _appendFrame(frame) { |
| 879 var index = this._entryData.length; | 879 var index = this._entryData.length; |
| 880 this._entryData.push(frame); | 880 this._entryData.push(frame); |
| 881 this._entryIndexToTitle[index] = Number.millisToString(frame.duration, true)
; | 881 this._entryIndexToTitle[index] = Number.millisToString(frame.duration, true)
; |
| 882 this._timelineData.entryLevels[index] = this._currentLevel; | 882 this._timelineData.entryLevels[index] = this._currentLevel; |
| 883 this._timelineData.entryTotalTimes[index] = frame.duration; | 883 this._timelineData.entryTotalTimes[index] = frame.duration; |
| 884 this._timelineData.entryStartTimes[index] = frame.startTime; | 884 this._timelineData.entryStartTimes[index] = frame.startTime; |
| 885 } | 885 } |
| 886 | 886 |
| 887 /** | 887 /** |
| 888 * @param {!WebInspector.Segment} segment | 888 * @param {!Common.Segment} segment |
| 889 */ | 889 */ |
| 890 _appendSegment(segment) { | 890 _appendSegment(segment) { |
| 891 var index = this._entryData.length; | 891 var index = this._entryData.length; |
| 892 this._entryData.push(/** @type {!WebInspector.TimelineIRModel.Phases} */ (se
gment.data)); | 892 this._entryData.push(/** @type {!TimelineModel.TimelineIRModel.Phases} */ (s
egment.data)); |
| 893 this._entryIndexToTitle[index] = /** @type {string} */ (segment.data); | 893 this._entryIndexToTitle[index] = /** @type {string} */ (segment.data); |
| 894 this._timelineData.entryLevels[index] = this._currentLevel; | 894 this._timelineData.entryLevels[index] = this._currentLevel; |
| 895 this._timelineData.entryTotalTimes[index] = segment.end - segment.begin; | 895 this._timelineData.entryTotalTimes[index] = segment.end - segment.begin; |
| 896 this._timelineData.entryStartTimes[index] = segment.begin; | 896 this._timelineData.entryStartTimes[index] = segment.begin; |
| 897 } | 897 } |
| 898 | 898 |
| 899 /** | 899 /** |
| 900 * @override | 900 * @override |
| 901 * @param {number} entryIndex | 901 * @param {number} entryIndex |
| 902 * @return {?WebInspector.TimelineSelection} | 902 * @return {?Timeline.TimelineSelection} |
| 903 */ | 903 */ |
| 904 createSelection(entryIndex) { | 904 createSelection(entryIndex) { |
| 905 var type = this._entryType(entryIndex); | 905 var type = this._entryType(entryIndex); |
| 906 var timelineSelection = null; | 906 var timelineSelection = null; |
| 907 if (type === WebInspector.TimelineFlameChartEntryType.Event) | 907 if (type === Timeline.TimelineFlameChartEntryType.Event) |
| 908 timelineSelection = WebInspector.TimelineSelection.fromTraceEvent( | 908 timelineSelection = Timeline.TimelineSelection.fromTraceEvent( |
| 909 /** @type {!WebInspector.TracingModel.Event} */ (this._entryData[entry
Index])); | 909 /** @type {!SDK.TracingModel.Event} */ (this._entryData[entryIndex])); |
| 910 else if (type === WebInspector.TimelineFlameChartEntryType.Frame) | 910 else if (type === Timeline.TimelineFlameChartEntryType.Frame) |
| 911 timelineSelection = WebInspector.TimelineSelection.fromFrame( | 911 timelineSelection = Timeline.TimelineSelection.fromFrame( |
| 912 /** @type {!WebInspector.TimelineFrame} */ (this._entryData[entryIndex
])); | 912 /** @type {!TimelineModel.TimelineFrame} */ (this._entryData[entryInde
x])); |
| 913 if (timelineSelection) | 913 if (timelineSelection) |
| 914 this._lastSelection = new WebInspector.TimelineFlameChartView.Selection(ti
melineSelection, entryIndex); | 914 this._lastSelection = new Timeline.TimelineFlameChartView.Selection(timeli
neSelection, entryIndex); |
| 915 return timelineSelection; | 915 return timelineSelection; |
| 916 } | 916 } |
| 917 | 917 |
| 918 /** | 918 /** |
| 919 * @param {?WebInspector.TimelineSelection} selection | 919 * @param {?Timeline.TimelineSelection} selection |
| 920 * @return {number} | 920 * @return {number} |
| 921 */ | 921 */ |
| 922 entryIndexForSelection(selection) { | 922 entryIndexForSelection(selection) { |
| 923 if (!selection || selection.type() === WebInspector.TimelineSelection.Type.R
ange) | 923 if (!selection || selection.type() === Timeline.TimelineSelection.Type.Range
) |
| 924 return -1; | 924 return -1; |
| 925 | 925 |
| 926 if (this._lastSelection && this._lastSelection.timelineSelection.object() ==
= selection.object()) | 926 if (this._lastSelection && this._lastSelection.timelineSelection.object() ==
= selection.object()) |
| 927 return this._lastSelection.entryIndex; | 927 return this._lastSelection.entryIndex; |
| 928 var index = this._entryData.indexOf( | 928 var index = this._entryData.indexOf( |
| 929 /** @type {!WebInspector.TracingModel.Event|!WebInspector.TimelineFrame|
!WebInspector.TimelineIRModel.Phases} */ | 929 /** @type {!SDK.TracingModel.Event|!TimelineModel.TimelineFrame|!Timelin
eModel.TimelineIRModel.Phases} */ |
| 930 (selection.object())); | 930 (selection.object())); |
| 931 if (index !== -1) | 931 if (index !== -1) |
| 932 this._lastSelection = new WebInspector.TimelineFlameChartView.Selection(se
lection, index); | 932 this._lastSelection = new Timeline.TimelineFlameChartView.Selection(select
ion, index); |
| 933 return index; | 933 return index; |
| 934 } | 934 } |
| 935 }; | 935 }; |
| 936 | 936 |
| 937 WebInspector.TimelineFlameChartDataProvider.InstantEventVisibleDurationMs = 0.00
1; | 937 Timeline.TimelineFlameChartDataProvider.InstantEventVisibleDurationMs = 0.001; |
| 938 | 938 |
| 939 /** | 939 /** |
| 940 * @unrestricted | 940 * @unrestricted |
| 941 */ | 941 */ |
| 942 WebInspector.TimelineFlameChartNetworkDataProvider = class extends WebInspector.
TimelineFlameChartDataProviderBase { | 942 Timeline.TimelineFlameChartNetworkDataProvider = class extends Timeline.Timeline
FlameChartDataProviderBase { |
| 943 /** | 943 /** |
| 944 * @param {!WebInspector.TimelineModel} model | 944 * @param {!TimelineModel.TimelineModel} model |
| 945 */ | 945 */ |
| 946 constructor(model) { | 946 constructor(model) { |
| 947 super(model, []); | 947 super(model, []); |
| 948 var loadingCategory = WebInspector.TimelineUIUtils.categories()['loading']; | 948 var loadingCategory = Timeline.TimelineUIUtils.categories()['loading']; |
| 949 this._waitingColor = loadingCategory.childColor; | 949 this._waitingColor = loadingCategory.childColor; |
| 950 this._processingColor = loadingCategory.color; | 950 this._processingColor = loadingCategory.color; |
| 951 } | 951 } |
| 952 | 952 |
| 953 /** | 953 /** |
| 954 * @override | 954 * @override |
| 955 * @return {!WebInspector.FlameChart.TimelineData} | 955 * @return {!UI.FlameChart.TimelineData} |
| 956 */ | 956 */ |
| 957 timelineData() { | 957 timelineData() { |
| 958 if (this._timelineData) | 958 if (this._timelineData) |
| 959 return this._timelineData; | 959 return this._timelineData; |
| 960 /** @type {!Array<!WebInspector.TimelineModel.NetworkRequest>} */ | 960 /** @type {!Array<!TimelineModel.TimelineModel.NetworkRequest>} */ |
| 961 this._requests = []; | 961 this._requests = []; |
| 962 this._timelineData = new WebInspector.FlameChart.TimelineData([], [], [], []
); | 962 this._timelineData = new UI.FlameChart.TimelineData([], [], [], []); |
| 963 this._appendTimelineData(this._model.mainThreadEvents()); | 963 this._appendTimelineData(this._model.mainThreadEvents()); |
| 964 return this._timelineData; | 964 return this._timelineData; |
| 965 } | 965 } |
| 966 | 966 |
| 967 /** | 967 /** |
| 968 * @override | 968 * @override |
| 969 */ | 969 */ |
| 970 reset() { | 970 reset() { |
| 971 super.reset(); | 971 super.reset(); |
| 972 /** @type {!Array<!WebInspector.TimelineModel.NetworkRequest>} */ | 972 /** @type {!Array<!TimelineModel.TimelineModel.NetworkRequest>} */ |
| 973 this._requests = []; | 973 this._requests = []; |
| 974 } | 974 } |
| 975 | 975 |
| 976 /** | 976 /** |
| 977 * @param {number} startTime | 977 * @param {number} startTime |
| 978 * @param {number} endTime | 978 * @param {number} endTime |
| 979 */ | 979 */ |
| 980 setWindowTimes(startTime, endTime) { | 980 setWindowTimes(startTime, endTime) { |
| 981 this._startTime = startTime; | 981 this._startTime = startTime; |
| 982 this._endTime = endTime; | 982 this._endTime = endTime; |
| 983 this._updateTimelineData(); | 983 this._updateTimelineData(); |
| 984 } | 984 } |
| 985 | 985 |
| 986 /** | 986 /** |
| 987 * @override | 987 * @override |
| 988 * @param {number} index | 988 * @param {number} index |
| 989 * @return {?WebInspector.TimelineSelection} | 989 * @return {?Timeline.TimelineSelection} |
| 990 */ | 990 */ |
| 991 createSelection(index) { | 991 createSelection(index) { |
| 992 if (index === -1) | 992 if (index === -1) |
| 993 return null; | 993 return null; |
| 994 var request = this._requests[index]; | 994 var request = this._requests[index]; |
| 995 this._lastSelection = new WebInspector.TimelineFlameChartView.Selection( | 995 this._lastSelection = new Timeline.TimelineFlameChartView.Selection( |
| 996 WebInspector.TimelineSelection.fromNetworkRequest(request), index); | 996 Timeline.TimelineSelection.fromNetworkRequest(request), index); |
| 997 return this._lastSelection.timelineSelection; | 997 return this._lastSelection.timelineSelection; |
| 998 } | 998 } |
| 999 | 999 |
| 1000 /** | 1000 /** |
| 1001 * @param {?WebInspector.TimelineSelection} selection | 1001 * @param {?Timeline.TimelineSelection} selection |
| 1002 * @return {number} | 1002 * @return {number} |
| 1003 */ | 1003 */ |
| 1004 entryIndexForSelection(selection) { | 1004 entryIndexForSelection(selection) { |
| 1005 if (!selection) | 1005 if (!selection) |
| 1006 return -1; | 1006 return -1; |
| 1007 | 1007 |
| 1008 if (this._lastSelection && this._lastSelection.timelineSelection.object() ==
= selection.object()) | 1008 if (this._lastSelection && this._lastSelection.timelineSelection.object() ==
= selection.object()) |
| 1009 return this._lastSelection.entryIndex; | 1009 return this._lastSelection.entryIndex; |
| 1010 | 1010 |
| 1011 if (selection.type() !== WebInspector.TimelineSelection.Type.NetworkRequest) | 1011 if (selection.type() !== Timeline.TimelineSelection.Type.NetworkRequest) |
| 1012 return -1; | 1012 return -1; |
| 1013 var request = /** @type{!WebInspector.TimelineModel.NetworkRequest} */ (sele
ction.object()); | 1013 var request = /** @type{!TimelineModel.TimelineModel.NetworkRequest} */ (sel
ection.object()); |
| 1014 var index = this._requests.indexOf(request); | 1014 var index = this._requests.indexOf(request); |
| 1015 if (index !== -1) | 1015 if (index !== -1) |
| 1016 this._lastSelection = new WebInspector.TimelineFlameChartView.Selection( | 1016 this._lastSelection = new Timeline.TimelineFlameChartView.Selection( |
| 1017 WebInspector.TimelineSelection.fromNetworkRequest(request), index); | 1017 Timeline.TimelineSelection.fromNetworkRequest(request), index); |
| 1018 return index; | 1018 return index; |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 /** | 1021 /** |
| 1022 * @override | 1022 * @override |
| 1023 * @param {number} index | 1023 * @param {number} index |
| 1024 * @return {string} | 1024 * @return {string} |
| 1025 */ | 1025 */ |
| 1026 entryColor(index) { | 1026 entryColor(index) { |
| 1027 var request = /** @type {!WebInspector.TimelineModel.NetworkRequest} */ (thi
s._requests[index]); | 1027 var request = /** @type {!TimelineModel.TimelineModel.NetworkRequest} */ (th
is._requests[index]); |
| 1028 var category = WebInspector.TimelineUIUtils.networkRequestCategory(request); | 1028 var category = Timeline.TimelineUIUtils.networkRequestCategory(request); |
| 1029 return WebInspector.TimelineUIUtils.networkCategoryColor(category); | 1029 return Timeline.TimelineUIUtils.networkCategoryColor(category); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 /** | 1032 /** |
| 1033 * @override | 1033 * @override |
| 1034 * @param {number} index | 1034 * @param {number} index |
| 1035 * @return {?string} | 1035 * @return {?string} |
| 1036 */ | 1036 */ |
| 1037 entryTitle(index) { | 1037 entryTitle(index) { |
| 1038 var request = /** @type {!WebInspector.TimelineModel.NetworkRequest} */ (thi
s._requests[index]); | 1038 var request = /** @type {!TimelineModel.TimelineModel.NetworkRequest} */ (th
is._requests[index]); |
| 1039 return request.url || null; | 1039 return request.url || null; |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 /** | 1042 /** |
| 1043 * @override | 1043 * @override |
| 1044 * @param {number} index | 1044 * @param {number} index |
| 1045 * @param {!CanvasRenderingContext2D} context | 1045 * @param {!CanvasRenderingContext2D} context |
| 1046 * @param {?string} text | 1046 * @param {?string} text |
| 1047 * @param {number} barX | 1047 * @param {number} barX |
| 1048 * @param {number} barY | 1048 * @param {number} barY |
| 1049 * @param {number} barWidth | 1049 * @param {number} barWidth |
| 1050 * @param {number} barHeight | 1050 * @param {number} barHeight |
| 1051 * @param {number} unclippedBarX | 1051 * @param {number} unclippedBarX |
| 1052 * @param {number} timeToPixelRatio | 1052 * @param {number} timeToPixelRatio |
| 1053 * @return {boolean} | 1053 * @return {boolean} |
| 1054 */ | 1054 */ |
| 1055 decorateEntry(index, context, text, barX, barY, barWidth, barHeight, unclipped
BarX, timeToPixelRatio) { | 1055 decorateEntry(index, context, text, barX, barY, barWidth, barHeight, unclipped
BarX, timeToPixelRatio) { |
| 1056 const request = /** @type {!WebInspector.TimelineModel.NetworkRequest} */ (t
his._requests[index]); | 1056 const request = /** @type {!TimelineModel.TimelineModel.NetworkRequest} */ (
this._requests[index]); |
| 1057 if (!request.timing) | 1057 if (!request.timing) |
| 1058 return false; | 1058 return false; |
| 1059 | 1059 |
| 1060 /** | 1060 /** |
| 1061 * @param {number} time | 1061 * @param {number} time |
| 1062 * @return {number} | 1062 * @return {number} |
| 1063 */ | 1063 */ |
| 1064 function timeToPixel(time) { | 1064 function timeToPixel(time) { |
| 1065 return Math.floor(unclippedBarX + (time - startTime) * timeToPixelRatio); | 1065 return Math.floor(unclippedBarX + (time - startTime) * timeToPixelRatio); |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 const minBarWidthPx = 2; | 1068 const minBarWidthPx = 2; |
| 1069 const startTime = request.startTime; | 1069 const startTime = request.startTime; |
| 1070 const endTime = request.endTime; | 1070 const endTime = request.endTime; |
| 1071 const requestTime = request.timing.requestTime * 1000; | 1071 const requestTime = request.timing.requestTime * 1000; |
| 1072 const sendStart = Math.max(timeToPixel(requestTime + request.timing.sendStar
t), unclippedBarX); | 1072 const sendStart = Math.max(timeToPixel(requestTime + request.timing.sendStar
t), unclippedBarX); |
| 1073 const headersEnd = Math.max(timeToPixel(requestTime + request.timing.receive
HeadersEnd), sendStart); | 1073 const headersEnd = Math.max(timeToPixel(requestTime + request.timing.receive
HeadersEnd), sendStart); |
| 1074 const finish = Math.max(timeToPixel(request.finishTime || endTime), headersE
nd + minBarWidthPx); | 1074 const finish = Math.max(timeToPixel(request.finishTime || endTime), headersE
nd + minBarWidthPx); |
| 1075 const end = Math.max(timeToPixel(endTime), finish); | 1075 const end = Math.max(timeToPixel(endTime), finish); |
| 1076 | 1076 |
| 1077 context.fillStyle = 'hsla(0, 100%, 100%, 0.8)'; | 1077 context.fillStyle = 'hsla(0, 100%, 100%, 0.8)'; |
| 1078 context.fillRect(sendStart + 0.5, barY + 0.5, headersEnd - sendStart - 0.5,
barHeight - 2); | 1078 context.fillRect(sendStart + 0.5, barY + 0.5, headersEnd - sendStart - 0.5,
barHeight - 2); |
| 1079 context.fillStyle = WebInspector.themeSupport.patchColor('white', WebInspect
or.ThemeSupport.ColorUsage.Background); | 1079 context.fillStyle = UI.themeSupport.patchColor('white', UI.ThemeSupport.Colo
rUsage.Background); |
| 1080 context.fillRect(barX, barY - 0.5, sendStart - barX, barHeight); | 1080 context.fillRect(barX, barY - 0.5, sendStart - barX, barHeight); |
| 1081 context.fillRect(finish, barY - 0.5, barX + barWidth - finish, barHeight); | 1081 context.fillRect(finish, barY - 0.5, barX + barWidth - finish, barHeight); |
| 1082 | 1082 |
| 1083 /** | 1083 /** |
| 1084 * @param {number} begin | 1084 * @param {number} begin |
| 1085 * @param {number} end | 1085 * @param {number} end |
| 1086 * @param {number} y | 1086 * @param {number} y |
| 1087 */ | 1087 */ |
| 1088 function drawTick(begin, end, y) { | 1088 function drawTick(begin, end, y) { |
| 1089 const tickHeightPx = 6; | 1089 const tickHeightPx = 6; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 const textStart = Math.max(sendStart, 0); | 1113 const textStart = Math.max(sendStart, 0); |
| 1114 const textWidth = finish - textStart; | 1114 const textWidth = finish - textStart; |
| 1115 const minTextWidthPx = 20; | 1115 const minTextWidthPx = 20; |
| 1116 const textPadding = 6; | 1116 const textPadding = 6; |
| 1117 if (textWidth >= minTextWidthPx) { | 1117 if (textWidth >= minTextWidthPx) { |
| 1118 const text = this.entryTitle(index); | 1118 const text = this.entryTitle(index); |
| 1119 if (text && text.length) { | 1119 if (text && text.length) { |
| 1120 context.fillStyle = '#333'; | 1120 context.fillStyle = '#333'; |
| 1121 const trimmedText = WebInspector.trimTextMiddle(context, text, textWidth
- 2 * textPadding); | 1121 const trimmedText = UI.trimTextMiddle(context, text, textWidth - 2 * tex
tPadding); |
| 1122 const textBaseHeight = barHeight - this.textBaseline(); | 1122 const textBaseHeight = barHeight - this.textBaseline(); |
| 1123 context.fillText(trimmedText, textStart + textPadding, barY + textBaseHe
ight); | 1123 context.fillText(trimmedText, textStart + textPadding, barY + textBaseHe
ight); |
| 1124 } | 1124 } |
| 1125 } | 1125 } |
| 1126 | 1126 |
| 1127 return true; | 1127 return true; |
| 1128 } | 1128 } |
| 1129 | 1129 |
| 1130 /** | 1130 /** |
| 1131 * @override | 1131 * @override |
| 1132 * @param {number} index | 1132 * @param {number} index |
| 1133 * @return {boolean} | 1133 * @return {boolean} |
| 1134 */ | 1134 */ |
| 1135 forceDecoration(index) { | 1135 forceDecoration(index) { |
| 1136 return true; | 1136 return true; |
| 1137 } | 1137 } |
| 1138 | 1138 |
| 1139 /** | 1139 /** |
| 1140 * @override | 1140 * @override |
| 1141 * @param {number} index | 1141 * @param {number} index |
| 1142 * @return {?Element} | 1142 * @return {?Element} |
| 1143 */ | 1143 */ |
| 1144 prepareHighlightedEntryInfo(index) { | 1144 prepareHighlightedEntryInfo(index) { |
| 1145 var /** @const */ maxURLChars = 80; | 1145 var /** @const */ maxURLChars = 80; |
| 1146 var request = /** @type {!WebInspector.TimelineModel.NetworkRequest} */ (thi
s._requests[index]); | 1146 var request = /** @type {!TimelineModel.TimelineModel.NetworkRequest} */ (th
is._requests[index]); |
| 1147 if (!request.url) | 1147 if (!request.url) |
| 1148 return null; | 1148 return null; |
| 1149 var element = createElement('div'); | 1149 var element = createElement('div'); |
| 1150 var root = WebInspector.createShadowRootWithCoreStyles(element, 'timeline/ti
melineFlamechartPopover.css'); | 1150 var root = UI.createShadowRootWithCoreStyles(element, 'timeline/timelineFlam
echartPopover.css'); |
| 1151 var contents = root.createChild('div', 'timeline-flamechart-popover'); | 1151 var contents = root.createChild('div', 'timeline-flamechart-popover'); |
| 1152 var duration = request.endTime - request.startTime; | 1152 var duration = request.endTime - request.startTime; |
| 1153 if (request.startTime && isFinite(duration)) | 1153 if (request.startTime && isFinite(duration)) |
| 1154 contents.createChild('span', 'timeline-info-network-time').textContent = N
umber.millisToString(duration); | 1154 contents.createChild('span', 'timeline-info-network-time').textContent = N
umber.millisToString(duration); |
| 1155 if (typeof request.priority === 'string') { | 1155 if (typeof request.priority === 'string') { |
| 1156 var div = contents.createChild('span'); | 1156 var div = contents.createChild('span'); |
| 1157 div.textContent = | 1157 div.textContent = |
| 1158 WebInspector.uiLabelForPriority(/** @type {!Protocol.Network.ResourceP
riority} */ (request.priority)); | 1158 Components.uiLabelForPriority(/** @type {!Protocol.Network.ResourcePri
ority} */ (request.priority)); |
| 1159 div.style.color = this._colorForPriority(request.priority) || 'black'; | 1159 div.style.color = this._colorForPriority(request.priority) || 'black'; |
| 1160 } | 1160 } |
| 1161 contents.createChild('span').textContent = request.url.trimMiddle(maxURLChar
s); | 1161 contents.createChild('span').textContent = request.url.trimMiddle(maxURLChar
s); |
| 1162 return element; | 1162 return element; |
| 1163 } | 1163 } |
| 1164 | 1164 |
| 1165 /** | 1165 /** |
| 1166 * @param {string} priority | 1166 * @param {string} priority |
| 1167 * @return {?string} | 1167 * @return {?string} |
| 1168 */ | 1168 */ |
| 1169 _colorForPriority(priority) { | 1169 _colorForPriority(priority) { |
| 1170 switch (/** @type {!Protocol.Network.ResourcePriority} */ (priority)) { | 1170 switch (/** @type {!Protocol.Network.ResourcePriority} */ (priority)) { |
| 1171 case Protocol.Network.ResourcePriority.VeryLow: | 1171 case Protocol.Network.ResourcePriority.VeryLow: |
| 1172 return '#080'; | 1172 return '#080'; |
| 1173 case Protocol.Network.ResourcePriority.Low: | 1173 case Protocol.Network.ResourcePriority.Low: |
| 1174 return '#6c0'; | 1174 return '#6c0'; |
| 1175 case Protocol.Network.ResourcePriority.Medium: | 1175 case Protocol.Network.ResourcePriority.Medium: |
| 1176 return '#fa0'; | 1176 return '#fa0'; |
| 1177 case Protocol.Network.ResourcePriority.High: | 1177 case Protocol.Network.ResourcePriority.High: |
| 1178 return '#f60'; | 1178 return '#f60'; |
| 1179 case Protocol.Network.ResourcePriority.VeryHigh: | 1179 case Protocol.Network.ResourcePriority.VeryHigh: |
| 1180 return '#f00'; | 1180 return '#f00'; |
| 1181 } | 1181 } |
| 1182 return null; | 1182 return null; |
| 1183 } | 1183 } |
| 1184 | 1184 |
| 1185 /** | 1185 /** |
| 1186 * @param {!Array.<!WebInspector.TracingModel.Event>} events | 1186 * @param {!Array.<!SDK.TracingModel.Event>} events |
| 1187 */ | 1187 */ |
| 1188 _appendTimelineData(events) { | 1188 _appendTimelineData(events) { |
| 1189 this._minimumBoundary = this._model.minimumRecordTime(); | 1189 this._minimumBoundary = this._model.minimumRecordTime(); |
| 1190 this._maximumBoundary = this._model.maximumRecordTime(); | 1190 this._maximumBoundary = this._model.maximumRecordTime(); |
| 1191 this._timeSpan = this._model.isEmpty() ? 1000 : this._maximumBoundary - this
._minimumBoundary; | 1191 this._timeSpan = this._model.isEmpty() ? 1000 : this._maximumBoundary - this
._minimumBoundary; |
| 1192 this._model.networkRequests().forEach(this._appendEntry.bind(this)); | 1192 this._model.networkRequests().forEach(this._appendEntry.bind(this)); |
| 1193 this._updateTimelineData(); | 1193 this._updateTimelineData(); |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 _updateTimelineData() { | 1196 _updateTimelineData() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1208 if (lastTime > r.startTime) | 1208 if (lastTime > r.startTime) |
| 1209 ++index; | 1209 ++index; |
| 1210 lastTime = r.endTime; | 1210 lastTime = r.endTime; |
| 1211 this._timelineData.entryLevels[i] = index; | 1211 this._timelineData.entryLevels[i] = index; |
| 1212 } | 1212 } |
| 1213 ++index; | 1213 ++index; |
| 1214 for (var i = 0; i < this._requests.length; ++i) { | 1214 for (var i = 0; i < this._requests.length; ++i) { |
| 1215 if (this._timelineData.entryLevels[i] === -1) | 1215 if (this._timelineData.entryLevels[i] === -1) |
| 1216 this._timelineData.entryLevels[i] = index; | 1216 this._timelineData.entryLevels[i] = index; |
| 1217 } | 1217 } |
| 1218 this._timelineData = new WebInspector.FlameChart.TimelineData( | 1218 this._timelineData = new UI.FlameChart.TimelineData( |
| 1219 this._timelineData.entryLevels, this._timelineData.entryTotalTimes, this
._timelineData.entryStartTimes, null); | 1219 this._timelineData.entryLevels, this._timelineData.entryTotalTimes, this
._timelineData.entryStartTimes, null); |
| 1220 this._currentLevel = index; | 1220 this._currentLevel = index; |
| 1221 } | 1221 } |
| 1222 | 1222 |
| 1223 /** | 1223 /** |
| 1224 * @param {!WebInspector.TimelineModel.NetworkRequest} request | 1224 * @param {!TimelineModel.TimelineModel.NetworkRequest} request |
| 1225 */ | 1225 */ |
| 1226 _appendEntry(request) { | 1226 _appendEntry(request) { |
| 1227 this._requests.push(request); | 1227 this._requests.push(request); |
| 1228 this._timelineData.entryStartTimes.push(request.startTime); | 1228 this._timelineData.entryStartTimes.push(request.startTime); |
| 1229 this._timelineData.entryTotalTimes.push(request.endTime - request.startTime)
; | 1229 this._timelineData.entryTotalTimes.push(request.endTime - request.startTime)
; |
| 1230 this._timelineData.entryLevels.push(this._requests.length - 1); | 1230 this._timelineData.entryLevels.push(this._requests.length - 1); |
| 1231 } | 1231 } |
| 1232 }; | 1232 }; |
| 1233 | 1233 |
| 1234 /** | 1234 /** |
| 1235 * @implements {WebInspector.FlameChartMarker} | 1235 * @implements {UI.FlameChartMarker} |
| 1236 * @unrestricted | 1236 * @unrestricted |
| 1237 */ | 1237 */ |
| 1238 WebInspector.TimelineFlameChartMarker = class { | 1238 Timeline.TimelineFlameChartMarker = class { |
| 1239 /** | 1239 /** |
| 1240 * @param {number} startTime | 1240 * @param {number} startTime |
| 1241 * @param {number} startOffset | 1241 * @param {number} startOffset |
| 1242 * @param {!WebInspector.TimelineMarkerStyle} style | 1242 * @param {!Timeline.TimelineMarkerStyle} style |
| 1243 */ | 1243 */ |
| 1244 constructor(startTime, startOffset, style) { | 1244 constructor(startTime, startOffset, style) { |
| 1245 this._startTime = startTime; | 1245 this._startTime = startTime; |
| 1246 this._startOffset = startOffset; | 1246 this._startOffset = startOffset; |
| 1247 this._style = style; | 1247 this._style = style; |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 /** | 1250 /** |
| 1251 * @override | 1251 * @override |
| 1252 * @return {number} | 1252 * @return {number} |
| 1253 */ | 1253 */ |
| 1254 startTime() { | 1254 startTime() { |
| 1255 return this._startTime; | 1255 return this._startTime; |
| 1256 } | 1256 } |
| 1257 | 1257 |
| 1258 /** | 1258 /** |
| 1259 * @override | 1259 * @override |
| 1260 * @return {string} | 1260 * @return {string} |
| 1261 */ | 1261 */ |
| 1262 color() { | 1262 color() { |
| 1263 return this._style.color; | 1263 return this._style.color; |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 /** | 1266 /** |
| 1267 * @override | 1267 * @override |
| 1268 * @return {string} | 1268 * @return {string} |
| 1269 */ | 1269 */ |
| 1270 title() { | 1270 title() { |
| 1271 var startTime = Number.millisToString(this._startOffset); | 1271 var startTime = Number.millisToString(this._startOffset); |
| 1272 return WebInspector.UIString('%s at %s', this._style.title, startTime); | 1272 return Common.UIString('%s at %s', this._style.title, startTime); |
| 1273 } | 1273 } |
| 1274 | 1274 |
| 1275 /** | 1275 /** |
| 1276 * @override | 1276 * @override |
| 1277 * @param {!CanvasRenderingContext2D} context | 1277 * @param {!CanvasRenderingContext2D} context |
| 1278 * @param {number} x | 1278 * @param {number} x |
| 1279 * @param {number} height | 1279 * @param {number} height |
| 1280 * @param {number} pixelsPerMillisecond | 1280 * @param {number} pixelsPerMillisecond |
| 1281 */ | 1281 */ |
| 1282 draw(context, x, height, pixelsPerMillisecond) { | 1282 draw(context, x, height, pixelsPerMillisecond) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1303 context.moveTo(x, height); | 1303 context.moveTo(x, height); |
| 1304 context.setLineDash(this._style.dashStyle); | 1304 context.setLineDash(this._style.dashStyle); |
| 1305 context.lineTo(x, context.canvas.height); | 1305 context.lineTo(x, context.canvas.height); |
| 1306 context.stroke(); | 1306 context.stroke(); |
| 1307 } | 1307 } |
| 1308 context.restore(); | 1308 context.restore(); |
| 1309 } | 1309 } |
| 1310 }; | 1310 }; |
| 1311 | 1311 |
| 1312 /** | 1312 /** |
| 1313 * @implements {WebInspector.TimelineModeView} | 1313 * @implements {Timeline.TimelineModeView} |
| 1314 * @implements {WebInspector.FlameChartDelegate} | 1314 * @implements {UI.FlameChartDelegate} |
| 1315 * @unrestricted | 1315 * @unrestricted |
| 1316 */ | 1316 */ |
| 1317 WebInspector.TimelineFlameChartView = class extends WebInspector.VBox { | 1317 Timeline.TimelineFlameChartView = class extends UI.VBox { |
| 1318 /** | 1318 /** |
| 1319 * @param {!WebInspector.TimelineModeViewDelegate} delegate | 1319 * @param {!Timeline.TimelineModeViewDelegate} delegate |
| 1320 * @param {!WebInspector.TimelineModel} timelineModel | 1320 * @param {!TimelineModel.TimelineModel} timelineModel |
| 1321 * @param {!WebInspector.TimelineFrameModel} frameModel | 1321 * @param {!TimelineModel.TimelineFrameModel} frameModel |
| 1322 * @param {!WebInspector.TimelineIRModel} irModel | 1322 * @param {!TimelineModel.TimelineIRModel} irModel |
| 1323 * @param {!Array<!WebInspector.TimelineModel.Filter>} filters | 1323 * @param {!Array<!TimelineModel.TimelineModel.Filter>} filters |
| 1324 */ | 1324 */ |
| 1325 constructor(delegate, timelineModel, frameModel, irModel, filters) { | 1325 constructor(delegate, timelineModel, frameModel, irModel, filters) { |
| 1326 super(); | 1326 super(); |
| 1327 this.element.classList.add('timeline-flamechart'); | 1327 this.element.classList.add('timeline-flamechart'); |
| 1328 this._delegate = delegate; | 1328 this._delegate = delegate; |
| 1329 this._model = timelineModel; | 1329 this._model = timelineModel; |
| 1330 | 1330 |
| 1331 this._splitWidget = new WebInspector.SplitWidget(false, false, 'timelineFlam
echartMainView', 150); | 1331 this._splitWidget = new UI.SplitWidget(false, false, 'timelineFlamechartMain
View', 150); |
| 1332 | 1332 |
| 1333 this._dataProvider = new WebInspector.TimelineFlameChartDataProvider(this._m
odel, frameModel, irModel, filters); | 1333 this._dataProvider = new Timeline.TimelineFlameChartDataProvider(this._model
, frameModel, irModel, filters); |
| 1334 var mainViewGroupExpansionSetting = | 1334 var mainViewGroupExpansionSetting = |
| 1335 WebInspector.settings.createSetting('timelineFlamechartMainViewGroupExpa
nsion', {}); | 1335 Common.settings.createSetting('timelineFlamechartMainViewGroupExpansion'
, {}); |
| 1336 this._mainView = new WebInspector.FlameChart(this._dataProvider, this, mainV
iewGroupExpansionSetting); | 1336 this._mainView = new UI.FlameChart(this._dataProvider, this, mainViewGroupEx
pansionSetting); |
| 1337 | 1337 |
| 1338 this._networkDataProvider = new WebInspector.TimelineFlameChartNetworkDataPr
ovider(this._model); | 1338 this._networkDataProvider = new Timeline.TimelineFlameChartNetworkDataProvid
er(this._model); |
| 1339 this._networkView = new WebInspector.FlameChart(this._networkDataProvider, t
his); | 1339 this._networkView = new UI.FlameChart(this._networkDataProvider, this); |
| 1340 | 1340 |
| 1341 this._splitWidget.setMainWidget(this._mainView); | 1341 this._splitWidget.setMainWidget(this._mainView); |
| 1342 this._splitWidget.setSidebarWidget(this._networkView); | 1342 this._splitWidget.setSidebarWidget(this._networkView); |
| 1343 this._splitWidget.show(this.element); | 1343 this._splitWidget.show(this.element); |
| 1344 | 1344 |
| 1345 this._onMainEntrySelected = this._onEntrySelected.bind(this, this._dataProvi
der); | 1345 this._onMainEntrySelected = this._onEntrySelected.bind(this, this._dataProvi
der); |
| 1346 this._onNetworkEntrySelected = this._onEntrySelected.bind(this, this._networ
kDataProvider); | 1346 this._onNetworkEntrySelected = this._onEntrySelected.bind(this, this._networ
kDataProvider); |
| 1347 this._mainView.addEventListener(WebInspector.FlameChart.Events.EntrySelected
, this._onMainEntrySelected, this); | 1347 this._mainView.addEventListener(UI.FlameChart.Events.EntrySelected, this._on
MainEntrySelected, this); |
| 1348 this._networkView.addEventListener( | 1348 this._networkView.addEventListener( |
| 1349 WebInspector.FlameChart.Events.EntrySelected, this._onNetworkEntrySelect
ed, this); | 1349 UI.FlameChart.Events.EntrySelected, this._onNetworkEntrySelected, this); |
| 1350 WebInspector.blackboxManager.addChangeListener(this.refreshRecords, this); | 1350 Bindings.blackboxManager.addChangeListener(this.refreshRecords, this); |
| 1351 } | 1351 } |
| 1352 | 1352 |
| 1353 /** | 1353 /** |
| 1354 * @override | 1354 * @override |
| 1355 */ | 1355 */ |
| 1356 dispose() { | 1356 dispose() { |
| 1357 this._mainView.removeEventListener(WebInspector.FlameChart.Events.EntrySelec
ted, this._onMainEntrySelected, this); | 1357 this._mainView.removeEventListener(UI.FlameChart.Events.EntrySelected, this.
_onMainEntrySelected, this); |
| 1358 this._networkView.removeEventListener( | 1358 this._networkView.removeEventListener( |
| 1359 WebInspector.FlameChart.Events.EntrySelected, this._onNetworkEntrySelect
ed, this); | 1359 UI.FlameChart.Events.EntrySelected, this._onNetworkEntrySelected, this); |
| 1360 WebInspector.blackboxManager.removeChangeListener(this.refreshRecords, this)
; | 1360 Bindings.blackboxManager.removeChangeListener(this.refreshRecords, this); |
| 1361 } | 1361 } |
| 1362 | 1362 |
| 1363 /** | 1363 /** |
| 1364 * @override | 1364 * @override |
| 1365 * @return {?Element} | 1365 * @return {?Element} |
| 1366 */ | 1366 */ |
| 1367 resizerElement() { | 1367 resizerElement() { |
| 1368 return null; | 1368 return null; |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 /** | 1371 /** |
| 1372 * @override | 1372 * @override |
| 1373 * @param {number} windowStartTime | 1373 * @param {number} windowStartTime |
| 1374 * @param {number} windowEndTime | 1374 * @param {number} windowEndTime |
| 1375 */ | 1375 */ |
| 1376 requestWindowTimes(windowStartTime, windowEndTime) { | 1376 requestWindowTimes(windowStartTime, windowEndTime) { |
| 1377 this._delegate.requestWindowTimes(windowStartTime, windowEndTime); | 1377 this._delegate.requestWindowTimes(windowStartTime, windowEndTime); |
| 1378 } | 1378 } |
| 1379 | 1379 |
| 1380 /** | 1380 /** |
| 1381 * @override | 1381 * @override |
| 1382 * @param {number} startTime | 1382 * @param {number} startTime |
| 1383 * @param {number} endTime | 1383 * @param {number} endTime |
| 1384 */ | 1384 */ |
| 1385 updateRangeSelection(startTime, endTime) { | 1385 updateRangeSelection(startTime, endTime) { |
| 1386 this._delegate.select(WebInspector.TimelineSelection.fromRange(startTime, en
dTime)); | 1386 this._delegate.select(Timeline.TimelineSelection.fromRange(startTime, endTim
e)); |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 /** | 1389 /** |
| 1390 * @override | 1390 * @override |
| 1391 */ | 1391 */ |
| 1392 refreshRecords() { | 1392 refreshRecords() { |
| 1393 this._dataProvider.reset(); | 1393 this._dataProvider.reset(); |
| 1394 this._mainView.scheduleUpdate(); | 1394 this._mainView.scheduleUpdate(); |
| 1395 this._networkDataProvider.reset(); | 1395 this._networkDataProvider.reset(); |
| 1396 this._networkView.scheduleUpdate(); | 1396 this._networkView.scheduleUpdate(); |
| 1397 } | 1397 } |
| 1398 | 1398 |
| 1399 /** | 1399 /** |
| 1400 * @override | 1400 * @override |
| 1401 * @param {?WebInspector.TracingModel.Event} event | 1401 * @param {?SDK.TracingModel.Event} event |
| 1402 */ | 1402 */ |
| 1403 highlightEvent(event) { | 1403 highlightEvent(event) { |
| 1404 var entryIndex = | 1404 var entryIndex = |
| 1405 event ? this._dataProvider.entryIndexForSelection(WebInspector.TimelineS
election.fromTraceEvent(event)) : -1; | 1405 event ? this._dataProvider.entryIndexForSelection(Timeline.TimelineSelec
tion.fromTraceEvent(event)) : -1; |
| 1406 if (entryIndex >= 0) | 1406 if (entryIndex >= 0) |
| 1407 this._mainView.highlightEntry(entryIndex); | 1407 this._mainView.highlightEntry(entryIndex); |
| 1408 else | 1408 else |
| 1409 this._mainView.hideHighlight(); | 1409 this._mainView.hideHighlight(); |
| 1410 } | 1410 } |
| 1411 | 1411 |
| 1412 /** | 1412 /** |
| 1413 * @override | 1413 * @override |
| 1414 */ | 1414 */ |
| 1415 wasShown() { | 1415 wasShown() { |
| 1416 this._mainView.scheduleUpdate(); | 1416 this._mainView.scheduleUpdate(); |
| 1417 this._networkView.scheduleUpdate(); | 1417 this._networkView.scheduleUpdate(); |
| 1418 } | 1418 } |
| 1419 | 1419 |
| 1420 /** | 1420 /** |
| 1421 * @override | 1421 * @override |
| 1422 * @return {!WebInspector.Widget} | 1422 * @return {!UI.Widget} |
| 1423 */ | 1423 */ |
| 1424 view() { | 1424 view() { |
| 1425 return this; | 1425 return this; |
| 1426 } | 1426 } |
| 1427 | 1427 |
| 1428 /** | 1428 /** |
| 1429 * @override | 1429 * @override |
| 1430 */ | 1430 */ |
| 1431 reset() { | 1431 reset() { |
| 1432 this._dataProvider.reset(); | 1432 this._dataProvider.reset(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1443 * @param {number} endTime | 1443 * @param {number} endTime |
| 1444 */ | 1444 */ |
| 1445 setWindowTimes(startTime, endTime) { | 1445 setWindowTimes(startTime, endTime) { |
| 1446 this._mainView.setWindowTimes(startTime, endTime); | 1446 this._mainView.setWindowTimes(startTime, endTime); |
| 1447 this._networkView.setWindowTimes(startTime, endTime); | 1447 this._networkView.setWindowTimes(startTime, endTime); |
| 1448 this._networkDataProvider.setWindowTimes(startTime, endTime); | 1448 this._networkDataProvider.setWindowTimes(startTime, endTime); |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 /** | 1451 /** |
| 1452 * @override | 1452 * @override |
| 1453 * @param {?WebInspector.TracingModel.Event} event | 1453 * @param {?SDK.TracingModel.Event} event |
| 1454 * @param {string=} regex | 1454 * @param {string=} regex |
| 1455 * @param {boolean=} select | 1455 * @param {boolean=} select |
| 1456 */ | 1456 */ |
| 1457 highlightSearchResult(event, regex, select) { | 1457 highlightSearchResult(event, regex, select) { |
| 1458 if (!event) { | 1458 if (!event) { |
| 1459 this._delegate.select(null); | 1459 this._delegate.select(null); |
| 1460 return; | 1460 return; |
| 1461 } | 1461 } |
| 1462 var entryIndex = this._dataProvider._entryData.indexOf(event); | 1462 var entryIndex = this._dataProvider._entryData.indexOf(event); |
| 1463 var timelineSelection = this._dataProvider.createSelection(entryIndex); | 1463 var timelineSelection = this._dataProvider.createSelection(entryIndex); |
| 1464 if (timelineSelection) | 1464 if (timelineSelection) |
| 1465 this._delegate.select(timelineSelection); | 1465 this._delegate.select(timelineSelection); |
| 1466 } | 1466 } |
| 1467 | 1467 |
| 1468 /** | 1468 /** |
| 1469 * @override | 1469 * @override |
| 1470 * @param {?WebInspector.TimelineSelection} selection | 1470 * @param {?Timeline.TimelineSelection} selection |
| 1471 */ | 1471 */ |
| 1472 setSelection(selection) { | 1472 setSelection(selection) { |
| 1473 var index = this._dataProvider.entryIndexForSelection(selection); | 1473 var index = this._dataProvider.entryIndexForSelection(selection); |
| 1474 this._mainView.setSelectedEntry(index); | 1474 this._mainView.setSelectedEntry(index); |
| 1475 index = this._networkDataProvider.entryIndexForSelection(selection); | 1475 index = this._networkDataProvider.entryIndexForSelection(selection); |
| 1476 this._networkView.setSelectedEntry(index); | 1476 this._networkView.setSelectedEntry(index); |
| 1477 } | 1477 } |
| 1478 | 1478 |
| 1479 /** | 1479 /** |
| 1480 * @param {!WebInspector.FlameChartDataProvider} dataProvider | 1480 * @param {!UI.FlameChartDataProvider} dataProvider |
| 1481 * @param {!WebInspector.Event} event | 1481 * @param {!Common.Event} event |
| 1482 */ | 1482 */ |
| 1483 _onEntrySelected(dataProvider, event) { | 1483 _onEntrySelected(dataProvider, event) { |
| 1484 var entryIndex = /** @type{number} */ (event.data); | 1484 var entryIndex = /** @type{number} */ (event.data); |
| 1485 this._delegate.select(dataProvider.createSelection(entryIndex)); | 1485 this._delegate.select(dataProvider.createSelection(entryIndex)); |
| 1486 } | 1486 } |
| 1487 | 1487 |
| 1488 /** | 1488 /** |
| 1489 * @param {boolean} enable | 1489 * @param {boolean} enable |
| 1490 * @param {boolean=} animate | 1490 * @param {boolean=} animate |
| 1491 */ | 1491 */ |
| 1492 enableNetworkPane(enable, animate) { | 1492 enableNetworkPane(enable, animate) { |
| 1493 if (enable) | 1493 if (enable) |
| 1494 this._splitWidget.showBoth(animate); | 1494 this._splitWidget.showBoth(animate); |
| 1495 else | 1495 else |
| 1496 this._splitWidget.hideSidebar(animate); | 1496 this._splitWidget.hideSidebar(animate); |
| 1497 } | 1497 } |
| 1498 }; | 1498 }; |
| 1499 | 1499 |
| 1500 /** | 1500 /** |
| 1501 * @unrestricted | 1501 * @unrestricted |
| 1502 */ | 1502 */ |
| 1503 WebInspector.TimelineFlameChartView.Selection = class { | 1503 Timeline.TimelineFlameChartView.Selection = class { |
| 1504 /** | 1504 /** |
| 1505 * @param {!WebInspector.TimelineSelection} selection | 1505 * @param {!Timeline.TimelineSelection} selection |
| 1506 * @param {number} entryIndex | 1506 * @param {number} entryIndex |
| 1507 */ | 1507 */ |
| 1508 constructor(selection, entryIndex) { | 1508 constructor(selection, entryIndex) { |
| 1509 this.timelineSelection = selection; | 1509 this.timelineSelection = selection; |
| 1510 this.entryIndex = entryIndex; | 1510 this.entryIndex = entryIndex; |
| 1511 } | 1511 } |
| 1512 }; | 1512 }; |
| OLD | NEW |