| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.SidebarPane} | 7 * @extends {WebInspector.SidebarPane} |
| 8 * @param {string} title | 8 * @param {string} title |
| 9 */ | 9 */ |
| 10 WebInspector.ElementsSidebarPane = function(title) | 10 WebInspector.ElementsSidebarPane = function(title) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 * @param {?WebInspector.DOMNode} node | 44 * @param {?WebInspector.DOMNode} node |
| 45 */ | 45 */ |
| 46 setNode: function(node) | 46 setNode: function(node) |
| 47 { | 47 { |
| 48 this._node = node; | 48 this._node = node; |
| 49 this._updateTarget(node ? node.target() : null); | 49 this._updateTarget(node ? node.target() : null); |
| 50 this.update(); | 50 this.update(); |
| 51 }, | 51 }, |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * @param {!WebInspector.Throttler.FinishCallback} finishedCallback | |
| 55 * @protected | 54 * @protected |
| 55 * @return {!Promise.<?>} |
| 56 */ | 56 */ |
| 57 doUpdate: function(finishedCallback) | 57 doUpdate: function() |
| 58 { | 58 { |
| 59 finishedCallback(); | 59 return Promise.resolve(); |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 update: function() | 62 update: function() |
| 63 { | 63 { |
| 64 this._updateController.update(); | 64 this._updateController.update(); |
| 65 }, | 65 }, |
| 66 | 66 |
| 67 wasShown: function() | 67 wasShown: function() |
| 68 { | 68 { |
| 69 WebInspector.SidebarPane.prototype.wasShown.call(this); | 69 WebInspector.SidebarPane.prototype.wasShown.call(this); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 onCSSModelChanged: function() { }, | 127 onCSSModelChanged: function() { }, |
| 128 | 128 |
| 129 onFrameResizedThrottled: function() { }, | 129 onFrameResizedThrottled: function() { }, |
| 130 | 130 |
| 131 __proto__: WebInspector.SidebarPane.prototype | 131 __proto__: WebInspector.SidebarPane.prototype |
| 132 } | 132 } |
| 133 | 133 |
| 134 /** | 134 /** |
| 135 * @constructor | 135 * @constructor |
| 136 * @param {!WebInspector.Widget} view | 136 * @param {!WebInspector.Widget} view |
| 137 * @param {function(!WebInspector.Throttler.FinishCallback)} doUpdate | 137 * @param {function():!Promise.<?>} doUpdate |
| 138 */ | 138 */ |
| 139 WebInspector.ElementsSidebarPane._UpdateController = function(view, doUpdate) | 139 WebInspector.ElementsSidebarPane._UpdateController = function(view, doUpdate) |
| 140 { | 140 { |
| 141 this._view = view; | 141 this._view = view; |
| 142 this._updateThrottler = new WebInspector.Throttler(100); | 142 this._updateThrottler = new WebInspector.Throttler(100); |
| 143 this._updateWhenVisible = false; | 143 this._updateWhenVisible = false; |
| 144 this._doUpdate = doUpdate; | 144 this._doUpdate = doUpdate; |
| 145 } | 145 } |
| 146 | 146 |
| 147 WebInspector.ElementsSidebarPane._UpdateController.prototype = { | 147 WebInspector.ElementsSidebarPane._UpdateController.prototype = { |
| 148 update: function() | 148 update: function() |
| 149 { | 149 { |
| 150 this._updateWhenVisible = !this._view.isShowing(); | 150 this._updateWhenVisible = !this._view.isShowing(); |
| 151 if (this._updateWhenVisible) | 151 if (this._updateWhenVisible) |
| 152 return; | 152 return; |
| 153 this._updateThrottler.schedule(innerUpdate.bind(this)); | 153 this._updateThrottler.schedule(innerUpdate.bind(this)); |
| 154 | 154 |
| 155 /** | 155 /** |
| 156 * @param {!WebInspector.Throttler.FinishCallback} finishedCallback | |
| 157 * @this {WebInspector.ElementsSidebarPane._UpdateController} | 156 * @this {WebInspector.ElementsSidebarPane._UpdateController} |
| 157 * @return {!Promise.<?>} |
| 158 */ | 158 */ |
| 159 function innerUpdate(finishedCallback) | 159 function innerUpdate() |
| 160 { | 160 { |
| 161 if (this._view.isShowing()) | 161 return this._view.isShowing() ? this._doUpdate.call(null) : Promise.
resolve(); |
| 162 this._doUpdate.call(null, finishedCallback); | |
| 163 else | |
| 164 finishedCallback(); | |
| 165 } | 162 } |
| 166 }, | 163 }, |
| 167 | 164 |
| 168 viewWasShown: function() | 165 viewWasShown: function() |
| 169 { | 166 { |
| 170 if (this._updateWhenVisible) | 167 if (this._updateWhenVisible) |
| 171 this.update(); | 168 this.update(); |
| 172 } | 169 } |
| 173 } | 170 } |
| OLD | NEW |