Changeset 109216 in webkit


Ignore:
Timestamp:
Feb 29, 2012 7:59:30 AM (12 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: remove calculator's updateBoundaries in the timeline panel.
https://bugs.webkit.org/show_bug.cgi?id=79907

Reviewed by Yury Semikhatsky.

  • inspector/front-end/NetworkPanel.js:

(WebInspector.NetworkBaseCalculator.prototype.computeBarGraphLabels):
(WebInspector.NetworkBaseCalculator.prototype.formatTime):
(WebInspector.NetworkTimeCalculator.prototype.computeBarGraphLabels):
(WebInspector.NetworkTimeCalculator.prototype.formatTime):
(WebInspector.NetworkTransferTimeCalculator.prototype.formatTime):
(WebInspector.NetworkTransferDurationCalculator.prototype.formatTime):

  • inspector/front-end/TimelineGrid.js:

(WebInspector.TimelineGrid.prototype.updateDividers):

  • inspector/front-end/TimelineOverviewPane.js:

(WebInspector.TimelineOverviewCalculator.prototype.formatTime):
(WebInspector.TimelineStartAtZeroOverview):
(WebInspector.TimelineStartAtZeroOverview.prototype.update):

  • inspector/front-end/TimelinePanel.js:

(WebInspector.TimelinePanel):
(WebInspector.TimelinePanel.prototype._toggleStartAtZeroButtonClicked):
(WebInspector.TimelinePanel.prototype._refresh):
(WebInspector.TimelinePanel.prototype._refreshRecords):
(WebInspector.TimelinePanel.prototype.get timelinePaddingLeft):
(WebInspector.TimelineCalculator):
(WebInspector.TimelineCalculator.prototype.setWindow):
(WebInspector.TimelineCalculator.prototype.setRecords):
(WebInspector.TimelineCalculator.prototype.formatTime):
(WebInspector.TimelineFitInWindowCalculator):
(WebInspector.TimelineFitInWindowCalculator.prototype.setWindow):
(WebInspector.TimelineFitInWindowCalculator.prototype.setRecords):

  • inspector/front-end/TimelinePresentationModel.js:

(WebInspector.TimelinePresentationModel.Record.prototype.generatePopupContent):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r109214 r109216  
     12012-02-29  Pavel Feldman  <pfeldman@google.com>
     2
     3        Web Inspector: remove calculator's updateBoundaries in the timeline panel.
     4        https://bugs.webkit.org/show_bug.cgi?id=79907
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        * inspector/front-end/NetworkPanel.js:
     9        (WebInspector.NetworkBaseCalculator.prototype.computeBarGraphLabels):
     10        (WebInspector.NetworkBaseCalculator.prototype.formatTime):
     11        (WebInspector.NetworkTimeCalculator.prototype.computeBarGraphLabels):
     12        (WebInspector.NetworkTimeCalculator.prototype.formatTime):
     13        (WebInspector.NetworkTransferTimeCalculator.prototype.formatTime):
     14        (WebInspector.NetworkTransferDurationCalculator.prototype.formatTime):
     15        * inspector/front-end/TimelineGrid.js:
     16        (WebInspector.TimelineGrid.prototype.updateDividers):
     17        * inspector/front-end/TimelineOverviewPane.js:
     18        (WebInspector.TimelineOverviewCalculator.prototype.formatTime):
     19        (WebInspector.TimelineStartAtZeroOverview):
     20        (WebInspector.TimelineStartAtZeroOverview.prototype.update):
     21        * inspector/front-end/TimelinePanel.js:
     22        (WebInspector.TimelinePanel):
     23        (WebInspector.TimelinePanel.prototype._toggleStartAtZeroButtonClicked):
     24        (WebInspector.TimelinePanel.prototype._refresh):
     25        (WebInspector.TimelinePanel.prototype._refreshRecords):
     26        (WebInspector.TimelinePanel.prototype.get timelinePaddingLeft):
     27        (WebInspector.TimelineCalculator):
     28        (WebInspector.TimelineCalculator.prototype.setWindow):
     29        (WebInspector.TimelineCalculator.prototype.setRecords):
     30        (WebInspector.TimelineCalculator.prototype.formatTime):
     31        (WebInspector.TimelineFitInWindowCalculator):
     32        (WebInspector.TimelineFitInWindowCalculator.prototype.setWindow):
     33        (WebInspector.TimelineFitInWindowCalculator.prototype.setRecords):
     34        * inspector/front-end/TimelinePresentationModel.js:
     35        (WebInspector.TimelinePresentationModel.Record.prototype.generatePopupContent):
     36
    1372012-02-29  Yury Semikhatsky  <yurys@chromium.org>
    238
  • trunk/Source/WebCore/inspector/front-end/NetworkPanel.js

    r105619 r109216  
    14521452    computeBarGraphLabels: function(item)
    14531453    {
    1454         const label = this.formatValue(this._value(item));
     1454        const label = this.formatTime(this._value(item));
    14551455        return {left: label, right: label, tooltip: label};
    14561456    },
     
    14841484    },
    14851485
    1486     formatValue: function(value)
     1486    formatTime: function(value)
    14871487    {
    14881488        return value.toString();
     
    15541554        var rightLabel = "";
    15551555        if (resource.responseReceivedTime !== -1 && resource.endTime !== -1)
    1556             rightLabel = this.formatValue(resource.endTime - resource.responseReceivedTime);
     1556            rightLabel = this.formatTime(resource.endTime - resource.responseReceivedTime);
    15571557
    15581558        var hasLatency = resource.latency > 0;
    15591559        if (hasLatency)
    1560             var leftLabel = this.formatValue(resource.latency);
     1560            var leftLabel = this.formatTime(resource.latency);
    15611561        else
    15621562            var leftLabel = rightLabel;
     
    15661566
    15671567        if (hasLatency && rightLabel) {
    1568             var total = this.formatValue(resource.duration);
     1568            var total = this.formatTime(resource.duration);
    15691569            var tooltip = WebInspector.UIString("%s latency, %s download (%s total)", leftLabel, rightLabel, total);
    15701570        } else if (hasLatency)
     
    16021602    },
    16031603
    1604     formatValue: function(value)
     1604    formatTime: function(value)
    16051605    {
    16061606        return Number.secondsToString(value);
     
    16301630
    16311631WebInspector.NetworkTransferTimeCalculator.prototype = {
    1632     formatValue: function(value)
     1632    formatTime: function(value)
    16331633    {
    16341634        return Number.secondsToString(value);
     
    16581658
    16591659WebInspector.NetworkTransferDurationCalculator.prototype = {
    1660     formatValue: function(value)
     1660    formatTime: function(value)
    16611661    {
    16621662        return Number.secondsToString(value);
  • trunk/Source/WebCore/inspector/front-end/TimelineGrid.js

    r109102 r109216  
    120120
    121121            if (!isNaN(slice))
    122                 dividerLabelBar._labelElement.textContent = calculator.formatValue(slice * i);
     122                dividerLabelBar._labelElement.textContent = calculator.formatTime(slice * i);
    123123            else
    124124                dividerLabelBar._labelElement.textContent = "";
  • trunk/Source/WebCore/inspector/front-end/TimelineOverviewPane.js

    r109114 r109216  
    544544    },
    545545
    546     formatValue: function(value)
     546    formatTime: function(value)
    547547    {
    548548        return Number.secondsToString(value);
     
    775775    this._overviewWindow.addEventListener(WebInspector.TimelineOverviewWindow.Events.WindowChanged, this._onWindowChanged, this);
    776776    this._recordsPerBar = 1;
    777     this._calculator = new WebInspector.TimelineStartAtZeroCalculator();
    778777}
    779778
     
    787786    update: function(records)
    788787    {
    789         this._calculator.reset();
    790788        records = this._filterRecords(records);
    791         records.forEach(this._calculator.updateBoundaries, this._calculator);
    792         this._calculator.calculateWindow();
    793 
    794         var scale = (this._overviewElement.clientHeight - 4) / this._calculator.boundarySpan;
     789        var boundarySpan = 0;
     790        for (var i = 0; i < records.length; ++i) {
     791            var record = records[i];
     792            var duration = record.endTime - record.startTime;
     793            if (boundarySpan < duration)
     794                boundarySpan = duration;
     795        }
     796     
     797        var scale = (this._overviewElement.clientHeight - 4) / boundarySpan;
    795798        this._recordsPerBar = Math.max(1, records.length * 4 / this.element.clientWidth);
    796799        var numberOfBars = Math.ceil(records.length / this._recordsPerBar);
  • trunk/Source/WebCore/inspector/front-end/TimelinePanel.js

    r109204 r109216  
    9595    this._itemsGraphsElement.appendChild(this._expandElements);
    9696
    97     this._calculator = new WebInspector.TimelineCalculator();
     97    this._calculator = new WebInspector.TimelineCalculator(this._presentationModel);
    9898    var shortRecordThresholdTitle = Number.secondsToString(WebInspector.TimelinePresentationModel.shortRecordThreshold);
    9999    this._showShortRecordsTitleText = WebInspector.UIString("Show the records that are shorter than %s", shortRecordThresholdTitle);
     
    426426        this._glueParentButton.disabled = toggled;
    427427        this.toggleStartAtZeroButton.toggled = toggled;
    428         this._calculator = toggled ? new WebInspector.TimelineStartAtZeroCalculator() : new WebInspector.TimelineCalculator();
     428        this._calculator = toggled ? new WebInspector.TimelineFitInWindowCalculator(this._presentationModel) : new WebInspector.TimelineCalculator(this._presentationModel);
    429429        this._presentationModel.setGlueRecords(this._glueParentButton.toggled && !this.toggleStartAtZeroButton.toggled);
    430430        this._repopulateRecords();
     
    557557        this._overviewPane.update(this._rootRecord().children, this._showShortEvents);
    558558
    559         if (!this._boundariesAreValid)
    560             this._updateBoundaries();
     559        if (!this._boundariesAreValid) {
     560            var min = this._presentationModel.minimumRecordTime();
     561            var max = this._presentationModel.maximumRecordTime();
     562            this._calculator.setWindow(min + (max - min) * this._overviewPane.windowLeft(), min + (max - min) * this._overviewPane.windowRight());
     563        }
     564
    561565        var recordsInWindowCount = this._refreshRecords(!this._boundariesAreValid);
    562566        this._updateRecordsCounter(recordsInWindowCount);
     
    566570            this._memoryStatistics.refresh();
    567571        this._boundariesAreValid = true;
    568     },
    569 
    570     _updateBoundaries: function()
    571     {
    572         this._calculator.reset();
    573         this._calculator.windowLeft = this._overviewPane.windowLeft();
    574         this._calculator.windowRight = this._overviewPane.windowRight();
    575 
    576         for (var i = 0; i < this._rootRecord().children.length; ++i)
    577             this._calculator.updateBoundaries(this._rootRecord().children[i]);
    578 
    579         this._calculator.calculateWindow();
    580572    },
    581573
     
    613605    {
    614606        var recordsInWindow = this._presentationModel.filteredRecords();
     607        this._calculator.setRecords(recordsInWindow);
    615608
    616609        // Calculate the visible area.
     
    694687    get timelinePaddingLeft()
    695688    {
    696         return this._calculator.windowLeft === 0 ? this._expandOffset : 0;
     689        return !this._overviewPane.windowLeft() ? this._expandOffset : 0;
    697690    },
    698691
     
    756749/**
    757750 * @constructor
     751 * @param {WebInspector.TimelinePresentationModel} presentationModel
    758752 */
    759 WebInspector.TimelineCalculator = function()
     753WebInspector.TimelineCalculator = function(presentationModel)
    760754{
    761     this.reset();
    762     this.windowLeft = 0.0;
    763     this.windowRight = 1.0;
     755    this._presentationModel = presentationModel;
    764756}
    765757
     
    790782    },
    791783
    792     calculateWindow: function()
    793     {
    794         this.minimumBoundary = this._absoluteMinimumBoundary + this.windowLeft * (this._absoluteMaximumBoundary - this._absoluteMinimumBoundary);
    795         this.maximumBoundary = this._absoluteMinimumBoundary + this.windowRight * (this._absoluteMaximumBoundary - this._absoluteMinimumBoundary);
     784    setWindow: function(minimumBoundary, maximumBoundary)
     785    {
     786        this.minimumBoundary = minimumBoundary;
     787        this.maximumBoundary = maximumBoundary;
    796788        this.boundarySpan = this.maximumBoundary - this.minimumBoundary;
    797789    },
    798790
    799     reset: function()
    800     {
    801         this._absoluteMinimumBoundary = -1;
    802         this._absoluteMaximumBoundary = -1;
    803     },
    804 
    805     updateBoundaries: function(record)
    806     {
    807         var lowerBound = record.startTime;
    808         if (this._absoluteMinimumBoundary === -1 || lowerBound < this._absoluteMinimumBoundary)
    809             this._absoluteMinimumBoundary = lowerBound;
    810 
    811         const minimumTimeFrame = 0.1;
    812         const minimumDeltaForZeroSizeEvents = 0.01;
    813         var upperBound = Math.max(record.lastChildEndTime + minimumDeltaForZeroSizeEvents, lowerBound + minimumTimeFrame);
    814         if (this._absoluteMaximumBoundary === -1 || upperBound > this._absoluteMaximumBoundary)
    815             this._absoluteMaximumBoundary = upperBound;
    816     },
    817 
    818     formatValue: function(value)
    819     {
    820         return Number.secondsToString(value + this.minimumBoundary - this._absoluteMinimumBoundary);
     791    setRecords: function(records)
     792    {
     793    },
     794
     795    formatTime: function(value)
     796    {
     797        return Number.secondsToString(value + this.minimumBoundary - this._presentationModel.minimumRecordTime());
    821798    }
    822799}
     
    824801/**
    825802 * @constructor
     803 * @param {WebInspector.TimelinePresentationModel} presentationModel
    826804 * @extends WebInspector.TimelineCalculator
    827805 */
    828 WebInspector.TimelineStartAtZeroCalculator = function()
     806WebInspector.TimelineFitInWindowCalculator = function(presentationModel)
    829807{
    830     this.reset();
    831     this.windowLeft = 0.0;
    832     this.windowRight = 1.0;
    833 }
    834 
    835 WebInspector.TimelineStartAtZeroCalculator.prototype = {
    836     computeBarGraphPercentages: function(record)
    837     {
    838         var scale = 100 / this.maximumBoundary;
    839         return {
    840             start: record._initiatorOffset * scale,
    841             end: (record._initiatorOffset + record.endTime - record.startTime) * scale,
    842             endWithChildren: (record._initiatorOffset + record.lastChildEndTime - record.startTime) * scale
    843         };
    844     },
    845 
    846     computeBarGraphWindowPosition: function(record, clientWidth)
    847     {
    848         const minWidth = 5;
    849         const borderWidth = 4;
    850         var workingArea = clientWidth - minWidth - borderWidth;
    851         var percentages = this.computeBarGraphPercentages(record);
    852         var left = percentages.start / 100 * workingArea;
    853         var width = (percentages.end - percentages.start) / 100 * workingArea + minWidth;
    854         var widthWithChildren =  (percentages.endWithChildren - percentages.start) / 100 * workingArea;
    855         if (percentages.endWithChildren > percentages.end)
    856             widthWithChildren += borderWidth + minWidth;
    857 
    858         return {left: left, width: width, widthWithChildren: widthWithChildren};
    859     },
    860 
    861     calculateWindow: function()
    862     {
    863         this.minimumBoundary = this._absoluteMinimumBoundary;
    864         this.maximumBoundary = this._absoluteMaximumBoundary * 1.05;
    865         this.boundarySpan = this.maximumBoundary >= 0 ? this.maximumBoundary : 0;
    866     },
    867 
    868     reset: function()
    869     {
    870         this._absoluteMinimumBoundary = -1;
    871         this._absoluteMaximumBoundary = -1;
    872     },
    873 
    874     updateBoundaries: function(record)
    875     {
    876         var lowerBound = record.startTime;
    877         if (this._absoluteMinimumBoundary === -1 || lowerBound < this._absoluteMinimumBoundary)
    878             this._absoluteMinimumBoundary = lowerBound;
    879 
    880         const minimumTimeFrame = 0.001;
    881         var upperBound = Math.max(record.endTime - record.startTime, minimumTimeFrame);
    882         if (this._absoluteMaximumBoundary === -1 || upperBound > this._absoluteMaximumBoundary)
    883             this._absoluteMaximumBoundary = upperBound;
    884     },
    885 
    886     formatValue: function(value)
    887     {
    888         return Number.secondsToString(value, true);
     808    WebInspector.TimelineCalculator.call(this, presentationModel);
     809}
     810
     811WebInspector.TimelineFitInWindowCalculator.prototype = {
     812    setWindow: function(minimumBoundary, maximumBoundary)
     813    {
     814    },
     815
     816    setRecords: function(records)
     817    {
     818        this.minimumBoundary = -1;
     819        this.maximumBoundary = -1;
     820
     821        var boundarySpan = 0;
     822        for (var i = 0; i < records.length; ++i) {
     823            var record = records[i];
     824            if (this.minimumBoundary == -1 || record.startTime < this.minimumBoundary)
     825                this.minimumBoundary = record.startTime;
     826            if (this.maximumBoundary == -1 || record.endTime > this.maximumBoundary)
     827                this.maximumBoundary = record.endTime;
     828        }
     829        this.boundarySpan = this.maximumBoundary - this.minimumBoundary;
    889830    }
    890 };
     831}
     832
     833WebInspector.TimelineFitInWindowCalculator.prototype.__proto__ = WebInspector.TimelineCalculator.prototype;
    891834
    892835/**
  • trunk/Source/WebCore/inspector/front-end/TimelinePresentationModel.js

    r109114 r109216  
    432432        }
    433433        var text = WebInspector.UIString("%s (at %s)", Number.secondsToString(this._lastChildEndTime - this.startTime, true),
    434             calculator.formatValue(this.startTime - calculator.minimumBoundary));
     434            Number.secondsToString(this.startTime - this._presentationModel.minimumRecordTime()));
    435435        contentHelper._appendTextRow(WebInspector.UIString("Duration"), text);
    436436
Note: See TracChangeset for help on using the changeset viewer.