Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/ThrottledWidget.js

Issue 2157713002: DevTools: introduce View: a named widget with the toolbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcean Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 /**
6 * @constructor
7 * @extends {WebInspector.Widget}
8 * @param {boolean=} isWebComponent
9 */
10 WebInspector.ThrottledWidget = function(isWebComponent)
11 {
12 WebInspector.Widget.call(this, isWebComponent);
13 this._updateThrottler = new WebInspector.Throttler(100);
14 this._updateWhenVisible = false;
15 }
16
17 WebInspector.ThrottledWidget.prototype = {
18 /**
19 * @protected
20 * @return {!Promise.<?>}
21 */
22 doUpdate: function()
23 {
24 return Promise.resolve();
25 },
26
27 update: function()
28 {
29 this._updateWhenVisible = !this.isShowing();
30 if (this._updateWhenVisible)
31 return;
32 this._updateThrottler.schedule(innerUpdate.bind(this));
33
34 /**
35 * @this {WebInspector.ThrottledWidget}
36 * @return {!Promise.<?>}
37 */
38 function innerUpdate()
39 {
40 if (this.isShowing()) {
41 return this.doUpdate();
42 } else {
43 this._updateWhenVisible = true;
44 return Promise.resolve();
45 }
46 }
47 },
48
49 /**
50 * @override
51 */
52 wasShown: function()
53 {
54 WebInspector.Widget.prototype.wasShown.call(this);
55 if (this._updateWhenVisible)
56 this.update();
57 },
58
59 __proto__: WebInspector.Widget.prototype
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698