| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 }; | 302 }; |
| 303 | 303 |
| 304 /** | 304 /** |
| 305 * Initializes a single tile. | 305 * Initializes a single tile. |
| 306 * | 306 * |
| 307 * @param {Mosaic.Tile} tile Tile. | 307 * @param {Mosaic.Tile} tile Tile. |
| 308 * @param {function()} callback Completion callback. | 308 * @param {function()} callback Completion callback. |
| 309 * @private | 309 * @private |
| 310 */ | 310 */ |
| 311 Mosaic.prototype.initTile_ = function(tile, callback) { | 311 Mosaic.prototype.initTile_ = function(tile, callback) { |
| 312 var url = tile.getItem().getUrl(); | |
| 313 var onImageMeasured = callback; | 312 var onImageMeasured = callback; |
| 314 this.metadataCache_.get(url, Gallery.METADATA_TYPE, | 313 this.metadataCache_.get(tile.getItem().getEntry(), Gallery.METADATA_TYPE, |
| 315 function(metadata) { | 314 function(metadata) { |
| 316 tile.init(metadata, onImageMeasured); | 315 tile.init(metadata, onImageMeasured); |
| 317 }); | 316 }); |
| 318 }; | 317 }; |
| 319 | 318 |
| 320 /** | 319 /** |
| 321 * Reload all tiles. | 320 * Reload all tiles. |
| 322 */ | 321 */ |
| 323 Mosaic.prototype.reload = function() { | 322 Mosaic.prototype.reload = function() { |
| 324 this.layoutModel_.reset_(); | 323 this.layoutModel_.reset_(); |
| (...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 * @param {function()} onImageMeasured Image measured callback. | 1770 * @param {function()} onImageMeasured Image measured callback. |
| 1772 */ | 1771 */ |
| 1773 Mosaic.Tile.prototype.init = function(metadata, onImageMeasured) { | 1772 Mosaic.Tile.prototype.init = function(metadata, onImageMeasured) { |
| 1774 this.markUnloaded(); | 1773 this.markUnloaded(); |
| 1775 this.left_ = null; // Mark as not laid out. | 1774 this.left_ = null; // Mark as not laid out. |
| 1776 | 1775 |
| 1777 // Set higher priority for the selected elements to load them first. | 1776 // Set higher priority for the selected elements to load them first. |
| 1778 var priority = this.getAttribute('selected') ? 2 : 3; | 1777 var priority = this.getAttribute('selected') ? 2 : 3; |
| 1779 | 1778 |
| 1780 // Use embedded thumbnails on Drive, since they have higher resolution. | 1779 // Use embedded thumbnails on Drive, since they have higher resolution. |
| 1781 var hidpiEmbedded = FileType.isOnDrive(this.getItem().getUrl()); | 1780 var hidpiEmbedded = FileType.isOnDrive(this.getItem().getEntry()); |
| 1782 this.thumbnailLoader_ = new ThumbnailLoader( | 1781 this.thumbnailLoader_ = new ThumbnailLoader( |
| 1783 this.getItem().getUrl(), | 1782 this.getItem().getEntry().toURL(), |
| 1784 ThumbnailLoader.LoaderType.CANVAS, | 1783 ThumbnailLoader.LoaderType.CANVAS, |
| 1785 metadata, | 1784 metadata, |
| 1786 undefined, // Media type. | 1785 undefined, // Media type. |
| 1787 hidpiEmbedded ? ThumbnailLoader.UseEmbedded.USE_EMBEDDED : | 1786 hidpiEmbedded ? ThumbnailLoader.UseEmbedded.USE_EMBEDDED : |
| 1788 ThumbnailLoader.UseEmbedded.NO_EMBEDDED, | 1787 ThumbnailLoader.UseEmbedded.NO_EMBEDDED, |
| 1789 priority); | 1788 priority); |
| 1790 | 1789 |
| 1791 // If no hidpi embedded thumbnail available, then use the low resolution | 1790 // If no hidpi embedded thumbnail available, then use the low resolution |
| 1792 // for preloading. | 1791 // for preloading. |
| 1793 if (!hidpiEmbedded) { | 1792 if (!hidpiEmbedded) { |
| 1794 this.thumbnailPreloader_ = new ThumbnailLoader( | 1793 this.thumbnailPreloader_ = new ThumbnailLoader( |
| 1795 this.getItem().getUrl(), | 1794 this.getItem().getEntry().toURL(), |
| 1796 ThumbnailLoader.LoaderType.CANVAS, | 1795 ThumbnailLoader.LoaderType.CANVAS, |
| 1797 metadata, | 1796 metadata, |
| 1798 undefined, // Media type. | 1797 undefined, // Media type. |
| 1799 ThumbnailLoader.UseEmbedded.USE_EMBEDDED, | 1798 ThumbnailLoader.UseEmbedded.USE_EMBEDDED, |
| 1800 2); // Preloaders have always higher priotity, so the preload images | 1799 2); // Preloaders have always higher priotity, so the preload images |
| 1801 // are loaded as soon as possible. | 1800 // are loaded as soon as possible. |
| 1802 } | 1801 } |
| 1803 | 1802 |
| 1804 var setDimensions = function(width, height) { | 1803 var setDimensions = function(width, height) { |
| 1805 if (width > height) { | 1804 if (width > height) { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 return new Rect(this.left_ - this.container_.scrollLeft, this.top_, | 2003 return new Rect(this.left_ - this.container_.scrollLeft, this.top_, |
| 2005 this.width_, this.height_).inflate(-margin, -margin); | 2004 this.width_, this.height_).inflate(-margin, -margin); |
| 2006 }; | 2005 }; |
| 2007 | 2006 |
| 2008 /** | 2007 /** |
| 2009 * @return {number} X coordinate of the tile center. | 2008 * @return {number} X coordinate of the tile center. |
| 2010 */ | 2009 */ |
| 2011 Mosaic.Tile.prototype.getCenterX = function() { | 2010 Mosaic.Tile.prototype.getCenterX = function() { |
| 2012 return this.left_ + Math.round(this.width_ / 2); | 2011 return this.left_ + Math.round(this.width_ / 2); |
| 2013 }; | 2012 }; |
| OLD | NEW |