Changeset 147213 in webkit
- Timestamp:
- Mar 29, 2013 6:56:55 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r147212 r147213 1 2013-03-29 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Web Inspector: Flame Chart. Developers will have more clue 4 if two different profiles will have same colors for same functions. 5 https://bugs.webkit.org/show_bug.cgi?id=113410 6 7 Reviewed by Pavel Feldman. 8 9 The code related to color generator was extracted into a separate class. 10 The instance of the class was stored as static private member of the FlameChart class, 11 so all the profiles will share the same instance and will use same colors. 12 The colors itself were slightly adjusted. 13 14 Drive by fix: coordinatesToNodeIndex was fixed. The error was introduced in the patch about left padding. 15 16 * inspector/front-end/FlameChart.js: 17 (WebInspector.FlameChart): 18 (WebInspector.FlameChart.ColorGenerator): 19 (WebInspector.FlameChart.ColorGenerator.prototype._colorPairForID): 20 (WebInspector.FlameChart.prototype._calculateTimelineData): 21 (WebInspector.FlameChart.prototype._calculateTimelineDataForSamples): 22 (WebInspector.FlameChart.prototype._coordinatesToNodeIndex): 23 1 24 2013-03-29 Charles Wei <charles.wei@torchmobile.com.cn> 2 25 -
trunk/Source/WebCore/inspector/front-end/FlameChart.js
r146981 r147213 71 71 this._linkifier = new WebInspector.Linkifier(); 72 72 this._highlightedNodeIndex = -1; 73 74 if (!WebInspector.FlameChart._colorGenerator) 75 WebInspector.FlameChart._colorGenerator = new WebInspector.FlameChart.ColorGenerator(); 73 76 } 74 77 … … 184 187 SelectedNode: "SelectedNode" 185 188 } 189 190 /** 191 * @constructor 192 */ 193 WebInspector.FlameChart.ColorGenerator = function() 194 { 195 this._colorPairs = {}; 196 this._currentColorIndex = 0; 197 } 198 199 WebInspector.FlameChart.ColorGenerator.prototype = { 200 /** 201 * @param {!string} id 202 */ 203 _colorPairForID: function(id) 204 { 205 var colorPairs = this._colorPairs; 206 var colorPair = colorPairs[id]; 207 if (!colorPair) { 208 var currentColorIndex = ++this._currentColorIndex; 209 var hue = (currentColorIndex * 5 + 11 * (currentColorIndex % 2)) % 360; 210 colorPairs[id] = colorPair = {highlighted: "hsla(" + hue + ", 100%, 33%, 0.7)", normal: "hsla(" + hue + ", 100%, 66%, 0.7)"}; 211 } 212 return colorPair; 213 } 214 } 215 186 216 187 217 WebInspector.FlameChart.prototype = { … … 254 284 var levelOffsets = /** @type {Array.<!number>} */ ([0]); 255 285 var levelExitIndexes = /** @type {Array.<!number>} */ ([0]); 286 var colorGenerator = WebInspector.FlameChart._colorGenerator; 256 287 257 288 while (stack.length) { … … 260 291 var offset = levelOffsets[level]; 261 292 262 var functionUID = node.functionName + ":" + node.url + ":" + node.lineNumber; 263 var colorPair = functionColorPairs[functionUID]; 264 if (!colorPair) { 265 ++currentColorIndex; 266 var hue = (currentColorIndex * 5 + 11 * (currentColorIndex % 2)) % 360; 267 functionColorPairs[functionUID] = colorPair = {highlighted: "hsl(" + hue + ", 100%, 33%)", normal: "hsl(" + hue + ", 100%, 66%)"}; 268 } 293 var colorPair = colorGenerator._colorPairForID(node.functionName + ":" + node.url + ":" + node.lineNumber); 269 294 270 295 entries.push({ … … 276 301 }); 277 302 278 279 303 ++index; 280 304 … … 319 343 var openIntervals = []; 320 344 var stackTrace = []; 345 var colorGenerator = WebInspector.FlameChart._colorGenerator; 321 346 for (var sampleIndex = 0; sampleIndex < samplesCount; sampleIndex++) { 322 347 var node = idToNode[samples[sampleIndex]]; … … 342 367 343 368 while (node) { 344 var functionUID = node.functionName + ":" + node.url + ":" + node.lineNumber; 345 var colorPair = functionColorPairs[functionUID]; 346 if (!colorPair) { 347 ++currentColorIndex; 348 var hue = (currentColorIndex * 5 + 11 * (currentColorIndex % 2)) % 360; 349 functionColorPairs[functionUID] = colorPair = {highlighted: "hsl(" + hue + ", 100%, 33%)", normal: "hsl(" + hue + ", 100%, 66%)"}; 350 } 369 var colorPair = colorGenerator._colorPairForID(node.functionName + ":" + node.url + ":" + node.lineNumber); 351 370 352 371 entries.push({ … … 464 483 return -1; 465 484 var timelineEntries = timelineData.entries; 466 var cursorTime = (x + this._pixelWindowLeft ) * this._pixelToTime;485 var cursorTime = (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTime; 467 486 var cursorLevel = Math.floor((this._canvas.height - y) / this._barHeight); 468 487
Note: See TracChangeset
for help on using the changeset viewer.