| 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 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1776 | 1776 |
| 1777 // Dimensions are always acquired from the metadata. For local files, it is | 1777 // 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. | 1778 // 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 | 1779 // If the dimensions are not available, then the fallback dimensions will be |
| 1780 // used (same as for the generic icon). | 1780 // used (same as for the generic icon). |
| 1781 var width; | 1781 var width; |
| 1782 var height; | 1782 var height; |
| 1783 if (metadata.media && metadata.media.width) { | 1783 if (metadata.media && metadata.media.width) { |
| 1784 width = metadata.media.width; | 1784 width = metadata.media.width; |
| 1785 height = metadata.media.height; | 1785 height = metadata.media.height; |
| 1786 } else if (metadata.drive && metadata.drive.imageWidth && | 1786 } else if (metadata.external && metadata.external.imageWidth && |
| 1787 metadata.drive.imageHeight) { | 1787 metadata.external.imageHeight) { |
| 1788 width = metadata.drive.imageWidth; | 1788 width = metadata.external.imageWidth; |
| 1789 height = metadata.drive.imageHeight; | 1789 height = metadata.external.imageHeight; |
| 1790 } else { | 1790 } else { |
| 1791 // No dimensions in metadata, then use the generic dimensions. | 1791 // No dimensions in metadata, then use the generic dimensions. |
| 1792 width = Mosaic.Tile.GENERIC_ICON_SIZE; | 1792 width = Mosaic.Tile.GENERIC_ICON_SIZE; |
| 1793 height = Mosaic.Tile.GENERIC_ICON_SIZE; | 1793 height = Mosaic.Tile.GENERIC_ICON_SIZE; |
| 1794 } | 1794 } |
| 1795 | 1795 |
| 1796 if (width > height) { | 1796 if (width > height) { |
| 1797 if (width > Mosaic.Tile.MAX_CONTENT_SIZE) { | 1797 if (width > Mosaic.Tile.MAX_CONTENT_SIZE) { |
| 1798 height = Math.round(height * Mosaic.Tile.MAX_CONTENT_SIZE / width); | 1798 height = Math.round(height * Mosaic.Tile.MAX_CONTENT_SIZE / width); |
| 1799 width = Mosaic.Tile.MAX_CONTENT_SIZE; | 1799 width = Mosaic.Tile.MAX_CONTENT_SIZE; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 return new Rect(this.left_ - this.container_.scrollLeft, this.top_, | 1978 return new Rect(this.left_ - this.container_.scrollLeft, this.top_, |
| 1979 this.width_, this.height_).inflate(-margin, -margin); | 1979 this.width_, this.height_).inflate(-margin, -margin); |
| 1980 }; | 1980 }; |
| 1981 | 1981 |
| 1982 /** | 1982 /** |
| 1983 * @return {number} X coordinate of the tile center. | 1983 * @return {number} X coordinate of the tile center. |
| 1984 */ | 1984 */ |
| 1985 Mosaic.Tile.prototype.getCenterX = function() { | 1985 Mosaic.Tile.prototype.getCenterX = function() { |
| 1986 return this.left_ + Math.round(this.width_ / 2); | 1986 return this.left_ + Math.round(this.width_ / 2); |
| 1987 }; | 1987 }; |
| OLD | NEW |