Commit 35ea7d4d authored by sergeyv@chromium.org's avatar sergeyv@chromium.org

DevTools: Remove redundant dependency on target from TimelineFrameModel

BUG=

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

git-svn-id: svn://svn.chromium.org/blink/trunk@178384 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent fd8c01e3
......@@ -54,7 +54,7 @@ function test()
if (!record.data["layerTree"])
return;
++pendingEventCount;
var layerTree = new WebInspector.AgentLayerTree(WebInspector.targetManager.activeTarget().weakReference());
var layerTree = new WebInspector.AgentLayerTree(WebInspector.targetManager.activeTarget());
layerTree.setLayers(record.data["layerTree"], onLayersSet.bind(null, layerTree));
}
......
......@@ -49,7 +49,7 @@ WebInspector.TracingLayerPayload;
WebInspector.LayerTreeModel = function(target)
{
WebInspector.SDKObject.call(this, target);
InspectorBackend.registerLayerTreeDispatcher(new WebInspector.LayerTreeDispatcher(this));
target.registerLayerTreeDispatcher(new WebInspector.LayerTreeDispatcher(this));
target.domModel.addEventListener(WebInspector.DOMModel.Events.DocumentUpdated, this._onDocumentUpdated, this);
/** @type {?WebInspector.LayerTreeBase} */
this._layerTree = null;
......@@ -74,7 +74,7 @@ WebInspector.LayerTreeModel.prototype = {
return;
this._enabled = false;
this._layerTree = null;
LayerTreeAgent.disable();
this.target().layerTreeAgent().disable();
},
enable: function()
......@@ -82,9 +82,9 @@ WebInspector.LayerTreeModel.prototype = {
if (this._enabled)
return;
this._enabled = true;
this._layerTree = new WebInspector.AgentLayerTree(this.target().weakReference());
this._layerTree = new WebInspector.AgentLayerTree(this.target());
this._lastPaintRectByLayerId = {};
LayerTreeAgent.enable();
this.target().layerTreeAgent().enable();
},
/**
......@@ -163,11 +163,11 @@ WebInspector.LayerTreeModel.prototype = {
/**
* @constructor
* @param {!WeakReference.<!WebInspector.Target>} weakTarget
* @param {?WebInspector.Target} target
*/
WebInspector.LayerTreeBase = function(weakTarget)
WebInspector.LayerTreeBase = function(target)
{
this._weakTarget = weakTarget;
this._target = target;
this._layersById = {};
this._backendNodeIdToNodeId = {};
this._reset();
......@@ -226,13 +226,12 @@ WebInspector.LayerTreeBase.prototype = {
*/
_resolveBackendNodeIds: function(requestedNodeIds, callback)
{
var target = this._weakTarget.get();
if (!requestedNodeIds.length || !target) {
if (!requestedNodeIds.length || !this._target) {
callback();
return;
}
target.domModel.pushNodesByBackendIdsToFrontend(requestedNodeIds, populateBackendNodeIdMap.bind(this));
this._target.domModel.pushNodesByBackendIdsToFrontend(requestedNodeIds, populateBackendNodeIdMap.bind(this));
/**
* @this {WebInspector.LayerTreeBase}
......@@ -273,19 +272,18 @@ WebInspector.LayerTreeBase.prototype = {
*/
_nodeForId: function(id)
{
var target = this._weakTarget.get();
return target ? target.domModel.nodeForId(id) : null;
return this._target ? this._target.domModel.nodeForId(id) : null;
}
};
/**
* @constructor
* @extends {WebInspector.LayerTreeBase}
* @param {!WeakReference.<!WebInspector.Target>} weakTarget
* @param {?WebInspector.Target} target
*/
WebInspector.TracingLayerTree = function(weakTarget)
WebInspector.TracingLayerTree = function(target)
{
WebInspector.LayerTreeBase.call(this, weakTarget);
WebInspector.LayerTreeBase.call(this, target);
}
WebInspector.TracingLayerTree.prototype = {
......@@ -357,12 +355,12 @@ WebInspector.TracingLayerTree.prototype = {
/**
* @constructor
* @param {!WeakReference.<!WebInspector.Target>} weakTarget
* @param {?WebInspector.Target} target
* @extends {WebInspector.LayerTreeBase}
*/
WebInspector.AgentLayerTree = function(weakTarget)
WebInspector.AgentLayerTree = function(target)
{
WebInspector.LayerTreeBase.call(this, weakTarget);
WebInspector.LayerTreeBase.call(this, target);
}
WebInspector.AgentLayerTree.prototype = {
......@@ -417,7 +415,7 @@ WebInspector.AgentLayerTree.prototype = {
if (layer)
layer._reset(layers[i]);
else
layer = new WebInspector.AgentLayer(this._weakTarget, layers[i]);
layer = new WebInspector.AgentLayer(this._target, layers[i]);
this._layersById[layerId] = layer;
if (layers[i].backendNodeId) {
layer._setNode(this._nodeForId(this._backendNodeIdToNodeId[layers[i].backendNodeId]));
......@@ -560,12 +558,12 @@ WebInspector.Layer.prototype = {
/**
* @constructor
* @implements {WebInspector.Layer}
* @param {!WeakReference.<!WebInspector.Target>} weakTarget
* @param {?WebInspector.Target} target
* @param {!LayerTreeAgent.Layer} layerPayload
*/
WebInspector.AgentLayer = function(weakTarget, layerPayload)
WebInspector.AgentLayer = function(target, layerPayload)
{
this._weakTarget = weakTarget;
this._target = target;
this._reset(layerPayload);
}
......@@ -746,8 +744,13 @@ WebInspector.AgentLayer.prototype = {
*/
requestCompositingReasons: function(callback)
{
if (!this._target) {
callback([]);
return;
}
var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTreeAgent.reasonsForCompositingLayer(): ", undefined, []);
LayerTreeAgent.compositingReasons(this.id(), wrappedCallback);
this._target.layerTreeAgent().compositingReasons(this.id(), wrappedCallback);
},
/**
......@@ -755,8 +758,13 @@ WebInspector.AgentLayer.prototype = {
*/
requestSnapshot: function(callback)
{
var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTreeAgent.makeSnapshot(): ", WebInspector.PaintProfilerSnapshot.bind(null, this._weakTarget));
LayerTreeAgent.makeSnapshot(this.id(), wrappedCallback);
if (!this._target) {
callback();
return;
}
var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTreeAgent.makeSnapshot(): ", WebInspector.PaintProfilerSnapshot.bind(null, this._target));
this._target.layerTreeAgent().makeSnapshot(this.id(), wrappedCallback);
},
/**
......@@ -1093,11 +1101,11 @@ WebInspector.TracingLayer.prototype = {
/**
* @constructor
* @param {!WeakReference.<!WebInspector.Target>} weakTarget
* @param {?WebInspector.Target} target
*/
WebInspector.DeferredLayerTree = function(weakTarget)
WebInspector.DeferredLayerTree = function(target)
{
this._weakTarget = weakTarget;
this._target = target;
}
WebInspector.DeferredLayerTree.prototype = {
......@@ -1107,23 +1115,23 @@ WebInspector.DeferredLayerTree.prototype = {
resolve: function(callback) { },
/**
* @return {!WeakReference.<!WebInspector.Target>}
* @return {?WebInspector.Target}
*/
weakTarget: function()
target: function()
{
return this._weakTarget;
return this._target;
}
};
/**
* @constructor
* @extends {WebInspector.DeferredLayerTree}
* @param {!WeakReference.<!WebInspector.Target>} weakTarget
* @param {?WebInspector.Target} target
* @param {!Array.<!LayerTreeAgent.Layer>} layers
*/
WebInspector.DeferredAgentLayerTree = function(weakTarget, layers)
WebInspector.DeferredAgentLayerTree = function(target, layers)
{
WebInspector.DeferredLayerTree.call(this, weakTarget);
WebInspector.DeferredLayerTree.call(this, target);
this._layers = layers;
}
......@@ -1133,7 +1141,7 @@ WebInspector.DeferredAgentLayerTree.prototype = {
*/
resolve: function(callback)
{
var result = new WebInspector.AgentLayerTree(this._weakTarget);
var result = new WebInspector.AgentLayerTree(this._target);
result.setLayers(this._layers, callback.bind(null, result));
},
......@@ -1143,13 +1151,13 @@ WebInspector.DeferredAgentLayerTree.prototype = {
/**
* @constructor
* @extends {WebInspector.DeferredLayerTree}
* @param {!WeakReference.<!WebInspector.Target>} weakTarget
* @param {?WebInspector.Target} target
* @param {!WebInspector.TracingLayerPayload} root
* @param {!Object} viewportSize
*/
WebInspector.DeferredTracingLayerTree = function(weakTarget, root, viewportSize)
WebInspector.DeferredTracingLayerTree = function(target, root, viewportSize)
{
WebInspector.DeferredLayerTree.call(this, weakTarget);
WebInspector.DeferredLayerTree.call(this, target);
this._root = root;
this._viewportSize = viewportSize;
}
......@@ -1160,7 +1168,7 @@ WebInspector.DeferredTracingLayerTree.prototype = {
*/
resolve: function(callback)
{
var result = new WebInspector.TracingLayerTree(this._weakTarget);
var result = new WebInspector.TracingLayerTree(this._target);
result.setViewportSize(this._viewportSize);
result.setLayers(this._root, callback.bind(null, result));
},
......
......@@ -30,12 +30,12 @@
/**
* @constructor
* @param {!WeakReference.<!WebInspector.Target>} weakTarget
* @param {!WebInspector.Target} target
* @param {string} snapshotId
*/
WebInspector.PaintProfilerSnapshot = function(weakTarget, snapshotId)
WebInspector.PaintProfilerSnapshot = function(target, snapshotId)
{
this._weakTarget = weakTarget;
this._target = target;
this._id = snapshotId;
}
......@@ -46,7 +46,7 @@ WebInspector.PaintProfilerSnapshot = function(weakTarget, snapshotId)
*/
WebInspector.PaintProfilerSnapshot.load = function(target, encodedPicture, callback)
{
var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTreeAgent.loadSnapshot(): ", WebInspector.PaintProfilerSnapshot.bind(null, target.weakReference()));
var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTreeAgent.loadSnapshot(): ", WebInspector.PaintProfilerSnapshot.bind(null, target));
target.layerTreeAgent().loadSnapshot(encodedPicture, wrappedCallback);
}
......@@ -100,17 +100,15 @@ WebInspector.PaintProfilerSnapshot._processAnnotations = function(log)
WebInspector.PaintProfilerSnapshot.prototype = {
dispose: function()
{
var target = this._weakTarget.get();
if (target)
target.layerTreeAgent().releaseSnapshot(this._id);
this._target.layerTreeAgent().releaseSnapshot(this._id);
},
/**
* @return {?WebInspector.Target}
* @return {!WebInspector.Target}
*/
target: function()
{
return this._weakTarget.get();
return this._target;
},
/**
......@@ -121,13 +119,8 @@ WebInspector.PaintProfilerSnapshot.prototype = {
*/
requestImage: function(firstStep, lastStep, scale, callback)
{
var target = this._weakTarget.get();
if (!target) {
callback();
return;
}
var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTreeAgent.replaySnapshot(): ");
target.layerTreeAgent().replaySnapshot(this._id, firstStep || undefined, lastStep || undefined, scale || 1.0, wrappedCallback);
this._target.layerTreeAgent().replaySnapshot(this._id, firstStep || undefined, lastStep || undefined, scale || 1.0, wrappedCallback);
},
/**
......@@ -135,13 +128,8 @@ WebInspector.PaintProfilerSnapshot.prototype = {
*/
profile: function(callback)
{
var target = this._weakTarget.get();
if (!target) {
callback();
return;
}
var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "LayerTreeAgent.profileSnapshot(): ");
target.layerTreeAgent().profileSnapshot(this._id, 5, 1, wrappedCallback);
this._target.layerTreeAgent().profileSnapshot(this._id, 5, 1, wrappedCallback);
},
/**
......@@ -149,11 +137,6 @@ WebInspector.PaintProfilerSnapshot.prototype = {
*/
commandLog: function(callback)
{
var target = this._weakTarget.get();
if (!target) {
callback();
return;
}
/**
* @param {?string} error
* @param {!Array.<!WebInspector.RawPaintProfilerLogItem>} log
......@@ -168,7 +151,7 @@ WebInspector.PaintProfilerSnapshot.prototype = {
callback(WebInspector.PaintProfilerSnapshot._processAnnotations(log));
}
target.layerTreeAgent().snapshotCommandLog(this._id, callbackWrapper);
this._target.layerTreeAgent().snapshotCommandLog(this._id, callbackWrapper);
}
};
......
......@@ -30,13 +30,9 @@
/**
* @constructor
* @extends {WebInspector.SDKObject}
* @param {!WebInspector.Target} target
*/
WebInspector.TimelineFrameModelBase = function(target)
WebInspector.TimelineFrameModelBase = function()
{
WebInspector.SDKObject.call(this, target);
this.reset();
}
......@@ -207,19 +203,16 @@ WebInspector.TimelineFrameModelBase.prototype = {
return result;
}
return null;
},
__proto__: WebInspector.SDKObject.prototype
}
}
/**
* @constructor
* @param {!WebInspector.Target} target
* @extends {WebInspector.TimelineFrameModelBase}
*/
WebInspector.TimelineFrameModel = function(target)
WebInspector.TimelineFrameModel = function()
{
WebInspector.TimelineFrameModelBase.call(this, target);
WebInspector.TimelineFrameModelBase.call(this);
}
WebInspector.TimelineFrameModel._mainFrameMarkers = [
......@@ -312,7 +305,7 @@ WebInspector.TimelineFrameModel.prototype = {
{
var recordTypes = WebInspector.TimelineModel.RecordType;
if (record.type() === recordTypes.UpdateLayerTree && record.data()["layerTree"])
this.handleLayerTreeSnapshot(new WebInspector.DeferredAgentLayerTree(this.target().weakReference(), record.data()["layerTree"]));
this.handleLayerTreeSnapshot(new WebInspector.DeferredAgentLayerTree(record.target(), record.data()["layerTree"]));
if (!this._hasThreadedCompositing) {
if (record.type() === recordTypes.BeginFrame)
this._startMainThreadFrame(record.startTime());
......@@ -356,12 +349,11 @@ WebInspector.TimelineFrameModel.prototype = {
/**
* @constructor
* @param {!WebInspector.Target} target
* @extends {WebInspector.TimelineFrameModelBase}
*/
WebInspector.TracingTimelineFrameModel = function(target)
WebInspector.TracingTimelineFrameModel = function()
{
WebInspector.TimelineFrameModelBase.call(this, target);
WebInspector.TimelineFrameModelBase.call(this);
}
WebInspector.TracingTimelineFrameModel._mainFrameMarkers = [
......@@ -415,9 +407,8 @@ WebInspector.TracingTimelineFrameModel.prototype = {
_addBackgroundTraceEvent: function(event)
{
var eventNames = WebInspector.TracingTimelineModel.RecordType;
if (event.phase === WebInspector.TracingModel.Phase.SnapshotObject && event.name === eventNames.LayerTreeHostImplSnapshot && parseInt(event.id, 0) === this._layerTreeId) {
this.handleLayerTreeSnapshot(new WebInspector.DeferredTracingLayerTree(this.target().weakReference(), event.args["snapshot"]["active_tree"]["root_layer"], event.args["snapshot"]["device_viewport_size"]));
this.handleLayerTreeSnapshot(new WebInspector.DeferredTracingLayerTree(event.thread.target(), event.args["snapshot"]["active_tree"]["root_layer"], event.args["snapshot"]["device_viewport_size"]));
return;
}
if (this._lastFrame && event.selfTime)
......
......@@ -47,14 +47,13 @@ WebInspector.TimelineLayersView.prototype = {
{
var layerTree;
this._weakTarget = this._deferredLayerTree.weakTarget();
this._target = this._deferredLayerTree.target();
var originalTiles = this._paintTiles;
var tilesReadyBarrier = new CallbackBarrier();
this._deferredLayerTree.resolve(tilesReadyBarrier.createCallback(onLayersReady));
var target = this._weakTarget.get();
if (target) {
if (this._target) {
for (var i = 0; this._paints && i < this._paints.length; ++i)
WebInspector.PaintProfilerSnapshot.load(target, this._paints[i].picture, tilesReadyBarrier.createCallback(onSnapshotLoaded.bind(this, this._paints[i])));
WebInspector.PaintProfilerSnapshot.load(this._target, this._paints[i].picture, tilesReadyBarrier.createCallback(onSnapshotLoaded.bind(this, this._paints[i])));
}
tilesReadyBarrier.callWhenDone(onLayersAndTilesReady.bind(this));
......@@ -128,9 +127,8 @@ WebInspector.TimelineLayersView.prototype = {
node.highlightForTwoSeconds();
return;
}
var target = this._weakTarget.get();
if (target)
target.domModel.hideDOMNodeHighlight();
if (this._target)
this._target.domModel.hideDOMNodeHighlight();
},
......
......@@ -261,11 +261,11 @@ WebInspector.TimelinePanel.prototype = {
if (this._lazyFrameModel)
return this._lazyFrameModel;
if (this._tracingModel) {
var tracingFrameModel = new WebInspector.TracingTimelineFrameModel(this._model.target());
var tracingFrameModel = new WebInspector.TracingTimelineFrameModel();
tracingFrameModel.addTraceEvents(this._tracingTimelineModel.inspectedTargetEvents(), this._tracingModel.sessionId() || "");
this._lazyFrameModel = tracingFrameModel;
} else {
var frameModel = new WebInspector.TimelineFrameModel(this._model.target());
var frameModel = new WebInspector.TimelineFrameModel();
frameModel.setMergeRecords(!WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled() || !this._recordingInProgress);
frameModel.addRecords(this._model.records());
this._lazyFrameModel = frameModel;
......
......@@ -117,12 +117,10 @@ WebInspector.TimelineTracingView.prototype = {
contentHelper.appendTextRow(WebInspector.UIString("Duration"), Number.millisToString(record.duration, true));
if (!Object.isEmpty(record.args))
contentHelper.appendElementRow(WebInspector.UIString("Arguments"), this._formatArguments(record.args));
/**
* @this {WebInspector.TimelineTracingView}
*/
function reveal()
{
WebInspector.Revealer.reveal(new WebInspector.DeferredTracingLayerTree(this._tracingModel.target().weakReference(), record.args["snapshot"]["active_tree"]["root_layer"], record.args["snapshot"]["device_viewport_size"]));
WebInspector.Revealer.reveal(new WebInspector.DeferredTracingLayerTree(record.thread.target(), record.args["snapshot"]["active_tree"]["root_layer"], record.args["snapshot"]["device_viewport_size"]));
}
/**
* @param {!Node=} node
......@@ -143,7 +141,7 @@ WebInspector.TimelineTracingView.prototype = {
var link = document.createElement("span");
link.classList.add("revealable-link");
link.textContent = "show";
link.addEventListener("click", reveal.bind(this), false);
link.addEventListener("click", reveal, false);
contentHelper.appendElementRow(WebInspector.UIString("Layer tree"), link);
// Fall-through intended.
default:
......
......@@ -467,6 +467,16 @@ WebInspector.TracingModel.Thread = function(process, id)
}
WebInspector.TracingModel.Thread.prototype = {
/**
* @return {?WebInspector.Target}
*/
target: function()
{
//FIXME: correctly specify target
return WebInspector.targetManager.targets()[0];
},
/**
* @param {!WebInspector.TracingModel.EventPayload} payload
* @return {?WebInspector.TracingModel.Event} event
......
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