Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: ui/file_manager/gallery/js/mosaic_mode.js

Issue 976713004: Add thumbnailMetadataItem to GalleryItem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 /** 540 /**
541 * Content change handler. 541 * Content change handler.
542 * 542 *
543 * @param {!Event} event Event. 543 * @param {!Event} event Event.
544 * @private 544 * @private
545 */ 545 */
546 Mosaic.prototype.onContentChange_ = function(event) { 546 Mosaic.prototype.onContentChange_ = function(event) {
547 if (!this.tiles_) 547 if (!this.tiles_)
548 return; 548 return;
549 549
550 if (!event.metadata) 550 if (!event.thumbnailChanged)
551 return; // Thumbnail unchanged, nothing to do. 551 return; // Thumbnail unchanged, nothing to do.
552 552
553 var index = this.dataModel_.indexOf(event.item); 553 var index = this.dataModel_.indexOf(event.item);
554 if (index !== this.selectionModel_.selectedIndex) 554 if (index !== this.selectionModel_.selectedIndex)
555 console.error('Content changed for unselected item'); 555 console.error('Content changed for unselected item');
556 556
557 this.layoutModel_.invalidateFromTile_(index); 557 this.layoutModel_.invalidateFromTile_(index);
558 this.tiles_[index].init(); 558 this.tiles_[index].init();
559 this.tiles_[index].unload(); 559 this.tiles_[index].unload();
560 this.tiles_[index].load( 560 this.tiles_[index].load(
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 this.imageLoaded_ = false; 2047 this.imageLoaded_ = false;
2048 this.imageLoading_ = false; 2048 this.imageLoading_ = false;
2049 } 2049 }
2050 }; 2050 };
2051 2051
2052 /** 2052 /**
2053 * Initializes the thumbnail in the tile. Does not load an image, but sets 2053 * Initializes the thumbnail in the tile. Does not load an image, but sets
2054 * target dimensions using metadata. 2054 * target dimensions using metadata.
2055 */ 2055 */
2056 Mosaic.Tile.prototype.init = function() { 2056 Mosaic.Tile.prototype.init = function() {
2057 var metadata = this.getItem().getMetadata();
2058 this.markUnloaded(); 2057 this.markUnloaded();
2059 this.left_ = null; // Mark as not laid out. 2058 this.left_ = null; // Mark as not laid out.
2060 2059
2061 // Set higher priority for the selected elements to load them first. 2060 // Set higher priority for the selected elements to load them first.
2062 var priority = this.getAttribute('selected') ? 2 : 3; 2061 var priority = this.getAttribute('selected') ? 2 : 3;
2063 2062
2064 // Use embedded thumbnails on Drive, since they have higher resolution. 2063 // Use embedded thumbnails on Drive, since they have higher resolution.
2065 this.thumbnailLoader_ = new ThumbnailLoader( 2064 this.thumbnailLoader_ = new ThumbnailLoader(
2066 this.getItem().getEntry(), 2065 this.getItem().getEntry(),
2067 ThumbnailLoader.LoaderType.CANVAS, 2066 ThumbnailLoader.LoaderType.CANVAS,
2068 metadata, 2067 this.getItem().getThumbnailMetadataItem(),
2069 undefined, // Media type. 2068 undefined, // Media type.
2070 [ 2069 [
2071 ThumbnailLoader.LoadTarget.EXTERNAL_METADATA, 2070 ThumbnailLoader.LoadTarget.EXTERNAL_METADATA,
2072 ThumbnailLoader.LoadTarget.FILE_ENTRY 2071 ThumbnailLoader.LoadTarget.FILE_ENTRY
2073 ]); 2072 ]);
2074 2073
2075 // If no hidpi embedded thumbnail available, then use the low resolution 2074 // If no hidpi embedded thumbnail available, then use the low resolution
2076 // for preloading. 2075 // for preloading.
2077 if (this.thumbnailLoader_.getLoadTarget() === 2076 if (this.thumbnailLoader_.getLoadTarget() ===
2078 ThumbnailLoader.LoadTarget.FILE_ENTRY) { 2077 ThumbnailLoader.LoadTarget.FILE_ENTRY) {
2079 this.thumbnailPreloader_ = new ThumbnailLoader( 2078 this.thumbnailPreloader_ = new ThumbnailLoader(
2080 this.getItem().getEntry(), 2079 this.getItem().getEntry(),
2081 ThumbnailLoader.LoaderType.CANVAS, 2080 ThumbnailLoader.LoaderType.CANVAS,
2082 metadata, 2081 this.getItem().getThumbnailMetadataItem(),
2083 undefined, // Media type. 2082 undefined, // Media type.
2084 [ 2083 [
2085 ThumbnailLoader.LoadTarget.CONTENT_METADATA 2084 ThumbnailLoader.LoadTarget.CONTENT_METADATA
2086 ], 2085 ],
2087 // Preloaders have always higher priotity, so the preload images 2086 // Preloaders have always higher priotity, so the preload images
2088 // are loaded as soon as possible. 2087 // are loaded as soon as possible.
2089 2); 2088 2);
2090 if (!this.thumbnailPreloader_.getLoadTarget()) 2089 if (!this.thumbnailPreloader_.getLoadTarget())
2091 this.thumbnailPreloader_ = null; 2090 this.thumbnailPreloader_ = null;
2092 } 2091 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2310 return new ImageRect(this.left_ - this.container_.scrollLeft, this.top_, 2309 return new ImageRect(this.left_ - this.container_.scrollLeft, this.top_,
2311 this.width_, this.height_).inflate(-margin, -margin); 2310 this.width_, this.height_).inflate(-margin, -margin);
2312 }; 2311 };
2313 2312
2314 /** 2313 /**
2315 * @return {number} X coordinate of the tile center. 2314 * @return {number} X coordinate of the tile center.
2316 */ 2315 */
2317 Mosaic.Tile.prototype.getCenterX = function() { 2316 Mosaic.Tile.prototype.getCenterX = function() {
2318 return this.left_ + Math.round(this.width_ / 2); 2317 return this.left_ + Math.round(this.width_ / 2);
2319 }; 2318 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698