| 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 /** | 90 /** |
| 91 * @return {?WebInspector.Layer} | 91 * @return {?WebInspector.Layer} |
| 92 */ | 92 */ |
| 93 contentRoot: function() | 93 contentRoot: function() |
| 94 { | 94 { |
| 95 return this._contentRoot; | 95 return this._contentRoot; |
| 96 }, | 96 }, |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * @param {function(!WebInspector.Layer)} callback | 99 * @param {function(!WebInspector.Layer)} callback |
| 100 * @param {?WebInspector.Layer} root | 100 * @param {?WebInspector.Layer=} root |
| 101 * @return {boolean} | 101 * @return {boolean} |
| 102 */ | 102 */ |
| 103 forEachLayer: function(callback, root) | 103 forEachLayer: function(callback, root) |
| 104 { | 104 { |
| 105 if (!root) { | 105 if (!root) { |
| 106 root = this.root(); | 106 root = this.root(); |
| 107 if (!root) | 107 if (!root) |
| 108 return false; | 108 return false; |
| 109 } | 109 } |
| 110 return callback(root) || root.children().some(this.forEachLayer.bind(thi
s, callback)); | 110 return callback(root) || root.children().some(this.forEachLayer.bind(thi
s, callback)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 126 { | 126 { |
| 127 if (payload) | 127 if (payload) |
| 128 this._resolveBackendNodeIdsForLayers(payload, onBackendNodeIdsResolv
ed.bind(this)); | 128 this._resolveBackendNodeIdsForLayers(payload, onBackendNodeIdsResolv
ed.bind(this)); |
| 129 else | 129 else |
| 130 onBackendNodeIdsResolved.call(this); | 130 onBackendNodeIdsResolved.call(this); |
| 131 /** | 131 /** |
| 132 * @this {WebInspector.LayerTreeModel} | 132 * @this {WebInspector.LayerTreeModel} |
| 133 */ | 133 */ |
| 134 function onBackendNodeIdsResolved() | 134 function onBackendNodeIdsResolved() |
| 135 { | 135 { |
| 136 this._repopulate(payload); | 136 this._repopulate(payload || []); |
| 137 this.dispatchEventToListeners(WebInspector.LayerTreeModel.Events.Lay
erTreeChanged); | 137 this.dispatchEventToListeners(WebInspector.LayerTreeModel.Events.Lay
erTreeChanged); |
| 138 } | 138 } |
| 139 }, | 139 }, |
| 140 | 140 |
| 141 /** | 141 /** |
| 142 * @param {!Array.<!LayerTreeAgent.Layer>=} payload | 142 * @param {!Array.<!LayerTreeAgent.Layer>} layers |
| 143 */ | 143 */ |
| 144 _repopulate: function(payload) | 144 _repopulate: function(layers) |
| 145 { | 145 { |
| 146 this._root = null; | 146 this._root = null; |
| 147 this._contentRoot = null; | 147 this._contentRoot = null; |
| 148 // Payload will be null when not in the composited mode. | 148 // Payload will be null when not in the composited mode. |
| 149 if (!payload) | 149 if (!layers) |
| 150 return; | 150 return; |
| 151 var oldLayersById = this._layersById; | 151 var oldLayersById = this._layersById; |
| 152 this._layersById = {}; | 152 this._layersById = {}; |
| 153 for (var i = 0; i < payload.length; ++i) { | 153 for (var i = 0; i < layers.length; ++i) { |
| 154 var layerId = payload[i].layerId; | 154 var layerId = layers[i].layerId; |
| 155 var layer = oldLayersById[layerId]; | 155 var layer = oldLayersById[layerId]; |
| 156 if (layer) | 156 if (layer) |
| 157 layer._reset(payload[i]); | 157 layer._reset(layers[i]); |
| 158 else | 158 else |
| 159 layer = new WebInspector.Layer(payload[i]); | 159 layer = new WebInspector.Layer(layers[i]); |
| 160 this._layersById[layerId] = layer; | 160 this._layersById[layerId] = layer; |
| 161 if (payload[i].backendNodeId) { | 161 if (layers[i].backendNodeId) { |
| 162 layer._setNodeId(this._backendNodeIdToNodeId[payload[i].backendN
odeId]); | 162 layer._setNodeId(this._backendNodeIdToNodeId[layers[i].backendNo
deId]); |
| 163 if (!this._contentRoot) | 163 if (!this._contentRoot) |
| 164 this._contentRoot = layer; | 164 this._contentRoot = layer; |
| 165 } | 165 } |
| 166 var lastPaintRect = this._lastPaintRectByLayerId[layerId]; | 166 var lastPaintRect = this._lastPaintRectByLayerId[layerId]; |
| 167 if (lastPaintRect) | 167 if (lastPaintRect) |
| 168 layer._lastPaintRect = lastPaintRect; | 168 layer._lastPaintRect = lastPaintRect; |
| 169 var parentId = layer.parentId(); | 169 var parentId = layer.parentId(); |
| 170 if (parentId) { | 170 if (parentId) { |
| 171 var parent = this._layersById[parentId]; | 171 var parent = this._layersById[parentId]; |
| 172 if (!parent) | 172 if (!parent) |
| 173 console.assert(parent, "missing parent " + parentId + " for
layer " + layerId); | 173 console.assert(parent, "missing parent " + parentId + " for
layer " + layerId); |
| 174 parent.addChild(layer); | 174 parent.addChild(layer); |
| 175 } else { | 175 } else { |
| 176 if (this._root) | 176 if (this._root) |
| 177 console.assert(false, "Multiple root layers"); | 177 console.assert(false, "Multiple root layers"); |
| 178 this._root = layer; | 178 this._root = layer; |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 this._lastPaintRectByLayerId = {}; | 181 this._lastPaintRectByLayerId = {}; |
| 182 }, | 182 }, |
| 183 | 183 |
| 184 /** | 184 /** |
| 185 * @param {!Array.<!LayerTreeAgent.Layer>=} payload | 185 * @param {!Array.<!LayerTreeAgent.Layer>=} layers |
| 186 */ | 186 */ |
| 187 _layerTreeChanged: function(payload) | 187 _layerTreeChanged: function(layers) |
| 188 { | 188 { |
| 189 if (!this._enabled) | 189 if (!this._enabled) |
| 190 return; | 190 return; |
| 191 this._resolveNodesAndRepopulate(payload); | 191 this._resolveNodesAndRepopulate(layers); |
| 192 }, | 192 }, |
| 193 | 193 |
| 194 /** | 194 /** |
| 195 * @param {!Array.<!LayerTreeAgent.Layer>} layers | 195 * @param {!Array.<!LayerTreeAgent.Layer>} layers |
| 196 * @param {function()} callback | 196 * @param {function()} callback |
| 197 */ | 197 */ |
| 198 _resolveBackendNodeIdsForLayers: function(layers, callback) | 198 _resolveBackendNodeIdsForLayers: function(layers, callback) |
| 199 { | 199 { |
| 200 var idsToResolve = {}; | 200 var idsToResolve = {}; |
| 201 var requestedIds = []; | 201 var requestedIds = []; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 254 |
| 255 __proto__: WebInspector.Object.prototype | 255 __proto__: WebInspector.Object.prototype |
| 256 } | 256 } |
| 257 | 257 |
| 258 /** | 258 /** |
| 259 * @constructor | 259 * @constructor |
| 260 * @param {!LayerTreeAgent.Layer} layerPayload | 260 * @param {!LayerTreeAgent.Layer} layerPayload |
| 261 */ | 261 */ |
| 262 WebInspector.Layer = function(layerPayload) | 262 WebInspector.Layer = function(layerPayload) |
| 263 { | 263 { |
| 264 this._scrollRects = []; |
| 264 this._reset(layerPayload); | 265 this._reset(layerPayload); |
| 265 } | 266 } |
| 266 | 267 |
| 267 WebInspector.Layer.prototype = { | 268 WebInspector.Layer.prototype = { |
| 268 /** | 269 /** |
| 269 * @return {string} | 270 * @return {string} |
| 270 */ | 271 */ |
| 271 id: function() | 272 id: function() |
| 272 { | 273 { |
| 273 return this._layerPayload.layerId; | 274 return this._layerPayload.layerId; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 416 |
| 416 /** | 417 /** |
| 417 * @return {?DOMAgent.Rect} | 418 * @return {?DOMAgent.Rect} |
| 418 */ | 419 */ |
| 419 lastPaintRect: function() | 420 lastPaintRect: function() |
| 420 { | 421 { |
| 421 return this._lastPaintRect; | 422 return this._lastPaintRect; |
| 422 }, | 423 }, |
| 423 | 424 |
| 424 /** | 425 /** |
| 426 * @return {!Array.<!LayerTreeAgent.ScrollRect>} |
| 427 */ |
| 428 scrollRects: function() |
| 429 { |
| 430 return this._scrollRects; |
| 431 }, |
| 432 |
| 433 /** |
| 425 * @param {function(!Array.<string>)} callback | 434 * @param {function(!Array.<string>)} callback |
| 426 */ | 435 */ |
| 427 requestCompositingReasons: function(callback) | 436 requestCompositingReasons: function(callback) |
| 428 { | 437 { |
| 429 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay
erTreeAgent.reasonsForCompositingLayer(): ", undefined, []); | 438 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay
erTreeAgent.reasonsForCompositingLayer(): ", undefined, []); |
| 430 LayerTreeAgent.compositingReasons(this.id(), wrappedCallback); | 439 LayerTreeAgent.compositingReasons(this.id(), wrappedCallback); |
| 431 }, | 440 }, |
| 432 | 441 |
| 433 /** | 442 /** |
| 434 * @param {function(!WebInspector.PaintProfilerSnapshot=)} callback | 443 * @param {function(!WebInspector.PaintProfilerSnapshot=)} callback |
| (...skipping 18 matching lines...) Expand all Loading... |
| 453 * @param {!LayerTreeAgent.Layer} layerPayload | 462 * @param {!LayerTreeAgent.Layer} layerPayload |
| 454 */ | 463 */ |
| 455 _reset: function(layerPayload) | 464 _reset: function(layerPayload) |
| 456 { | 465 { |
| 457 this._children = []; | 466 this._children = []; |
| 458 this._parent = null; | 467 this._parent = null; |
| 459 this._paintCount = 0; | 468 this._paintCount = 0; |
| 460 this._layerPayload = layerPayload; | 469 this._layerPayload = layerPayload; |
| 461 this._image = null; | 470 this._image = null; |
| 462 this._nodeId = 0; | 471 this._nodeId = 0; |
| 472 this._scrollRects = this._layerPayload.scrollRects || []; |
| 463 } | 473 } |
| 464 } | 474 } |
| 465 | 475 |
| 466 /** | 476 /** |
| 467 * @constructor | 477 * @constructor |
| 468 * @param {!Array.<!LayerTreeAgent.Layer>} layers | 478 * @param {!Array.<!LayerTreeAgent.Layer>} layers |
| 469 */ | 479 */ |
| 470 WebInspector.LayerTreeSnapshot = function(layers) | 480 WebInspector.LayerTreeSnapshot = function(layers) |
| 471 { | 481 { |
| 472 this.layers = layers; | 482 this.layers = layers; |
| 473 } | 483 } |
| 474 | 484 |
| 475 /** | 485 /** |
| 476 * @constructor | 486 * @constructor |
| 477 * @implements {LayerTreeAgent.Dispatcher} | 487 * @implements {LayerTreeAgent.Dispatcher} |
| 478 * @param {!WebInspector.LayerTreeModel} layerTreeModel | 488 * @param {!WebInspector.LayerTreeModel} layerTreeModel |
| 479 */ | 489 */ |
| 480 WebInspector.LayerTreeDispatcher = function(layerTreeModel) | 490 WebInspector.LayerTreeDispatcher = function(layerTreeModel) |
| 481 { | 491 { |
| 482 this._layerTreeModel = layerTreeModel; | 492 this._layerTreeModel = layerTreeModel; |
| 483 } | 493 } |
| 484 | 494 |
| 485 WebInspector.LayerTreeDispatcher.prototype = { | 495 WebInspector.LayerTreeDispatcher.prototype = { |
| 486 /** | 496 /** |
| 487 * @param {!Array.<!LayerTreeAgent.Layer>=} payload | 497 * @param {!Array.<!LayerTreeAgent.Layer>=} layers |
| 488 */ | 498 */ |
| 489 layerTreeDidChange: function(payload) | 499 layerTreeDidChange: function(layers) |
| 490 { | 500 { |
| 491 this._layerTreeModel._layerTreeChanged(payload); | 501 this._layerTreeModel._layerTreeChanged(layers); |
| 492 }, | 502 }, |
| 493 | 503 |
| 494 /** | 504 /** |
| 495 * @param {!LayerTreeAgent.LayerId} layerId | 505 * @param {!LayerTreeAgent.LayerId} layerId |
| 496 * @param {!DOMAgent.Rect} clipRect | 506 * @param {!DOMAgent.Rect} clipRect |
| 497 */ | 507 */ |
| 498 layerPainted: function(layerId, clipRect) | 508 layerPainted: function(layerId, clipRect) |
| 499 { | 509 { |
| 500 this._layerTreeModel._layerPainted(layerId, clipRect); | 510 this._layerTreeModel._layerPainted(layerId, clipRect); |
| 501 } | 511 } |
| 502 } | 512 } |
| OLD | NEW |