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

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: Make devtools work without layer tree hierarchy 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._extractNodeIdsToResolve(idsToResolve, {}, root);
332 } else {
333 for (var i = 0; i < layers.length; ++i)
334 this._extractNodeIdsToResolve(idsToResolve, {}, layers[i]);
335 }
321 this._resolveBackendNodeIds(idsToResolve, onBackendNodeIdsResolved.bind( this)); 336 this._resolveBackendNodeIds(idsToResolve, onBackendNodeIdsResolved.bind( this));
322 337
323 /** 338 /**
324 * @this {WebInspector.TracingLayerTree} 339 * @this {WebInspector.TracingLayerTree}
325 */ 340 */
326 function onBackendNodeIdsResolved() 341 function onBackendNodeIdsResolved()
327 { 342 {
328 var oldLayersById = this._layersById; 343 var oldLayersById = this._layersById;
329 this._layersById = {}; 344 this._layersById = {};
330 this._contentRoot = null; 345 this._contentRoot = null;
331 this._root = this._innerSetLayers(oldLayersById, root); 346 if (root) {
347 this._root = this._innerSetLayers(oldLayersById, root);
348 } else {
349 this._layers = [];
350 for (var i = 0; i < layers.length; ++i)
351 this._layers.push(this._innerSetLayers(oldLayersById, layers[i ]));
352 if (layers.length > 0) {
353 this._root = this._contentRoot;
sunxd 2016/05/31 14:52:17 Before this line, the layer tree has no root, but
354 for (var i = 0; i < this._layers.length; ++i) {
355 if (this._layers[i].id() !== this._contentRoot.id()) {
356 this._contentRoot.addChild(this._layers[i]);
357 }
358 }
359 }
360 }
332 callback(); 361 callback();
333 } 362 }
334 }, 363 },
335 364
336 /** 365 /**
337 * @param {!Array.<!WebInspector.TracingLayerTile>} tiles 366 * @param {!Array.<!WebInspector.TracingLayerTile>} tiles
338 */ 367 */
339 setTiles: function(tiles) 368 setTiles: function(tiles)
340 { 369 {
341 this._tileById = new Map(); 370 this._tileById = new Map();
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 WebInspector.LayerTreeModel.fromTarget = function(target) 1302 WebInspector.LayerTreeModel.fromTarget = function(target)
1274 { 1303 {
1275 if (!target.isPage()) 1304 if (!target.isPage())
1276 return null; 1305 return null;
1277 1306
1278 var model = /** @type {?WebInspector.LayerTreeModel} */ (target.model(WebIns pector.LayerTreeModel)); 1307 var model = /** @type {?WebInspector.LayerTreeModel} */ (target.model(WebIns pector.LayerTreeModel));
1279 if (!model) 1308 if (!model)
1280 model = new WebInspector.LayerTreeModel(target); 1309 model = new WebInspector.LayerTreeModel(target);
1281 return model; 1310 return model;
1282 } 1311 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698