Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Intel Inc. All rights reserved. | 3 * Copyright (C) 2012 Intel Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * @constructor | 33 * @constructor |
| 34 * @extends {WebInspector.Object} | 34 * @extends {WebInspector.Object} |
| 35 */ | 35 */ |
| 36 WebInspector.TimelinePresentationModel = function() | 36 WebInspector.TimelinePresentationModel = function() |
| 37 { | 37 { |
| 38 this._linkifier = new WebInspector.Linkifier(); | |
| 39 this._filters = []; | 38 this._filters = []; |
| 40 this.reset(); | 39 this.reset(); |
| 41 } | 40 } |
| 42 | 41 |
| 43 /** | 42 /** |
| 44 * @param {!Array.<*>} recordsArray | 43 * @param {!Array.<*>} recordsArray |
| 45 * @param {?function(*)|?function(*,number)} preOrderCallback | 44 * @param {?function(*)|?function(*,number)} preOrderCallback |
| 46 * @param {function(*)|function(*,number)=} postOrderCallback | 45 * @param {function(*)|function(*,number)=} postOrderCallback |
| 47 */ | 46 */ |
| 48 WebInspector.TimelinePresentationModel.forAllRecords = function(recordsArray, pr eOrderCallback, postOrderCallback) | 47 WebInspector.TimelinePresentationModel.forAllRecords = function(recordsArray, pr eOrderCallback, postOrderCallback) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 /** | 107 /** |
| 109 * @return {!WebInspector.TimelinePresentationModel.Record} | 108 * @return {!WebInspector.TimelinePresentationModel.Record} |
| 110 */ | 109 */ |
| 111 rootRecord: function() | 110 rootRecord: function() |
| 112 { | 111 { |
| 113 return this._rootRecord; | 112 return this._rootRecord; |
| 114 }, | 113 }, |
| 115 | 114 |
| 116 reset: function() | 115 reset: function() |
| 117 { | 116 { |
| 118 this._linkifier.reset(); | |
| 119 this._rootRecord = new WebInspector.TimelinePresentationModel.Record(thi s, { type: WebInspector.TimelineModel.RecordType.Root }, null); | 117 this._rootRecord = new WebInspector.TimelinePresentationModel.Record(thi s, { type: WebInspector.TimelineModel.RecordType.Root }, null); |
| 120 this._sendRequestRecords = {}; | 118 this._sendRequestRecords = {}; |
| 121 this._timerRecords = {}; | 119 this._timerRecords = {}; |
| 122 this._requestAnimationFrameRecords = {}; | 120 this._requestAnimationFrameRecords = {}; |
| 123 this._eventDividerRecords = []; | 121 this._eventDividerRecords = []; |
| 124 this._minimumRecordTime = -1; | 122 this._minimumRecordTime = -1; |
| 125 this._layoutInvalidateStack = {}; | 123 this._layoutInvalidateStack = {}; |
| 126 this._lastScheduleStyleRecalculation = {}; | 124 this._lastScheduleStyleRecalculation = {}; |
| 127 this._webSocketCreateRecords = {}; | 125 this._webSocketCreateRecords = {}; |
| 128 this._coalescingBuckets = {}; | 126 this._coalescingBuckets = {}; |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 | 413 |
| 416 /** | 414 /** |
| 417 * @constructor | 415 * @constructor |
| 418 * @param {!WebInspector.TimelinePresentationModel} presentationModel | 416 * @param {!WebInspector.TimelinePresentationModel} presentationModel |
| 419 * @param {!Object} record | 417 * @param {!Object} record |
| 420 * @param {?WebInspector.TimelinePresentationModel.Record} parentRecord | 418 * @param {?WebInspector.TimelinePresentationModel.Record} parentRecord |
| 421 */ | 419 */ |
| 422 WebInspector.TimelinePresentationModel.Record = function(presentationModel, reco rd, parentRecord) | 420 WebInspector.TimelinePresentationModel.Record = function(presentationModel, reco rd, parentRecord) |
| 423 { | 421 { |
| 424 this._presentationModel = presentationModel; | 422 this._presentationModel = presentationModel; |
| 425 this._linkifier = presentationModel._linkifier; | |
| 426 this._aggregatedStats = {}; | 423 this._aggregatedStats = {}; |
| 427 this._record = /** @type {!TimelineAgent.TimelineEvent} */ (record); | 424 this._record = /** @type {!TimelineAgent.TimelineEvent} */ (record); |
| 428 this._children = []; | 425 this._children = []; |
| 429 if (parentRecord) { | 426 if (parentRecord) { |
| 430 this.parent = parentRecord; | 427 this.parent = parentRecord; |
| 431 parentRecord.children.push(this); | 428 parentRecord.children.push(this); |
| 432 } | 429 } |
| 433 | 430 |
| 434 this._selfTime = this.endTime - this.startTime; | 431 this._selfTime = this.endTime - this.startTime; |
| 435 this._lastChildEndTime = this.endTime; | 432 this._lastChildEndTime = this.endTime; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 453 | 450 |
| 454 var recordTypes = WebInspector.TimelineModel.RecordType; | 451 var recordTypes = WebInspector.TimelineModel.RecordType; |
| 455 switch (record.type) { | 452 switch (record.type) { |
| 456 case recordTypes.ResourceSendRequest: | 453 case recordTypes.ResourceSendRequest: |
| 457 // Make resource receive record last since request was sent; make finish record last since response received. | 454 // Make resource receive record last since request was sent; make finish record last since response received. |
| 458 presentationModel._sendRequestRecords[record.data["requestId"]] = this; | 455 presentationModel._sendRequestRecords[record.data["requestId"]] = this; |
| 459 break; | 456 break; |
| 460 | 457 |
| 461 case recordTypes.ResourceReceiveResponse: | 458 case recordTypes.ResourceReceiveResponse: |
| 462 var sendRequestRecord = presentationModel._sendRequestRecords[record.dat a["requestId"]]; | 459 var sendRequestRecord = presentationModel._sendRequestRecords[record.dat a["requestId"]]; |
| 463 if (sendRequestRecord) { // False if we started instrumentation in the m iddle of request. | 460 if (sendRequestRecord) // False if we started instrumentation in the mid dle of request. |
| 464 this.url = sendRequestRecord.url; | 461 this.url = sendRequestRecord.url; |
| 465 // Now that we have resource in the collection, recalculate details in order to display short url. | |
| 466 sendRequestRecord._refreshDetails(); | |
| 467 if (sendRequestRecord.parent !== presentationModel._rootRecord && se ndRequestRecord.parent.type === recordTypes.ScheduleResourceRequest) | |
| 468 sendRequestRecord.parent._refreshDetails(); | |
| 469 } | |
| 470 break; | 462 break; |
| 471 | 463 |
| 472 case recordTypes.ResourceReceivedData: | 464 case recordTypes.ResourceReceivedData: |
| 473 case recordTypes.ResourceFinish: | 465 case recordTypes.ResourceFinish: |
| 474 var sendRequestRecord = presentationModel._sendRequestRecords[record.dat a["requestId"]]; | 466 var sendRequestRecord = presentationModel._sendRequestRecords[record.dat a["requestId"]]; |
| 475 if (sendRequestRecord) // False for main resource. | 467 if (sendRequestRecord) // False for main resource. |
| 476 this.url = sendRequestRecord.url; | 468 this.url = sendRequestRecord.url; |
| 477 break; | 469 break; |
| 478 | 470 |
| 479 case recordTypes.TimerInstall: | 471 case recordTypes.TimerInstall: |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 633 * @return {!WebInspector.TimelineCategory} | 625 * @return {!WebInspector.TimelineCategory} |
| 634 */ | 626 */ |
| 635 get category() | 627 get category() |
| 636 { | 628 { |
| 637 return WebInspector.TimelineUIUtils.categoryForRecord(this._record); | 629 return WebInspector.TimelineUIUtils.categoryForRecord(this._record); |
| 638 }, | 630 }, |
| 639 | 631 |
| 640 /** | 632 /** |
| 641 * @return {string} | 633 * @return {string} |
| 642 */ | 634 */ |
| 643 get title() | 635 title: function() |
| 644 { | 636 { |
| 645 return WebInspector.TimelineUIUtils.recordTitle(this._presentationModel, this._record); | 637 return WebInspector.TimelineUIUtils.recordTitle(this._presentationModel, this._record); |
| 646 }, | 638 }, |
| 647 | 639 |
| 648 /** | 640 /** |
| 649 * @return {number} | 641 * @return {number} |
| 650 */ | 642 */ |
| 651 get startTime() | 643 get startTime() |
| 652 { | 644 { |
| 653 return this._record.startTime; | 645 return this._record.startTime; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 | 713 |
| 722 /** | 714 /** |
| 723 * @return {boolean} | 715 * @return {boolean} |
| 724 */ | 716 */ |
| 725 containsTime: function(time) | 717 containsTime: function(time) |
| 726 { | 718 { |
| 727 return this.startTime <= time && time <= this.endTime; | 719 return this.startTime <= time && time <= this.endTime; |
| 728 }, | 720 }, |
| 729 | 721 |
| 730 /** | 722 /** |
| 723 * @param {!WebInspector.Linkifier} linkifier | |
| 731 * @param {function(!DocumentFragment)} callback | 724 * @param {function(!DocumentFragment)} callback |
| 732 */ | 725 */ |
| 733 generatePopupContent: function(callback) | 726 generatePopupContent: function(linkifier, callback) |
| 734 { | 727 { |
| 735 var barrier = new CallbackBarrier(); | 728 var barrier = new CallbackBarrier(); |
| 736 if (WebInspector.TimelineUIUtils.needsPreviewElement(this.type) && !this ._imagePreviewElement) | 729 if (WebInspector.TimelineUIUtils.needsPreviewElement(this.type) && !this ._imagePreviewElement) |
| 737 WebInspector.DOMPresentationUtils.buildImagePreviewContents(this.url , false, barrier.createCallback(this._setImagePreviewElement.bind(this))); | 730 WebInspector.DOMPresentationUtils.buildImagePreviewContents(this.url , false, barrier.createCallback(this._setImagePreviewElement.bind(this))); |
| 738 if (this._relatedBackendNodeId && !this._relatedNode) | 731 if (this._relatedBackendNodeId && !this._relatedNode) |
| 739 WebInspector.domAgent.pushNodeByBackendIdToFrontend(this._relatedBac kendNodeId, barrier.createCallback(this._setRelatedNode.bind(this))); | 732 WebInspector.domAgent.pushNodeByBackendIdToFrontend(this._relatedBac kendNodeId, barrier.createCallback(this._setRelatedNode.bind(this))); |
| 740 | 733 |
| 741 barrier.callWhenDone(callbackWrapper.bind(this)); | 734 barrier.callWhenDone(callbackWrapper.bind(this)); |
| 742 | 735 |
| 743 /** | 736 /** |
| 744 * @this {WebInspector.TimelinePresentationModel.Record} | 737 * @this {WebInspector.TimelinePresentationModel.Record} |
| 745 */ | 738 */ |
| 746 function callbackWrapper() | 739 function callbackWrapper() |
| 747 { | 740 { |
| 748 callback(this._generatePopupContentSynchronously()); | 741 callback(this._generatePopupContentSynchronously(linkifier)); |
| 749 } | 742 } |
| 750 }, | 743 }, |
| 751 | 744 |
| 752 /** | 745 /** |
| 753 * @param {string} key | 746 * @param {string} key |
| 754 * @return {?Object} | 747 * @return {?Object} |
| 755 */ | 748 */ |
| 756 getUserObject: function(key) | 749 getUserObject: function(key) |
| 757 { | 750 { |
| 758 if (!this._userObjects) | 751 if (!this._userObjects) |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 782 /** | 775 /** |
| 783 * @param {?DOMAgent.NodeId} nodeId | 776 * @param {?DOMAgent.NodeId} nodeId |
| 784 */ | 777 */ |
| 785 _setRelatedNode: function(nodeId) | 778 _setRelatedNode: function(nodeId) |
| 786 { | 779 { |
| 787 if (typeof nodeId === "number") | 780 if (typeof nodeId === "number") |
| 788 this._relatedNode = WebInspector.domAgent.nodeForId(nodeId); | 781 this._relatedNode = WebInspector.domAgent.nodeForId(nodeId); |
| 789 }, | 782 }, |
| 790 | 783 |
| 791 /** | 784 /** |
| 785 * @param {!WebInspector.Linkifier} linkifier | |
| 792 * @return {!DocumentFragment} | 786 * @return {!DocumentFragment} |
| 793 */ | 787 */ |
| 794 _generatePopupContentSynchronously: function() | 788 _generatePopupContentSynchronously: function(linkifier) |
| 795 { | 789 { |
| 796 var fragment = document.createDocumentFragment(); | 790 var fragment = document.createDocumentFragment(); |
| 797 if (!this.coalesced && this._children.length) | 791 if (!this.coalesced && this._children.length) |
| 798 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(t his._aggregatedStats, this.category, this._selfTime)); | 792 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(t his._aggregatedStats, this.category, this._selfTime)); |
| 799 else | 793 else |
| 800 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(t his._aggregatedStats)); | 794 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(t his._aggregatedStats)); |
| 801 | 795 |
| 802 if (this.coalesced) | 796 if (this.coalesced) |
| 803 return fragment; | 797 return fragment; |
| 804 | 798 |
| 805 const recordTypes = WebInspector.TimelineModel.RecordType; | 799 const recordTypes = WebInspector.TimelineModel.RecordType; |
| 806 | 800 |
| 807 // The messages may vary per record type; | 801 // The messages may vary per record type; |
| 808 var callSiteStackTraceLabel; | 802 var callSiteStackTraceLabel; |
| 809 var callStackLabel; | 803 var callStackLabel; |
| 810 var relatedNodeLabel; | 804 var relatedNodeLabel; |
| 811 | 805 |
| 812 var contentHelper = new WebInspector.TimelineDetailsContentHelper(true); | 806 var contentHelper = new WebInspector.TimelineDetailsContentHelper(linkif ier, true); |
| 813 contentHelper.appendTextRow(WebInspector.UIString("Self Time"), Number.m illisToString(this._selfTime, true)); | 807 contentHelper.appendTextRow(WebInspector.UIString("Self Time"), Number.m illisToString(this._selfTime, true)); |
| 814 contentHelper.appendTextRow(WebInspector.UIString("Start Time"), Number. millisToString(this._startTimeOffset)); | 808 contentHelper.appendTextRow(WebInspector.UIString("Start Time"), Number. millisToString(this._startTimeOffset)); |
| 815 | 809 |
| 816 switch (this.type) { | 810 switch (this.type) { |
| 817 case recordTypes.GCEvent: | 811 case recordTypes.GCEvent: |
| 818 contentHelper.appendTextRow(WebInspector.UIString("Collected"), Number.bytesToString(this.data["usedHeapSizeDelta"])); | 812 contentHelper.appendTextRow(WebInspector.UIString("Collected"), Number.bytesToString(this.data["usedHeapSizeDelta"])); |
| 819 break; | 813 break; |
| 820 case recordTypes.TimerFire: | 814 case recordTypes.TimerFire: |
| 821 callSiteStackTraceLabel = WebInspector.UIString("Timer installed "); | 815 callSiteStackTraceLabel = WebInspector.UIString("Timer installed "); |
| 822 // Fall-through intended. | 816 // Fall-through intended. |
| 823 | 817 |
| 824 case recordTypes.TimerInstall: | 818 case recordTypes.TimerInstall: |
| 825 case recordTypes.TimerRemove: | 819 case recordTypes.TimerRemove: |
| 826 contentHelper.appendTextRow(WebInspector.UIString("Timer ID"), t his.data["timerId"]); | 820 contentHelper.appendTextRow(WebInspector.UIString("Timer ID"), t his.data["timerId"]); |
| 827 if (typeof this.timeout === "number") { | 821 if (typeof this.timeout === "number") { |
| 828 contentHelper.appendTextRow(WebInspector.UIString("Timeout") , Number.millisToString(this.timeout)); | 822 contentHelper.appendTextRow(WebInspector.UIString("Timeout") , Number.millisToString(this.timeout)); |
| 829 contentHelper.appendTextRow(WebInspector.UIString("Repeats") , !this.singleShot); | 823 contentHelper.appendTextRow(WebInspector.UIString("Repeats") , !this.singleShot); |
| 830 } | 824 } |
| 831 break; | 825 break; |
| 832 case recordTypes.FireAnimationFrame: | 826 case recordTypes.FireAnimationFrame: |
| 833 callSiteStackTraceLabel = WebInspector.UIString("Animation frame requested"); | 827 callSiteStackTraceLabel = WebInspector.UIString("Animation frame requested"); |
| 834 contentHelper.appendTextRow(WebInspector.UIString("Callback ID") , this.data["id"]); | 828 contentHelper.appendTextRow(WebInspector.UIString("Callback ID") , this.data["id"]); |
| 835 break; | 829 break; |
| 836 case recordTypes.FunctionCall: | 830 case recordTypes.FunctionCall: |
| 837 if (this.scriptName) | 831 if (this.scriptName) |
| 838 contentHelper.appendElementRow(WebInspector.UIString("Locati on"), this._linkifyLocation(this.scriptName, this.scriptLine, 0)); | 832 contentHelper.appendLocationRow(WebInspector.UIString("Locat ion"), this.scriptName, this.scriptLine); |
| 839 break; | 833 break; |
| 840 case recordTypes.ScheduleResourceRequest: | 834 case recordTypes.ScheduleResourceRequest: |
| 841 case recordTypes.ResourceSendRequest: | 835 case recordTypes.ResourceSendRequest: |
| 842 case recordTypes.ResourceReceiveResponse: | 836 case recordTypes.ResourceReceiveResponse: |
| 843 case recordTypes.ResourceReceivedData: | 837 case recordTypes.ResourceReceivedData: |
| 844 case recordTypes.ResourceFinish: | 838 case recordTypes.ResourceFinish: |
| 845 contentHelper.appendElementRow(WebInspector.UIString("Resource") , WebInspector.linkifyResourceAsNode(this.url)); | 839 contentHelper.appendElementRow(WebInspector.UIString("Resource") , WebInspector.linkifyResourceAsNode(this.url)); |
| 846 if (this._imagePreviewElement) | 840 if (this._imagePreviewElement) |
| 847 contentHelper.appendElementRow(WebInspector.UIString("Previe w"), this._imagePreviewElement); | 841 contentHelper.appendElementRow(WebInspector.UIString("Previe w"), this._imagePreviewElement); |
| 848 if (this.data["requestMethod"]) | 842 if (this.data["requestMethod"]) |
| 849 contentHelper.appendTextRow(WebInspector.UIString("Request M ethod"), this.data["requestMethod"]); | 843 contentHelper.appendTextRow(WebInspector.UIString("Request M ethod"), this.data["requestMethod"]); |
| 850 if (typeof this.data["statusCode"] === "number") | 844 if (typeof this.data["statusCode"] === "number") |
| 851 contentHelper.appendTextRow(WebInspector.UIString("Status Co de"), this.data["statusCode"]); | 845 contentHelper.appendTextRow(WebInspector.UIString("Status Co de"), this.data["statusCode"]); |
| 852 if (this.data["mimeType"]) | 846 if (this.data["mimeType"]) |
| 853 contentHelper.appendTextRow(WebInspector.UIString("MIME Type "), this.data["mimeType"]); | 847 contentHelper.appendTextRow(WebInspector.UIString("MIME Type "), this.data["mimeType"]); |
| 854 if (this.data["encodedDataLength"]) | 848 if (this.data["encodedDataLength"]) |
| 855 contentHelper.appendTextRow(WebInspector.UIString("Encoded D ata Length"), WebInspector.UIString("%d Bytes", this.data["encodedDataLength"])) ; | 849 contentHelper.appendTextRow(WebInspector.UIString("Encoded D ata Length"), WebInspector.UIString("%d Bytes", this.data["encodedDataLength"])) ; |
| 856 break; | 850 break; |
| 857 case recordTypes.EvaluateScript: | 851 case recordTypes.EvaluateScript: |
| 858 if (this.data && this.url) | 852 if (this.data && this.url) |
| 859 contentHelper.appendElementRow(WebInspector.UIString("Script "), this._linkifyLocation(this.url, this.data["lineNumber"])); | 853 contentHelper.appendLocationRow(WebInspector.UIString("Scrip t"), this.url, this.data["lineNumber"]); |
| 860 break; | 854 break; |
| 861 case recordTypes.Paint: | 855 case recordTypes.Paint: |
| 862 var clip = this.data["clip"]; | 856 var clip = this.data["clip"]; |
| 863 if (clip) { | 857 if (clip) { |
| 864 contentHelper.appendTextRow(WebInspector.UIString("Location" ), WebInspector.UIString("(%d, %d)", clip[0], clip[1])); | 858 contentHelper.appendTextRow(WebInspector.UIString("Location" ), WebInspector.UIString("(%d, %d)", clip[0], clip[1])); |
| 865 var clipWidth = WebInspector.TimelinePresentationModel.quadW idth(clip); | 859 var clipWidth = WebInspector.TimelinePresentationModel.quadW idth(clip); |
| 866 var clipHeight = WebInspector.TimelinePresentationModel.quad Height(clip); | 860 var clipHeight = WebInspector.TimelinePresentationModel.quad Height(clip); |
| 867 contentHelper.appendTextRow(WebInspector.UIString("Dimension s"), WebInspector.UIString("%d × %d", clipWidth, clipHeight)); | 861 contentHelper.appendTextRow(WebInspector.UIString("Dimension s"), WebInspector.UIString("%d × %d", clipWidth, clipHeight)); |
| 868 } else { | 862 } else { |
| 869 // Backward compatibility: older version used x, y, width, h eight fields directly in data. | 863 // Backward compatibility: older version used x, y, width, h eight fields directly in data. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 917 contentHelper.appendTextRow(WebInspector.UIString("URL"), th is.webSocketURL); | 911 contentHelper.appendTextRow(WebInspector.UIString("URL"), th is.webSocketURL); |
| 918 if (typeof this.webSocketProtocol !== "undefined") | 912 if (typeof this.webSocketProtocol !== "undefined") |
| 919 contentHelper.appendTextRow(WebInspector.UIString("WebSocket Protocol"), this.webSocketProtocol); | 913 contentHelper.appendTextRow(WebInspector.UIString("WebSocket Protocol"), this.webSocketProtocol); |
| 920 if (typeof this.data["message"] !== "undefined") | 914 if (typeof this.data["message"] !== "undefined") |
| 921 contentHelper.appendTextRow(WebInspector.UIString("Message") , this.data["message"]); | 915 contentHelper.appendTextRow(WebInspector.UIString("Message") , this.data["message"]); |
| 922 break; | 916 break; |
| 923 case recordTypes.EmbedderCallback: | 917 case recordTypes.EmbedderCallback: |
| 924 contentHelper.appendTextRow(WebInspector.UIString("Callback Func tion"), this.embedderCallbackName); | 918 contentHelper.appendTextRow(WebInspector.UIString("Callback Func tion"), this.embedderCallbackName); |
| 925 break; | 919 break; |
| 926 default: | 920 default: |
| 927 if (this.detailsNode()) | 921 var detailsNode = this.buildDetailsNode(linkifier); |
| 928 contentHelper.appendElementRow(WebInspector.UIString("Detail s"), this.detailsNode().childNodes[1].cloneNode()); | 922 if (detailsNode) |
| 923 contentHelper.appendElementRow(WebInspector.UIString("Detail s"), detailsNode); | |
| 929 break; | 924 break; |
| 930 } | 925 } |
| 931 | 926 |
| 932 if (this._relatedNode) | 927 if (this._relatedNode) |
| 933 contentHelper.appendElementRow(relatedNodeLabel || WebInspector.UISt ring("Related node"), this._createNodeAnchor(this._relatedNode)); | 928 contentHelper.appendElementRow(relatedNodeLabel || WebInspector.UISt ring("Related node"), this._createNodeAnchor(this._relatedNode)); |
| 934 | 929 |
| 935 if (this.scriptName && this.type !== recordTypes.FunctionCall) | 930 if (this.scriptName && this.type !== recordTypes.FunctionCall) |
| 936 contentHelper.appendElementRow(WebInspector.UIString("Function Call" ), this._linkifyLocation(this.scriptName, this.scriptLine, 0)); | 931 contentHelper.appendLocationRow(WebInspector.UIString("Function Call "), this.scriptName, this.scriptLine); |
| 937 | 932 |
| 938 if (this.jsHeapSizeUsed) { | 933 if (this.jsHeapSizeUsed) { |
| 939 if (this.usedHeapSizeDelta) { | 934 if (this.usedHeapSizeDelta) { |
| 940 var sign = this.usedHeapSizeDelta > 0 ? "+" : "-"; | 935 var sign = this.usedHeapSizeDelta > 0 ? "+" : "-"; |
| 941 contentHelper.appendTextRow(WebInspector.UIString("Used JavaScri pt Heap Size"), | 936 contentHelper.appendTextRow(WebInspector.UIString("Used JavaScri pt Heap Size"), |
| 942 WebInspector.UIString("%s (%s%s)", Number.bytesToString(this .jsHeapSizeUsed), sign, Number.bytesToString(Math.abs(this.usedHeapSizeDelta)))) ; | 937 WebInspector.UIString("%s (%s%s)", Number.bytesToString(this .jsHeapSizeUsed), sign, Number.bytesToString(Math.abs(this.usedHeapSizeDelta)))) ; |
| 943 } else if (this.category === WebInspector.TimelineUIUtils.categories ().scripting) | 938 } else if (this.category === WebInspector.TimelineUIUtils.categories ().scripting) |
| 944 contentHelper.appendTextRow(WebInspector.UIString("Used JavaScri pt Heap Size"), Number.bytesToString(this.jsHeapSizeUsed)); | 939 contentHelper.appendTextRow(WebInspector.UIString("Used JavaScri pt Heap Size"), Number.bytesToString(this.jsHeapSizeUsed)); |
| 945 } | 940 } |
| 946 | 941 |
| 947 if (this.callSiteStackTrace) | 942 if (this.callSiteStackTrace) |
| 948 contentHelper.appendStackTrace(callSiteStackTraceLabel || WebInspect or.UIString("Call Site stack"), this.callSiteStackTrace, this._linkifyCallFrame. bind(this)); | 943 contentHelper.appendStackTrace(callSiteStackTraceLabel || WebInspect or.UIString("Call Site stack"), this.callSiteStackTrace); |
| 949 | 944 |
| 950 if (this.stackTrace) | 945 if (this.stackTrace) |
| 951 contentHelper.appendStackTrace(callStackLabel || WebInspector.UIStri ng("Call Stack"), this.stackTrace, this._linkifyCallFrame.bind(this)); | 946 contentHelper.appendStackTrace(callStackLabel || WebInspector.UIStri ng("Call Stack"), this.stackTrace); |
| 952 | 947 |
| 953 if (this._warnings) { | 948 if (this._warnings) { |
| 954 var ul = document.createElement("ul"); | 949 var ul = document.createElement("ul"); |
| 955 for (var i = 0; i < this._warnings.length; ++i) | 950 for (var i = 0; i < this._warnings.length; ++i) |
| 956 ul.createChild("li").textContent = this._warnings[i]; | 951 ul.createChild("li").textContent = this._warnings[i]; |
| 957 contentHelper.appendElementRow(WebInspector.UIString("Warning"), ul) ; | 952 contentHelper.appendElementRow(WebInspector.UIString("Warning"), ul) ; |
| 958 } | 953 } |
| 959 fragment.appendChild(contentHelper.element); | 954 fragment.appendChild(contentHelper.element); |
| 960 return fragment; | 955 return fragment; |
| 961 }, | 956 }, |
| 962 | 957 |
| 963 /** | 958 /** |
| 964 * @param {!WebInspector.DOMNode} node | 959 * @param {!WebInspector.DOMNode} node |
| 965 */ | 960 */ |
| 966 _createNodeAnchor: function(node) | 961 _createNodeAnchor: function(node) |
| 967 { | 962 { |
| 968 var span = document.createElement("span"); | 963 var span = document.createElement("span"); |
| 969 span.classList.add("node-link"); | 964 span.classList.add("node-link"); |
| 970 span.addEventListener("click", WebInspector.Revealer.reveal.bind(WebInsp ector.Revealer, node, undefined), false); | 965 span.addEventListener("click", WebInspector.Revealer.reveal.bind(WebInsp ector.Revealer, node, undefined), false); |
| 971 WebInspector.DOMPresentationUtils.decorateNodeLabel(node, span); | 966 WebInspector.DOMPresentationUtils.decorateNodeLabel(node, span); |
| 972 return span; | 967 return span; |
| 973 }, | 968 }, |
| 974 | 969 |
| 975 _refreshDetails: function() | |
| 976 { | |
| 977 delete this._detailsNode; | |
| 978 }, | |
| 979 | |
| 980 /** | |
| 981 * @return {?Node} | |
| 982 */ | |
| 983 detailsNode: function() | |
| 984 { | |
| 985 if (typeof this._detailsNode === "undefined") { | |
| 986 this._detailsNode = this._getRecordDetails(); | |
| 987 | |
| 988 if (this._detailsNode && !this.coalesced) { | |
| 989 this._detailsNode.insertBefore(document.createTextNode("("), thi s._detailsNode.firstChild); | |
| 990 this._detailsNode.appendChild(document.createTextNode(")")); | |
| 991 } | |
| 992 } | |
| 993 return this._detailsNode; | |
| 994 }, | |
| 995 | |
| 996 _createSpanWithText: function(textContent) | 970 _createSpanWithText: function(textContent) |
| 997 { | 971 { |
| 998 var node = document.createElement("span"); | 972 var node = document.createElement("span"); |
| 999 node.textContent = textContent; | 973 node.textContent = textContent; |
| 1000 return node; | 974 return node; |
| 1001 }, | 975 }, |
| 1002 | 976 |
| 1003 /** | 977 /** |
| 978 * @param {!WebInspector.Linkifier} linkifier | |
| 1004 * @return {?Node} | 979 * @return {?Node} |
| 1005 */ | 980 */ |
| 1006 _getRecordDetails: function() | 981 buildDetailsNode: function(linkifier) |
| 1007 { | 982 { |
| 1008 var details; | 983 var details; |
| 984 var detailsText; | |
| 1009 if (this.coalesced) | 985 if (this.coalesced) |
| 1010 return this._createSpanWithText(WebInspector.UIString("× %d", this.c hildren.length)); | 986 return this._createSpanWithText(WebInspector.UIString("× %d", this.c hildren.length)); |
| 1011 | 987 |
| 1012 switch (this.type) { | 988 switch (this.type) { |
| 1013 case WebInspector.TimelineModel.RecordType.GCEvent: | 989 case WebInspector.TimelineModel.RecordType.GCEvent: |
| 1014 details = WebInspector.UIString("%s collected", Number.bytesToString (this.data["usedHeapSizeDelta"])); | 990 detailsText = WebInspector.UIString("%s collected", Number.bytesToSt ring(this.data["usedHeapSizeDelta"])); |
| 1015 break; | 991 break; |
| 1016 case WebInspector.TimelineModel.RecordType.TimerFire: | 992 case WebInspector.TimelineModel.RecordType.TimerFire: |
| 1017 details = this._linkifyScriptLocation(this.data["timerId"]); | 993 details = this._linkifyScriptLocation(linkifier); |
| 994 detailsText = this.data["timerId"]; | |
| 1018 break; | 995 break; |
| 1019 case WebInspector.TimelineModel.RecordType.FunctionCall: | 996 case WebInspector.TimelineModel.RecordType.FunctionCall: |
| 1020 if (this.scriptName) | 997 if (this.scriptName) |
| 1021 details = this._linkifyLocation(this.scriptName, this.scriptLine , 0); | 998 details = this._linkifyLocation(linkifier, this.scriptName, this .scriptLine, 0); |
| 1022 break; | 999 break; |
| 1023 case WebInspector.TimelineModel.RecordType.FireAnimationFrame: | 1000 case WebInspector.TimelineModel.RecordType.FireAnimationFrame: |
| 1024 details = this._linkifyScriptLocation(this.data["id"]); | 1001 details = this._linkifyScriptLocation(linkifier); |
| 1002 detailsText = this.data["id"]; | |
| 1025 break; | 1003 break; |
| 1026 case WebInspector.TimelineModel.RecordType.EventDispatch: | 1004 case WebInspector.TimelineModel.RecordType.EventDispatch: |
| 1027 details = this.data ? this.data["type"] : null; | 1005 detailsText = this.data ? this.data["type"] : null; |
| 1028 break; | 1006 break; |
| 1029 case WebInspector.TimelineModel.RecordType.Paint: | 1007 case WebInspector.TimelineModel.RecordType.Paint: |
| 1030 var width = this.data.clip ? WebInspector.TimelinePresentationModel. quadWidth(this.data.clip) : this.data.width; | 1008 var width = this.data.clip ? WebInspector.TimelinePresentationModel. quadWidth(this.data.clip) : this.data.width; |
| 1031 var height = this.data.clip ? WebInspector.TimelinePresentationModel .quadHeight(this.data.clip) : this.data.height; | 1009 var height = this.data.clip ? WebInspector.TimelinePresentationModel .quadHeight(this.data.clip) : this.data.height; |
| 1032 if (width && height) | 1010 if (width && height) |
| 1033 details = WebInspector.UIString("%d\u2009\u00d7\u2009%d", width, height); | 1011 detailsText = WebInspector.UIString("%d\u2009\u00d7\u2009%d", wi dth, height); |
| 1034 break; | 1012 break; |
| 1035 case WebInspector.TimelineModel.RecordType.TimerInstall: | 1013 case WebInspector.TimelineModel.RecordType.TimerInstall: |
| 1036 case WebInspector.TimelineModel.RecordType.TimerRemove: | 1014 case WebInspector.TimelineModel.RecordType.TimerRemove: |
| 1037 details = this._linkifyTopCallFrame(this.data["timerId"]); | 1015 details = this._linkifyTopCallFrame(linkifier); |
| 1016 detailsText = this.data["timerId"]; | |
| 1038 break; | 1017 break; |
| 1039 case WebInspector.TimelineModel.RecordType.RequestAnimationFrame: | 1018 case WebInspector.TimelineModel.RecordType.RequestAnimationFrame: |
| 1040 case WebInspector.TimelineModel.RecordType.CancelAnimationFrame: | 1019 case WebInspector.TimelineModel.RecordType.CancelAnimationFrame: |
| 1041 details = this._linkifyTopCallFrame(this.data["id"]); | 1020 details = this._linkifyTopCallFrame(linkifier); |
| 1021 detailsText = this.data["id"]; | |
| 1042 break; | 1022 break; |
| 1043 case WebInspector.TimelineModel.RecordType.ParseHTML: | 1023 case WebInspector.TimelineModel.RecordType.ParseHTML: |
| 1044 case WebInspector.TimelineModel.RecordType.RecalculateStyles: | 1024 case WebInspector.TimelineModel.RecordType.RecalculateStyles: |
| 1045 details = this._linkifyTopCallFrame(); | 1025 details = this._linkifyTopCallFrame(linkifier); |
| 1046 break; | 1026 break; |
| 1047 case WebInspector.TimelineModel.RecordType.EvaluateScript: | 1027 case WebInspector.TimelineModel.RecordType.EvaluateScript: |
| 1048 details = this.url ? this._linkifyLocation(this.url, this.data["line Number"], 0) : null; | 1028 details = this.url ? this._linkifyLocation(linkifier, this.url, this .data["lineNumber"], 0) : null; |
| 1049 break; | 1029 break; |
| 1050 case WebInspector.TimelineModel.RecordType.XHRReadyStateChange: | 1030 case WebInspector.TimelineModel.RecordType.XHRReadyStateChange: |
| 1051 case WebInspector.TimelineModel.RecordType.XHRLoad: | 1031 case WebInspector.TimelineModel.RecordType.XHRLoad: |
| 1052 case WebInspector.TimelineModel.RecordType.ScheduleResourceRequest: | 1032 case WebInspector.TimelineModel.RecordType.ScheduleResourceRequest: |
| 1053 case WebInspector.TimelineModel.RecordType.ResourceSendRequest: | 1033 case WebInspector.TimelineModel.RecordType.ResourceSendRequest: |
| 1054 case WebInspector.TimelineModel.RecordType.ResourceReceivedData: | 1034 case WebInspector.TimelineModel.RecordType.ResourceReceivedData: |
| 1055 case WebInspector.TimelineModel.RecordType.ResourceReceiveResponse: | 1035 case WebInspector.TimelineModel.RecordType.ResourceReceiveResponse: |
| 1056 case WebInspector.TimelineModel.RecordType.ResourceFinish: | 1036 case WebInspector.TimelineModel.RecordType.ResourceFinish: |
| 1057 case WebInspector.TimelineModel.RecordType.DecodeImage: | 1037 case WebInspector.TimelineModel.RecordType.DecodeImage: |
| 1058 case WebInspector.TimelineModel.RecordType.ResizeImage: | 1038 case WebInspector.TimelineModel.RecordType.ResizeImage: |
| 1059 details = WebInspector.displayNameForURL(this.url); | 1039 detailsText = WebInspector.displayNameForURL(this.url); |
| 1060 break; | 1040 break; |
| 1061 case WebInspector.TimelineModel.RecordType.ConsoleTime: | 1041 case WebInspector.TimelineModel.RecordType.ConsoleTime: |
| 1062 details = this.data["message"]; | 1042 detailsText = this.data["message"]; |
| 1063 break; | 1043 break; |
| 1064 case WebInspector.TimelineModel.RecordType.EmbedderCallback: | 1044 case WebInspector.TimelineModel.RecordType.EmbedderCallback: |
| 1065 details = this.data["callbackName"]; | 1045 detailsText = this.data["callbackName"]; |
| 1066 break; | 1046 break; |
| 1067 default: | 1047 default: |
| 1068 details = this.scriptName ? this._linkifyLocation(this.scriptName, t his.scriptLine, 0) : (this._linkifyTopCallFrame() || null); | 1048 details = this.scriptName ? this._linkifyLocation(linkifier, this.sc riptName, this.scriptLine, 0) : (this._linkifyTopCallFrame(linkifier) || null); |
| 1069 break; | 1049 break; |
| 1070 } | 1050 } |
| 1071 | 1051 |
| 1072 if (details) { | 1052 if (!details && detailsText) |
| 1073 if (details instanceof Node) | 1053 details = document.createTextNode(detailsText); |
| 1074 details.tabIndex = -1; | 1054 return details; |
| 1075 else | |
| 1076 return this._createSpanWithText("" + details); | |
| 1077 } | |
| 1078 | |
| 1079 return details || null; | |
| 1080 }, | 1055 }, |
| 1081 | 1056 |
| 1082 /** | 1057 /** |
| 1058 * @param {!WebInspector.Linkifier} linkifier | |
| 1083 * @param {string} url | 1059 * @param {string} url |
| 1084 * @param {number} lineNumber | 1060 * @param {number} lineNumber |
| 1085 * @param {number=} columnNumber | 1061 * @param {number=} columnNumber |
| 1086 */ | 1062 */ |
| 1087 _linkifyLocation: function(url, lineNumber, columnNumber) | 1063 _linkifyLocation: function(linkifier, url, lineNumber, columnNumber) |
| 1088 { | 1064 { |
| 1089 // FIXME(62725): stack trace line/column numbers are one-based. | 1065 // FIXME(62725): stack trace line/column numbers are one-based. |
| 1090 columnNumber = columnNumber ? columnNumber - 1 : 0; | 1066 columnNumber = columnNumber ? columnNumber - 1 : 0; |
| 1091 return this._linkifier.linkifyLocation(url, lineNumber - 1, columnNumber , "timeline-details"); | 1067 return linkifier.linkifyLocation(url, lineNumber - 1, columnNumber, "tim eline-details"); |
| 1092 }, | 1068 }, |
| 1093 | 1069 |
| 1094 /** | 1070 /** |
| 1071 * @param {!WebInspector.Linkifier} linkifier | |
| 1095 * @param {!ConsoleAgent.CallFrame} callFrame | 1072 * @param {!ConsoleAgent.CallFrame} callFrame |
| 1096 */ | 1073 */ |
| 1097 _linkifyCallFrame: function(callFrame) | 1074 _linkifyCallFrame: function(linkifier, callFrame) |
| 1098 { | 1075 { |
| 1099 return this._linkifyLocation(callFrame.url, callFrame.lineNumber, callFr ame.columnNumber); | 1076 return this._linkifyLocation(linkifier, callFrame.url, callFrame.lineNum ber, callFrame.columnNumber); |
| 1100 }, | 1077 }, |
| 1101 | 1078 |
| 1102 /** | 1079 /** |
| 1103 * @param {string=} defaultValue | 1080 * @param {!WebInspector.Linkifier} linkifier |
| 1081 * @return {?Element} | |
| 1104 */ | 1082 */ |
| 1105 _linkifyTopCallFrame: function(defaultValue) | 1083 _linkifyTopCallFrame: function(linkifier) |
| 1106 { | 1084 { |
| 1107 if (this.stackTrace) | 1085 if (this.stackTrace) |
| 1108 return this._linkifyCallFrame(this.stackTrace[0]); | 1086 return this._linkifyCallFrame(linkifier, this.stackTrace[0]); |
| 1109 if (this.callSiteStackTrace) | 1087 if (this.callSiteStackTrace) |
| 1110 return this._linkifyCallFrame(this.callSiteStackTrace[0]); | 1088 return this._linkifyCallFrame(linkifier, this.callSiteStackTrace[0]) ; |
| 1111 return defaultValue; | 1089 return null; |
| 1112 }, | 1090 }, |
| 1113 | 1091 |
| 1114 /** | 1092 /** |
| 1115 * @param {*} defaultValue | 1093 * @param {!WebInspector.Linkifier} linkifier |
| 1116 * @return {!Element|string} | 1094 * @return {?Element} |
| 1117 */ | 1095 */ |
| 1118 _linkifyScriptLocation: function(defaultValue) | 1096 _linkifyScriptLocation: function(linkifier) |
| 1119 { | 1097 { |
| 1120 return this.scriptName ? this._linkifyLocation(this.scriptName, this.scr iptLine, 0) : "" + defaultValue; | 1098 return this.scriptName ? this._linkifyLocation(linkifier, this.scriptNam e, this.scriptLine, 0) : null; |
| 1121 }, | 1099 }, |
| 1122 | 1100 |
| 1123 calculateAggregatedStats: function() | 1101 calculateAggregatedStats: function() |
| 1124 { | 1102 { |
| 1125 this._aggregatedStats = {}; | 1103 this._aggregatedStats = {}; |
| 1126 this._cpuTime = this._selfTime; | 1104 this._cpuTime = this._selfTime; |
| 1127 | 1105 |
| 1128 for (var index = this._children.length; index; --index) { | 1106 for (var index = this._children.length; index; --index) { |
| 1129 var child = this._children[index - 1]; | 1107 var child = this._children[index - 1]; |
| 1130 for (var category in child._aggregatedStats) | 1108 for (var category in child._aggregatedStats) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1168 { | 1146 { |
| 1169 return this._childHasWarnings; | 1147 return this._childHasWarnings; |
| 1170 }, | 1148 }, |
| 1171 | 1149 |
| 1172 /** | 1150 /** |
| 1173 * @param {!RegExp} regExp | 1151 * @param {!RegExp} regExp |
| 1174 * @return {boolean} | 1152 * @return {boolean} |
| 1175 */ | 1153 */ |
| 1176 testContentMatching: function(regExp) | 1154 testContentMatching: function(regExp) |
| 1177 { | 1155 { |
| 1178 var toSearchText = this.title; | 1156 var tokens = [this.title()]; |
| 1179 if (this.detailsNode()) | 1157 for (var key in this._record.data) |
|
caseq
2014/03/03 07:53:15
Use Object.values()?
pfeldman
2014/03/03 09:16:48
Done.
| |
| 1180 toSearchText += " " + this.detailsNode().textContent; | 1158 tokens.push(this._record.data[key]) |
| 1181 return regExp.test(toSearchText); | 1159 return regExp.test(tokens.join("|")); |
| 1182 } | 1160 } |
| 1183 } | 1161 } |
| 1184 | 1162 |
| 1185 /** | 1163 /** |
| 1186 * @param {!Array.<number>} quad | 1164 * @param {!Array.<number>} quad |
| 1187 * @return {number} | 1165 * @return {number} |
| 1188 */ | 1166 */ |
| 1189 WebInspector.TimelinePresentationModel.quadWidth = function(quad) | 1167 WebInspector.TimelinePresentationModel.quadWidth = function(quad) |
| 1190 { | 1168 { |
| 1191 return Math.round(Math.sqrt(Math.pow(quad[0] - quad[2], 2) + Math.pow(quad[1 ] - quad[3], 2))); | 1169 return Math.round(Math.sqrt(Math.pow(quad[0] - quad[2], 2) + Math.pow(quad[1 ] - quad[3], 2))); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1222 { | 1200 { |
| 1223 } | 1201 } |
| 1224 | 1202 |
| 1225 WebInspector.TimelinePresentationModel.Filter.prototype = { | 1203 WebInspector.TimelinePresentationModel.Filter.prototype = { |
| 1226 /** | 1204 /** |
| 1227 * @param {!WebInspector.TimelinePresentationModel.Record} record | 1205 * @param {!WebInspector.TimelinePresentationModel.Record} record |
| 1228 * @return {boolean} | 1206 * @return {boolean} |
| 1229 */ | 1207 */ |
| 1230 accept: function(record) { return false; } | 1208 accept: function(record) { return false; } |
| 1231 } | 1209 } |
| OLD | NEW |