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