Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline_model/LayerTreeModel.js

Issue 1945813002: cc: Make LayerTreeImpl dump layer list to FrameViewer and Devtools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 /** @type Map<number, ?WebInspector.DOMNode> */ 187 /** @type Map<number, ?WebInspector.DOMNode> */
188 this._backendNodeIdToNode = new Map(); 188 this._backendNodeIdToNode = new Map();
189 this._reset(); 189 this._reset();
190 } 190 }
191 191
192 WebInspector.LayerTreeBase.prototype = { 192 WebInspector.LayerTreeBase.prototype = {
193 _reset: function() 193 _reset: function()
194 { 194 {
195 this._root = null; 195 this._root = null;
196 this._contentRoot = null; 196 this._contentRoot = null;
197 this._layers = null;
197 }, 198 },
198 199
199 /** 200 /**
200 * @return {?WebInspector.Target} 201 * @return {?WebInspector.Target}
201 */ 202 */
202 target: function() 203 target: function()
203 { 204 {
204 return this._target; 205 return this._target;
205 }, 206 },
206 207
207 /** 208 /**
208 * @return {?WebInspector.Layer} 209 * @return {?WebInspector.Layer}
209 */ 210 */
210 root: function() 211 root: function()
211 { 212 {
212 return this._root; 213 return this._root;
213 }, 214 },
214 215
215 /** 216 /**
216 * @return {?WebInspector.Layer} 217 * @return {?WebInspector.Layer}
217 */ 218 */
218 contentRoot: function() 219 contentRoot: function()
219 { 220 {
220 return this._contentRoot; 221 return this._contentRoot;
221 }, 222 },
222 223
223 /** 224 /**
225 * @return {!Array.<!WebInspector.Layer>}
226 */
227 layers: function()
228 {
229 return this._layers;
230 },
231
232 /**
224 * @param {function(!WebInspector.Layer)} callback 233 * @param {function(!WebInspector.Layer)} callback
225 * @param {?WebInspector.Layer=} root 234 * @param {?WebInspector.Layer=} root
226 * @return {boolean} 235 * @return {boolean}
227 */ 236 */
228 forEachLayer: function(callback, root) 237 forEachLayer: function(callback, root)
229 { 238 {
230 if (!root) { 239 if (!root) {
231 root = this.root(); 240 root = this.root();
232 if (!root) 241 if (!root)
233 return false; 242 return false;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 WebInspector.TracingLayerTree = function(target) 314 WebInspector.TracingLayerTree = function(target)
306 { 315 {
307 WebInspector.LayerTreeBase.call(this, target); 316 WebInspector.LayerTreeBase.call(this, target);
308 /** @type {!Map.<string, !WebInspector.TracingLayerTile>} */ 317 /** @type {!Map.<string, !WebInspector.TracingLayerTile>} */
309 this._tileById = new Map(); 318 this._tileById = new Map();
310 } 319 }
311 320
312 WebInspector.TracingLayerTree.prototype = { 321 WebInspector.TracingLayerTree.prototype = {
313 /** 322 /**
314 * @param {!WebInspector.TracingLayerPayload} root 323 * @param {!WebInspector.TracingLayerPayload} root
324 * @param {?Array.<!WebInspector.TracingLayerPayload>} layers
315 * @param {function()} callback 325 * @param {function()} callback
316 */ 326 */
317 setLayers: function(root, callback) 327 setLayers: function(root, layers, callback)
318 { 328 {
319 var idsToResolve = new Set(); 329 var idsToResolve = new Set();
320 this._extractNodeIdsToResolve(idsToResolve, {}, root); 330 if (root) {
331 // This is a legacy code path for compatibility, as cc is removing
332 // layer tree hierarchy, this code will eventually be removed.
333 this._extractNodeIdsToResolve(idsToResolve, {}, root);
334 } else {
335 for (var i = 0; i < layers.length; ++i)
336 this._extractNodeIdsToResolve(idsToResolve, {}, layers[i]);
337 }
321 this._resolveBackendNodeIds(idsToResolve, onBackendNodeIdsResolved.bind( this)); 338 this._resolveBackendNodeIds(idsToResolve, onBackendNodeIdsResolved.bind( this));
322 339
323 /** 340 /**
324 * @this {WebInspector.TracingLayerTree} 341 * @this {WebInspector.TracingLayerTree}
325 */ 342 */
326 function onBackendNodeIdsResolved() 343 function onBackendNodeIdsResolved()
327 { 344 {
328 var oldLayersById = this._layersById; 345 var oldLayersById = this._layersById;
329 this._layersById = {}; 346 this._layersById = {};
330 this._contentRoot = null; 347 this._contentRoot = null;
331 this._root = this._innerSetLayers(oldLayersById, root); 348 if (root) {
349 this._root = this._innerSetLayers(oldLayersById, root);
350 } else {
351 this._layers = layers.map(this._innerSetLayers.bind(this, oldLay ersById));
352 this._root = this._contentRoot;
353 for (var i = 0; i < this._layers.length; ++i) {
354 if (this._layers[i].id() !== this._contentRoot.id()) {
355 this._contentRoot.addChild(this._layers[i]);
356 }
357 }
358 }
332 callback(); 359 callback();
333 } 360 }
334 }, 361 },
335 362
336 /** 363 /**
337 * @param {!Array.<!WebInspector.TracingLayerTile>} tiles 364 * @param {!Array.<!WebInspector.TracingLayerTile>} tiles
338 */ 365 */
339 setTiles: function(tiles) 366 setTiles: function(tiles)
340 { 367 {
341 this._tileById = new Map(); 368 this._tileById = new Map();
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 WebInspector.LayerTreeModel.fromTarget = function(target) 1300 WebInspector.LayerTreeModel.fromTarget = function(target)
1274 { 1301 {
1275 if (!target.isPage()) 1302 if (!target.isPage())
1276 return null; 1303 return null;
1277 1304
1278 var model = /** @type {?WebInspector.LayerTreeModel} */ (target.model(WebIns pector.LayerTreeModel)); 1305 var model = /** @type {?WebInspector.LayerTreeModel} */ (target.model(WebIns pector.LayerTreeModel));
1279 if (!model) 1306 if (!model)
1280 model = new WebInspector.LayerTreeModel(target); 1307 model = new WebInspector.LayerTreeModel(target);
1281 return model; 1308 return model;
1282 } 1309 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698