Chromium Code Reviews| 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.addEventListener(WebInspector.Layers3DView.Events.JumpToP aintEventRequested, this._jumpToPaintEvent, this); | |
| 19 this._layers3DView.show(this.element); | 20 this._layers3DView.show(this.element); |
| 20 } | 21 } |
| 21 | 22 |
| 22 WebInspector.TimelineLayersView.prototype = { | 23 WebInspector.TimelineLayersView.prototype = { |
| 23 /** | 24 /** |
| 24 * @param {!WebInspector.DeferredLayerTree} deferredLayerTree | 25 * @param {!WebInspector.DeferredLayerTree} deferredLayerTree |
| 25 * @param {?Array.<!WebInspector.LayerPaintEvent>} paints | 26 * @param {?Array.<!WebInspector.LayerPaintEvent>} paints |
| 26 */ | 27 */ |
| 27 showLayerTree: function(deferredLayerTree, paints) | 28 showLayerTree: function(deferredLayerTree, paints) |
| 28 { | 29 { |
| 29 this._disposeTiles(); | 30 this._disposeTiles(); |
| 30 this._deferredLayerTree = deferredLayerTree; | 31 this._deferredLayerTree = deferredLayerTree; |
| 31 this._paints = paints; | 32 this._paints = paints; |
| 32 if (this.isShowing()) | 33 if (this.isShowing()) |
| 33 this._update(); | 34 this._update(); |
| 34 else | 35 else |
| 35 this._updateWhenVisible = true; | 36 this._updateWhenVisible = true; |
| 36 }, | 37 }, |
| 37 | 38 |
| 38 wasShown: function() | 39 wasShown: function() |
| 39 { | 40 { |
| 40 if (this._updateWhenVisible) { | 41 if (this._updateWhenVisible) { |
| 41 this._updateWhenVisible = false; | 42 this._updateWhenVisible = false; |
| 42 this._update(); | 43 this._update(); |
| 43 } | 44 } |
| 44 }, | 45 }, |
| 45 | 46 |
| 47 /** | |
| 48 * @param {!WebInspector.TimelineModel} model | |
| 49 * @param {!WebInspector.TimelineModeViewDelegate} delegate | |
| 50 */ | |
| 51 setTimelineModelAndDelegate: function(model, delegate) | |
| 52 { | |
| 53 this._model = model; | |
| 54 this._delegate = delegate; | |
| 55 }, | |
| 56 | |
| 57 /** | |
| 58 * @param {!WebInspector.Event} event | |
| 59 */ | |
| 60 _jumpToPaintEvent: function(event) | |
| 61 { | |
| 62 var traceEvent = event.data; | |
| 63 var eventRecord = undefined; | |
|
caseq
2014/07/17 16:24:12
nit: drop undefined
malch
2014/07/17 16:29:46
Done.
| |
| 64 | |
| 65 function findRecordWithEvent(record) | |
| 66 { | |
| 67 if (record.traceEvent() === traceEvent) { | |
| 68 eventRecord = record; | |
| 69 return true; | |
| 70 } | |
| 71 return false; | |
| 72 } | |
| 73 | |
| 74 this._model.forAllRecords(findRecordWithEvent); | |
| 75 if (eventRecord) { | |
| 76 var selection = WebInspector.TimelineSelection.fromRecord(eventRecor d); | |
| 77 this._delegate.select(selection); | |
| 78 } | |
| 79 }, | |
| 80 | |
| 46 _update: function() | 81 _update: function() |
| 47 { | 82 { |
| 48 var layerTree; | 83 var layerTree; |
| 49 | 84 |
| 50 this._weakTarget = this._deferredLayerTree.weakTarget(); | 85 this._weakTarget = this._deferredLayerTree.weakTarget(); |
| 51 var originalTiles = this._paintTiles; | 86 var originalTiles = this._paintTiles; |
| 52 var tilesReadyBarrier = new CallbackBarrier(); | 87 var tilesReadyBarrier = new CallbackBarrier(); |
| 53 this._deferredLayerTree.resolve(tilesReadyBarrier.createCallback(onLayer sReady)); | 88 this._deferredLayerTree.resolve(tilesReadyBarrier.createCallback(onLayer sReady)); |
| 54 var target = this._weakTarget.get(); | 89 var target = this._weakTarget.get(); |
| 55 if (target) { | 90 if (target) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 73 */ | 108 */ |
| 74 function onSnapshotLoaded(paintEvent, snapshot) | 109 function onSnapshotLoaded(paintEvent, snapshot) |
| 75 { | 110 { |
| 76 if (!snapshot) | 111 if (!snapshot) |
| 77 return; | 112 return; |
| 78 // We're too late and there's a new generation of tiles being loaded . | 113 // We're too late and there's a new generation of tiles being loaded . |
| 79 if (originalTiles !== this._paintTiles) { | 114 if (originalTiles !== this._paintTiles) { |
| 80 snapshot.dispose(); | 115 snapshot.dispose(); |
| 81 return; | 116 return; |
| 82 } | 117 } |
| 83 this._paintTiles.push({layerId: paintEvent.layerId, rect: paintEvent .rect, snapshot: snapshot}); | 118 this._paintTiles.push({layerId: paintEvent.layerId, rect: paintEvent .rect, snapshot: snapshot, traceEvent: paintEvent.traceEvent}); |
| 84 } | 119 } |
| 85 | 120 |
| 86 /** | 121 /** |
| 87 * @this {WebInspector.TimelineLayersView} | 122 * @this {WebInspector.TimelineLayersView} |
| 88 */ | 123 */ |
| 89 function onLayersAndTilesReady() | 124 function onLayersAndTilesReady() |
| 90 { | 125 { |
| 91 this._layers3DView.setLayerTree(layerTree); | 126 this._layers3DView.setLayerTree(layerTree); |
| 92 this._layers3DView.setTiles(this._paintTiles); | 127 this._layers3DView.setTiles(this._paintTiles); |
| 93 } | 128 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 | 189 |
| 155 _disposeTiles: function() | 190 _disposeTiles: function() |
| 156 { | 191 { |
| 157 for (var i = 0; i < this._paintTiles.length; ++i) | 192 for (var i = 0; i < this._paintTiles.length; ++i) |
| 158 this._paintTiles[i].snapshot.dispose(); | 193 this._paintTiles[i].snapshot.dispose(); |
| 159 this._paintTiles = []; | 194 this._paintTiles = []; |
| 160 }, | 195 }, |
| 161 | 196 |
| 162 __proto__: WebInspector.VBox.prototype | 197 __proto__: WebInspector.VBox.prototype |
| 163 } | 198 } |
| OLD | NEW |