Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.TimelineUIUtils} | 7 * @extends {WebInspector.TimelineUIUtils} |
| 8 */ | 8 */ |
| 9 WebInspector.TracingTimelineUIUtils = function() | 9 WebInspector.TracingTimelineUIUtils = function() |
| 10 { | 10 { |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 var relatedNode = null; | 487 var relatedNode = null; |
| 488 var barrier = new CallbackBarrier(); | 488 var barrier = new CallbackBarrier(); |
| 489 if (!event.previewElement && target) { | 489 if (!event.previewElement && target) { |
| 490 if (event.imageURL) | 490 if (event.imageURL) |
| 491 WebInspector.DOMPresentationUtils.buildImagePreviewContents(target, event.imageURL, false, barrier.createCallback(saveImage)); | 491 WebInspector.DOMPresentationUtils.buildImagePreviewContents(target, event.imageURL, false, barrier.createCallback(saveImage)); |
| 492 else if (event.picture) | 492 else if (event.picture) |
| 493 WebInspector.TracingTimelineUIUtils.buildPicturePreviewContent(event , barrier.createCallback(saveImage)); | 493 WebInspector.TracingTimelineUIUtils.buildPicturePreviewContent(event , barrier.createCallback(saveImage)); |
| 494 } | 494 } |
| 495 if (event.backendNodeId && target) | 495 if (event.backendNodeId && target) |
| 496 target.domModel.pushNodesByBackendIdsToFrontend([event.backendNodeId], b arrier.createCallback(setRelatedNode)); | 496 target.domModel.pushNodesByBackendIdsToFrontend([event.backendNodeId], b arrier.createCallback(setRelatedNode)); |
| 497 if (target && event.invalidationTrackingEvents) | |
|
caseq
2014/10/15 16:24:54
Please drop test for target (the one above is like
pdr.
2014/10/16 07:46:48
Fixed, and removed the two above.
| |
| 498 WebInspector.TracingTimelineUIUtils._resolveInvalidationTrackingNodeIds( event, barrier); | |
| 497 barrier.callWhenDone(callbackWrapper); | 499 barrier.callWhenDone(callbackWrapper); |
| 498 | 500 |
| 499 /** | 501 /** |
| 500 * @param {!Element=} element | 502 * @param {!Element=} element |
| 501 */ | 503 */ |
| 502 function saveImage(element) | 504 function saveImage(element) |
| 503 { | 505 { |
| 504 event.previewElement = element || null; | 506 event.previewElement = element || null; |
| 505 } | 507 } |
| 506 | 508 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 case recordTypes.PaintImage: | 607 case recordTypes.PaintImage: |
| 606 case recordTypes.DecodeLazyPixelRef: | 608 case recordTypes.DecodeLazyPixelRef: |
| 607 case recordTypes.DecodeImage: | 609 case recordTypes.DecodeImage: |
| 608 case recordTypes.ResizeImage: | 610 case recordTypes.ResizeImage: |
| 609 case recordTypes.DrawLazyPixelRef: | 611 case recordTypes.DrawLazyPixelRef: |
| 610 relatedNodeLabel = WebInspector.UIString("Image element"); | 612 relatedNodeLabel = WebInspector.UIString("Image element"); |
| 611 if (event.imageURL) | 613 if (event.imageURL) |
| 612 contentHelper.appendElementRow(WebInspector.UIString("Image URL"), W ebInspector.linkifyResourceAsNode(event.imageURL)); | 614 contentHelper.appendElementRow(WebInspector.UIString("Image URL"), W ebInspector.linkifyResourceAsNode(event.imageURL)); |
| 613 break; | 615 break; |
| 614 case recordTypes.RecalculateStyles: // We don't want to see default details. | 616 case recordTypes.RecalculateStyles: // We don't want to see default details. |
| 617 // FIXME: Show invalidation tracking for updating style. | |
| 615 contentHelper.appendTextRow(WebInspector.UIString("Elements affected"), event.args["elementCount"]); | 618 contentHelper.appendTextRow(WebInspector.UIString("Elements affected"), event.args["elementCount"]); |
| 616 break; | 619 break; |
| 617 case recordTypes.Layout: | 620 case recordTypes.Layout: |
| 618 var beginData = event.args["beginData"]; | 621 var beginData = event.args["beginData"]; |
| 619 contentHelper.appendTextRow(WebInspector.UIString("Nodes that need layou t"), beginData["dirtyObjects"]); | 622 contentHelper.appendTextRow(WebInspector.UIString("Nodes that need layou t"), beginData["dirtyObjects"]); |
| 620 contentHelper.appendTextRow(WebInspector.UIString("Layout tree size"), b eginData["totalObjects"]); | 623 contentHelper.appendTextRow(WebInspector.UIString("Layout tree size"), b eginData["totalObjects"]); |
| 621 contentHelper.appendTextRow(WebInspector.UIString("Layout scope"), | 624 contentHelper.appendTextRow(WebInspector.UIString("Layout scope"), |
| 622 beginData["partialLayout"] ? WebInspector.UI String("Partial") : WebInspector.UIString("Whole document")); | 625 beginData["partialLayout"] ? WebInspector.UI String("Partial") : WebInspector.UIString("Whole document")); |
| 623 relatedNodeLabel = WebInspector.UIString("Layout root"); | 626 relatedNodeLabel = WebInspector.UIString("Layout root"); |
| 627 // FIXME: Show invalidation tracking for updating layout. | |
| 628 break; | |
| 629 case recordTypes.UpdateLayerTree: | |
| 630 // FIXME: Show invalidation tracking for updating the layer tree. | |
| 624 break; | 631 break; |
| 625 case recordTypes.ConsoleTime: | 632 case recordTypes.ConsoleTime: |
| 626 contentHelper.appendTextRow(WebInspector.UIString("Message"), event.name ); | 633 contentHelper.appendTextRow(WebInspector.UIString("Message"), event.name ); |
| 627 break; | 634 break; |
| 628 case recordTypes.WebSocketCreate: | 635 case recordTypes.WebSocketCreate: |
| 629 case recordTypes.WebSocketSendHandshakeRequest: | 636 case recordTypes.WebSocketSendHandshakeRequest: |
| 630 case recordTypes.WebSocketReceiveHandshakeResponse: | 637 case recordTypes.WebSocketReceiveHandshakeResponse: |
| 631 case recordTypes.WebSocketDestroy: | 638 case recordTypes.WebSocketDestroy: |
| 632 var initiatorData = initiator ? initiator.args["data"] : eventData; | 639 var initiatorData = initiator ? initiator.args["data"] : eventData; |
| 633 if (typeof initiatorData["webSocketURL"] !== "undefined") | 640 if (typeof initiatorData["webSocketURL"] !== "undefined") |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 655 | 662 |
| 656 var warning = event.warning; | 663 var warning = event.warning; |
| 657 if (warning) { | 664 if (warning) { |
| 658 var div = document.createElement("div"); | 665 var div = document.createElement("div"); |
| 659 div.textContent = warning; | 666 div.textContent = warning; |
| 660 contentHelper.appendElementRow(WebInspector.UIString("Warning"), div); | 667 contentHelper.appendElementRow(WebInspector.UIString("Warning"), div); |
| 661 } | 668 } |
| 662 if (event.previewElement) | 669 if (event.previewElement) |
| 663 contentHelper.appendElementRow(WebInspector.UIString("Preview"), event.p reviewElement); | 670 contentHelper.appendElementRow(WebInspector.UIString("Preview"), event.p reviewElement); |
| 664 | 671 |
| 665 if (event.stackTrace || (event.initiator && event.initiator.stackTrace)) | 672 if (event.stackTrace || (event.initiator && event.initiator.stackTrace) || e vent.invalidationTrackingEvents) |
| 666 WebInspector.TracingTimelineUIUtils._generateCauses(event, contentHelper ); | 673 WebInspector.TracingTimelineUIUtils._generateCauses(event, linkifier, co ntentHelper); |
| 667 | 674 |
| 668 fragment.appendChild(contentHelper.element); | 675 fragment.appendChild(contentHelper.element); |
| 669 return fragment; | 676 return fragment; |
| 670 } | 677 } |
| 671 | 678 |
| 672 /** | 679 /** |
| 673 * @param {!WebInspector.TracingModel.Event} event | 680 * @param {!WebInspector.TracingModel.Event} event |
| 681 * @param {!WebInspector.Linkifier} linkifier | |
| 674 * @param {!WebInspector.TimelineDetailsContentHelper} contentHelper | 682 * @param {!WebInspector.TimelineDetailsContentHelper} contentHelper |
| 675 */ | 683 */ |
| 676 WebInspector.TracingTimelineUIUtils._generateCauses = function(event, contentHel per) | 684 WebInspector.TracingTimelineUIUtils._generateCauses = function(event, linkifier, contentHelper) |
| 677 { | 685 { |
| 678 var recordTypes = WebInspector.TracingTimelineModel.RecordType; | 686 var recordTypes = WebInspector.TracingTimelineModel.RecordType; |
| 679 | 687 |
| 680 var callSiteStackLabel; | 688 var callSiteStackLabel; |
| 681 var stackLabel; | 689 var stackLabel; |
| 690 var initiator = event.initiator; | |
| 682 | 691 |
| 683 switch (event.name) { | 692 switch (event.name) { |
| 684 case recordTypes.TimerFire: | 693 case recordTypes.TimerFire: |
| 685 callSiteStackLabel = WebInspector.UIString("Timer installed"); | 694 callSiteStackLabel = WebInspector.UIString("Timer installed"); |
| 686 break; | 695 break; |
| 687 case recordTypes.FireAnimationFrame: | 696 case recordTypes.FireAnimationFrame: |
| 688 callSiteStackLabel = WebInspector.UIString("Animation frame requested"); | 697 callSiteStackLabel = WebInspector.UIString("Animation frame requested"); |
| 689 break; | 698 break; |
| 690 case recordTypes.RecalculateStyles: | 699 case recordTypes.RecalculateStyles: |
| 691 stackLabel = WebInspector.UIString("Stack when style recalculation was f orced"); | 700 stackLabel = WebInspector.UIString("Stack when style recalculation was f orced"); |
| 692 break; | 701 break; |
| 693 case recordTypes.Layout: | 702 case recordTypes.Layout: |
| 694 callSiteStackLabel = WebInspector.UIString("First layout invalidation"); | 703 callSiteStackLabel = WebInspector.UIString("First layout invalidation"); |
| 695 stackLabel = WebInspector.UIString("Stack when layout was forced"); | 704 stackLabel = WebInspector.UIString("Stack when layout was forced"); |
| 696 break; | 705 break; |
| 697 } | 706 } |
| 698 | 707 |
| 699 // Direct cause. | 708 // Direct cause. |
| 700 if (event.stackTrace) | 709 if (event.stackTrace) |
| 701 contentHelper.appendStackTrace(stackLabel || WebInspector.UIString("Stac k when this event occurred"), event.stackTrace); | 710 contentHelper.appendStackTrace(stackLabel || WebInspector.UIString("Stac k when this event occurred"), event.stackTrace); |
| 702 | 711 |
| 703 // Indirect cause / invalidation. | 712 // Indirect causes. |
| 704 var initiator = event.initiator; | 713 if (event.invalidationTrackingEvents) { // Full invalidation tracking (exper imental). |
| 705 if (initiator && initiator.stackTrace) | 714 WebInspector.TracingTimelineUIUtils._generateInvalidations(event, linkif ier, contentHelper); |
| 715 } else if (initiator && initiator.stackTrace) { // Partial invalidation trac king. | |
| 706 contentHelper.appendStackTrace(callSiteStackLabel || WebInspector.UIStri ng("Stack when first invalidated"), initiator.stackTrace); | 716 contentHelper.appendStackTrace(callSiteStackLabel || WebInspector.UIStri ng("Stack when first invalidated"), initiator.stackTrace); |
| 717 } | |
| 707 } | 718 } |
| 708 | 719 |
| 709 /** | 720 /** |
| 721 * @param {!WebInspector.TracingModel.Event} event | |
| 722 * @param {!WebInspector.Linkifier} linkifier | |
| 723 * @param {!WebInspector.TimelineDetailsContentHelper} contentHelper | |
| 724 */ | |
| 725 WebInspector.TracingTimelineUIUtils._generateInvalidations = function(event, lin kifier, contentHelper) | |
| 726 { | |
| 727 if (!event.invalidationTrackingEvents) | |
| 728 return; | |
| 729 | |
| 730 var target = event.thread.target(); | |
| 731 var styleInvalidations = []; | |
|
kouhei (in TOK)
2014/10/15 05:34:00
We might want to use a map of arrays here, as we e
caseq
2014/10/15 16:24:53
+1
pdr.
2014/10/16 07:46:48
Excellent point. Refactored!
| |
| 732 var layoutInvalidations = []; | |
| 733 var layerInvalidations = []; | |
| 734 event.invalidationTrackingEvents.forEach(function(invalidation) { | |
| 735 switch (invalidation.type) { | |
| 736 case WebInspector.TracingTimelineModel.RecordType.StyleRecalcInvalidatio nTracking: | |
| 737 styleInvalidations.push(invalidation); | |
| 738 break; | |
| 739 case WebInspector.TracingTimelineModel.RecordType.LayoutInvalidationTrac king: | |
| 740 layoutInvalidations.push(invalidation); | |
| 741 break; | |
| 742 case WebInspector.TracingTimelineModel.RecordType.LayerInvalidationTrack ing: | |
| 743 layerInvalidations.push(invalidation); | |
| 744 break; | |
| 745 default: | |
| 746 console.error("Unknown invalidation tracking event."); | |
| 747 console.error(invalidation); | |
| 748 } | |
| 749 }); | |
| 750 if (styleInvalidations.length) | |
|
caseq
2014/10/15 16:24:54
style: here and below, please use {} for multi-lin
pdr.
2014/10/16 07:46:48
Refactored this to be much cleaner. I'm not sure w
| |
| 751 contentHelper.element.appendChild( | |
| 752 WebInspector.TracingTimelineUIUtils._buildInvalidationDetailsNode(We bInspector.UIString("Style invalidations"), linkifier, target, styleInvalidation s)); | |
| 753 if (layoutInvalidations.length) | |
| 754 contentHelper.element.appendChild( | |
| 755 WebInspector.TracingTimelineUIUtils._buildInvalidationDetailsNode(We bInspector.UIString("Layout invalidations"), linkifier, target, layoutInvalidati ons)); | |
| 756 if (layerInvalidations.length) | |
| 757 contentHelper.element.appendChild( | |
| 758 WebInspector.TracingTimelineUIUtils._buildInvalidationDetailsNode(We bInspector.UIString("Layer invalidations"), linkifier, target, layerInvalidation s)); | |
| 759 } | |
| 760 | |
| 761 /** | |
| 762 * @param {string} title | |
| 763 * @param {!WebInspector.Linkifier} linkifier | |
| 764 * @param {?WebInspector.Target} target | |
| 765 * @param {!WebInspector.TimelineDetailsContentHelper} contentHelper | |
| 766 */ | |
| 767 WebInspector.TracingTimelineUIUtils._buildInvalidationDetailsNode = function(tit le, linkifier, target, invalidationEvents) | |
| 768 { | |
| 769 var detailsNode = document.createElement("div"); | |
| 770 detailsNode.className = "timeline-details-view-row"; | |
| 771 var titleElement = document.createElement("span"); | |
| 772 titleElement.className = "timeline-details-view-row-title"; | |
| 773 titleElement.textContent = WebInspector.UIString("%s: ", title); | |
| 774 detailsNode.appendChild(titleElement); | |
|
caseq
2014/10/15 16:24:54
nit: var titleElement = detailsNode.createChild("s
| |
| 775 var eventsList = document.createElement("ol"); | |
| 776 detailsNode.appendChild(eventsList); | |
|
caseq
2014/10/15 16:24:53
ditto
| |
| 777 | |
| 778 invalidationEvents.forEach(function(invalidation, idx) { | |
| 779 var row = document.createElement("li"); | |
| 780 eventsList.appendChild(row); | |
|
caseq
2014/10/15 16:24:54
ditto
| |
| 781 | |
| 782 var nodeRow = document.createElement("div"); | |
| 783 row.appendChild(nodeRow); | |
|
caseq
2014/10/15 16:24:53
ditto
| |
| 784 var node = target.domModel.nodeForId(invalidation.frontendNodeId); | |
| 785 if (node) | |
| 786 nodeRow.appendChild(WebInspector.DOMPresentationUtils.linkifyNodeRef erence(node)); | |
| 787 else if (invalidation.nodeName) | |
| 788 nodeRow.textContent = '[' + invalidation.nodeName + ']'; | |
|
caseq
2014/10/15 16:24:53
WebInspector.UIString("[ %s ]", invalidation.nodeN
| |
| 789 else | |
| 790 nodeRow.textContent = '[ unknown node ]'; | |
|
caseq
2014/10/15 16:24:53
WebInspector.UISreing("[ unknown node ]")
| |
| 791 | |
| 792 if (invalidation.reason) { | |
| 793 var reasonRow = document.createElement("div"); | |
| 794 reasonRow.textContent = 'Reason: ' + invalidation.reason + (invalida tion.reason.endsWith('.') ? '' : '.'); | |
|
caseq
2014/10/15 16:24:53
ditto
| |
| 795 row.appendChild(reasonRow); | |
| 796 } | |
| 797 | |
| 798 var callstack = invalidation.callstack ? JSON.parse(invalidation.callsta ck) : []; | |
|
caseq
2014/10/15 16:24:53
I think we need to capture callstacks the usual wa
pdr.
2014/10/16 07:46:48
I wasn't able to find the benefit of this, but I m
| |
| 799 if (callstack.length > 0) { | |
|
caseq
2014/10/15 16:24:53
if (callstack.length)
| |
| 800 var callstackRow = document.createElement("div"); | |
| 801 row.appendChild(callstackRow); | |
| 802 callstack.forEach(function(stackFrame) { | |
| 803 var frameRow = document.createElement("div"); | |
| 804 frameRow.className = "timeline-details-view-row monospace"; | |
| 805 callstackRow.appendChild(frameRow); | |
| 806 frameRow.textContent = stackFrame.functionName || WebInspector.U IString("(anonymous function)"); | |
| 807 frameRow.textContent += " @ "; | |
| 808 var urlElement = linkifier.linkifyScriptLocation(target, stackFr ame.scriptId, stackFrame.url, stackFrame.lineNumber - 1, stackFrame.columnNumber - 1); | |
|
kouhei (in TOK)
2014/10/15 05:34:00
This part looks similar to WebInspector.TimelineDe
pdr.
2014/10/16 07:46:48
Factored this out into the content helper itself.
| |
| 809 frameRow.appendChild(urlElement); | |
| 810 }); | |
| 811 } | |
| 812 }); | |
| 813 | |
| 814 return detailsNode; | |
| 815 } | |
| 816 | |
| 817 /** | |
| 818 * @param {!WebInspector.TracingModel.Event} event | |
| 819 * @param {!CallbackBarrier} barrier | |
| 820 */ | |
| 821 WebInspector.TracingTimelineUIUtils._resolveInvalidationTrackingNodeIds = functi on(event, barrier) | |
| 822 { | |
| 823 var backendNodeIdSet = {}; | |
| 824 if (event.nodeId) | |
| 825 backendNodeIdSet[event.nodeId] = true; | |
| 826 event.invalidationTrackingEvents.forEach(function(invalidation) { | |
| 827 if (invalidation.nodeId) | |
| 828 backendNodeIdSet[invalidation.nodeId] = true; | |
| 829 }); | |
|
kouhei (in TOK)
2014/10/15 05:34:00
This looks a bit complicated. If Object.keys(backe
pdr.
2014/10/16 07:46:48
This is the simplest way I know how to create a se
| |
| 830 | |
| 831 var backendNodeIds = []; | |
| 832 Object.keys(backendNodeIdSet).forEach(function(backendNodeId) { | |
| 833 backendNodeIds.push(parseInt(backendNodeId)); | |
|
kouhei (in TOK)
2014/10/15 05:34:00
in other words, can we only use backendNodeIds?
pdr.
2014/10/16 07:46:48
It's the opposite--we can only use frontendNodeIds
| |
| 834 }); | |
| 835 event.thread.target().domModel.pushNodesByBackendIdsToFrontend( | |
| 836 backendNodeIds, barrier.createCallback(updateInvalidationNodeIds)); | |
|
caseq
2014/10/15 16:24:53
You're calling barrier.createCallback() exactly on
pdr.
2014/10/16 07:46:48
I think we need to use the barrier as it increment
| |
| 837 | |
| 838 function updateInvalidationNodeIds(frontendNodeIds) | |
| 839 { | |
| 840 if (!frontendNodeIds) | |
| 841 return; | |
| 842 if (frontendNodeIds.length != backendNodeIds.length) { | |
| 843 console.error('Did not resolve the correct number of frontend node i ds.'); | |
| 844 return; | |
| 845 } | |
| 846 | |
| 847 var backendToFrontendNodeIdMap = {}; | |
| 848 backendNodeIds.forEach(function(backendNodeId, index) { | |
| 849 backendToFrontendNodeIdMap[backendNodeId] = frontendNodeIds[index]; | |
| 850 }); | |
| 851 | |
| 852 if (event.nodeId) | |
| 853 event.frontendNodeId = backendToFrontendNodeIdMap[event.nodeId]; | |
| 854 event.invalidationTrackingEvents.forEach(function(invalidation) { | |
| 855 if (invalidation.nodeId) | |
| 856 invalidation.frontendNodeId = backendToFrontendNodeIdMap[invalid ation.nodeId]; | |
| 857 }); | |
| 858 } | |
| 859 } | |
| 860 | |
| 861 /** | |
| 710 * @param {!Object} total | 862 * @param {!Object} total |
| 711 * @param {!WebInspector.TracingTimelineModel} model | 863 * @param {!WebInspector.TracingTimelineModel} model |
| 712 * @param {!WebInspector.TracingModel.Event} event | 864 * @param {!WebInspector.TracingModel.Event} event |
| 713 * @return {boolean} | 865 * @return {boolean} |
| 714 */ | 866 */ |
| 715 WebInspector.TracingTimelineUIUtils._aggregatedStatsForTraceEvent = function(tot al, model, event) | 867 WebInspector.TracingTimelineUIUtils._aggregatedStatsForTraceEvent = function(tot al, model, event) |
| 716 { | 868 { |
| 717 var events = model.inspectedTargetEvents(); | 869 var events = model.inspectedTargetEvents(); |
| 718 /** | 870 /** |
| 719 * @param {number} startTime | 871 * @param {number} startTime |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 835 return result; | 987 return result; |
| 836 } | 988 } |
| 837 | 989 |
| 838 /** | 990 /** |
| 839 * @return {!WebInspector.TracingTimelineModel.Filter} | 991 * @return {!WebInspector.TracingTimelineModel.Filter} |
| 840 */ | 992 */ |
| 841 WebInspector.TracingTimelineUIUtils.hiddenEventsFilter = function() | 993 WebInspector.TracingTimelineUIUtils.hiddenEventsFilter = function() |
| 842 { | 994 { |
| 843 return new WebInspector.TracingTimelineModel.InclusiveEventNameFilter(WebIns pector.TracingTimelineUIUtils._visibleTypes()); | 995 return new WebInspector.TracingTimelineModel.InclusiveEventNameFilter(WebIns pector.TracingTimelineUIUtils._visibleTypes()); |
| 844 } | 996 } |
| OLD | NEW |