Chromium Code Reviews| Index: Source/devtools/front_end/timeline/TimelineFrameModel.js |
| diff --git a/Source/devtools/front_end/timeline/TimelineFrameModel.js b/Source/devtools/front_end/timeline/TimelineFrameModel.js |
| index 9ac37798d88633eff25c273300f1ea679366c5aa..819a07c61fc9e74c438137125137ee24189295f2 100644 |
| --- a/Source/devtools/front_end/timeline/TimelineFrameModel.js |
| +++ b/Source/devtools/front_end/timeline/TimelineFrameModel.js |
| @@ -209,6 +209,7 @@ WebInspector.TimelineFrameModelBase.prototype = { |
| this._mainFrameCommitted = false; |
| this._mainFrameRequested = false; |
| this._framePendingCommit = null; |
| + this._lastBeginFrame = null; |
|
alph
2015/06/05 16:55:39
Don't you need to reset _lastNeedsBeginFrame as we
|
| }, |
| /** |
| @@ -218,6 +219,7 @@ WebInspector.TimelineFrameModelBase.prototype = { |
| { |
| if (!this._lastFrame) |
| this._startBackgroundFrame(startTime); |
| + this._lastBeginFrame = startTime; |
| }, |
| /** |
| @@ -232,8 +234,18 @@ WebInspector.TimelineFrameModelBase.prototype = { |
| // - if it wasn't drawn, it didn't happen! |
| // - only show frames that either did not wait for the main thread frame or had one committed. |
| - if (this._mainFrameCommitted || !this._mainFrameRequested) |
| + if (this._mainFrameCommitted || !this._mainFrameRequested) { |
| + if (this._lastNeedsBeginFrame) { |
| + this._lastFrame.idle = true; |
| + var idleTimeEnd = this._framePendingActivation ? this._framePendingActivation.triggerTime : (this._lastBeginFrame || this._lastNeedsBeginFrame); |
| + this._startBackgroundFrame(idleTimeEnd); |
| + if (this._framePendingActivation) |
| + this._commitPendingFrame(); |
| + this._lastNeedsBeginFrame = null; |
| + this._lastBeginFrame = null; |
| + } |
| this._startBackgroundFrame(startTime); |
| + } |
| this._mainFrameCommitted = false; |
| }, |
| @@ -241,12 +253,8 @@ WebInspector.TimelineFrameModelBase.prototype = { |
| { |
| if (!this._lastFrame) |
| return; |
| - if (this._framePendingActivation) { |
| - this._lastFrame._addTimeForCategories(this._framePendingActivation.timeByCategory); |
| - this._lastFrame.paints = this._framePendingActivation.paints; |
| - this._lastFrame._mainFrameId = this._framePendingActivation.mainFrameId; |
| - this._framePendingActivation = null; |
| - } |
| + if (this._framePendingActivation && !this._lastNeedsBeginFrame) |
| + this._commitPendingFrame(); |
| }, |
| handleRequestMainThreadFrame: function() |
| @@ -276,6 +284,16 @@ WebInspector.TimelineFrameModelBase.prototype = { |
| /** |
| * @param {number} startTime |
| + * @param {boolean} needsBeginFrame |
| + */ |
| + handleNeedFrameChanged: function(startTime, needsBeginFrame) |
| + { |
| + if (needsBeginFrame) |
| + this._lastNeedsBeginFrame = startTime; |
| + }, |
| + |
| + /** |
| + * @param {number} startTime |
| */ |
| _startBackgroundFrame: function(startTime) |
| { |
| @@ -314,6 +332,14 @@ WebInspector.TimelineFrameModelBase.prototype = { |
| this._frameById[frame._mainFrameId] = frame; |
| }, |
| + _commitPendingFrame: function() |
| + { |
| + this._lastFrame._addTimeForCategories(this._framePendingActivation.timeByCategory); |
| + this._lastFrame.paints = this._framePendingActivation.paints; |
| + this._lastFrame._mainFrameId = this._framePendingActivation.mainFrameId; |
| + this._framePendingActivation = null; |
| + }, |
| + |
| /** |
| * @param {!Array.<string>} types |
| * @param {!WebInspector.TimelineModel.Record} record |
| @@ -420,6 +446,8 @@ WebInspector.TracingTimelineFrameModel.prototype = { |
| this.handleActivateLayerTree(); |
| else if (event.name === eventNames.RequestMainThreadFrame) |
| this.handleRequestMainThreadFrame(); |
| + else if (event.name === eventNames.NeedsBeginFrameChanged) |
| + this.handleNeedFrameChanged(timestamp, event.args["data"] && event.args["data"]["needsBeginFrame"]); |
| }, |
| /** |
| @@ -444,10 +472,12 @@ WebInspector.TracingTimelineFrameModel.prototype = { |
| return; |
| } |
| - if (WebInspector.TracingModel.isTopLevelEvent(event)) |
| + if (WebInspector.TracingModel.isTopLevelEvent(event)) { |
| this._currentTaskTimeByCategory = {}; |
| + this._lastTaskBeginTime = event.startTime; |
| + } |
| if (!this._framePendingCommit && WebInspector.TracingTimelineFrameModel._mainFrameMarkers.indexOf(event.name) >= 0) |
| - this._framePendingCommit = new WebInspector.PendingFrame(this._currentTaskTimeByCategory); |
| + this._framePendingCommit = new WebInspector.PendingFrame(this._lastTaskBeginTime, this._currentTaskTimeByCategory); |
| if (!this._framePendingCommit) { |
| this._addTimeForCategory(this._currentTaskTimeByCategory, event); |
| return; |
| @@ -532,6 +562,7 @@ WebInspector.TimelineFrame = function(startTime, startTimeOffset) |
| this.duration = 0; |
| this.timeByCategory = {}; |
| this.cpuTime = 0; |
| + this.idle = false; |
| /** @type {?WebInspector.DeferredLayerTree} */ |
| this.layerTree = null; |
| /** @type {number|undefined} */ |
| @@ -648,9 +679,10 @@ WebInspector.LayerPaintEvent.prototype = { |
| /** |
| * @constructor |
| + * @param {number} triggerTime |
| * @param {!Object.<string, number>} timeByCategory |
| */ |
| -WebInspector.PendingFrame = function(timeByCategory) |
| +WebInspector.PendingFrame = function(triggerTime, timeByCategory) |
| { |
| /** @type {!Object.<string, number>} */ |
| this.timeByCategory = timeByCategory; |
| @@ -658,4 +690,5 @@ WebInspector.PendingFrame = function(timeByCategory) |
| this.paints = []; |
| /** @type {number|undefined} */ |
| this.mainFrameId = undefined; |
| + this.triggerTime = triggerTime; |
| } |