| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @constructor | 8 * @constructor |
| 9 * @extends {WebInspector.VBox} | 9 * @extends {WebInspector.VBox} |
| 10 */ | 10 */ |
| 11 WebInspector.TimelineLayersView = function() | 11 WebInspector.TimelineLayersView = function() |
| 12 { | 12 { |
| 13 WebInspector.VBox.call(this); | 13 WebInspector.VBox.call(this); |
| 14 | 14 |
| 15 this._paintTiles = []; | 15 this._paintTiles = []; |
| 16 this._layers3DView = new WebInspector.Layers3DView(); | 16 this._layers3DView = new WebInspector.Layers3DView(); |
| 17 this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.ObjectS
elected, this._onObjectSelected, this); | 17 this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.ObjectS
elected, this._onObjectSelected, this); |
| 18 this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.ObjectH
overed, this._onObjectHovered, this); | 18 this._layers3DView.addEventListener(WebInspector.Layers3DView.Events.ObjectH
overed, this._onObjectHovered, this); |
| 19 this._layers3DView.show(this.element); | 19 this._layers3DView.show(this.element); |
| 20 } | 20 } |
| 21 | 21 |
| 22 WebInspector.TimelineLayersView.prototype = { | 22 WebInspector.TimelineLayersView.prototype = { |
| 23 /** | 23 /** |
| 24 * @param {!WebInspector.DeferredLayerTree} deferredLayerTree | 24 * @param {!WebInspector.DeferredLayerTree} deferredLayerTree |
| 25 * @param {?Array.<!WebInspector.LayerPaintEvent>} paints | 25 * @param {?Array.<!WebInspector.LayerPaintEvent>} paints |
| 26 */ | 26 */ |
| 27 showLayerTree: function(deferredLayerTree, paints) | 27 showLayerTree: function(deferredLayerTree, paints) |
| 28 { | 28 { |
| 29 this._disposeTiles(); | 29 this._disposeTiles(); |
| 30 if (!this.isShowing()) { | 30 this._deferredLayerTree = deferredLayerTree; |
| 31 this._pendingLayerTree = deferredLayerTree, | 31 this._paints = paints; |
| 32 this._pendingPaints = paints; | 32 if (this.isShowing()) |
| 33 return; | 33 this._update(); |
| 34 } | 34 else |
| 35 this._actuallyShowLayerTree(deferredLayerTree, paints); | 35 this._updateWhenVisible = true; |
| 36 }, | 36 }, |
| 37 | 37 |
| 38 wasShown: function() | 38 wasShown: function() |
| 39 { | 39 { |
| 40 if (!this._pendingLayerTree) | 40 if (this._updateWhenVisible) { |
| 41 return; | 41 this._updateWhenVisible = false; |
| 42 this._actuallyShowLayerTree(this._pendingLayerTree, this._pendingPaints)
; | 42 this._update(); |
| 43 this._pendingLayerTree = null; | 43 } |
| 44 this._pendingPaints = null; | |
| 45 }, | 44 }, |
| 46 | 45 |
| 47 /** | 46 _update: function() |
| 48 * @param {!WebInspector.DeferredLayerTree} deferredLayerTree | |
| 49 * @param {?Array.<!WebInspector.LayerPaintEvent>} paints | |
| 50 */ | |
| 51 _actuallyShowLayerTree: function(deferredLayerTree, paints) | |
| 52 { | 47 { |
| 53 var layerTree; | 48 var layerTree; |
| 54 | 49 |
| 55 this._target = deferredLayerTree.target(); | 50 this._weakTarget = this._deferredLayerTree.weakTarget(); |
| 56 var originalTiles = this._paintTiles; | 51 var originalTiles = this._paintTiles; |
| 57 var tilesReadyBarrier = new CallbackBarrier(); | 52 var tilesReadyBarrier = new CallbackBarrier(); |
| 58 deferredLayerTree.resolve(tilesReadyBarrier.createCallback(onLayersReady
)); | 53 this._deferredLayerTree.resolve(tilesReadyBarrier.createCallback(onLayer
sReady)); |
| 59 for (var i = 0; paints && i < paints.length; ++i) | 54 var target = this._weakTarget.get(); |
| 60 WebInspector.PaintProfilerSnapshot.load(paints[i].picture, tilesRead
yBarrier.createCallback(onSnapshotLoaded.bind(this, paints[i]))); | 55 if (target) { |
| 56 for (var i = 0; this._paints && i < this._paints.length; ++i) |
| 57 WebInspector.PaintProfilerSnapshot.load(target, this._paints[i].
picture, tilesReadyBarrier.createCallback(onSnapshotLoaded.bind(this, this._pain
ts[i]))); |
| 58 } |
| 61 tilesReadyBarrier.callWhenDone(onLayersAndTilesReady.bind(this)); | 59 tilesReadyBarrier.callWhenDone(onLayersAndTilesReady.bind(this)); |
| 62 | 60 |
| 63 /** | 61 /** |
| 64 * @param {!WebInspector.LayerTreeBase} resolvedLayerTree | 62 * @param {!WebInspector.LayerTreeBase} resolvedLayerTree |
| 65 */ | 63 */ |
| 66 function onLayersReady(resolvedLayerTree) | 64 function onLayersReady(resolvedLayerTree) |
| 67 { | 65 { |
| 68 layerTree = resolvedLayerTree; | 66 layerTree = resolvedLayerTree; |
| 69 } | 67 } |
| 70 | 68 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 97 | 95 |
| 98 /** | 96 /** |
| 99 * @param {?WebInspector.Layers3DView.ActiveObject} activeObject | 97 * @param {?WebInspector.Layers3DView.ActiveObject} activeObject |
| 100 */ | 98 */ |
| 101 _selectObject: function(activeObject) | 99 _selectObject: function(activeObject) |
| 102 { | 100 { |
| 103 var layer = activeObject && activeObject.layer; | 101 var layer = activeObject && activeObject.layer; |
| 104 if (this._currentlySelectedLayer === activeObject) | 102 if (this._currentlySelectedLayer === activeObject) |
| 105 return; | 103 return; |
| 106 this._currentlySelectedLayer = activeObject; | 104 this._currentlySelectedLayer = activeObject; |
| 107 var node = layer ? layer.nodeForSelfOrAncestor() : null; | 105 this._toggleNodeHighlight(layer ? layer.nodeForSelfOrAncestor() : null); |
| 108 if (node) | |
| 109 node.highlightForTwoSeconds(); | |
| 110 else | |
| 111 this._target.domModel.hideDOMNodeHighlight(); | |
| 112 this._layers3DView.selectObject(activeObject); | 106 this._layers3DView.selectObject(activeObject); |
| 113 }, | 107 }, |
| 114 | 108 |
| 115 /** | 109 /** |
| 116 * @param {?WebInspector.Layers3DView.ActiveObject} activeObject | 110 * @param {?WebInspector.Layers3DView.ActiveObject} activeObject |
| 117 */ | 111 */ |
| 118 _hoverObject: function(activeObject) | 112 _hoverObject: function(activeObject) |
| 119 { | 113 { |
| 120 var layer = activeObject && activeObject.layer; | 114 var layer = activeObject && activeObject.layer; |
| 121 if (this._currentlyHoveredLayer === activeObject) | 115 if (this._currentlyHoveredLayer === activeObject) |
| 122 return; | 116 return; |
| 123 this._currentlyHoveredLayer = activeObject; | 117 this._currentlyHoveredLayer = activeObject; |
| 124 var node = layer ? layer.nodeForSelfOrAncestor() : null; | 118 this._toggleNodeHighlight(layer ? layer.nodeForSelfOrAncestor() : null); |
| 125 if (node) | |
| 126 node.highlight(); | |
| 127 else | |
| 128 this._target.domModel.hideDOMNodeHighlight(); | |
| 129 this._layers3DView.hoverObject(activeObject); | 119 this._layers3DView.hoverObject(activeObject); |
| 130 }, | 120 }, |
| 131 | 121 |
| 132 /** | 122 /** |
| 123 * @param {?WebInspector.DOMNode} node |
| 124 */ |
| 125 _toggleNodeHighlight: function(node) |
| 126 { |
| 127 if (node) { |
| 128 node.highlightForTwoSeconds(); |
| 129 return; |
| 130 } |
| 131 var target = this._weakTarget.get(); |
| 132 if (target) |
| 133 target.domModel.hideDOMNodeHighlight(); |
| 134 |
| 135 }, |
| 136 |
| 137 /** |
| 133 * @param {!WebInspector.Event} event | 138 * @param {!WebInspector.Event} event |
| 134 */ | 139 */ |
| 135 _onObjectSelected: function(event) | 140 _onObjectSelected: function(event) |
| 136 { | 141 { |
| 137 var activeObject = /** @type {!WebInspector.Layers3DView.ActiveObject} *
/ (event.data); | 142 var activeObject = /** @type {!WebInspector.Layers3DView.ActiveObject} *
/ (event.data); |
| 138 this._selectObject(activeObject); | 143 this._selectObject(activeObject); |
| 139 }, | 144 }, |
| 140 | 145 |
| 141 /** | 146 /** |
| 142 * @param {!WebInspector.Event} event | 147 * @param {!WebInspector.Event} event |
| 143 */ | 148 */ |
| 144 _onObjectHovered: function(event) | 149 _onObjectHovered: function(event) |
| 145 { | 150 { |
| 146 var activeObject = /** @type {!WebInspector.Layers3DView.ActiveObject} *
/ (event.data); | 151 var activeObject = /** @type {!WebInspector.Layers3DView.ActiveObject} *
/ (event.data); |
| 147 this._hoverObject(activeObject); | 152 this._hoverObject(activeObject); |
| 148 }, | 153 }, |
| 149 | 154 |
| 150 _disposeTiles: function() | 155 _disposeTiles: function() |
| 151 { | 156 { |
| 152 for (var i = 0; i < this._paintTiles.length; ++i) | 157 for (var i = 0; i < this._paintTiles.length; ++i) |
| 153 this._paintTiles[i].snapshot.dispose(); | 158 this._paintTiles[i].snapshot.dispose(); |
| 154 this._paintTiles = []; | 159 this._paintTiles = []; |
| 155 }, | 160 }, |
| 156 | 161 |
| 157 __proto__: WebInspector.VBox.prototype | 162 __proto__: WebInspector.VBox.prototype |
| 158 } | 163 } |
| OLD | NEW |