Chromium Code Reviews| Index: chrome/browser/resources/shared/js/cr/ui/grid.js |
| diff --git a/chrome/browser/resources/shared/js/cr/ui/grid.js b/chrome/browser/resources/shared/js/cr/ui/grid.js |
| index bafb5322b42a3f867ae1dab2ce104ab2a9b5a912..4706ce21022d26e10c718d5780feafdec8d09f47 100644 |
| --- a/chrome/browser/resources/shared/js/cr/ui/grid.js |
| +++ b/chrome/browser/resources/shared/js/cr/ui/grid.js |
| @@ -75,19 +75,29 @@ cr.define('cr.ui', function() { |
| * @override |
| */ |
| get leadItemHeight() { |
| - return this.getItemHeight_(); |
| + return this.getDefaultItemHeight_(); |
| }, |
| set leadItemHeight(height) { |
| // Lead item height cannot be set. |
| }, |
| /** |
| + * Whether or not the rows on list have various heights. |
| + * Shows a warning at the setter because cr.ui.Grid does not support this. |
| + * @type {boolean} |
| + */ |
| + set fixedHeight(fixedHeight) { |
|
arv (Not doing code reviews)
2011/11/21 20:38:01
missing getter
yoshiki
2011/11/28 11:03:31
Done.
|
| + if (!fixedHeight) |
| + console.warn("cr.ui.Grid does not support fixedHeight = false"); |
|
arv (Not doing code reviews)
2011/11/21 20:38:01
Use single quotes
yoshiki
2011/11/28 11:03:31
Done.
|
| + }, |
| + |
| + /** |
| * @return {number} The number of columns determined by width of the grid |
| * and width of the items. |
| * @private |
| */ |
| getColumnCount_: function() { |
| - var size = this.getItemSize_(); |
| + var size = this.getDefaultItemSize_(); |
| var width = size.width + size.marginHorizontal; // Uncollapse margin. |
| return width ? Math.floor(this.clientWidth / width) : 0; |
| }, |
| @@ -117,7 +127,7 @@ cr.define('cr.ui', function() { |
| * @override |
| */ |
| getItemTop: function(index) { |
| - return Math.floor(index / this.columns) * this.getItemHeight_(); |
| + return Math.floor(index / this.columns) * this.getDefaultItemHeight_(); |
| }, |
| /** |
| @@ -151,17 +161,18 @@ cr.define('cr.ui', function() { |
| }, |
| /** |
| - * Calculates the number of items fitting in viewport given the index of |
| - * first item and heights. |
| - * @param {number} itemHeight The height of the item. |
| - * @param {number} firstIndex Index of the first item in viewport. |
| + * Calculates the number of items fitting in the given viewport. |
| * @param {number} scrollTop The scroll top position. |
| - * @return {number} The number of items in view port. |
| + * @param {number} clientHeight The height of viewport. |
| + * @return {{first: number, length: number, last: number}} The index of |
| + * first item in view port, The number of items, The item past the last. |
| * @override |
| */ |
| - getItemsInViewPort: function(itemHeight, firstIndex, scrollTop) { |
| + getItemsInViewPort: function(scrollTop, clientHeight) { |
| + var itemHeight = this.getDefaultItemHeight_(); |
| + var firstIndex = |
| + this.autoExpands ? 0 : this.getIndexForListOffset_(scrollTop); |
| var columns = this.columns; |
| - var clientHeight = this.clientHeight; |
| var count = this.autoExpands_ ? this.dataModel.length : Math.max( |
| columns * (Math.ceil(clientHeight / itemHeight) + 1), |
| this.countItemsInRange_(firstIndex, scrollTop + clientHeight)); |