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)); |
111 }, | 111 }, |
112 | 112 |
113 /** | 113 /** |
114 * @param {string} id | 114 * @param {string} id |
115 * @return {?WebInspector.Layer} | 115 * @return {?WebInspector.Layer} |
116 */ | 116 */ |
117 layerById: function(id) | 117 layerById: function(id) |
118 { | 118 { |
119 return this._layersById[id] || null; | 119 return this._layersById[id] || null; |
120 }, | 120 }, |
121 | 121 |
122 /** | 122 /** |
123 * @param {!Array.<!LayerTreeAgent.Layer>} payload | 123 * @param {!Array.<!LayerTreeAgent.Layer>} layers |
124 */ | 124 */ |
125 _repopulate: function(payload) | 125 _repopulate: function(layers) |
126 { | 126 { |
127 var oldLayersById = this._layersById; | 127 var oldLayersById = this._layersById; |
128 this._layersById = {}; | 128 this._layersById = {}; |
129 for (var i = 0; i < payload.length; ++i) { | 129 for (var i = 0; i < layers.length; ++i) { |
130 var layerId = payload[i].layerId; | 130 var layerId = layers[i].layerId; |
131 var layer = oldLayersById[layerId]; | 131 var layer = oldLayersById[layerId]; |
132 if (layer) | 132 if (layer) |
133 layer._reset(payload[i]); | 133 layer._reset(layers[i]); |
134 else | 134 else |
135 layer = new WebInspector.Layer(payload[i]); | 135 layer = new WebInspector.Layer(layers[i]); |
136 this._layersById[layerId] = layer; | 136 this._layersById[layerId] = layer; |
137 var parentId = layer.parentId(); | 137 var parentId = layer.parentId(); |
138 if (!this._contentRoot && layer.nodeId()) | 138 if (!this._contentRoot && layer.nodeId()) |
139 this._contentRoot = layer; | 139 this._contentRoot = layer; |
140 var lastPaintRect = this._lastPaintRectByLayerId[layerId]; | 140 var lastPaintRect = this._lastPaintRectByLayerId[layerId]; |
141 if (lastPaintRect) | 141 if (lastPaintRect) |
142 layer._lastPaintRect = lastPaintRect; | 142 layer._lastPaintRect = lastPaintRect; |
143 if (parentId) { | 143 if (parentId) { |
144 var parent = this._layersById[parentId]; | 144 var parent = this._layersById[parentId]; |
145 if (!parent) | 145 if (!parent) |
146 console.assert(parent, "missing parent " + parentId + " for layer " + layerId); | 146 console.assert(parent, "missing parent " + parentId + " for layer " + layerId); |
147 parent.addChild(layer); | 147 parent.addChild(layer); |
148 } else { | 148 } else { |
149 if (this._root) | 149 if (this._root) |
150 console.assert(false, "Multiple root layers"); | 150 console.assert(false, "Multiple root layers"); |
151 this._root = layer; | 151 this._root = layer; |
152 } | 152 } |
153 } | 153 } |
154 this._lastPaintRectByLayerId = {}; | 154 this._lastPaintRectByLayerId = {}; |
155 }, | 155 }, |
156 | 156 |
157 /** | 157 /** |
158 * @param {!Array.<!LayerTreeAgent.Layer>=} payload | 158 * @param {!Array.<!LayerTreeAgent.Layer>=} layers |
159 */ | 159 */ |
160 _layerTreeChanged: function(payload) | 160 _layerTreeChanged: function(layers) |
161 { | 161 { |
162 this._root = null; | 162 this._root = null; |
163 this._contentRoot = null; | 163 this._contentRoot = null; |
164 // Payload will be null when not in the composited mode. | 164 // Payload will be null when not in the composited mode. |
165 if (payload) | 165 if (layers) |
166 this._repopulate(payload); | 166 this._repopulate(layers); |
167 this.dispatchEventToListeners(WebInspector.LayerTreeModel.Events.LayerTr eeChanged); | 167 this.dispatchEventToListeners(WebInspector.LayerTreeModel.Events.LayerTr eeChanged); |
168 }, | 168 }, |
169 | 169 |
170 /** | 170 /** |
171 * @param {!LayerTreeAgent.LayerId} layerId | 171 * @param {!LayerTreeAgent.LayerId} layerId |
172 * @param {!DOMAgent.Rect} clipRect | 172 * @param {!DOMAgent.Rect} clipRect |
173 */ | 173 */ |
174 _layerPainted: function(layerId, clipRect) | 174 _layerPainted: function(layerId, clipRect) |
175 { | 175 { |
176 var layer = this._layersById[layerId]; | 176 var layer = this._layersById[layerId]; |
(...skipping 13 matching lines...) Expand all Loading... | |
190 | 190 |
191 __proto__: WebInspector.Object.prototype | 191 __proto__: WebInspector.Object.prototype |
192 } | 192 } |
193 | 193 |
194 /** | 194 /** |
195 * @constructor | 195 * @constructor |
196 * @param {!LayerTreeAgent.Layer} layerPayload | 196 * @param {!LayerTreeAgent.Layer} layerPayload |
197 */ | 197 */ |
198 WebInspector.Layer = function(layerPayload) | 198 WebInspector.Layer = function(layerPayload) |
199 { | 199 { |
200 this._scrollRects = []; | |
200 this._reset(layerPayload); | 201 this._reset(layerPayload); |
201 } | 202 } |
202 | 203 |
203 WebInspector.Layer.prototype = { | 204 WebInspector.Layer.prototype = { |
204 /** | 205 /** |
205 * @return {string} | 206 * @return {string} |
206 */ | 207 */ |
207 id: function() | 208 id: function() |
208 { | 209 { |
209 return this._layerPayload.layerId; | 210 return this._layerPayload.layerId; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 | 344 |
344 /** | 345 /** |
345 * @return {?DOMAgent.Rect} | 346 * @return {?DOMAgent.Rect} |
346 */ | 347 */ |
347 lastPaintRect: function() | 348 lastPaintRect: function() |
348 { | 349 { |
349 return this._lastPaintRect; | 350 return this._lastPaintRect; |
350 }, | 351 }, |
351 | 352 |
352 /** | 353 /** |
354 * @return {!Array.<!LayerTreeAgent.ScrollRect>} | |
355 */ | |
356 scrollRects: function() | |
357 { | |
358 return this._scrollRects; | |
359 }, | |
360 | |
361 /** | |
353 * @param {function(!Array.<string>)} callback | 362 * @param {function(!Array.<string>)} callback |
354 */ | 363 */ |
355 requestCompositingReasons: function(callback) | 364 requestCompositingReasons: function(callback) |
356 { | 365 { |
357 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay erTreeAgent.reasonsForCompositingLayer(): ", undefined, []); | 366 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Lay erTreeAgent.reasonsForCompositingLayer(): ", undefined, []); |
358 LayerTreeAgent.compositingReasons(this.id(), wrappedCallback); | 367 LayerTreeAgent.compositingReasons(this.id(), wrappedCallback); |
359 }, | 368 }, |
360 | 369 |
361 /** | 370 /** |
362 * @param {function(!WebInspector.PaintProfilerSnapshot=)} callback | 371 * @param {function(!WebInspector.PaintProfilerSnapshot=)} callback |
(...skipping 17 matching lines...) Expand all Loading... | |
380 /** | 389 /** |
381 * @param {!LayerTreeAgent.Layer} layerPayload | 390 * @param {!LayerTreeAgent.Layer} layerPayload |
382 */ | 391 */ |
383 _reset: function(layerPayload) | 392 _reset: function(layerPayload) |
384 { | 393 { |
385 this._children = []; | 394 this._children = []; |
386 this._parent = null; | 395 this._parent = null; |
387 this._paintCount = 0; | 396 this._paintCount = 0; |
388 this._layerPayload = layerPayload; | 397 this._layerPayload = layerPayload; |
389 this._image = null; | 398 this._image = null; |
399 this._updateScrollRects(); | |
400 }, | |
401 | |
402 _updateScrollRects: function() | |
403 { | |
404 this._scrollRects = this._layerPayload.scrollRects || []; | |
caseq
2014/03/11 13:40:32
Looks like this is not worth extracting.
malch
2014/03/11 13:48:56
Done.
| |
390 } | 405 } |
391 } | 406 } |
392 | 407 |
393 /** | 408 /** |
394 * @constructor | 409 * @constructor |
395 * @implements {LayerTreeAgent.Dispatcher} | 410 * @implements {LayerTreeAgent.Dispatcher} |
396 * @param {!WebInspector.LayerTreeModel} layerTreeModel | 411 * @param {!WebInspector.LayerTreeModel} layerTreeModel |
397 */ | 412 */ |
398 WebInspector.LayerTreeDispatcher = function(layerTreeModel) | 413 WebInspector.LayerTreeDispatcher = function(layerTreeModel) |
399 { | 414 { |
400 this._layerTreeModel = layerTreeModel; | 415 this._layerTreeModel = layerTreeModel; |
401 } | 416 } |
402 | 417 |
403 WebInspector.LayerTreeDispatcher.prototype = { | 418 WebInspector.LayerTreeDispatcher.prototype = { |
404 /** | 419 /** |
405 * @param {!Array.<!LayerTreeAgent.Layer>=} payload | 420 * @param {!Array.<!LayerTreeAgent.Layer>=} layers |
406 */ | 421 */ |
407 layerTreeDidChange: function(payload) | 422 layerTreeDidChange: function(layers) |
408 { | 423 { |
409 this._layerTreeModel._layerTreeChanged(payload); | 424 this._layerTreeModel._layerTreeChanged(layers); |
410 }, | 425 }, |
411 | 426 |
412 /** | 427 /** |
413 * @param {!LayerTreeAgent.LayerId} layerId | 428 * @param {!LayerTreeAgent.LayerId} layerId |
414 * @param {!DOMAgent.Rect} clipRect | 429 * @param {!DOMAgent.Rect} clipRect |
415 */ | 430 */ |
416 layerPainted: function(layerId, clipRect) | 431 layerPainted: function(layerId, clipRect) |
417 { | 432 { |
418 this._layerTreeModel._layerPainted(layerId, clipRect); | 433 this._layerTreeModel._layerPainted(layerId, clipRect); |
419 } | 434 } |
420 } | 435 } |
OLD | NEW |