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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/CPUProfileView.js ('k') | Source/devtools/front_end/TimelineFlameChart.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/FlameChart.js
diff --git a/Source/devtools/front_end/FlameChart.js b/Source/devtools/front_end/FlameChart.js
index d4aeffbb2bc66237ae6ac96208b5ff55d6ef5e01..49b0b4072cfdc07fee1c8ddec5deee58607e69c9 100644
--- a/Source/devtools/front_end/FlameChart.js
+++ b/Source/devtools/front_end/FlameChart.js
@@ -181,6 +181,22 @@ WebInspector.FlameChartDataProvider.prototype = {
* @return {!string}
*/
entryColor: function(entryIndex) { },
+
+ /**
+ * @param {number} entryIndex
+ * @return {!string}
+ */
+ textColor: function(entryIndex) { },
+
+ /**
+ * @return {number}
+ */
+ textBaseline: function() { },
+
+ /**
+ * @return {number}
+ */
+ textPadding: function() { }
}
/**
@@ -819,8 +835,8 @@ WebInspector.FlameChart.MainPane.prototype = {
var titleIndexes = new Uint32Array(timelineData.entryTotalTimes);
var lastTitleIndex = 0;
var dotsWidth = context.measureText("\u2026").width;
- var textPaddingLeft = 2;
- this._minTextWidth = context.measureText("\u2026").width + textPaddingLeft;
+ var textPadding = this._dataProvider.textPadding();
+ this._minTextWidth = context.measureText("\u2026").width + 2 * textPadding;
var minTextWidth = this._minTextWidth;
var lastDrawOffset = new Int32Array(this._dataProvider.maxStackDepth());
@@ -843,9 +859,11 @@ WebInspector.FlameChart.MainPane.prototype = {
var colors = [];
var bucket = [];
- var textBaseHeight = this._baseHeight + this._barHeight - 4;
+ var textBaseHeight = this._baseHeight + this._barHeight - this._dataProvider.textBaseline();
var lastUsedFont = "";
var font;
+ var textColor;
+ var lastTextColor = "";
var text = "";
var xText = 0;
var textWidth = 0;
@@ -919,18 +937,25 @@ WebInspector.FlameChart.MainPane.prototype = {
if (!text || !text.length)
continue;
font = this._dataProvider.entryFont(entryIndex);
- if (font !== lastUsedFont)
- context.font = font;
-
entryOffset = entryOffsets[entryIndex];
barX = this._offsetToPosition(entryOffset);
barRight = this._offsetToPosition(entryOffset + entryTotalTimes[entryIndex]);
barWidth = Math.max(barRight - barX, minWidth);
xText = Math.max(0, barX);
- textWidth = barWidth - textPaddingLeft + barX - xText;
+ textWidth = barWidth - 2 * textPadding + barX - xText;
title = this._prepareText(context, text, textWidth);
- if (title)
- context.fillText(title, xText + textPaddingLeft, textBaseHeight - entryLevels[entryIndex] * this._barHeightDelta);
+ if (!title)
+ continue;
+ if (font !== lastUsedFont) {
+ context.font = font;
+ lastUsedFont = font;
+ }
+ textColor = this._dataProvider.textColor(entryIndex);
+ if (textColor !== lastTextColor) {
+ context.fillStyle = textColor;
+ lastTextColor = textColor;
+ }
+ context.fillText(title, xText + textPadding, textBaseHeight - entryLevels[entryIndex] * this._barHeightDelta);
}
this._updateHighlightElement();
},
« 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