| 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 /** | 5 /** |
| 6 * @param {!Element} container Content container. | 6 * @param {!Element} container Content container. |
| 7 * @param {!ErrorBanner} errorBanner Error banner. | 7 * @param {!ErrorBanner} errorBanner Error banner. |
| 8 * @param {!cr.ui.ArrayDataModel} dataModel Data model. | 8 * @param {!cr.ui.ArrayDataModel} dataModel Data model. |
| 9 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. | 9 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. |
| 10 * @param {!VolumeManager} volumeManager Volume manager. | 10 * @param {!VolumeManager} volumeManager Volume manager. |
| (...skipping 2077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2088 // are loaded as soon as possible. | 2088 // are loaded as soon as possible. |
| 2089 2); | 2089 2); |
| 2090 if (!this.thumbnailPreloader_.getLoadTarget()) | 2090 if (!this.thumbnailPreloader_.getLoadTarget()) |
| 2091 this.thumbnailPreloader_ = null; | 2091 this.thumbnailPreloader_ = null; |
| 2092 } | 2092 } |
| 2093 | 2093 |
| 2094 // Dimensions are always acquired from the metadata. For local files, it is | 2094 // Dimensions are always acquired from the metadata. For local files, it is |
| 2095 // extracted from headers. For Drive files, it is received via the Drive API. | 2095 // extracted from headers. For Drive files, it is received via the Drive API. |
| 2096 // If the dimensions are not available, then the fallback dimensions will be | 2096 // If the dimensions are not available, then the fallback dimensions will be |
| 2097 // used (same as for the generic icon). | 2097 // used (same as for the generic icon). |
| 2098 var metadataItem = this.getItem().getMetadataItem(); |
| 2098 var width; | 2099 var width; |
| 2099 var height; | 2100 var height; |
| 2100 if (metadata.media && metadata.media.width) { | 2101 if (metadataItem.imageWidth && metadataItem.imageHeight) { |
| 2101 width = metadata.media.width; | 2102 width = metadataItem.imageWidth; |
| 2102 height = metadata.media.height; | 2103 height = metadataItem.imageHeight; |
| 2103 } else if (metadata.external && metadata.external.imageWidth && | |
| 2104 metadata.external.imageHeight) { | |
| 2105 width = metadata.external.imageWidth; | |
| 2106 height = metadata.external.imageHeight; | |
| 2107 } else { | 2104 } else { |
| 2108 // No dimensions in metadata, then use the generic dimensions. | 2105 // No dimensions in metadata, then use the generic dimensions. |
| 2109 width = Mosaic.Tile.GENERIC_ICON_SIZE; | 2106 width = Mosaic.Tile.GENERIC_ICON_SIZE; |
| 2110 height = Mosaic.Tile.GENERIC_ICON_SIZE; | 2107 height = Mosaic.Tile.GENERIC_ICON_SIZE; |
| 2111 } | 2108 } |
| 2112 | 2109 |
| 2113 if (width > height) { | 2110 if (width > height) { |
| 2114 if (width > Mosaic.Tile.MAX_CONTENT_SIZE) { | 2111 if (width > Mosaic.Tile.MAX_CONTENT_SIZE) { |
| 2115 height = Math.round(height * Mosaic.Tile.MAX_CONTENT_SIZE / width); | 2112 height = Math.round(height * Mosaic.Tile.MAX_CONTENT_SIZE / width); |
| 2116 width = Mosaic.Tile.MAX_CONTENT_SIZE; | 2113 width = Mosaic.Tile.MAX_CONTENT_SIZE; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2313 return new ImageRect(this.left_ - this.container_.scrollLeft, this.top_, | 2310 return new ImageRect(this.left_ - this.container_.scrollLeft, this.top_, |
| 2314 this.width_, this.height_).inflate(-margin, -margin); | 2311 this.width_, this.height_).inflate(-margin, -margin); |
| 2315 }; | 2312 }; |
| 2316 | 2313 |
| 2317 /** | 2314 /** |
| 2318 * @return {number} X coordinate of the tile center. | 2315 * @return {number} X coordinate of the tile center. |
| 2319 */ | 2316 */ |
| 2320 Mosaic.Tile.prototype.getCenterX = function() { | 2317 Mosaic.Tile.prototype.getCenterX = function() { |
| 2321 return this.left_ + Math.round(this.width_ / 2); | 2318 return this.left_ + Math.round(this.width_ / 2); |
| 2322 }; | 2319 }; |
| OLD | NEW |