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

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

Issue 186833002: DevTools: customize text baseline and style in flame chard. (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 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 * @param {number} entryIndex 174 * @param {number} entryIndex
175 * @return {?string} 175 * @return {?string}
176 */ 176 */
177 entryFont: function(entryIndex) { }, 177 entryFont: function(entryIndex) { },
178 178
179 /** 179 /**
180 * @param {number} entryIndex 180 * @param {number} entryIndex
181 * @return {!string} 181 * @return {!string}
182 */ 182 */
183 entryColor: function(entryIndex) { }, 183 entryColor: function(entryIndex) { },
184
185 /**
186 * @param {number} entryIndex
187 * @return {!string}
188 */
189 textColor: function(entryIndex) { },
190
191 /**
192 * @return {number}
193 */
194 textBaseline: function() { },
195
196 /**
197 * @return {number}
198 */
199 textPadding: function() { }
184 } 200 }
185 201
186 /** 202 /**
187 * @constructor 203 * @constructor
188 * @implements {WebInspector.TimelineGrid.Calculator} 204 * @implements {WebInspector.TimelineGrid.Calculator}
189 */ 205 */
190 WebInspector.FlameChart.Calculator = function() 206 WebInspector.FlameChart.Calculator = function()
191 { 207 {
192 this._paddingLeft = 0; 208 this._paddingLeft = 0;
193 } 209 }
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 var pixelWindowLeft = this._pixelWindowLeft; 828 var pixelWindowLeft = this._pixelWindowLeft;
813 var paddingLeft = this._paddingLeft; 829 var paddingLeft = this._paddingLeft;
814 var minWidth = this._minWidth; 830 var minWidth = this._minWidth;
815 var entryTotalTimes = timelineData.entryTotalTimes; 831 var entryTotalTimes = timelineData.entryTotalTimes;
816 var entryOffsets = timelineData.entryOffsets; 832 var entryOffsets = timelineData.entryOffsets;
817 var entryLevels = timelineData.entryLevels; 833 var entryLevels = timelineData.entryLevels;
818 834
819 var titleIndexes = new Uint32Array(timelineData.entryTotalTimes); 835 var titleIndexes = new Uint32Array(timelineData.entryTotalTimes);
820 var lastTitleIndex = 0; 836 var lastTitleIndex = 0;
821 var dotsWidth = context.measureText("\u2026").width; 837 var dotsWidth = context.measureText("\u2026").width;
822 var textPaddingLeft = 2; 838 var textPadding = this._dataProvider.textPadding();
823 this._minTextWidth = context.measureText("\u2026").width + textPaddingLe ft; 839 this._minTextWidth = context.measureText("\u2026").width + 2 * textPaddi ng;
824 var minTextWidth = this._minTextWidth; 840 var minTextWidth = this._minTextWidth;
825 841
826 var lastDrawOffset = new Int32Array(this._dataProvider.maxStackDepth()); 842 var lastDrawOffset = new Int32Array(this._dataProvider.maxStackDepth());
827 for (var i = 0; i < lastDrawOffset.length; ++i) 843 for (var i = 0; i < lastDrawOffset.length; ++i)
828 lastDrawOffset[i] = -1; 844 lastDrawOffset[i] = -1;
829 845
830 var barX = 0; 846 var barX = 0;
831 var barY = 0; 847 var barY = 0;
832 var barWidth = 0; 848 var barWidth = 0;
833 var barRight = 0; 849 var barRight = 0;
834 var barLevel = 0; 850 var barLevel = 0;
835 var barHeight = this._barHeight; 851 var barHeight = this._barHeight;
836 this._baseHeight = this._isTopDown ? WebInspector.FlameChart.DividersBar Height : height - this._barHeight; 852 this._baseHeight = this._isTopDown ? WebInspector.FlameChart.DividersBar Height : height - this._barHeight;
837 context.strokeStyle = "black"; 853 context.strokeStyle = "black";
838 var color; 854 var color;
839 var entryIndex = 0; 855 var entryIndex = 0;
840 var entryOffset = 0; 856 var entryOffset = 0;
841 857
842 var colorBuckets = {}; 858 var colorBuckets = {};
843 var colors = []; 859 var colors = [];
844 var bucket = []; 860 var bucket = [];
845 861
846 var textBaseHeight = this._baseHeight + this._barHeight - 4; 862 var textBaseHeight = this._baseHeight + this._barHeight - this._dataProv ider.textBaseline();
847 var lastUsedFont = ""; 863 var lastUsedFont = "";
848 var font; 864 var font;
865 var textColor;
866 var lastTextColor = "";
849 var text = ""; 867 var text = "";
850 var xText = 0; 868 var xText = 0;
851 var textWidth = 0; 869 var textWidth = 0;
852 var title = ""; 870 var title = "";
853 var i = 0; 871 var i = 0;
854 var c = 0; 872 var c = 0;
855 873
856 var entryOffsetRight = 0; 874 var entryOffsetRight = 0;
857 var maxBarLevel = height / this._barHeight; 875 var maxBarLevel = height / this._barHeight;
858 for (entryIndex = 0; entryIndex < entryOffsets.length; ++entryIndex) { 876 for (entryIndex = 0; entryIndex < entryOffsets.length; ++entryIndex) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 context.textBaseline = "alphabetic"; 930 context.textBaseline = "alphabetic";
913 context.fillStyle = "#333"; 931 context.fillStyle = "#333";
914 this._dotsWidth = context.measureText("\u2026").width; 932 this._dotsWidth = context.measureText("\u2026").width;
915 933
916 for (i = 0; i < lastTitleIndex; ++i) { 934 for (i = 0; i < lastTitleIndex; ++i) {
917 entryIndex = titleIndexes[i]; 935 entryIndex = titleIndexes[i];
918 text = this._dataProvider.entryTitle(entryIndex); 936 text = this._dataProvider.entryTitle(entryIndex);
919 if (!text || !text.length) 937 if (!text || !text.length)
920 continue; 938 continue;
921 font = this._dataProvider.entryFont(entryIndex); 939 font = this._dataProvider.entryFont(entryIndex);
922 if (font !== lastUsedFont)
923 context.font = font;
924
925 entryOffset = entryOffsets[entryIndex]; 940 entryOffset = entryOffsets[entryIndex];
926 barX = this._offsetToPosition(entryOffset); 941 barX = this._offsetToPosition(entryOffset);
927 barRight = this._offsetToPosition(entryOffset + entryTotalTimes[entr yIndex]); 942 barRight = this._offsetToPosition(entryOffset + entryTotalTimes[entr yIndex]);
928 barWidth = Math.max(barRight - barX, minWidth); 943 barWidth = Math.max(barRight - barX, minWidth);
929 xText = Math.max(0, barX); 944 xText = Math.max(0, barX);
930 textWidth = barWidth - textPaddingLeft + barX - xText; 945 textWidth = barWidth - 2 * textPadding + barX - xText;
931 title = this._prepareText(context, text, textWidth); 946 title = this._prepareText(context, text, textWidth);
932 if (title) 947 if (!title)
933 context.fillText(title, xText + textPaddingLeft, textBaseHeight - entryLevels[entryIndex] * this._barHeightDelta); 948 continue;
949 if (font !== lastUsedFont) {
950 context.font = font;
951 lastUsedFont = font;
952 }
953 textColor = this._dataProvider.textColor(entryIndex);
954 if (textColor !== lastTextColor) {
955 context.fillStyle = textColor;
956 lastTextColor = textColor;
957 }
958 context.fillText(title, xText + textPadding, textBaseHeight - entryL evels[entryIndex] * this._barHeightDelta);
934 } 959 }
935 this._updateHighlightElement(); 960 this._updateHighlightElement();
936 }, 961 },
937 962
938 _updateHighlightElement: function() 963 _updateHighlightElement: function()
939 { 964 {
940 if (this._highlightElement.parentElement) 965 if (this._highlightElement.parentElement)
941 this._highlightElement.remove(); 966 this._highlightElement.remove();
942 var entryIndex = this._highlightedEntryIndex; 967 var entryIndex = this._highlightedEntryIndex;
943 if (entryIndex === -1) 968 if (entryIndex === -1)
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 this._timelineGrid.hideDividers(); 1098 this._timelineGrid.hideDividers();
1074 this.draw(this.element.clientWidth, this.element.clientHeight); 1099 this.draw(this.element.clientWidth, this.element.clientHeight);
1075 this._calculator._updateBoundaries(this); 1100 this._calculator._updateBoundaries(this);
1076 this._timelineGrid.element.style.width = this.element.clientWidth; 1101 this._timelineGrid.element.style.width = this.element.clientWidth;
1077 var offsets = this._dataProvider.dividerOffsets(this._calculator.minimum Boundary(), this._calculator.maximumBoundary()); 1102 var offsets = this._dataProvider.dividerOffsets(this._calculator.minimum Boundary(), this._calculator.maximumBoundary());
1078 this._timelineGrid.updateDividers(this._calculator, offsets, true); 1103 this._timelineGrid.updateDividers(this._calculator, offsets, true);
1079 }, 1104 },
1080 1105
1081 __proto__: WebInspector.View.prototype 1106 __proto__: WebInspector.View.prototype
1082 } 1107 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/CPUProfileView.js ('k') | Source/devtools/front_end/TimelineFlameChart.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698