| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @param {Element} container Content container. | 8 * @param {Element} container Content container. |
| 9 * @param {cr.ui.ArrayDataModel} dataModel Data model. | 9 * @param {cr.ui.ArrayDataModel} dataModel Data model. |
| 10 * @param {cr.ui.ListSelectionModel} selectionModel Selection model. | 10 * @param {cr.ui.ListSelectionModel} selectionModel Selection model. |
| (...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 return this.rows_[r].getEdgeTileIndex_(direction); | 1277 return this.rows_[r].getEdgeTileIndex_(direction); |
| 1278 } | 1278 } |
| 1279 return -1; | 1279 return -1; |
| 1280 }; | 1280 }; |
| 1281 | 1281 |
| 1282 /** | 1282 /** |
| 1283 * @param {number} index Tile index. | 1283 * @param {number} index Tile index. |
| 1284 * @return {Mosaic.Row} The row containing the tile with a given index. | 1284 * @return {Mosaic.Row} The row containing the tile with a given index. |
| 1285 */ | 1285 */ |
| 1286 Mosaic.Column.prototype.getRowByTileIndex = function(index) { | 1286 Mosaic.Column.prototype.getRowByTileIndex = function(index) { |
| 1287 for (var r = 0; r !== this.rows_.length; r++) | 1287 for (var r = 0; r !== this.rows_.length; r++) { |
| 1288 if (this.rows_[r].hasTile(index)) | 1288 if (this.rows_[r].hasTile(index)) |
| 1289 return this.rows_[r]; | 1289 return this.rows_[r]; |
| 1290 | 1290 } |
| 1291 return null; | 1291 return null; |
| 1292 }; | 1292 }; |
| 1293 | 1293 |
| 1294 /** | 1294 /** |
| 1295 * Adds a tile to the column. | 1295 * Adds a tile to the column. |
| 1296 * | 1296 * |
| 1297 * @param {Mosaic.Tile} tile The tile to add. | 1297 * @param {Mosaic.Tile} tile The tile to add. |
| 1298 */ | 1298 */ |
| 1299 Mosaic.Column.prototype.add = function(tile) { | 1299 Mosaic.Column.prototype.add = function(tile) { |
| 1300 var rowIndex = this.getNextRowIndex(); | 1300 var rowIndex = this.getNextRowIndex(); |
| 1301 | 1301 |
| 1302 if (!this.newRow_) | 1302 if (!this.newRow_) |
| 1303 this.newRow_ = new Mosaic.Row(this.getNextTileIndex()); | 1303 this.newRow_ = new Mosaic.Row(this.getNextTileIndex()); |
| 1304 | 1304 |
| 1305 this.tiles_.push(tile); | 1305 this.tiles_.push(tile); |
| 1306 this.newRow_.add(tile); | 1306 this.newRow_.add(tile); |
| 1307 | 1307 |
| 1308 if (this.density_.isRowComplete(this.newRow_.getTileCount(), rowIndex)) { | 1308 if (this.density_.isRowComplete(this.newRow_.getTileCount(), rowIndex)) { |
| 1309 this.rows_.push(this.newRow_); | 1309 this.rows_.push(this.newRow_); |
| 1310 this.newRow_ = null; | 1310 this.newRow_ = null; |
| 1311 } | 1311 } |
| 1312 }; | 1312 }; |
| 1313 | 1313 |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 | 1763 |
| 1764 // If no hidpi embedded thumbnail available, then use the low resolution | 1764 // If no hidpi embedded thumbnail available, then use the low resolution |
| 1765 // for preloading. | 1765 // for preloading. |
| 1766 if (!this.hidpiEmbedded_) { | 1766 if (!this.hidpiEmbedded_) { |
| 1767 this.thumbnailPreloader_ = new ThumbnailLoader( | 1767 this.thumbnailPreloader_ = new ThumbnailLoader( |
| 1768 this.getItem().getEntry(), | 1768 this.getItem().getEntry(), |
| 1769 ThumbnailLoader.LoaderType.CANVAS, | 1769 ThumbnailLoader.LoaderType.CANVAS, |
| 1770 metadata, | 1770 metadata, |
| 1771 undefined, // Media type. | 1771 undefined, // Media type. |
| 1772 ThumbnailLoader.UseEmbedded.USE_EMBEDDED, | 1772 ThumbnailLoader.UseEmbedded.USE_EMBEDDED, |
| 1773 2); // Preloaders have always higher priotity, so the preload images | 1773 // Preloaders have always higher priotity, so the preload images |
| 1774 // are loaded as soon as possible. | 1774 // are loaded as soon as possible. |
| 1775 2); |
| 1775 } | 1776 } |
| 1776 | 1777 |
| 1777 // Dimensions are always acquired from the metadata. For local files, it is | 1778 // Dimensions are always acquired from the metadata. For local files, it is |
| 1778 // extracted from headers. For Drive files, it is received via the Drive API. | 1779 // extracted from headers. For Drive files, it is received via the Drive API. |
| 1779 // If the dimensions are not available, then the fallback dimensions will be | 1780 // If the dimensions are not available, then the fallback dimensions will be |
| 1780 // used (same as for the generic icon). | 1781 // used (same as for the generic icon). |
| 1781 var width; | 1782 var width; |
| 1782 var height; | 1783 var height; |
| 1783 if (metadata.media && metadata.media.width) { | 1784 if (metadata.media && metadata.media.width) { |
| 1784 width = metadata.media.width; | 1785 width = metadata.media.width; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 return new Rect(this.left_ - this.container_.scrollLeft, this.top_, | 1979 return new Rect(this.left_ - this.container_.scrollLeft, this.top_, |
| 1979 this.width_, this.height_).inflate(-margin, -margin); | 1980 this.width_, this.height_).inflate(-margin, -margin); |
| 1980 }; | 1981 }; |
| 1981 | 1982 |
| 1982 /** | 1983 /** |
| 1983 * @return {number} X coordinate of the tile center. | 1984 * @return {number} X coordinate of the tile center. |
| 1984 */ | 1985 */ |
| 1985 Mosaic.Tile.prototype.getCenterX = function() { | 1986 Mosaic.Tile.prototype.getCenterX = function() { |
| 1986 return this.left_ + Math.round(this.width_ / 2); | 1987 return this.left_ + Math.round(this.width_ / 2); |
| 1987 }; | 1988 }; |
| OLD | NEW |