Changeset 147213 in webkit


Ignore:
Timestamp:
Mar 29, 2013 6:56:55 AM (11 years ago)
Author:
loislo@chromium.org
Message:

Web Inspector: Flame Chart. Developers will have more clue
if two different profiles will have same colors for same functions.
https://bugs.webkit.org/show_bug.cgi?id=113410

Reviewed by Pavel Feldman.

The code related to color generator was extracted into a separate class.
The instance of the class was stored as static private member of the FlameChart class,
so all the profiles will share the same instance and will use same colors.
The colors itself were slightly adjusted.

Drive by fix: coordinatesToNodeIndex was fixed. The error was introduced in the patch about left padding.

  • inspector/front-end/FlameChart.js:

(WebInspector.FlameChart):
(WebInspector.FlameChart.ColorGenerator):
(WebInspector.FlameChart.ColorGenerator.prototype._colorPairForID):
(WebInspector.FlameChart.prototype._calculateTimelineData):
(WebInspector.FlameChart.prototype._calculateTimelineDataForSamples):
(WebInspector.FlameChart.prototype._coordinatesToNodeIndex):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r147212 r147213  
     12013-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
    1242013-03-29  Charles Wei  <charles.wei@torchmobile.com.cn>
    225
  • trunk/Source/WebCore/inspector/front-end/FlameChart.js

    r146981 r147213  
    7171    this._linkifier = new WebInspector.Linkifier();
    7272    this._highlightedNodeIndex = -1;
     73
     74    if (!WebInspector.FlameChart._colorGenerator)
     75        WebInspector.FlameChart._colorGenerator = new WebInspector.FlameChart.ColorGenerator();
    7376}
    7477
     
    184187    SelectedNode: "SelectedNode"
    185188}
     189
     190/**
     191 * @constructor
     192 */
     193WebInspector.FlameChart.ColorGenerator = function()
     194{
     195    this._colorPairs = {};
     196    this._currentColorIndex = 0;
     197}
     198
     199WebInspector.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
    186216
    187217WebInspector.FlameChart.prototype = {
     
    254284        var levelOffsets = /** @type {Array.<!number>} */ ([0]);
    255285        var levelExitIndexes = /** @type {Array.<!number>} */ ([0]);
     286        var colorGenerator = WebInspector.FlameChart._colorGenerator;
    256287
    257288        while (stack.length) {
     
    260291            var offset = levelOffsets[level];
    261292
    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);
    269294
    270295            entries.push({
     
    276301            });
    277302
    278 
    279303            ++index;
    280304
     
    319343        var openIntervals = [];
    320344        var stackTrace = [];
     345        var colorGenerator = WebInspector.FlameChart._colorGenerator;
    321346        for (var sampleIndex = 0; sampleIndex < samplesCount; sampleIndex++) {
    322347            var node = idToNode[samples[sampleIndex]];
     
    342367
    343368            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);
    351370
    352371                entries.push({
     
    464483            return -1;
    465484        var timelineEntries = timelineData.entries;
    466         var cursorTime = (x + this._pixelWindowLeft) * this._pixelToTime;
     485        var cursorTime = (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTime;
    467486        var cursorLevel = Math.floor((this._canvas.height - y) / this._barHeight);
    468487
Note: See TracChangeset for help on using the changeset viewer.