Changeset 109216 in webkit
- Timestamp:
- Feb 29, 2012 7:59:30 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r109214 r109216 1 2012-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 1 37 2012-02-29 Yury Semikhatsky <yurys@chromium.org> 2 38 -
trunk/Source/WebCore/inspector/front-end/NetworkPanel.js
r105619 r109216 1452 1452 computeBarGraphLabels: function(item) 1453 1453 { 1454 const label = this.format Value(this._value(item));1454 const label = this.formatTime(this._value(item)); 1455 1455 return {left: label, right: label, tooltip: label}; 1456 1456 }, … … 1484 1484 }, 1485 1485 1486 format Value: function(value)1486 formatTime: function(value) 1487 1487 { 1488 1488 return value.toString(); … … 1554 1554 var rightLabel = ""; 1555 1555 if (resource.responseReceivedTime !== -1 && resource.endTime !== -1) 1556 rightLabel = this.format Value(resource.endTime - resource.responseReceivedTime);1556 rightLabel = this.formatTime(resource.endTime - resource.responseReceivedTime); 1557 1557 1558 1558 var hasLatency = resource.latency > 0; 1559 1559 if (hasLatency) 1560 var leftLabel = this.format Value(resource.latency);1560 var leftLabel = this.formatTime(resource.latency); 1561 1561 else 1562 1562 var leftLabel = rightLabel; … … 1566 1566 1567 1567 if (hasLatency && rightLabel) { 1568 var total = this.format Value(resource.duration);1568 var total = this.formatTime(resource.duration); 1569 1569 var tooltip = WebInspector.UIString("%s latency, %s download (%s total)", leftLabel, rightLabel, total); 1570 1570 } else if (hasLatency) … … 1602 1602 }, 1603 1603 1604 format Value: function(value)1604 formatTime: function(value) 1605 1605 { 1606 1606 return Number.secondsToString(value); … … 1630 1630 1631 1631 WebInspector.NetworkTransferTimeCalculator.prototype = { 1632 format Value: function(value)1632 formatTime: function(value) 1633 1633 { 1634 1634 return Number.secondsToString(value); … … 1658 1658 1659 1659 WebInspector.NetworkTransferDurationCalculator.prototype = { 1660 format Value: function(value)1660 formatTime: function(value) 1661 1661 { 1662 1662 return Number.secondsToString(value); -
trunk/Source/WebCore/inspector/front-end/TimelineGrid.js
r109102 r109216 120 120 121 121 if (!isNaN(slice)) 122 dividerLabelBar._labelElement.textContent = calculator.format Value(slice * i);122 dividerLabelBar._labelElement.textContent = calculator.formatTime(slice * i); 123 123 else 124 124 dividerLabelBar._labelElement.textContent = ""; -
trunk/Source/WebCore/inspector/front-end/TimelineOverviewPane.js
r109114 r109216 544 544 }, 545 545 546 format Value: function(value)546 formatTime: function(value) 547 547 { 548 548 return Number.secondsToString(value); … … 775 775 this._overviewWindow.addEventListener(WebInspector.TimelineOverviewWindow.Events.WindowChanged, this._onWindowChanged, this); 776 776 this._recordsPerBar = 1; 777 this._calculator = new WebInspector.TimelineStartAtZeroCalculator();778 777 } 779 778 … … 787 786 update: function(records) 788 787 { 789 this._calculator.reset();790 788 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; 795 798 this._recordsPerBar = Math.max(1, records.length * 4 / this.element.clientWidth); 796 799 var numberOfBars = Math.ceil(records.length / this._recordsPerBar); -
trunk/Source/WebCore/inspector/front-end/TimelinePanel.js
r109204 r109216 95 95 this._itemsGraphsElement.appendChild(this._expandElements); 96 96 97 this._calculator = new WebInspector.TimelineCalculator( );97 this._calculator = new WebInspector.TimelineCalculator(this._presentationModel); 98 98 var shortRecordThresholdTitle = Number.secondsToString(WebInspector.TimelinePresentationModel.shortRecordThreshold); 99 99 this._showShortRecordsTitleText = WebInspector.UIString("Show the records that are shorter than %s", shortRecordThresholdTitle); … … 426 426 this._glueParentButton.disabled = toggled; 427 427 this.toggleStartAtZeroButton.toggled = toggled; 428 this._calculator = toggled ? new WebInspector.Timeline StartAtZeroCalculator() : new WebInspector.TimelineCalculator();428 this._calculator = toggled ? new WebInspector.TimelineFitInWindowCalculator(this._presentationModel) : new WebInspector.TimelineCalculator(this._presentationModel); 429 429 this._presentationModel.setGlueRecords(this._glueParentButton.toggled && !this.toggleStartAtZeroButton.toggled); 430 430 this._repopulateRecords(); … … 557 557 this._overviewPane.update(this._rootRecord().children, this._showShortEvents); 558 558 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 561 565 var recordsInWindowCount = this._refreshRecords(!this._boundariesAreValid); 562 566 this._updateRecordsCounter(recordsInWindowCount); … … 566 570 this._memoryStatistics.refresh(); 567 571 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();580 572 }, 581 573 … … 613 605 { 614 606 var recordsInWindow = this._presentationModel.filteredRecords(); 607 this._calculator.setRecords(recordsInWindow); 615 608 616 609 // Calculate the visible area. … … 694 687 get timelinePaddingLeft() 695 688 { 696 return this._calculator.windowLeft === 0? this._expandOffset : 0;689 return !this._overviewPane.windowLeft() ? this._expandOffset : 0; 697 690 }, 698 691 … … 756 749 /** 757 750 * @constructor 751 * @param {WebInspector.TimelinePresentationModel} presentationModel 758 752 */ 759 WebInspector.TimelineCalculator = function( )753 WebInspector.TimelineCalculator = function(presentationModel) 760 754 { 761 this.reset(); 762 this.windowLeft = 0.0; 763 this.windowRight = 1.0; 755 this._presentationModel = presentationModel; 764 756 } 765 757 … … 790 782 }, 791 783 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; 796 788 this.boundarySpan = this.maximumBoundary - this.minimumBoundary; 797 789 }, 798 790 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()); 821 798 } 822 799 } … … 824 801 /** 825 802 * @constructor 803 * @param {WebInspector.TimelinePresentationModel} presentationModel 826 804 * @extends WebInspector.TimelineCalculator 827 805 */ 828 WebInspector.Timeline StartAtZeroCalculator = function()806 WebInspector.TimelineFitInWindowCalculator = function(presentationModel) 829 807 { 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 811 WebInspector.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; 889 830 } 890 }; 831 } 832 833 WebInspector.TimelineFitInWindowCalculator.prototype.__proto__ = WebInspector.TimelineCalculator.prototype; 891 834 892 835 /** -
trunk/Source/WebCore/inspector/front-end/TimelinePresentationModel.js
r109114 r109216 432 432 } 433 433 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())); 435 435 contentHelper._appendTextRow(WebInspector.UIString("Duration"), text); 436 436
Note: See TracChangeset
for help on using the changeset viewer.