| 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 21 matching lines...) Expand all Loading... |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.SDKModel} | 33 * @extends {WebInspector.SDKModel} |
| 34 */ | 34 */ |
| 35 WebInspector.LayerTreeModel = function(target) | 35 WebInspector.LayerTreeModel = function(target) |
| 36 { | 36 { |
| 37 WebInspector.SDKModel.call(this, WebInspector.LayerTreeModel, target); | 37 WebInspector.SDKModel.call(this, WebInspector.LayerTreeModel, target); |
| 38 target.registerLayerTreeDispatcher(new WebInspector.LayerTreeDispatcher(this
)); | 38 target.registerLayerTreeDispatcher(new WebInspector.LayerTreeDispatcher(this
)); |
| 39 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event
s.MainFrameNavigated, this._onMainFrameNavigated, this); | 39 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event
s.MainFrameNavigated, this._onMainFrameNavigated, this); |
| 40 /** @type {?WebInspector.LayerTreeBase} */ | 40 /** @type {?WebInspector.LayerTreeBase} */ |
| 41 this._layerTree = null; | 41 this._layerTree = null; |
| 42 } | 42 }; |
| 43 | 43 |
| 44 /** @enum {symbol} */ | 44 /** @enum {symbol} */ |
| 45 WebInspector.LayerTreeModel.Events = { | 45 WebInspector.LayerTreeModel.Events = { |
| 46 LayerTreeChanged: Symbol("LayerTreeChanged"), | 46 LayerTreeChanged: Symbol("LayerTreeChanged"), |
| 47 LayerPainted: Symbol("LayerPainted"), | 47 LayerPainted: Symbol("LayerPainted"), |
| 48 } | 48 }; |
| 49 | 49 |
| 50 WebInspector.LayerTreeModel.prototype = { | 50 WebInspector.LayerTreeModel.prototype = { |
| 51 disable: function() | 51 disable: function() |
| 52 { | 52 { |
| 53 if (!this._enabled) | 53 if (!this._enabled) |
| 54 return; | 54 return; |
| 55 this._enabled = false; | 55 this._enabled = false; |
| 56 this.target().layerTreeAgent().disable(); | 56 this.target().layerTreeAgent().disable(); |
| 57 }, | 57 }, |
| 58 | 58 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 }, | 126 }, |
| 127 | 127 |
| 128 _onMainFrameNavigated: function() | 128 _onMainFrameNavigated: function() |
| 129 { | 129 { |
| 130 this._layerTree = null; | 130 this._layerTree = null; |
| 131 if (this._enabled) | 131 if (this._enabled) |
| 132 this._forceEnable(); | 132 this._forceEnable(); |
| 133 }, | 133 }, |
| 134 | 134 |
| 135 __proto__: WebInspector.SDKModel.prototype | 135 __proto__: WebInspector.SDKModel.prototype |
| 136 } | 136 }; |
| 137 | 137 |
| 138 /** | 138 /** |
| 139 * @constructor | 139 * @constructor |
| 140 * @param {?WebInspector.Target} target | 140 * @param {?WebInspector.Target} target |
| 141 * @extends {WebInspector.LayerTreeBase} | 141 * @extends {WebInspector.LayerTreeBase} |
| 142 */ | 142 */ |
| 143 WebInspector.AgentLayerTree = function(target) | 143 WebInspector.AgentLayerTree = function(target) |
| 144 { | 144 { |
| 145 WebInspector.LayerTreeBase.call(this, target); | 145 WebInspector.LayerTreeBase.call(this, target); |
| 146 } | 146 }; |
| 147 | 147 |
| 148 WebInspector.AgentLayerTree.prototype = { | 148 WebInspector.AgentLayerTree.prototype = { |
| 149 /** | 149 /** |
| 150 * @param {?Array.<!LayerTreeAgent.Layer>} payload | 150 * @param {?Array.<!LayerTreeAgent.Layer>} payload |
| 151 * @param {function()} callback | 151 * @param {function()} callback |
| 152 */ | 152 */ |
| 153 setLayers: function(payload, callback) | 153 setLayers: function(payload, callback) |
| 154 { | 154 { |
| 155 if (!payload) { | 155 if (!payload) { |
| 156 onBackendNodeIdsResolved.call(this); | 156 onBackendNodeIdsResolved.call(this); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 root = layer; | 214 root = layer; |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 if (root) { | 217 if (root) { |
| 218 this.setRoot(root); | 218 this.setRoot(root); |
| 219 root._calculateQuad(new WebKitCSSMatrix()); | 219 root._calculateQuad(new WebKitCSSMatrix()); |
| 220 } | 220 } |
| 221 }, | 221 }, |
| 222 | 222 |
| 223 __proto__: WebInspector.LayerTreeBase.prototype | 223 __proto__: WebInspector.LayerTreeBase.prototype |
| 224 } | 224 }; |
| 225 | 225 |
| 226 /** | 226 /** |
| 227 * @constructor | 227 * @constructor |
| 228 * @implements {WebInspector.Layer} | 228 * @implements {WebInspector.Layer} |
| 229 * @param {?WebInspector.Target} target | 229 * @param {?WebInspector.Target} target |
| 230 * @param {!LayerTreeAgent.Layer} layerPayload | 230 * @param {!LayerTreeAgent.Layer} layerPayload |
| 231 */ | 231 */ |
| 232 WebInspector.AgentLayer = function(target, layerPayload) | 232 WebInspector.AgentLayer = function(target, layerPayload) |
| 233 { | 233 { |
| 234 this._target = target; | 234 this._target = target; |
| 235 this._reset(layerPayload); | 235 this._reset(layerPayload); |
| 236 } | 236 }; |
| 237 | 237 |
| 238 WebInspector.AgentLayer.prototype = { | 238 WebInspector.AgentLayer.prototype = { |
| 239 /** | 239 /** |
| 240 * @override | 240 * @override |
| 241 * @return {string} | 241 * @return {string} |
| 242 */ | 242 */ |
| 243 id: function() | 243 id: function() |
| 244 { | 244 { |
| 245 return this._layerPayload.layerId; | 245 return this._layerPayload.layerId; |
| 246 }, | 246 }, |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 this._quad.push(point.x, point.y); | 556 this._quad.push(point.x, point.y); |
| 557 } | 557 } |
| 558 | 558 |
| 559 function calculateQuadForLayer(layer) | 559 function calculateQuadForLayer(layer) |
| 560 { | 560 { |
| 561 layer._calculateQuad(matrix); | 561 layer._calculateQuad(matrix); |
| 562 } | 562 } |
| 563 | 563 |
| 564 this._children.forEach(calculateQuadForLayer); | 564 this._children.forEach(calculateQuadForLayer); |
| 565 } | 565 } |
| 566 } | 566 }; |
| 567 | 567 |
| 568 /** | 568 /** |
| 569 * @constructor | 569 * @constructor |
| 570 * @implements {LayerTreeAgent.Dispatcher} | 570 * @implements {LayerTreeAgent.Dispatcher} |
| 571 * @param {!WebInspector.LayerTreeModel} layerTreeModel | 571 * @param {!WebInspector.LayerTreeModel} layerTreeModel |
| 572 */ | 572 */ |
| 573 WebInspector.LayerTreeDispatcher = function(layerTreeModel) | 573 WebInspector.LayerTreeDispatcher = function(layerTreeModel) |
| 574 { | 574 { |
| 575 this._layerTreeModel = layerTreeModel; | 575 this._layerTreeModel = layerTreeModel; |
| 576 } | 576 }; |
| 577 | 577 |
| 578 WebInspector.LayerTreeDispatcher.prototype = { | 578 WebInspector.LayerTreeDispatcher.prototype = { |
| 579 /** | 579 /** |
| 580 * @override | 580 * @override |
| 581 * @param {!Array.<!LayerTreeAgent.Layer>=} layers | 581 * @param {!Array.<!LayerTreeAgent.Layer>=} layers |
| 582 */ | 582 */ |
| 583 layerTreeDidChange: function(layers) | 583 layerTreeDidChange: function(layers) |
| 584 { | 584 { |
| 585 this._layerTreeModel._layerTreeChanged(layers || null); | 585 this._layerTreeModel._layerTreeChanged(layers || null); |
| 586 }, | 586 }, |
| 587 | 587 |
| 588 /** | 588 /** |
| 589 * @override | 589 * @override |
| 590 * @param {!LayerTreeAgent.LayerId} layerId | 590 * @param {!LayerTreeAgent.LayerId} layerId |
| 591 * @param {!DOMAgent.Rect} clipRect | 591 * @param {!DOMAgent.Rect} clipRect |
| 592 */ | 592 */ |
| 593 layerPainted: function(layerId, clipRect) | 593 layerPainted: function(layerId, clipRect) |
| 594 { | 594 { |
| 595 this._layerTreeModel._layerPainted(layerId, clipRect); | 595 this._layerTreeModel._layerPainted(layerId, clipRect); |
| 596 } | 596 } |
| 597 } | 597 }; |
| 598 | 598 |
| 599 /** | 599 /** |
| 600 * @param {!WebInspector.Target} target | 600 * @param {!WebInspector.Target} target |
| 601 * @return {?WebInspector.LayerTreeModel} | 601 * @return {?WebInspector.LayerTreeModel} |
| 602 */ | 602 */ |
| 603 WebInspector.LayerTreeModel.fromTarget = function(target) | 603 WebInspector.LayerTreeModel.fromTarget = function(target) |
| 604 { | 604 { |
| 605 if (!target.hasDOMCapability()) | 605 if (!target.hasDOMCapability()) |
| 606 return null; | 606 return null; |
| 607 | 607 |
| 608 var model = /** @type {?WebInspector.LayerTreeModel} */ (target.model(WebIns
pector.LayerTreeModel)); | 608 var model = /** @type {?WebInspector.LayerTreeModel} */ (target.model(WebIns
pector.LayerTreeModel)); |
| 609 if (!model) | 609 if (!model) |
| 610 model = new WebInspector.LayerTreeModel(target); | 610 model = new WebInspector.LayerTreeModel(target); |
| 611 return model; | 611 return model; |
| 612 } | 612 }; |
| OLD | NEW |