Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 * @implements {UI.Searchable} | 7 * @implements {UI.Searchable} |
| 8 */ | 8 */ |
| 9 Timeline.TimelineTreeView = class extends UI.VBox { | 9 Timeline.TimelineTreeView = class extends UI.VBox { |
| 10 constructor() { | 10 constructor() { |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 if (columnId === 'activity') | 506 if (columnId === 'activity') |
| 507 return this._createNameCell(columnId); | 507 return this._createNameCell(columnId); |
| 508 return this._createValueCell(columnId) || super.createCell(columnId); | 508 return this._createValueCell(columnId) || super.createCell(columnId); |
| 509 } | 509 } |
| 510 | 510 |
| 511 /** | 511 /** |
| 512 * @param {string} columnId | 512 * @param {string} columnId |
| 513 * @return {!Element} | 513 * @return {!Element} |
| 514 */ | 514 */ |
| 515 _createNameCell(columnId) { | 515 _createNameCell(columnId) { |
| 516 const cell = this.createTD(columnId); | 516 var cell = this.createTD(columnId); |
| 517 const container = cell.createChild('div', 'name-container'); | 517 var container = cell.createChild('div', 'name-container'); |
| 518 const icon = container.createChild('div', 'activity-icon'); | 518 var iconContainer = container.createChild('div', 'activity-icon-container'); |
| 519 const name = container.createChild('div', 'activity-name'); | 519 var icon = iconContainer.createChild('div', 'activity-icon'); |
| 520 const event = this._profileNode.event; | 520 var name = container.createChild('div', 'activity-name'); |
| 521 var event = this._profileNode.event; | |
| 521 if (this._profileNode.isGroupNode()) { | 522 if (this._profileNode.isGroupNode()) { |
| 522 const treeView = /** @type {!Timeline.AggregatedTimelineTreeView} */ (this ._treeView); | 523 var treeView = /** @type {!Timeline.AggregatedTimelineTreeView} */ (this._ treeView); |
| 523 const info = treeView._displayInfoForGroupNode(this._profileNode); | 524 var info = treeView._displayInfoForGroupNode(this._profileNode); |
| 524 name.textContent = info.name; | 525 name.textContent = info.name; |
| 525 icon.style.backgroundColor = info.color; | 526 icon.style.backgroundColor = info.color; |
| 527 if (info.icon) { | |
| 528 info.icon.classList.add('activity-badge'); | |
| 529 iconContainer.insertBefore(info.icon, icon); | |
| 530 } | |
| 526 } else if (event) { | 531 } else if (event) { |
| 527 const data = event.args['data']; | 532 var data = event.args['data']; |
| 528 const deoptReason = data && data['deoptReason']; | 533 var deoptReason = data && data['deoptReason']; |
| 529 if (deoptReason) | 534 if (deoptReason) |
| 530 container.createChild('div', 'activity-warning').title = Common.UIString ('Not optimized: %s', deoptReason); | 535 container.createChild('div', 'activity-warning').title = Common.UIString ('Not optimized: %s', deoptReason); |
| 531 | 536 |
| 532 name.textContent = Timeline.TimelineUIUtils.eventTitle(event); | 537 name.textContent = Timeline.TimelineUIUtils.eventTitle(event); |
| 533 const link = this._treeView._linkifyLocation(event); | 538 var link = this._treeView._linkifyLocation(event); |
| 534 if (link) | 539 if (link) |
| 535 container.createChild('div', 'activity-link').appendChild(link); | 540 container.createChild('div', 'activity-link').appendChild(link); |
| 536 icon.style.backgroundColor = Timeline.TimelineUIUtils.eventColor(event); | 541 icon.style.backgroundColor = Timeline.TimelineUIUtils.eventColor(event); |
| 537 } | 542 } |
| 538 return cell; | 543 return cell; |
| 539 } | 544 } |
| 540 | 545 |
| 541 /** | 546 /** |
| 542 * @param {string} columnId | 547 * @param {string} columnId |
| 543 * @return {?Element} | 548 * @return {?Element} |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 629 */ | 634 */ |
| 630 constructor(filters) { | 635 constructor(filters) { |
| 631 super(); | 636 super(); |
| 632 this._groupBySetting = | 637 this._groupBySetting = |
| 633 Common.settings.createSetting('timelineTreeGroupBy', Timeline.Aggregated TimelineTreeView.GroupBy.None); | 638 Common.settings.createSetting('timelineTreeGroupBy', Timeline.Aggregated TimelineTreeView.GroupBy.None); |
| 634 this._groupBySetting.addChangeListener(this.refreshTree.bind(this)); | 639 this._groupBySetting.addChangeListener(this.refreshTree.bind(this)); |
| 635 this.init(filters); | 640 this.init(filters); |
| 636 this._stackView = new Timeline.TimelineStackView(this); | 641 this._stackView = new Timeline.TimelineStackView(this); |
| 637 this._stackView.addEventListener( | 642 this._stackView.addEventListener( |
| 638 Timeline.TimelineStackView.Events.SelectionChanged, this._onStackViewSel ectionChanged, this); | 643 Timeline.TimelineStackView.Events.SelectionChanged, this._onStackViewSel ectionChanged, this); |
| 644 this._badgePool = new ProductRegistry.BadgePool(); | |
| 639 /** @type {!Map<string, string>} */ | 645 /** @type {!Map<string, string>} */ |
| 640 this._productByURLCache = new Map(); | 646 this._productByURLCache = new Map(); |
| 647 /** @type {!Map<string, string>} */ | |
| 648 this._colorByURLCache = new Map(); | |
| 641 ProductRegistry.instance().then(registry => { | 649 ProductRegistry.instance().then(registry => { |
| 642 this._productRegistry = registry; | 650 this._productRegistry = registry; |
| 643 this.refreshTree(); | 651 this.refreshTree(); |
| 644 }); | 652 }); |
| 645 } | 653 } |
| 646 | 654 |
| 647 /** | 655 /** |
| 648 * @override | 656 * @override |
| 649 * @param {!Timeline.TimelineSelection} selection | 657 * @param {!Timeline.TimelineSelection} selection |
| 650 */ | 658 */ |
| 651 updateContents(selection) { | 659 updateContents(selection) { |
| 652 this._updateExtensionResolver(); | 660 this._updateExtensionResolver(); |
| 653 super.updateContents(selection); | 661 super.updateContents(selection); |
| 654 var rootNode = this._dataGrid.rootNode(); | 662 var rootNode = this._dataGrid.rootNode(); |
| 655 if (rootNode.children.length) | 663 if (rootNode.children.length) |
| 656 rootNode.children[0].revealAndSelect(); | 664 rootNode.children[0].revealAndSelect(); |
| 657 } | 665 } |
| 658 | 666 |
| 659 _updateExtensionResolver() { | 667 _updateExtensionResolver() { |
| 660 this._executionContextNamesByOrigin = new Map(); | 668 this._executionContextNamesByOrigin = new Map(); |
| 661 for (var runtimeModel of SDK.targetManager.models(SDK.RuntimeModel)) { | 669 for (var runtimeModel of SDK.targetManager.models(SDK.RuntimeModel)) { |
| 662 for (var context of runtimeModel.executionContexts()) | 670 for (var context of runtimeModel.executionContexts()) |
| 663 this._executionContextNamesByOrigin.set(context.origin, context.name); | 671 this._executionContextNamesByOrigin.set(context.origin, context.name); |
| 664 } | 672 } |
| 665 } | 673 } |
| 666 | 674 |
| 667 /** | 675 /** |
| 668 * @param {!TimelineModel.TimelineProfileTree.Node} node | 676 * @param {!TimelineModel.TimelineProfileTree.Node} node |
| 669 * @return {!{name: string, color: string}} | 677 * @return {!{name: string, color: string, icon: (!Element|undefined)}} |
| 670 */ | 678 */ |
| 671 _displayInfoForGroupNode(node) { | 679 _displayInfoForGroupNode(node) { |
| 672 var categories = Timeline.TimelineUIUtils.categories(); | 680 var categories = Timeline.TimelineUIUtils.categories(); |
| 673 var color = node.id ? Timeline.TimelineUIUtils.eventColor(/** @type {!SDK.Tr acingModel.Event} */ (node.event)) : | 681 var color = node.id ? Timeline.TimelineUIUtils.eventColor(/** @type {!SDK.Tr acingModel.Event} */ (node.event)) : |
| 674 categories['other'].color; | 682 categories['other'].color; |
| 675 var unattributed = Common.UIString('[unattributed]'); | 683 var unattributed = Common.UIString('[unattributed]'); |
| 676 /** | 684 /** |
| 677 * @param {string} name | 685 * @param {string} name |
| 678 * @return {string} | 686 * @return {string} |
| 679 * @this {Timeline.AggregatedTimelineTreeView} | 687 * @this {Timeline.AggregatedTimelineTreeView} |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 707 Common.UIString('JavaScript') : | 715 Common.UIString('JavaScript') : |
| 708 Timeline.TimelineUIUtils.eventTitle(node.event); | 716 Timeline.TimelineUIUtils.eventTitle(node.event); |
| 709 return { | 717 return { |
| 710 name: name, | 718 name: name, |
| 711 color: node.event.name === TimelineModel.TimelineModel.RecordType.JSFr ame ? | 719 color: node.event.name === TimelineModel.TimelineModel.RecordType.JSFr ame ? |
| 712 Timeline.TimelineUIUtils.eventStyle(node.event).category.color : | 720 Timeline.TimelineUIUtils.eventStyle(node.event).category.color : |
| 713 color | 721 color |
| 714 }; | 722 }; |
| 715 | 723 |
| 716 case Timeline.AggregatedTimelineTreeView.GroupBy.Product: | 724 case Timeline.AggregatedTimelineTreeView.GroupBy.Product: |
| 717 var productName = this._productByEvent(/** @type {!SDK.TracingModel.Even t} */ (node.event)); | 725 var event = /** @type {!SDK.TracingModel.Event} */ (node.event); |
| 718 color = productName ? ProductRegistry.BadgePool.colorForEntryName(produc tName) : '#eee'; | 726 var productName = this._productByEvent(event); |
| 719 var name = productName || this._domainByEvent(true, /** @type {!SDK.Trac ingModel.Event} */ (node.event)) || ''; | 727 color = Timeline.TimelineUIUtils.eventColorByProduct( |
| 720 return {name: beautifyDomainName.call(this, name) || unattributed, color : color}; | 728 this._productRegistry, this._model.timelineModel(), this._colorByURL Cache, event); |
| 729 var url = TimelineModel.TimelineProfileTree.eventURL(event); | |
| 730 var parsedURL = url ? url.asParsedURL() : null; | |
| 731 var icon = parsedURL ? this._badgePool.badgeForURL(parsedURL, false, tru e) : undefined; | |
|
caseq
2017/05/22 18:43:49
Can we encapsulate this logic into productByEvent(
alph
2017/05/22 22:53:26
Done.
| |
| 732 var name = productName || this._domainByEvent(true, event) || ''; | |
| 733 return {name: beautifyDomainName.call(this, name) || unattributed, color : color, icon: icon}; | |
| 721 | 734 |
| 722 case Timeline.AggregatedTimelineTreeView.GroupBy.URL: | 735 case Timeline.AggregatedTimelineTreeView.GroupBy.URL: |
| 723 break; | 736 break; |
| 724 | 737 |
| 725 case Timeline.AggregatedTimelineTreeView.GroupBy.Frame: | 738 case Timeline.AggregatedTimelineTreeView.GroupBy.Frame: |
| 726 var frame = this._model.timelineModel().pageFrameById(node.id); | 739 var frame = this._model.timelineModel().pageFrameById(node.id); |
| 727 var frameName = frame ? Timeline.TimelineUIUtils.displayNameForFrame(fra me, 80) : Common.UIString('Page'); | 740 var frameName = frame ? Timeline.TimelineUIUtils.displayNameForFrame(fra me, 80) : Common.UIString('Page'); |
| 728 return {name: frameName, color: color}; | 741 return {name: frameName, color: color}; |
| 729 | 742 |
| 730 default: | 743 default: |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1013 | 1026 |
| 1014 _onSelectionChanged() { | 1027 _onSelectionChanged() { |
| 1015 this.dispatchEventToListeners(Timeline.TimelineStackView.Events.SelectionCha nged); | 1028 this.dispatchEventToListeners(Timeline.TimelineStackView.Events.SelectionCha nged); |
| 1016 } | 1029 } |
| 1017 }; | 1030 }; |
| 1018 | 1031 |
| 1019 /** @enum {symbol} */ | 1032 /** @enum {symbol} */ |
| 1020 Timeline.TimelineStackView.Events = { | 1033 Timeline.TimelineStackView.Events = { |
| 1021 SelectionChanged: Symbol('SelectionChanged') | 1034 SelectionChanged: Symbol('SelectionChanged') |
| 1022 }; | 1035 }; |
| OLD | NEW |