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

Unified Diff: Source/devtools/front_end/components/FlameChart.js

Issue 319363002: DevTools: CPUFlameChart: stick function entry color to the function name and url. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comments addressed Created 6 years, 6 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 | « no previous file | Source/devtools/front_end/profiler/CPUProfileFlameChart.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/components/FlameChart.js
diff --git a/Source/devtools/front_end/components/FlameChart.js b/Source/devtools/front_end/components/FlameChart.js
index 1d2415f0752a3cca7bc881e2d0b9f49a729fd750..32cd82d9f2dd0925a61837bc55dd4a323b92a575 100644
--- a/Source/devtools/front_end/components/FlameChart.js
+++ b/Source/devtools/front_end/components/FlameChart.js
@@ -232,7 +232,6 @@ WebInspector.FlameChart.ColorGenerator = function(hueSpace, satSpace, lightnessS
this._satSpace = satSpace || 67;
this._lightnessSpace = lightnessSpace || 80;
this._colors = {};
- this._currentColorIndex = 0;
}
WebInspector.FlameChart.ColorGenerator.prototype = {
@@ -253,21 +252,22 @@ WebInspector.FlameChart.ColorGenerator.prototype = {
{
var color = this._colors[id];
if (!color) {
- color = this._createColor(this._currentColorIndex++);
+ color = this._generateColorForID(id);
this._colors[id] = color;
}
return color;
},
/**
- * @param {number} index
+ * @param {string} id
* @return {string}
*/
- _createColor: function(index)
+ _generateColorForID: function(id)
{
- var h = this._indexToValueInSpace(index, this._hueSpace);
- var s = this._indexToValueInSpace(index, this._satSpace);
- var l = this._indexToValueInSpace(index, this._lightnessSpace);
+ var hash = id.hashCode();
+ var h = this._indexToValueInSpace(hash, this._hueSpace);
+ var s = this._indexToValueInSpace(hash, this._satSpace);
+ var l = this._indexToValueInSpace(hash, this._lightnessSpace);
return "hsl(" + h + ", " + s + "%, " + l + "%)";
},
@@ -281,7 +281,7 @@ WebInspector.FlameChart.ColorGenerator.prototype = {
if (typeof space === "number")
return space;
index %= space.count;
- return space.min + index / space.count * (space.max - space.min);
+ return space.min + Math.floor(index / space.count * (space.max - space.min));
}
}
« no previous file with comments | « no previous file | Source/devtools/front_end/profiler/CPUProfileFlameChart.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698