| OLD | NEW |
| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 this._pendingRequestLayersCallbacks.push(callback); | 90 this._pendingRequestLayersCallbacks.push(callback); |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 this._pendingRequestLayersCallbacks = []; | 93 this._pendingRequestLayersCallbacks = []; |
| 94 this._pendingRequestLayersCallbacks.push(callback); | 94 this._pendingRequestLayersCallbacks.push(callback); |
| 95 function onGetLayers(error, layers) | 95 function onGetLayers(error, layers) |
| 96 { | 96 { |
| 97 this._root = null; | 97 this._root = null; |
| 98 if (error) { | 98 if (error) { |
| 99 console.error("LayerTreeAgent.getLayers(): " + error); | 99 console.error("LayerTreeAgent.getLayers(): " + error); |
| 100 return; | 100 layers = []; |
| 101 } | 101 } |
| 102 this._repopulate(layers); | 102 this._repopulate(layers); |
| 103 for (var i = 0; i < this._pendingRequestLayersCallbacks.length; ++i) | 103 for (var i = 0; i < this._pendingRequestLayersCallbacks.length; ++i) |
| 104 this._pendingRequestLayersCallbacks[i](); | 104 this._pendingRequestLayersCallbacks[i](); |
| 105 delete this._pendingRequestLayersCallbacks; | 105 delete this._pendingRequestLayersCallbacks; |
| 106 } | 106 } |
| 107 function onDocumentAvailable() | 107 function onDocumentAvailable() |
| 108 { | 108 { |
| 109 LayerTreeAgent.getLayers(undefined, onGetLayers.bind(this)) | 109 LayerTreeAgent.getLayers(undefined, onGetLayers.bind(this)) |
| 110 } | 110 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 * @constructor | 161 * @constructor |
| 162 * @param {LayerTreeAgent.Layer} layerPayload | 162 * @param {LayerTreeAgent.Layer} layerPayload |
| 163 */ | 163 */ |
| 164 WebInspector.Layer = function(layerPayload) | 164 WebInspector.Layer = function(layerPayload) |
| 165 { | 165 { |
| 166 this._reset(layerPayload); | 166 this._reset(layerPayload); |
| 167 } | 167 } |
| 168 | 168 |
| 169 WebInspector.Layer.prototype = { | 169 WebInspector.Layer.prototype = { |
| 170 /** | 170 /** |
| 171 * @return {string?} | 171 * @return {string} |
| 172 */ | 172 */ |
| 173 id: function() | 173 id: function() |
| 174 { | 174 { |
| 175 return this._layerPayload.layerId; | 175 return this._layerPayload.layerId; |
| 176 }, | 176 }, |
| 177 | 177 |
| 178 /** | 178 /** |
| 179 * @return {string?} | 179 * @return {string?} |
| 180 */ | 180 */ |
| 181 parentId: function() | 181 parentId: function() |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 anchorPoint: function() | 285 anchorPoint: function() |
| 286 { | 286 { |
| 287 return [ | 287 return [ |
| 288 this._layerPayload.anchorX || 0, | 288 this._layerPayload.anchorX || 0, |
| 289 this._layerPayload.anchorY || 0, | 289 this._layerPayload.anchorY || 0, |
| 290 this._layerPayload.anchorZ || 0, | 290 this._layerPayload.anchorZ || 0, |
| 291 ]; | 291 ]; |
| 292 }, | 292 }, |
| 293 | 293 |
| 294 /** | 294 /** |
| 295 * @return {number} |
| 296 */ |
| 297 paintCount: function() |
| 298 { |
| 299 return this._layerPayload.paintCount; |
| 300 }, |
| 301 |
| 302 /** |
| 303 * @param {function(Array.<string>?)} callback |
| 304 */ |
| 305 requestCompositingReasons: function(callback) |
| 306 { |
| 307 /** |
| 308 * @param {?string} error |
| 309 * @param {?Array.<string>} compositingReasons |
| 310 */ |
| 311 function callbackWrapper(error, compositingReasons) |
| 312 { |
| 313 if (error) { |
| 314 console.error("LayerTreeAgent.reasonsForCompositingLayer(): " +
error); |
| 315 callback(null); |
| 316 return; |
| 317 } |
| 318 callback(compositingReasons); |
| 319 } |
| 320 LayerTreeAgent.compositingReasons(this.id(), callbackWrapper.bind(this))
; |
| 321 }, |
| 322 |
| 323 /** |
| 295 * @param {LayerTreeAgent.Layer} layerPayload | 324 * @param {LayerTreeAgent.Layer} layerPayload |
| 296 */ | 325 */ |
| 297 _reset: function(layerPayload) | 326 _reset: function(layerPayload) |
| 298 { | 327 { |
| 299 this._children = []; | 328 this._children = []; |
| 300 this._parent = null; | 329 this._parent = null; |
| 301 this._layerPayload = layerPayload; | 330 this._layerPayload = layerPayload; |
| 302 } | 331 } |
| 303 } | 332 } |
| 304 | 333 |
| 305 /** | 334 /** |
| 306 * @constructor | 335 * @constructor |
| 307 * @implements {LayerTreeAgent.Dispatcher} | 336 * @implements {LayerTreeAgent.Dispatcher} |
| 308 * @param {WebInspector.LayerTreeModel} layerTreeModel | 337 * @param {WebInspector.LayerTreeModel} layerTreeModel |
| 309 */ | 338 */ |
| 310 WebInspector.LayerTreeDispatcher = function(layerTreeModel) | 339 WebInspector.LayerTreeDispatcher = function(layerTreeModel) |
| 311 { | 340 { |
| 312 this._layerTreeModel = layerTreeModel; | 341 this._layerTreeModel = layerTreeModel; |
| 313 } | 342 } |
| 314 | 343 |
| 315 WebInspector.LayerTreeDispatcher.prototype = { | 344 WebInspector.LayerTreeDispatcher.prototype = { |
| 316 layerTreeDidChange: function() | 345 layerTreeDidChange: function() |
| 317 { | 346 { |
| 318 this._layerTreeModel._layerTreeChanged(); | 347 this._layerTreeModel._layerTreeChanged(); |
| 319 } | 348 } |
| 320 } | 349 } |
| OLD | NEW |