Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1035)

Side by Side Diff: Source/devtools/front_end/TimelinePresentationModel.js

Issue 185323002: DevTools: prepare to move UI builders from timeline presentation record to timeline ui utils. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 get category() 643 get category()
644 { 644 {
645 return WebInspector.TimelineUIUtils.categoryForRecord(this._record); 645 return WebInspector.TimelineUIUtils.categoryForRecord(this._record);
646 }, 646 },
647 647
648 /** 648 /**
649 * @return {string} 649 * @return {string}
650 */ 650 */
651 title: function() 651 title: function()
652 { 652 {
653 return WebInspector.TimelineUIUtils.recordTitle(this._model, this._recor d); 653 return WebInspector.TimelineUIUtils.recordTitle(this._record);
654 }, 654 },
655 655
656 /** 656 /**
657 * @return {number} 657 * @return {number}
658 */ 658 */
659 get startTime() 659 get startTime()
660 { 660 {
661 return this._record.startTime; 661 return this._record.startTime;
662 }, 662 },
663 663
664 /** 664 /**
665 * @return {number} 665 * @return {number}
666 */ 666 */
667 get startTimeOffset()
668 {
669 return this._startTimeOffset;
670 },
671
672 /**
673 * @return {number}
674 */
667 get endTime() 675 get endTime()
668 { 676 {
669 return this._record.endTime || this._record.startTime; 677 return this._record.endTime || this._record.startTime;
670 }, 678 },
671 679
672 /** 680 /**
673 * @return {boolean} 681 * @return {boolean}
674 */ 682 */
675 isBackground: function() 683 isBackground: function()
676 { 684 {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 737
730 /** 738 /**
731 * @return {boolean} 739 * @return {boolean}
732 */ 740 */
733 containsTime: function(time) 741 containsTime: function(time)
734 { 742 {
735 return this.startTime <= time && time <= this.endTime; 743 return this.startTime <= time && time <= this.endTime;
736 }, 744 },
737 745
738 /** 746 /**
747 * @param {!WebInspector.TimelinePresentationModel.Record} record
739 * @param {!WebInspector.Linkifier} linkifier 748 * @param {!WebInspector.Linkifier} linkifier
740 * @param {function(!DocumentFragment)} callback 749 * @param {function(!DocumentFragment)} callback
741 */ 750 */
742 generatePopupContent: function(linkifier, callback) 751 generatePopupContent: function(record, linkifier, callback)
743 { 752 {
753 var imageElement = /** @type {?Element} */ (record.getUserObject("Timeli nePresentationModel::preview-element") || null);
754 var relatedNode = /** @type {?WebInspector.DOMNode} */ (record.getUserOb ject("TimelinePresentationModel::related-node") || null);
755
744 var barrier = new CallbackBarrier(); 756 var barrier = new CallbackBarrier();
745 if (WebInspector.TimelineUIUtils.needsPreviewElement(this.type) && !this ._imagePreviewElement) 757 if (!imageElement && WebInspector.TimelineUIUtils.needsPreviewElement(re cord.type))
746 WebInspector.DOMPresentationUtils.buildImagePreviewContents(this.url , false, barrier.createCallback(this._setImagePreviewElement.bind(this))); 758 WebInspector.DOMPresentationUtils.buildImagePreviewContents(record.u rl, false, barrier.createCallback(saveImage));
747 if (this._relatedBackendNodeId && !this._relatedNode) 759 if (!relatedNode && record.relatedBackendNodeId())
748 WebInspector.domAgent.pushNodeByBackendIdToFrontend(this._relatedBac kendNodeId, barrier.createCallback(this._setRelatedNode.bind(this))); 760 WebInspector.domAgent.pushNodeByBackendIdToFrontend(record.relatedBa ckendNodeId(), barrier.createCallback(saveNode));
761 barrier.callWhenDone(callbackWrapper.bind(this));
749 762
750 barrier.callWhenDone(callbackWrapper.bind(this)); 763 /**
764 * @param {!Element=} element
765 */
766 function saveImage(element)
767 {
768 imageElement = element || null;
769 record.setUserObject("TimelinePresentationModel::preview-element", e lement);
770 }
771
772 /**
773 * @param {?DOMAgent.NodeId} nodeId
774 */
775 function saveNode(nodeId)
776 {
777 if (nodeId !== null) {
778 relatedNode = WebInspector.domAgent.nodeForId(nodeId);
779 record.setUserObject("TimelinePresentationModel::related-node", relatedNode);
780 }
781 }
751 782
752 /** 783 /**
753 * @this {WebInspector.TimelinePresentationModel.Record} 784 * @this {WebInspector.TimelinePresentationModel.Record}
754 */ 785 */
755 function callbackWrapper() 786 function callbackWrapper()
756 { 787 {
757 callback(this._generatePopupContentSynchronously(linkifier)); 788 callback(this._generatePopupContentSynchronously(record, linkifier, imageElement, relatedNode));
758 } 789 }
759 }, 790 },
760 791
761 /** 792 /**
762 * @param {string} key 793 * @param {string} key
763 * @return {?Object} 794 * @return {?Object}
764 */ 795 */
765 getUserObject: function(key) 796 getUserObject: function(key)
766 { 797 {
767 if (!this._userObjects) 798 if (!this._userObjects)
768 return null; 799 return null;
769 return this._userObjects.get(key); 800 return this._userObjects.get(key);
770 }, 801 },
771 802
772 /** 803 /**
773 * @param {string} key 804 * @param {string} key
774 * @param {!Object} value 805 * @param {?Object|undefined} value
caseq 2014/03/03 08:29:25 ?Object=
775 */ 806 */
776 setUserObject: function(key, value) 807 setUserObject: function(key, value)
777 { 808 {
778 if (!this._userObjects) 809 if (!this._userObjects)
779 this._userObjects = new StringMap(); 810 this._userObjects = new StringMap();
780 this._userObjects.put(key, value); 811 this._userObjects.put(key, value);
781 }, 812 },
782 813
783 /** 814 /**
784 * @param {!Element} element 815 * @return {number} nodeId
785 */ 816 */
786 _setImagePreviewElement: function(element) 817 relatedBackendNodeId: function()
787 { 818 {
788 this._imagePreviewElement = element; 819 return this._relatedBackendNodeId;
789 }, 820 },
790 821
791 /** 822 /**
792 * @param {?DOMAgent.NodeId} nodeId 823 * @param {!WebInspector.TimelinePresentationModel.Record} record
793 */
794 _setRelatedNode: function(nodeId)
795 {
796 if (typeof nodeId === "number")
797 this._relatedNode = WebInspector.domAgent.nodeForId(nodeId);
798 },
799
800 /**
801 * @param {!WebInspector.Linkifier} linkifier 824 * @param {!WebInspector.Linkifier} linkifier
825 * @param {?Element} imagePreviewElement
826 * @param {?WebInspector.DOMNode} relatedNode
802 * @return {!DocumentFragment} 827 * @return {!DocumentFragment}
803 */ 828 */
804 _generatePopupContentSynchronously: function(linkifier) 829 _generatePopupContentSynchronously: function(record, linkifier, imagePreview Element, relatedNode)
805 { 830 {
806 var fragment = document.createDocumentFragment(); 831 var fragment = document.createDocumentFragment();
807 if (!this.coalesced && this._children.length) 832 if (!record.coalesced && record.children.length)
808 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(t his._aggregatedStats, this.category, this._selfTime)); 833 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(r ecord.aggregatedStats, record.category, record.selfTime));
809 else 834 else
810 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(t his._aggregatedStats)); 835 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(r ecord.aggregatedStats));
811 836
812 if (this.coalesced) 837 if (record.coalesced)
813 return fragment; 838 return fragment;
814 839
815 const recordTypes = WebInspector.TimelineModel.RecordType; 840 const recordTypes = WebInspector.TimelineModel.RecordType;
816 841
817 // The messages may vary per record type; 842 // The messages may vary per record type;
818 var callSiteStackTraceLabel; 843 var callSiteStackTraceLabel;
819 var callStackLabel; 844 var callStackLabel;
820 var relatedNodeLabel; 845 var relatedNodeLabel;
821 846
822 var contentHelper = new WebInspector.TimelineDetailsContentHelper(linkif ier, true); 847 var contentHelper = new WebInspector.TimelineDetailsContentHelper(linkif ier, true);
823 contentHelper.appendTextRow(WebInspector.UIString("Self Time"), Number.m illisToString(this._selfTime, true)); 848 contentHelper.appendTextRow(WebInspector.UIString("Self Time"), Number.m illisToString(record.selfTime, true));
824 contentHelper.appendTextRow(WebInspector.UIString("Start Time"), Number. millisToString(this._startTimeOffset)); 849 contentHelper.appendTextRow(WebInspector.UIString("Start Time"), Number. millisToString(record.startTimeOffset));
825 850
826 switch (this.type) { 851 switch (record.type) {
827 case recordTypes.GCEvent: 852 case recordTypes.GCEvent:
828 contentHelper.appendTextRow(WebInspector.UIString("Collected"), Number.bytesToString(this.data["usedHeapSizeDelta"])); 853 contentHelper.appendTextRow(WebInspector.UIString("Collected"), Number.bytesToString(record.data["usedHeapSizeDelta"]));
829 break; 854 break;
830 case recordTypes.TimerFire: 855 case recordTypes.TimerFire:
831 callSiteStackTraceLabel = WebInspector.UIString("Timer installed "); 856 callSiteStackTraceLabel = WebInspector.UIString("Timer installed ");
832 // Fall-through intended. 857 // Fall-through intended.
833 858
834 case recordTypes.TimerInstall: 859 case recordTypes.TimerInstall:
835 case recordTypes.TimerRemove: 860 case recordTypes.TimerRemove:
836 contentHelper.appendTextRow(WebInspector.UIString("Timer ID"), t his.data["timerId"]); 861 contentHelper.appendTextRow(WebInspector.UIString("Timer ID"), r ecord.data["timerId"]);
837 if (typeof this.timeout === "number") { 862 if (typeof record.timeout === "number") {
838 contentHelper.appendTextRow(WebInspector.UIString("Timeout") , Number.millisToString(this.timeout)); 863 contentHelper.appendTextRow(WebInspector.UIString("Timeout") , Number.millisToString(record.timeout));
839 contentHelper.appendTextRow(WebInspector.UIString("Repeats") , !this.singleShot); 864 contentHelper.appendTextRow(WebInspector.UIString("Repeats") , !record.singleShot);
840 } 865 }
841 break; 866 break;
842 case recordTypes.FireAnimationFrame: 867 case recordTypes.FireAnimationFrame:
843 callSiteStackTraceLabel = WebInspector.UIString("Animation frame requested"); 868 callSiteStackTraceLabel = WebInspector.UIString("Animation frame requested");
844 contentHelper.appendTextRow(WebInspector.UIString("Callback ID") , this.data["id"]); 869 contentHelper.appendTextRow(WebInspector.UIString("Callback ID") , record.data["id"]);
845 break; 870 break;
846 case recordTypes.FunctionCall: 871 case recordTypes.FunctionCall:
847 if (this.scriptName) 872 if (record.scriptName)
848 contentHelper.appendLocationRow(WebInspector.UIString("Locat ion"), this.scriptName, this.scriptLine); 873 contentHelper.appendLocationRow(WebInspector.UIString("Locat ion"), record.scriptName, record.scriptLine);
849 break; 874 break;
850 case recordTypes.ScheduleResourceRequest: 875 case recordTypes.ScheduleResourceRequest:
851 case recordTypes.ResourceSendRequest: 876 case recordTypes.ResourceSendRequest:
852 case recordTypes.ResourceReceiveResponse: 877 case recordTypes.ResourceReceiveResponse:
853 case recordTypes.ResourceReceivedData: 878 case recordTypes.ResourceReceivedData:
854 case recordTypes.ResourceFinish: 879 case recordTypes.ResourceFinish:
855 contentHelper.appendElementRow(WebInspector.UIString("Resource") , WebInspector.linkifyResourceAsNode(this.url)); 880 contentHelper.appendElementRow(WebInspector.UIString("Resource") , WebInspector.linkifyResourceAsNode(record.url));
856 if (this._imagePreviewElement) 881 if (imagePreviewElement)
857 contentHelper.appendElementRow(WebInspector.UIString("Previe w"), this._imagePreviewElement); 882 contentHelper.appendElementRow(WebInspector.UIString("Previe w"), imagePreviewElement);
858 if (this.data["requestMethod"]) 883 if (record.data["requestMethod"])
859 contentHelper.appendTextRow(WebInspector.UIString("Request M ethod"), this.data["requestMethod"]); 884 contentHelper.appendTextRow(WebInspector.UIString("Request M ethod"), record.data["requestMethod"]);
860 if (typeof this.data["statusCode"] === "number") 885 if (typeof record.data["statusCode"] === "number")
861 contentHelper.appendTextRow(WebInspector.UIString("Status Co de"), this.data["statusCode"]); 886 contentHelper.appendTextRow(WebInspector.UIString("Status Co de"), record.data["statusCode"]);
862 if (this.data["mimeType"]) 887 if (record.data["mimeType"])
863 contentHelper.appendTextRow(WebInspector.UIString("MIME Type "), this.data["mimeType"]); 888 contentHelper.appendTextRow(WebInspector.UIString("MIME Type "), record.data["mimeType"]);
864 if (this.data["encodedDataLength"]) 889 if (record.data["encodedDataLength"])
865 contentHelper.appendTextRow(WebInspector.UIString("Encoded D ata Length"), WebInspector.UIString("%d Bytes", this.data["encodedDataLength"])) ; 890 contentHelper.appendTextRow(WebInspector.UIString("Encoded D ata Length"), WebInspector.UIString("%d Bytes", record.data["encodedDataLength"] ));
866 break; 891 break;
867 case recordTypes.EvaluateScript: 892 case recordTypes.EvaluateScript:
868 if (this.data && this.url) 893 if (record.data && record.url)
869 contentHelper.appendLocationRow(WebInspector.UIString("Scrip t"), this.url, this.data["lineNumber"]); 894 contentHelper.appendLocationRow(WebInspector.UIString("Scrip t"), record.url, record.data["lineNumber"]);
870 break; 895 break;
871 case recordTypes.Paint: 896 case recordTypes.Paint:
872 var clip = this.data["clip"]; 897 var clip = record.data["clip"];
873 if (clip) { 898 if (clip) {
874 contentHelper.appendTextRow(WebInspector.UIString("Location" ), WebInspector.UIString("(%d, %d)", clip[0], clip[1])); 899 contentHelper.appendTextRow(WebInspector.UIString("Location" ), WebInspector.UIString("(%d, %d)", clip[0], clip[1]));
875 var clipWidth = WebInspector.TimelinePresentationModel.quadW idth(clip); 900 var clipWidth = WebInspector.TimelinePresentationModel.quadW idth(clip);
876 var clipHeight = WebInspector.TimelinePresentationModel.quad Height(clip); 901 var clipHeight = WebInspector.TimelinePresentationModel.quad Height(clip);
877 contentHelper.appendTextRow(WebInspector.UIString("Dimension s"), WebInspector.UIString("%d × %d", clipWidth, clipHeight)); 902 contentHelper.appendTextRow(WebInspector.UIString("Dimension s"), WebInspector.UIString("%d × %d", clipWidth, clipHeight));
878 } else { 903 } else {
879 // Backward compatibility: older version used x, y, width, h eight fields directly in data. 904 // Backward compatibility: older version used x, y, width, h eight fields directly in data.
880 if (typeof this.data["x"] !== "undefined" && typeof this.dat a["y"] !== "undefined") 905 if (typeof record.data["x"] !== "undefined" && typeof record .data["y"] !== "undefined")
881 contentHelper.appendTextRow(WebInspector.UIString("Locat ion"), WebInspector.UIString("(%d, %d)", this.data["x"], this.data["y"])); 906 contentHelper.appendTextRow(WebInspector.UIString("Locat ion"), WebInspector.UIString("(%d, %d)", record.data["x"], record.data["y"]));
882 if (typeof this.data["width"] !== "undefined" && typeof this .data["height"] !== "undefined") 907 if (typeof record.data["width"] !== "undefined" && typeof re cord.data["height"] !== "undefined")
883 contentHelper.appendTextRow(WebInspector.UIString("Dimen sions"), WebInspector.UIString("%d\u2009\u00d7\u2009%d", this.data["width"], thi s.data["height"])); 908 contentHelper.appendTextRow(WebInspector.UIString("Dimen sions"), WebInspector.UIString("%d\u2009\u00d7\u2009%d", record.data["width"], r ecord.data["height"]));
884 } 909 }
885 // Fall-through intended. 910 // Fall-through intended.
886 911
887 case recordTypes.PaintSetup: 912 case recordTypes.PaintSetup:
888 case recordTypes.Rasterize: 913 case recordTypes.Rasterize:
889 case recordTypes.ScrollLayer: 914 case recordTypes.ScrollLayer:
890 relatedNodeLabel = WebInspector.UIString("Layer root"); 915 relatedNodeLabel = WebInspector.UIString("Layer root");
891 break; 916 break;
892 case recordTypes.AutosizeText: 917 case recordTypes.AutosizeText:
893 relatedNodeLabel = WebInspector.UIString("Root node"); 918 relatedNodeLabel = WebInspector.UIString("Root node");
894 break; 919 break;
895 case recordTypes.DecodeImage: 920 case recordTypes.DecodeImage:
896 case recordTypes.ResizeImage: 921 case recordTypes.ResizeImage:
897 relatedNodeLabel = WebInspector.UIString("Image element"); 922 relatedNodeLabel = WebInspector.UIString("Image element");
898 if (this.url) 923 if (record.url)
899 contentHelper.appendElementRow(WebInspector.UIString("Image URL"), WebInspector.linkifyResourceAsNode(this.url)); 924 contentHelper.appendElementRow(WebInspector.UIString("Image URL"), WebInspector.linkifyResourceAsNode(record.url));
900 break; 925 break;
901 case recordTypes.RecalculateStyles: // We don't want to see default details. 926 case recordTypes.RecalculateStyles: // We don't want to see default details.
902 if (this.data["elementCount"]) 927 if (record.data["elementCount"])
903 contentHelper.appendTextRow(WebInspector.UIString("Elements affected"), this.data["elementCount"]); 928 contentHelper.appendTextRow(WebInspector.UIString("Elements affected"), record.data["elementCount"]);
904 callStackLabel = WebInspector.UIString("Styles recalculation for ced"); 929 callStackLabel = WebInspector.UIString("Styles recalculation for ced");
905 break; 930 break;
906 case recordTypes.Layout: 931 case recordTypes.Layout:
907 if (this.data["dirtyObjects"]) 932 if (record.data["dirtyObjects"])
908 contentHelper.appendTextRow(WebInspector.UIString("Nodes tha t need layout"), this.data["dirtyObjects"]); 933 contentHelper.appendTextRow(WebInspector.UIString("Nodes tha t need layout"), record.data["dirtyObjects"]);
909 if (this.data["totalObjects"]) 934 if (record.data["totalObjects"])
910 contentHelper.appendTextRow(WebInspector.UIString("Layout tr ee size"), this.data["totalObjects"]); 935 contentHelper.appendTextRow(WebInspector.UIString("Layout tr ee size"), record.data["totalObjects"]);
911 if (typeof this.data["partialLayout"] === "boolean") { 936 if (typeof record.data["partialLayout"] === "boolean") {
912 contentHelper.appendTextRow(WebInspector.UIString("Layout sc ope"), 937 contentHelper.appendTextRow(WebInspector.UIString("Layout sc ope"),
913 this.data["partialLayout"] ? WebInspector.UIString("Parti al") : WebInspector.UIString("Whole document")); 938 record.data["partialLayout"] ? WebInspector.UIString("Par tial") : WebInspector.UIString("Whole document"));
914 } 939 }
915 callSiteStackTraceLabel = WebInspector.UIString("Layout invalida ted"); 940 callSiteStackTraceLabel = WebInspector.UIString("Layout invalida ted");
916 callStackLabel = WebInspector.UIString("Layout forced"); 941 callStackLabel = WebInspector.UIString("Layout forced");
917 relatedNodeLabel = WebInspector.UIString("Layout root"); 942 relatedNodeLabel = WebInspector.UIString("Layout root");
918 break; 943 break;
919 case recordTypes.ConsoleTime: 944 case recordTypes.ConsoleTime:
920 contentHelper.appendTextRow(WebInspector.UIString("Message"), th is.data["message"]); 945 contentHelper.appendTextRow(WebInspector.UIString("Message"), re cord.data["message"]);
921 break; 946 break;
922 case recordTypes.WebSocketCreate: 947 case recordTypes.WebSocketCreate:
923 case recordTypes.WebSocketSendHandshakeRequest: 948 case recordTypes.WebSocketSendHandshakeRequest:
924 case recordTypes.WebSocketReceiveHandshakeResponse: 949 case recordTypes.WebSocketReceiveHandshakeResponse:
925 case recordTypes.WebSocketDestroy: 950 case recordTypes.WebSocketDestroy:
926 if (typeof this.webSocketURL !== "undefined") 951 if (typeof record.webSocketURL !== "undefined")
927 contentHelper.appendTextRow(WebInspector.UIString("URL"), th is.webSocketURL); 952 contentHelper.appendTextRow(WebInspector.UIString("URL"), re cord.webSocketURL);
928 if (typeof this.webSocketProtocol !== "undefined") 953 if (typeof record.webSocketProtocol !== "undefined")
929 contentHelper.appendTextRow(WebInspector.UIString("WebSocket Protocol"), this.webSocketProtocol); 954 contentHelper.appendTextRow(WebInspector.UIString("WebSocket Protocol"), record.webSocketProtocol);
930 if (typeof this.data["message"] !== "undefined") 955 if (typeof record.data["message"] !== "undefined")
931 contentHelper.appendTextRow(WebInspector.UIString("Message") , this.data["message"]); 956 contentHelper.appendTextRow(WebInspector.UIString("Message") , record.data["message"]);
932 break; 957 break;
933 case recordTypes.EmbedderCallback: 958 case recordTypes.EmbedderCallback:
934 contentHelper.appendTextRow(WebInspector.UIString("Callback Func tion"), this.embedderCallbackName); 959 contentHelper.appendTextRow(WebInspector.UIString("Callback Func tion"), record.embedderCallbackName);
935 break; 960 break;
936 default: 961 default:
937 var detailsNode = this.buildDetailsNode(linkifier); 962 var detailsNode = record.buildDetailsNode(record, linkifier);
938 if (detailsNode) 963 if (detailsNode)
939 contentHelper.appendElementRow(WebInspector.UIString("Detail s"), detailsNode); 964 contentHelper.appendElementRow(WebInspector.UIString("Detail s"), detailsNode);
940 break; 965 break;
941 } 966 }
942 967
943 if (this._relatedNode) 968 /**
944 contentHelper.appendElementRow(relatedNodeLabel || WebInspector.UISt ring("Related node"), this._createNodeAnchor(this._relatedNode)); 969 * @param {!WebInspector.DOMNode} node
945 970 */
946 if (this.scriptName && this.type !== recordTypes.FunctionCall) 971 function createNodeAnchor(node)
947 contentHelper.appendLocationRow(WebInspector.UIString("Function Call "), this.scriptName, this.scriptLine); 972 {
948 973 var span = document.createElement("span");
949 if (this.jsHeapSizeUsed) { 974 span.classList.add("node-link");
950 if (this.usedHeapSizeDelta) { 975 span.addEventListener("click", WebInspector.Revealer.reveal.bind(Web Inspector.Revealer, node, undefined), false);
951 var sign = this.usedHeapSizeDelta > 0 ? "+" : "-"; 976 WebInspector.DOMPresentationUtils.decorateNodeLabel(node, span);
952 contentHelper.appendTextRow(WebInspector.UIString("Used JavaScri pt Heap Size"), 977 return span;
953 WebInspector.UIString("%s (%s%s)", Number.bytesToString(this .jsHeapSizeUsed), sign, Number.bytesToString(Math.abs(this.usedHeapSizeDelta)))) ;
954 } else if (this.category === WebInspector.TimelineUIUtils.categories ().scripting)
955 contentHelper.appendTextRow(WebInspector.UIString("Used JavaScri pt Heap Size"), Number.bytesToString(this.jsHeapSizeUsed));
956 } 978 }
957 979
958 if (this.callSiteStackTrace) 980 if (relatedNode)
959 contentHelper.appendStackTrace(callSiteStackTraceLabel || WebInspect or.UIString("Call Site stack"), this.callSiteStackTrace); 981 contentHelper.appendElementRow(relatedNodeLabel || WebInspector.UISt ring("Related node"), createNodeAnchor(relatedNode));
960 982
961 if (this.stackTrace) 983 if (record.scriptName && record.type !== recordTypes.FunctionCall)
962 contentHelper.appendStackTrace(callStackLabel || WebInspector.UIStri ng("Call Stack"), this.stackTrace); 984 contentHelper.appendLocationRow(WebInspector.UIString("Function Call "), record.scriptName, record.scriptLine);
963 985
964 if (this._warnings) { 986 if (record.jsHeapSizeUsed) {
987 if (record.usedHeapSizeDelta) {
988 var sign = record.usedHeapSizeDelta > 0 ? "+" : "-";
989 contentHelper.appendTextRow(WebInspector.UIString("Used JavaScri pt Heap Size"),
990 WebInspector.UIString("%s (%s%s)", Number.bytesToString(reco rd.jsHeapSizeUsed), sign, Number.bytesToString(Math.abs(record.usedHeapSizeDelta ))));
991 } else if (record.category === WebInspector.TimelineUIUtils.categori es().scripting)
992 contentHelper.appendTextRow(WebInspector.UIString("Used JavaScri pt Heap Size"), Number.bytesToString(record.jsHeapSizeUsed));
993 }
994
995 if (record.callSiteStackTrace)
996 contentHelper.appendStackTrace(callSiteStackTraceLabel || WebInspect or.UIString("Call Site stack"), record.callSiteStackTrace);
997
998 if (record.stackTrace)
999 contentHelper.appendStackTrace(callStackLabel || WebInspector.UIStri ng("Call Stack"), record.stackTrace);
1000
1001 if (record.warnings) {
965 var ul = document.createElement("ul"); 1002 var ul = document.createElement("ul");
966 for (var i = 0; i < this._warnings.length; ++i) 1003 for (var i = 0; i < record.warnings.length; ++i)
967 ul.createChild("li").textContent = this._warnings[i]; 1004 ul.createChild("li").textContent = record.warnings[i];
968 contentHelper.appendElementRow(WebInspector.UIString("Warning"), ul) ; 1005 contentHelper.appendElementRow(WebInspector.UIString("Warning"), ul) ;
969 } 1006 }
970 fragment.appendChild(contentHelper.element); 1007 fragment.appendChild(contentHelper.element);
971 return fragment; 1008 return fragment;
972 }, 1009 },
973 1010
974 /** 1011 /**
975 * @param {!WebInspector.DOMNode} node 1012 * @param {!WebInspector.TimelinePresentationModel.Record} record
976 */
977 _createNodeAnchor: function(node)
978 {
979 var span = document.createElement("span");
980 span.classList.add("node-link");
981 span.addEventListener("click", WebInspector.Revealer.reveal.bind(WebInsp ector.Revealer, node, undefined), false);
982 WebInspector.DOMPresentationUtils.decorateNodeLabel(node, span);
983 return span;
984 },
985
986 _createSpanWithText: function(textContent)
987 {
988 var node = document.createElement("span");
989 node.textContent = textContent;
990 return node;
991 },
992
993 /**
994 * @param {!WebInspector.Linkifier} linkifier 1013 * @param {!WebInspector.Linkifier} linkifier
995 * @return {?Node} 1014 * @return {?Node}
996 */ 1015 */
997 buildDetailsNode: function(linkifier) 1016 buildDetailsNode: function(record, linkifier)
998 { 1017 {
999 var details; 1018 var details;
1000 var detailsText; 1019 var detailsText;
1001 if (this.coalesced) 1020 if (record.coalesced) {
1002 return this._createSpanWithText(WebInspector.UIString("× %d", this.c hildren.length)); 1021 var node = document.createElement("span");
1022 node.textContent = WebInspector.UIString("× %d", record.children.len gth);
1023 return node;
1024 }
1003 1025
1004 switch (this.type) { 1026 switch (record.type) {
1005 case WebInspector.TimelineModel.RecordType.GCEvent: 1027 case WebInspector.TimelineModel.RecordType.GCEvent:
1006 detailsText = WebInspector.UIString("%s collected", Number.bytesToSt ring(this.data["usedHeapSizeDelta"])); 1028 detailsText = WebInspector.UIString("%s collected", Number.bytesToSt ring(record.data["usedHeapSizeDelta"]));
1007 break; 1029 break;
1008 case WebInspector.TimelineModel.RecordType.TimerFire: 1030 case WebInspector.TimelineModel.RecordType.TimerFire:
1009 details = this._linkifyScriptLocation(linkifier); 1031 details = linkifyScriptLocation();
1010 detailsText = this.data["timerId"]; 1032 detailsText = record.data["timerId"];
1011 break; 1033 break;
1012 case WebInspector.TimelineModel.RecordType.FunctionCall: 1034 case WebInspector.TimelineModel.RecordType.FunctionCall:
1013 if (this.scriptName) 1035 if (record.scriptName)
1014 details = this._linkifyLocation(linkifier, this.scriptName, this .scriptLine, 0); 1036 details = linkifyLocation(record.scriptName, record.scriptLine, 0);
1015 break; 1037 break;
1016 case WebInspector.TimelineModel.RecordType.FireAnimationFrame: 1038 case WebInspector.TimelineModel.RecordType.FireAnimationFrame:
1017 details = this._linkifyScriptLocation(linkifier); 1039 details = linkifyScriptLocation();
1018 detailsText = this.data["id"]; 1040 detailsText = record.data["id"];
1019 break; 1041 break;
1020 case WebInspector.TimelineModel.RecordType.EventDispatch: 1042 case WebInspector.TimelineModel.RecordType.EventDispatch:
1021 detailsText = this.data ? this.data["type"] : null; 1043 detailsText = record.data ? record.data["type"] : null;
1022 break; 1044 break;
1023 case WebInspector.TimelineModel.RecordType.Paint: 1045 case WebInspector.TimelineModel.RecordType.Paint:
1024 var width = this.data.clip ? WebInspector.TimelinePresentationModel. quadWidth(this.data.clip) : this.data.width; 1046 var width = record.data.clip ? WebInspector.TimelinePresentationMode l.quadWidth(record.data.clip) : record.data.width;
1025 var height = this.data.clip ? WebInspector.TimelinePresentationModel .quadHeight(this.data.clip) : this.data.height; 1047 var height = record.data.clip ? WebInspector.TimelinePresentationMod el.quadHeight(record.data.clip) : record.data.height;
1026 if (width && height) 1048 if (width && height)
1027 detailsText = WebInspector.UIString("%d\u2009\u00d7\u2009%d", wi dth, height); 1049 detailsText = WebInspector.UIString("%d\u2009\u00d7\u2009%d", wi dth, height);
1028 break; 1050 break;
1029 case WebInspector.TimelineModel.RecordType.TimerInstall: 1051 case WebInspector.TimelineModel.RecordType.TimerInstall:
1030 case WebInspector.TimelineModel.RecordType.TimerRemove: 1052 case WebInspector.TimelineModel.RecordType.TimerRemove:
1031 details = this._linkifyTopCallFrame(linkifier); 1053 details = linkifyTopCallFrame();
1032 detailsText = this.data["timerId"]; 1054 detailsText = record.data["timerId"];
1033 break; 1055 break;
1034 case WebInspector.TimelineModel.RecordType.RequestAnimationFrame: 1056 case WebInspector.TimelineModel.RecordType.RequestAnimationFrame:
1035 case WebInspector.TimelineModel.RecordType.CancelAnimationFrame: 1057 case WebInspector.TimelineModel.RecordType.CancelAnimationFrame:
1036 details = this._linkifyTopCallFrame(linkifier); 1058 details = linkifyTopCallFrame();
1037 detailsText = this.data["id"]; 1059 detailsText = record.data["id"];
1038 break; 1060 break;
1039 case WebInspector.TimelineModel.RecordType.ParseHTML: 1061 case WebInspector.TimelineModel.RecordType.ParseHTML:
1040 case WebInspector.TimelineModel.RecordType.RecalculateStyles: 1062 case WebInspector.TimelineModel.RecordType.RecalculateStyles:
1041 details = this._linkifyTopCallFrame(linkifier); 1063 details = linkifyTopCallFrame();
1042 break; 1064 break;
1043 case WebInspector.TimelineModel.RecordType.EvaluateScript: 1065 case WebInspector.TimelineModel.RecordType.EvaluateScript:
1044 details = this.url ? this._linkifyLocation(linkifier, this.url, this .data["lineNumber"], 0) : null; 1066 details = record.url ? linkifyLocation(record.url, record.data["line Number"], 0) : null;
1045 break; 1067 break;
1046 case WebInspector.TimelineModel.RecordType.XHRReadyStateChange: 1068 case WebInspector.TimelineModel.RecordType.XHRReadyStateChange:
1047 case WebInspector.TimelineModel.RecordType.XHRLoad: 1069 case WebInspector.TimelineModel.RecordType.XHRLoad:
1048 case WebInspector.TimelineModel.RecordType.ScheduleResourceRequest: 1070 case WebInspector.TimelineModel.RecordType.ScheduleResourceRequest:
1049 case WebInspector.TimelineModel.RecordType.ResourceSendRequest: 1071 case WebInspector.TimelineModel.RecordType.ResourceSendRequest:
1050 case WebInspector.TimelineModel.RecordType.ResourceReceivedData: 1072 case WebInspector.TimelineModel.RecordType.ResourceReceivedData:
1051 case WebInspector.TimelineModel.RecordType.ResourceReceiveResponse: 1073 case WebInspector.TimelineModel.RecordType.ResourceReceiveResponse:
1052 case WebInspector.TimelineModel.RecordType.ResourceFinish: 1074 case WebInspector.TimelineModel.RecordType.ResourceFinish:
1053 case WebInspector.TimelineModel.RecordType.DecodeImage: 1075 case WebInspector.TimelineModel.RecordType.DecodeImage:
1054 case WebInspector.TimelineModel.RecordType.ResizeImage: 1076 case WebInspector.TimelineModel.RecordType.ResizeImage:
1055 detailsText = WebInspector.displayNameForURL(this.url); 1077 detailsText = WebInspector.displayNameForURL(record.url);
1056 break; 1078 break;
1057 case WebInspector.TimelineModel.RecordType.ConsoleTime: 1079 case WebInspector.TimelineModel.RecordType.ConsoleTime:
1058 detailsText = this.data["message"]; 1080 detailsText = record.data["message"];
1059 break; 1081 break;
1060 case WebInspector.TimelineModel.RecordType.EmbedderCallback: 1082 case WebInspector.TimelineModel.RecordType.EmbedderCallback:
1061 detailsText = this.data["callbackName"]; 1083 detailsText = record.data["callbackName"];
1062 break; 1084 break;
1063 default: 1085 default:
1064 details = this.scriptName ? this._linkifyLocation(linkifier, this.sc riptName, this.scriptLine, 0) : (this._linkifyTopCallFrame(linkifier) || null); 1086 details = record.scriptName ? linkifyLocation(record.scriptName, rec ord.scriptLine, 0) : linkifyTopCallFrame();
1065 break; 1087 break;
1066 } 1088 }
1067 1089
1068 if (!details && detailsText) 1090 if (!details && detailsText)
1069 details = document.createTextNode(detailsText); 1091 details = document.createTextNode(detailsText);
1070 return details; 1092 return details;
1071 },
1072 1093
1073 /** 1094 /**
1074 * @param {!WebInspector.Linkifier} linkifier 1095 * @param {string} url
1075 * @param {string} url 1096 * @param {number} lineNumber
1076 * @param {number} lineNumber 1097 * @param {number=} columnNumber
1077 * @param {number=} columnNumber 1098 */
1078 */ 1099 function linkifyLocation(url, lineNumber, columnNumber)
1079 _linkifyLocation: function(linkifier, url, lineNumber, columnNumber) 1100 {
1080 { 1101 // FIXME(62725): stack trace line/column numbers are one-based.
1081 // FIXME(62725): stack trace line/column numbers are one-based. 1102 columnNumber = columnNumber ? columnNumber - 1 : 0;
1082 columnNumber = columnNumber ? columnNumber - 1 : 0; 1103 return linkifier.linkifyLocation(url, lineNumber - 1, columnNumber, "timeline-details");
1083 return linkifier.linkifyLocation(url, lineNumber - 1, columnNumber, "tim eline-details"); 1104 }
1084 },
1085 1105
1086 /** 1106 /**
1087 * @param {!WebInspector.Linkifier} linkifier 1107 * @param {!ConsoleAgent.CallFrame} callFrame
1088 * @param {!ConsoleAgent.CallFrame} callFrame 1108 */
1089 */ 1109 function linkifyCallFrame(callFrame)
1090 _linkifyCallFrame: function(linkifier, callFrame) 1110 {
1091 { 1111 return linkifyLocation(callFrame.url, callFrame.lineNumber, callFram e.columnNumber);
1092 return this._linkifyLocation(linkifier, callFrame.url, callFrame.lineNum ber, callFrame.columnNumber); 1112 }
1093 },
1094 1113
1095 /** 1114 /**
1096 * @param {!WebInspector.Linkifier} linkifier 1115 * @return {?Element}
1097 * @return {?Element} 1116 */
1098 */ 1117 function linkifyTopCallFrame()
1099 _linkifyTopCallFrame: function(linkifier) 1118 {
1100 { 1119 if (record.stackTrace)
1101 if (this.stackTrace) 1120 return linkifyCallFrame(record.stackTrace[0]);
1102 return this._linkifyCallFrame(linkifier, this.stackTrace[0]); 1121 if (record.callSiteStackTrace)
1103 if (this.callSiteStackTrace) 1122 return linkifyCallFrame(record.callSiteStackTrace[0]);
1104 return this._linkifyCallFrame(linkifier, this.callSiteStackTrace[0]) ; 1123 return null;
1105 return null; 1124 }
1106 },
1107 1125
1108 /** 1126 /**
1109 * @param {!WebInspector.Linkifier} linkifier 1127 * @return {?Element}
1110 * @return {?Element} 1128 */
1111 */ 1129 function linkifyScriptLocation()
1112 _linkifyScriptLocation: function(linkifier) 1130 {
1113 { 1131 return record.scriptName ? linkifyLocation(record.scriptName, record .scriptLine, 0) : null;
1114 return this.scriptName ? this._linkifyLocation(linkifier, this.scriptNam e, this.scriptLine, 0) : null; 1132 }
1115 }, 1133 },
1116 1134
1117 calculateAggregatedStats: function() 1135 calculateAggregatedStats: function()
1118 { 1136 {
1119 this._aggregatedStats = {}; 1137 this._aggregatedStats = {};
1120 this._cpuTime = this._selfTime; 1138 this._cpuTime = this._selfTime;
1121 1139
1122 for (var index = this._children.length; index; --index) { 1140 for (var index = this._children.length; index; --index) {
1123 var child = this._children[index - 1]; 1141 var child = this._children[index - 1];
1124 for (var category in child._aggregatedStats) 1142 for (var category in child._aggregatedStats)
(...skipping 24 matching lines...) Expand all
1149 1167
1150 /** 1168 /**
1151 * @return {boolean} 1169 * @return {boolean}
1152 */ 1170 */
1153 hasWarnings: function() 1171 hasWarnings: function()
1154 { 1172 {
1155 return !!this._warnings; 1173 return !!this._warnings;
1156 }, 1174 },
1157 1175
1158 /** 1176 /**
1177 * @return {!Object}
1178 */
1179 warnings: function()
1180 {
1181 return this._warnings;
1182 },
1183
1184 /**
1159 * @return {boolean} 1185 * @return {boolean}
1160 */ 1186 */
1161 childHasWarnings: function() 1187 childHasWarnings: function()
1162 { 1188 {
1163 return this._childHasWarnings; 1189 return this._childHasWarnings;
1164 }, 1190 },
1165 1191
1166 /** 1192 /**
1167 * @param {!RegExp} regExp 1193 * @param {!RegExp} regExp
1168 * @return {boolean} 1194 * @return {boolean}
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 { 1242 {
1217 } 1243 }
1218 1244
1219 WebInspector.TimelinePresentationModel.Filter.prototype = { 1245 WebInspector.TimelinePresentationModel.Filter.prototype = {
1220 /** 1246 /**
1221 * @param {!WebInspector.TimelinePresentationModel.Record} record 1247 * @param {!WebInspector.TimelinePresentationModel.Record} record
1222 * @return {boolean} 1248 * @return {boolean}
1223 */ 1249 */
1224 accept: function(record) { return false; } 1250 accept: function(record) { return false; }
1225 } 1251 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/TimelinePanel.js ('k') | Source/devtools/front_end/TimelineUIUtils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698