| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.SplitView} | 7 * @extends {WebInspector.SplitView} |
| 8 */ | 8 */ |
| 9 WebInspector.TimelinePaintProfilerView = function() | 9 WebInspector.TimelinePaintProfilerView = function() |
| 10 { | 10 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 this._paintProfilerView.addEventListener(WebInspector.PaintProfilerView.Even
ts.WindowChanged, this._onWindowChanged, this); | 22 this._paintProfilerView.addEventListener(WebInspector.PaintProfilerView.Even
ts.WindowChanged, this._onWindowChanged, this); |
| 23 this._paintProfilerView.show(this.sidebarElement()); | 23 this._paintProfilerView.show(this.sidebarElement()); |
| 24 | 24 |
| 25 this._logTreeView = new WebInspector.PaintProfilerCommandLogView(); | 25 this._logTreeView = new WebInspector.PaintProfilerCommandLogView(); |
| 26 this._logTreeView.show(this._logAndImageSplitView.sidebarElement()); | 26 this._logTreeView.show(this._logAndImageSplitView.sidebarElement()); |
| 27 } | 27 } |
| 28 | 28 |
| 29 WebInspector.TimelinePaintProfilerView.prototype = { | 29 WebInspector.TimelinePaintProfilerView.prototype = { |
| 30 wasShown: function() | 30 wasShown: function() |
| 31 { | 31 { |
| 32 this._innerSetPicture(this._picture); | 32 if (this._updateWhenVisible) { |
| 33 this._updateWhenVisible = false; |
| 34 this._update(); |
| 35 } |
| 33 }, | 36 }, |
| 34 | 37 |
| 35 /** | 38 /** |
| 39 * @param {!WeakReference.<!WebInspector.Target>} weakTarget |
| 36 * @param {string} encodedPicture | 40 * @param {string} encodedPicture |
| 37 */ | 41 */ |
| 38 setPicture: function(encodedPicture) | 42 setPicture: function(weakTarget, encodedPicture) |
| 39 { | 43 { |
| 40 if (this._lastLoadedSnapshot) { | 44 this._disposeSnapshot(); |
| 41 this._lastLoadedSnapshot.dispose(); | |
| 42 this._lastLoadedSnapshot = null; | |
| 43 } | |
| 44 this._picture = encodedPicture; | 45 this._picture = encodedPicture; |
| 45 if (!this.isShowing()) | 46 this._weakTarget = weakTarget; |
| 46 return; | 47 if (this.isShowing()) |
| 47 this._innerSetPicture(this._picture); | 48 this._update(); |
| 49 else |
| 50 this._updateWhenVisible = true; |
| 48 }, | 51 }, |
| 49 | 52 |
| 50 /** | 53 _update: function() |
| 51 * @param {string} encodedPicture | |
| 52 */ | |
| 53 _innerSetPicture: function(encodedPicture) | |
| 54 { | 54 { |
| 55 WebInspector.PaintProfilerSnapshot.load(encodedPicture, onSnapshotLoaded
.bind(this)); | 55 var target = this._weakTarget.get(); |
| 56 if (!target) |
| 57 return; |
| 58 WebInspector.PaintProfilerSnapshot.load(target, this._picture, onSnapsho
tLoaded.bind(this)); |
| 56 /** | 59 /** |
| 57 * @param {?WebInspector.PaintProfilerSnapshot} snapshot | 60 * @param {?WebInspector.PaintProfilerSnapshot} snapshot |
| 58 * @this WebInspector.TimelinePaintProfilerView | 61 * @this WebInspector.TimelinePaintProfilerView |
| 59 */ | 62 */ |
| 60 function onSnapshotLoaded(snapshot) | 63 function onSnapshotLoaded(snapshot) |
| 61 { | 64 { |
| 65 this._disposeSnapshot(); |
| 62 this._lastLoadedSnapshot = snapshot; | 66 this._lastLoadedSnapshot = snapshot; |
| 63 snapshot.commandLog(onCommandLogDone.bind(this, snapshot)); | 67 snapshot.commandLog(onCommandLogDone.bind(this, snapshot)); |
| 64 } | 68 } |
| 65 | 69 |
| 66 /** | 70 /** |
| 67 * @param {!WebInspector.PaintProfilerSnapshot=} snapshot | 71 * @param {!WebInspector.PaintProfilerSnapshot=} snapshot |
| 68 * @param {!Array.<!WebInspector.PaintProfilerLogItem>=} log | 72 * @param {!Array.<!WebInspector.PaintProfilerLogItem>=} log |
| 69 * @this {WebInspector.TimelinePaintProfilerView} | 73 * @this {WebInspector.TimelinePaintProfilerView} |
| 70 */ | 74 */ |
| 71 function onCommandLogDone(snapshot, log) | 75 function onCommandLogDone(snapshot, log) |
| 72 { | 76 { |
| 73 this._logTreeView.setCommandLog(log); | 77 this._logTreeView.setCommandLog(log); |
| 74 this._paintProfilerView.setSnapshotAndLog(snapshot || null, log || [
]); | 78 this._paintProfilerView.setSnapshotAndLog(snapshot || null, log || [
]); |
| 75 } | 79 } |
| 76 }, | 80 }, |
| 77 | 81 |
| 82 _disposeSnapshot: function() |
| 83 { |
| 84 if (!this._lastLoadedSnapshot) |
| 85 return; |
| 86 this._lastLoadedSnapshot.dispose(); |
| 87 this._lastLoadedSnapshot = null; |
| 88 }, |
| 89 |
| 78 _onWindowChanged: function() | 90 _onWindowChanged: function() |
| 79 { | 91 { |
| 80 var window = this._paintProfilerView.windowBoundaries(); | 92 var window = this._paintProfilerView.windowBoundaries(); |
| 81 this._logTreeView.updateWindow(window.left, window.right); | 93 this._logTreeView.updateWindow(window.left, window.right); |
| 82 }, | 94 }, |
| 83 | 95 |
| 84 __proto__: WebInspector.SplitView.prototype | 96 __proto__: WebInspector.SplitView.prototype |
| 85 }; | 97 }; |
| 86 | 98 |
| 87 /** | 99 /** |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 * @param {string=} imageURL | 141 * @param {string=} imageURL |
| 130 */ | 142 */ |
| 131 showImage: function(imageURL) | 143 showImage: function(imageURL) |
| 132 { | 144 { |
| 133 this._imageElement.classList.toggle("hidden", !imageURL); | 145 this._imageElement.classList.toggle("hidden", !imageURL); |
| 134 this._imageElement.src = imageURL; | 146 this._imageElement.src = imageURL; |
| 135 }, | 147 }, |
| 136 | 148 |
| 137 __proto__: WebInspector.View.prototype | 149 __proto__: WebInspector.View.prototype |
| 138 }; | 150 }; |
| OLD | NEW |