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

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 10107016: Reduce blinking of icons in the preview panel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment added Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Setting the src of an img to an empty string can crash the browser, so we 5 // Setting the src of an img to an empty string can crash the browser, so we
6 // use an empty 1x1 gif instead. 6 // use an empty 1x1 gif instead.
7 7
8 /** 8 /**
9 * FileManager constructor. 9 * FileManager constructor.
10 * 10 *
(...skipping 2231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 }; 2242 };
2243 2243
2244 if (!selection.indexes.length) { 2244 if (!selection.indexes.length) {
2245 this.updateCommonActionButtons_(); 2245 this.updateCommonActionButtons_();
2246 this.updatePreviewPanelVisibility_(); 2246 this.updatePreviewPanelVisibility_();
2247 cr.dispatchSimpleEvent(this, 'selection-summarized'); 2247 cr.dispatchSimpleEvent(this, 'selection-summarized');
2248 return; 2248 return;
2249 } 2249 }
2250 2250
2251 this.previewSummary_.textContent = str('COMPUTING_SELECTION'); 2251 this.previewSummary_.textContent = str('COMPUTING_SELECTION');
2252 removeChildren(this.previewThumbnails_); 2252 var thumbnails = this.document_.createDocumentFragment();
2253 2253
2254 var fileCount = 0; 2254 var fileCount = 0;
2255 var byteCount = 0; 2255 var byteCount = 0;
2256 var pendingFiles = []; 2256 var pendingFiles = [];
2257 var thumbnailCount = 0; 2257 var thumbnailCount = 0;
2258 var thumbnailLoaded = -1;
2259 var forcedShowTimeout = null;
2260 var self = this;
2261
2262 function showThumbnails() {
2263 if (forcedShowTimeout === null)
2264 return;
2265 clearTimeout(forcedShowTimeout);
2266 forcedShowTimeout = null;
2267
2268 // Selection could change while images are loading.
2269 if (self.selection == selection) {
2270 removeChildren(self.previewThumbnails_);
2271 self.previewThumbnails_.appendChild(thumbnails);
2272 }
2273 }
2274
2275 function onThumbnailLoaded() {
2276 thumbnailLoaded++;
2277 if (thumbnailLoaded == thumbnailCount)
2278 showThumbnails();
2279 }
2258 2280
2259 for (var i = 0; i < selection.indexes.length; i++) { 2281 for (var i = 0; i < selection.indexes.length; i++) {
2260 var entry = this.directoryModel_.fileList.item(selection.indexes[i]); 2282 var entry = this.directoryModel_.fileList.item(selection.indexes[i]);
2261 if (!entry) 2283 if (!entry)
2262 continue; 2284 continue;
2263 2285
2264 selection.entries.push(entry); 2286 selection.entries.push(entry);
2265 selection.urls.push(entry.toURL()); 2287 selection.urls.push(entry.toURL());
2266 2288
2267 if (selection.iconType == null) { 2289 if (selection.iconType == null) {
2268 selection.iconType = this.getIconType(entry); 2290 selection.iconType = this.getIconType(entry);
2269 } else if (selection.iconType != 'unknown') { 2291 } else if (selection.iconType != 'unknown') {
2270 var iconType = this.getIconType(entry); 2292 var iconType = this.getIconType(entry);
2271 if (selection.iconType != iconType) 2293 if (selection.iconType != iconType)
2272 selection.iconType = 'unknown'; 2294 selection.iconType = 'unknown';
2273 } 2295 }
2274 2296
2275 if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) { 2297 if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) {
2276 var box = this.document_.createElement('div'); 2298 var box = this.document_.createElement('div');
2277 var imageLoadCalback = thumbnailCount == 0 && 2299 function imageLoadCalback(index, box, img, transform) {
2278 this.initThumbnailZoom_.bind(this, box); 2300 if (index == 0)
2279 var thumbnail = this.renderThumbnailBox_(entry, true, imageLoadCalback); 2301 self.initThumbnailZoom_(box, img, transform);
2302 onThumbnailLoaded();
2303 }
2304 var thumbnail = this.renderThumbnailBox_(entry, true,
2305 imageLoadCalback.bind(null, thumbnailCount, box));
2306 thumbnailCount++;
2280 box.appendChild(thumbnail); 2307 box.appendChild(thumbnail);
2281 box.style.zIndex = MAX_PREVIEW_THUMBAIL_COUNT + 1 - i; 2308 box.style.zIndex = MAX_PREVIEW_THUMBAIL_COUNT + 1 - i;
2282 box.addEventListener('click', 2309 box.addEventListener('click',
2283 this.dispatchDefaultTask_.bind(this, selection)); 2310 this.dispatchDefaultTask_.bind(this, selection));
2284 2311
2285 this.previewThumbnails_.appendChild(box); 2312 thumbnails.appendChild(box);
2286 thumbnailCount++;
2287 } 2313 }
2288 2314
2289 selection.totalCount++; 2315 selection.totalCount++;
2290 2316
2291 if (entry.isFile) { 2317 if (entry.isFile) {
2292 selection.fileCount += 1; 2318 selection.fileCount += 1;
2293 if (!('cachedSize_' in entry)) { 2319 if (!('cachedSize_' in entry)) {
2294 // Any file that hasn't been rendered may be missing its cachedSize_ 2320 // Any file that hasn't been rendered may be missing its cachedSize_
2295 // property. For example, visit a large file list, and press ctrl-a 2321 // property. For example, visit a large file list, and press ctrl-a
2296 // to select all. In this case, we need to asynchronously get the 2322 // to select all. In this case, we need to asynchronously get the
2297 // sizes for these files before telling the world the selection has 2323 // sizes for these files before telling the world the selection has
2298 // been summarized. See the 'computeNextFile' logic below. 2324 // been summarized. See the 'computeNextFile' logic below.
2299 pendingFiles.push(entry); 2325 pendingFiles.push(entry);
2300 } else { 2326 } else {
2301 selection.bytes += entry.cachedSize_; 2327 selection.bytes += entry.cachedSize_;
2302 selection.showBytes |= this.getFileType(entry).type != 'hosted'; 2328 selection.showBytes |= this.getFileType(entry).type != 'hosted';
2303 } 2329 }
2304 } else { 2330 } else {
2305 selection.directoryCount += 1; 2331 selection.directoryCount += 1;
2306 } 2332 }
2307 } 2333 }
2308 2334
2309 // Now this.selection is complete. Update buttons. 2335 // Now this.selection is complete. Update buttons.
2310 this.updateCommonActionButtons_(); 2336 this.updateCommonActionButtons_();
2311 this.updatePreviewPanelVisibility_(); 2337 this.updatePreviewPanelVisibility_();
2312 2338 forcedShowTimeout = setTimeout(showThumbnails, 100);
2313 var self = this; 2339 onThumbnailLoaded();
2314 2340
2315 function cacheNextFile(fileEntry) { 2341 function cacheNextFile(fileEntry) {
2316 if (fileEntry) { 2342 if (fileEntry) {
2317 // We're careful to modify the 'selection', rather than 'self.selection' 2343 // We're careful to modify the 'selection', rather than 'self.selection'
2318 // here, just in case the selection has changed since this summarization 2344 // here, just in case the selection has changed since this summarization
2319 // began. 2345 // began.
2320 selection.bytes += fileEntry.cachedSize_; 2346 selection.bytes += fileEntry.cachedSize_;
2321 selection.showBytes |= self.getFileType(fileEntry).type != 'hosted'; 2347 selection.showBytes |= self.getFileType(fileEntry).type != 'hosted';
2322 } 2348 }
2323 2349
(...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after
4422 4448
4423 chrome.fileBrowserPrivate.setGDataPreferences(changeInfo); 4449 chrome.fileBrowserPrivate.setGDataPreferences(changeInfo);
4424 4450
4425 if (oldValue) { 4451 if (oldValue) {
4426 event.target.removeAttribute('checked'); 4452 event.target.removeAttribute('checked');
4427 } else { 4453 } else {
4428 event.target.setAttribute('checked', 'checked'); 4454 event.target.setAttribute('checked', 'checked');
4429 } 4455 }
4430 }; 4456 };
4431 })(); 4457 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698