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
3 // found in the LICENSE file.
7 * @extends {WebInspector.Widget}
9 WebInspector
.ThrottledWidget = function()
11 WebInspector
.Widget
.call(this);
12 this._updateThrottler
= new WebInspector
.Throttler(100);
13 this._updateWhenVisible
= false;
16 WebInspector
.ThrottledWidget
.prototype = {
19 * @return {!Promise.<?>}
23 return Promise
.resolve();
28 this._updateWhenVisible
= !this.isShowing();
29 if (this._updateWhenVisible
)
31 this._updateThrottler
.schedule(innerUpdate
.bind(this));
34 * @this {WebInspector.ThrottledWidget}
35 * @return {!Promise.<?>}
37 function innerUpdate()
39 if (this.isShowing()) {
40 return this.doUpdate();
42 this._updateWhenVisible
= true;
43 return Promise
.resolve();
53 WebInspector
.Widget
.prototype.wasShown
.call(this);
54 if (this._updateWhenVisible
)
58 __proto__
: WebInspector
.Widget
.prototype