Commit 17db68eb authored by yurys@chromium.org's avatar yurys@chromium.org

Initialize min/max record time to 0 instead of -1 or null

This simplifies many boundary time computations all around the code.

BUG=361045

Review URL: https://codereview.chromium.org/322783002

git-svn-id: svn://svn.chromium.org/blink/trunk@175801 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2cadc42f
......@@ -131,7 +131,7 @@ WebInspector.TimelineFlameChartDataProvider.prototype = {
this._records = [];
this._entryThreadDepths = {};
this._minimumBoundary = Math.max(0, this._model.minimumRecordTime());
this._minimumBoundary = this._model.minimumRecordTime();
var cpuThreadRecordPayload = { type: WebInspector.TimelineModel.RecordType.Program };
this._cpuThreadRecord = new WebInspector.TimelineModel.RecordImpl(this._model, /** @type {!TimelineAgent.TimelineEvent} */ (cpuThreadRecordPayload), null);
......@@ -549,8 +549,8 @@ WebInspector.TracingBasedTimelineFlameChartDataProvider.prototype = {
};
this._currentLevel = 0;
this._minimumBoundary = this._model.minimumRecordTime() || 0;
this._timeSpan = Math.max((this._model.maximumRecordTime() || 0) - this._minimumBoundary, 1000000);
this._minimumBoundary = this._model.minimumRecordTime();
this._timeSpan = Math.max(this._model.maximumRecordTime() - this._minimumBoundary, 1000);
this._appendHeaderRecord("CPU");
var events = this._model.mainThreadEvents();
var maxStackDepth = 0;
......
......@@ -251,8 +251,8 @@ WebInspector.TimelineModel.prototype = {
{
this._loadedFromFile = false;
this._records = [];
this._minimumRecordTime = -1;
this._maximumRecordTime = -1;
this._minimumRecordTime = 0;
this._maximumRecordTime = 0;
/** @type {!Array.<!WebInspector.TimelineModel.Record>} */
this._mainThreadTasks = [];
/** @type {!Array.<!WebInspector.TimelineModel.Record>} */
......@@ -286,9 +286,9 @@ WebInspector.TimelineModel.prototype = {
var startTime = record.startTime();
var endTime = record.endTime();
if (this._minimumRecordTime === -1 || startTime < this._minimumRecordTime)
if (!this._minimumRecordTime || startTime < this._minimumRecordTime)
this._minimumRecordTime = startTime;
if ((this._maximumRecordTime === -1 && endTime) || endTime > this._maximumRecordTime)
if (endTime > this._maximumRecordTime)
this._maximumRecordTime = endTime;
},
......
......@@ -409,7 +409,7 @@ WebInspector.TimelineOverviewBase.prototype = {
{
var absoluteMin = this._model.minimumRecordTime();
var timeSpan = this._model.maximumRecordTime() - absoluteMin;
var haveRecords = absoluteMin >= 0;
var haveRecords = absoluteMin > 0;
return {
left: haveRecords && startTime ? Math.min((startTime - absoluteMin) / timeSpan, 1) : 0,
right: haveRecords && endTime < Infinity ? (endTime - absoluteMin) / timeSpan : 1
......
......@@ -202,10 +202,7 @@ WebInspector.TimelinePanel.prototype = {
{
if (this._windowStartTime)
return this._windowStartTime;
var minimumRecordTime = this._model.minimumRecordTime();
if (minimumRecordTime && minimumRecordTime !== -1)
return minimumRecordTime;
return 0;
return this._model.minimumRecordTime();
},
/**
......@@ -215,10 +212,7 @@ WebInspector.TimelinePanel.prototype = {
{
if (this._windowEndTime < Infinity)
return this._windowEndTime;
var maximumRecordTime = this._model.maximumRecordTime();
if (maximumRecordTime && maximumRecordTime !== -1)
return maximumRecordTime;
return Infinity;
return this._model.maximumRecordTime() || Infinity;
},
/**
......
......@@ -316,7 +316,7 @@ WebInspector.TraceViewFlameChartDataProvider.prototype = {
this._currentLevel = 0;
this._headerTitles = {};
this._minimumBoundary = this._timelineModelForMinimumBoundary.minimumRecordTime();
this._timeSpan = Math.max((this._model.maximumRecordTime() || 0) - this._minimumBoundary, 1000);
this._timeSpan = Math.max(this._model.maximumRecordTime() - this._minimumBoundary, 1000);
var processes = this._model.sortedProcesses();
for (var processIndex = 0; processIndex < processes.length; ++processIndex) {
var process = processes[processIndex];
......
......@@ -248,8 +248,8 @@ WebInspector.TimelineView.prototype = {
_resetView: function()
{
this._windowStartTime = -1;
this._windowEndTime = -1;
this._windowStartTime = 0;
this._windowEndTime = 0;
this._boundariesAreValid = false;
this._adjustScrollPosition(0);
this._linkifier.reset();
......@@ -456,13 +456,9 @@ WebInspector.TimelineView.prototype = {
clearTimeout(this._refreshTimeout);
delete this._refreshTimeout;
}
var windowStartTime = this._windowStartTime;
var windowEndTime = this._windowEndTime;
var windowStartTime = this._windowStartTime || this._model.minimumRecordTime();
var windowEndTime = this._windowEndTime || this._model.maximumRecordTime();
this._timelinePaddingLeft = this._expandOffset;
if (windowStartTime === -1)
windowStartTime = this._model.minimumRecordTime();
if (windowEndTime === -1)
windowEndTime = this._model.maximumRecordTime();
this._calculator.setWindow(windowStartTime, windowEndTime);
this._calculator.setDisplayWindow(this._timelinePaddingLeft, this._graphRowsElementWidth);
......
......@@ -168,8 +168,8 @@ WebInspector.TracingModel.prototype = {
reset: function()
{
this._processById = {};
this._minimumRecordTime = null;
this._maximumRecordTime = null;
this._minimumRecordTime = 0;
this._maximumRecordTime = 0;
this._sessionId = null;
this._devtoolsMetadataEvents = [];
},
......@@ -222,7 +222,7 @@ WebInspector.TracingModel.prototype = {
},
/**
* @return {?number}
* @return {number}
*/
minimumRecordTime: function()
{
......@@ -230,7 +230,7 @@ WebInspector.TracingModel.prototype = {
},
/**
* @return {?number}
* @return {number}
*/
maximumRecordTime: function()
{
......
......@@ -169,7 +169,7 @@ WebInspector.TracingTimelineModel.prototype = {
},
/**
* @return {?number}
* @return {number}
*/
minimumRecordTime: function()
{
......@@ -177,7 +177,7 @@ WebInspector.TracingTimelineModel.prototype = {
},
/**
* @return {?number}
* @return {number}
*/
maximumRecordTime: function()
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment