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 | |
5 /** | 4 /** |
6 * @constructor | 5 * @unrestricted |
7 * @extends {WebInspector.VBox} | |
8 */ | 6 */ |
9 WebInspector.ElementsSidebarPane = function() | 7 WebInspector.ElementsSidebarPane = class extends WebInspector.VBox { |
10 { | 8 constructor() { |
11 WebInspector.VBox.call(this); | 9 super(); |
12 this.element.classList.add("flex-none"); | 10 this.element.classList.add('flex-none'); |
13 this._computedStyleModel = new WebInspector.ComputedStyleModel(); | 11 this._computedStyleModel = new WebInspector.ComputedStyleModel(); |
14 this._computedStyleModel.addEventListener(WebInspector.ComputedStyleModel.Ev
ents.ComputedStyleChanged, this.onCSSModelChanged, this); | 12 this._computedStyleModel.addEventListener( |
| 13 WebInspector.ComputedStyleModel.Events.ComputedStyleChanged, this.onCSSM
odelChanged, this); |
15 | 14 |
16 this._updateThrottler = new WebInspector.Throttler(100); | 15 this._updateThrottler = new WebInspector.Throttler(100); |
17 this._updateWhenVisible = false; | 16 this._updateWhenVisible = false; |
18 }; | 17 } |
19 | 18 |
20 WebInspector.ElementsSidebarPane.prototype = { | 19 /** |
21 /** | 20 * @return {?WebInspector.DOMNode} |
22 * @return {?WebInspector.DOMNode} | 21 */ |
23 */ | 22 node() { |
24 node: function() | 23 return this._computedStyleModel.node(); |
25 { | 24 } |
26 return this._computedStyleModel.node(); | 25 |
27 }, | 26 /** |
| 27 * @return {?WebInspector.CSSModel} |
| 28 */ |
| 29 cssModel() { |
| 30 return this._computedStyleModel.cssModel(); |
| 31 } |
| 32 |
| 33 /** |
| 34 * @protected |
| 35 * @return {!Promise.<?>} |
| 36 */ |
| 37 doUpdate() { |
| 38 return Promise.resolve(); |
| 39 } |
| 40 |
| 41 update() { |
| 42 this._updateWhenVisible = !this.isShowing(); |
| 43 if (this._updateWhenVisible) |
| 44 return; |
| 45 this._updateThrottler.schedule(innerUpdate.bind(this)); |
28 | 46 |
29 /** | 47 /** |
30 * @return {?WebInspector.CSSModel} | 48 * @return {!Promise.<?>} |
| 49 * @this {WebInspector.ElementsSidebarPane} |
31 */ | 50 */ |
32 cssModel: function() | 51 function innerUpdate() { |
33 { | 52 return this.isShowing() ? this.doUpdate() : Promise.resolve(); |
34 return this._computedStyleModel.cssModel(); | 53 } |
35 }, | 54 } |
36 | 55 |
37 /** | 56 /** |
38 * @protected | 57 * @override |
39 * @return {!Promise.<?>} | 58 */ |
40 */ | 59 wasShown() { |
41 doUpdate: function() | 60 super.wasShown(); |
42 { | 61 if (this._updateWhenVisible) |
43 return Promise.resolve(); | 62 this.update(); |
44 }, | 63 } |
45 | 64 |
46 update: function() | 65 /** |
47 { | 66 * @param {!WebInspector.Event} event |
48 this._updateWhenVisible = !this.isShowing(); | 67 */ |
49 if (this._updateWhenVisible) | 68 onCSSModelChanged(event) { |
50 return; | 69 } |
51 this._updateThrottler.schedule(innerUpdate.bind(this)); | |
52 | |
53 /** | |
54 * @return {!Promise.<?>} | |
55 * @this {WebInspector.ElementsSidebarPane} | |
56 */ | |
57 function innerUpdate() | |
58 { | |
59 return this.isShowing() ? this.doUpdate() : Promise.resolve(); | |
60 } | |
61 }, | |
62 | |
63 wasShown: function() | |
64 { | |
65 WebInspector.VBox.prototype.wasShown.call(this); | |
66 if (this._updateWhenVisible) | |
67 this.update(); | |
68 }, | |
69 | |
70 /** | |
71 * @param {!WebInspector.Event} event | |
72 */ | |
73 onCSSModelChanged: function(event) { }, | |
74 | |
75 __proto__: WebInspector.VBox.prototype | |
76 }; | 70 }; |
OLD | NEW |