| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.StaticViewportControl = class { | 7 UI.StaticViewportControl = class { |
| 8 /** | 8 /** |
| 9 * @param {!WebInspector.StaticViewportControl.Provider} provider | 9 * @param {!UI.StaticViewportControl.Provider} provider |
| 10 */ | 10 */ |
| 11 constructor(provider) { | 11 constructor(provider) { |
| 12 this.element = createElement('div'); | 12 this.element = createElement('div'); |
| 13 this.element.style.overflow = 'auto'; | 13 this.element.style.overflow = 'auto'; |
| 14 this._innerElement = this.element.createChild('div'); | 14 this._innerElement = this.element.createChild('div'); |
| 15 this._innerElement.style.height = '0px'; | 15 this._innerElement.style.height = '0px'; |
| 16 this._innerElement.style.position = 'relative'; | 16 this._innerElement.style.position = 'relative'; |
| 17 this._innerElement.style.overflow = 'hidden'; | 17 this._innerElement.style.overflow = 'hidden'; |
| 18 | 18 |
| 19 this._provider = provider; | 19 this._provider = provider; |
| 20 this.element.addEventListener('scroll', this._update.bind(this), false); | 20 this.element.addEventListener('scroll', this._update.bind(this), false); |
| 21 this._itemCount = 0; | 21 this._itemCount = 0; |
| 22 this._indexSymbol = Symbol('WebInspector.StaticViewportControl._indexSymbol'
); | 22 this._indexSymbol = Symbol('UI.StaticViewportControl._indexSymbol'); |
| 23 } | 23 } |
| 24 | 24 |
| 25 refresh() { | 25 refresh() { |
| 26 this._itemCount = this._provider.itemCount(); | 26 this._itemCount = this._provider.itemCount(); |
| 27 this._innerElement.removeChildren(); | 27 this._innerElement.removeChildren(); |
| 28 | 28 |
| 29 var height = 0; | 29 var height = 0; |
| 30 this._cumulativeHeights = new Int32Array(this._itemCount); | 30 this._cumulativeHeights = new Int32Array(this._itemCount); |
| 31 for (var i = 0; i < this._itemCount; ++i) { | 31 for (var i = 0; i < this._itemCount; ++i) { |
| 32 height += this._provider.fastItemHeight(i); | 32 height += this._provider.fastItemHeight(i); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 * @return {number} | 134 * @return {number} |
| 135 */ | 135 */ |
| 136 _visibleHeight() { | 136 _visibleHeight() { |
| 137 return this.element.offsetHeight; | 137 return this.element.offsetHeight; |
| 138 } | 138 } |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 /** | 141 /** |
| 142 * @interface | 142 * @interface |
| 143 */ | 143 */ |
| 144 WebInspector.StaticViewportControl.Provider = function() {}; | 144 UI.StaticViewportControl.Provider = function() {}; |
| 145 | 145 |
| 146 WebInspector.StaticViewportControl.Provider.prototype = { | 146 UI.StaticViewportControl.Provider.prototype = { |
| 147 /** | 147 /** |
| 148 * @param {number} index | 148 * @param {number} index |
| 149 * @return {number} | 149 * @return {number} |
| 150 */ | 150 */ |
| 151 fastItemHeight: function(index) { | 151 fastItemHeight: function(index) { |
| 152 return 0; | 152 return 0; |
| 153 }, | 153 }, |
| 154 | 154 |
| 155 /** | 155 /** |
| 156 * @return {number} | 156 * @return {number} |
| 157 */ | 157 */ |
| 158 itemCount: function() { | 158 itemCount: function() { |
| 159 return 0; | 159 return 0; |
| 160 }, | 160 }, |
| 161 | 161 |
| 162 /** | 162 /** |
| 163 * @param {number} index | 163 * @param {number} index |
| 164 * @return {?Element} | 164 * @return {?Element} |
| 165 */ | 165 */ |
| 166 itemElement: function(index) { | 166 itemElement: function(index) { |
| 167 return null; | 167 return null; |
| 168 } | 168 } |
| 169 }; | 169 }; |
| OLD | NEW |