| 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 * The overlay displaying the image. | 6 * The overlay displaying the image. |
| 7 * | 7 * |
| 8 * @param {!HTMLElement} container The container element. | 8 * @param {!HTMLElement} container The container element. |
| 9 * @param {!Viewport} viewport The viewport. | 9 * @param {!Viewport} viewport The viewport. |
| 10 * @param {!MetadataModel} metadataModel | 10 * @param {!MetadataModel} metadataModel |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 if (!(effect instanceof ImageView.Effect.None)) { | 353 if (!(effect instanceof ImageView.Effect.None)) { |
| 354 // Skip effects when reloading repeatedly very quickly. | 354 // Skip effects when reloading repeatedly very quickly. |
| 355 var time = Date.now(); | 355 var time = Date.now(); |
| 356 if (this.lastLoadTime_ && | 356 if (this.lastLoadTime_ && |
| 357 (time - this.lastLoadTime_) < ImageView.FAST_SCROLL_INTERVAL) { | 357 (time - this.lastLoadTime_) < ImageView.FAST_SCROLL_INTERVAL) { |
| 358 effect = new ImageView.Effect.None(); | 358 effect = new ImageView.Effect.None(); |
| 359 } | 359 } |
| 360 this.lastLoadTime_ = time; | 360 this.lastLoadTime_ = time; |
| 361 } | 361 } |
| 362 | 362 |
| 363 ImageUtil.metrics.startInterval(ImageUtil.getMetricName('DisplayTime')); | 363 metrics.startInterval(ImageUtil.getMetricName('DisplayTime')); |
| 364 | 364 |
| 365 var self = this; | 365 var self = this; |
| 366 | 366 |
| 367 this.contentItem_ = item; | 367 this.contentItem_ = item; |
| 368 this.contentRevision_ = -1; | 368 this.contentRevision_ = -1; |
| 369 | 369 |
| 370 switch (ImageView.getLoadTarget(item, effect)) { | 370 switch (ImageView.getLoadTarget(item, effect)) { |
| 371 case ImageView.LoadTarget.CACHED_MAIN_IMAGE: | 371 case ImageView.LoadTarget.CACHED_MAIN_IMAGE: |
| 372 displayMainImage( | 372 displayMainImage( |
| 373 ImageView.LoadType.CACHED_FULL, | 373 ImageView.LoadType.CACHED_FULL, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 var animationDuration = 0; | 462 var animationDuration = 0; |
| 463 if (!(previewShown && loadType === ImageView.LoadType.ERROR)) { | 463 if (!(previewShown && loadType === ImageView.LoadType.ERROR)) { |
| 464 var replaceEffect = previewShown ? null : effect; | 464 var replaceEffect = previewShown ? null : effect; |
| 465 animationDuration = replaceEffect ? replaceEffect.getSafeInterval() : 0; | 465 animationDuration = replaceEffect ? replaceEffect.getSafeInterval() : 0; |
| 466 self.replace(content, replaceEffect); | 466 self.replace(content, replaceEffect); |
| 467 if (!previewShown && displayCallback) displayCallback(); | 467 if (!previewShown && displayCallback) displayCallback(); |
| 468 } | 468 } |
| 469 | 469 |
| 470 if (loadType !== ImageView.LoadType.ERROR && | 470 if (loadType !== ImageView.LoadType.ERROR && |
| 471 loadType !== ImageView.LoadType.CACHED_SCREEN) { | 471 loadType !== ImageView.LoadType.CACHED_SCREEN) { |
| 472 ImageUtil.metrics.recordInterval(ImageUtil.getMetricName('DisplayTime')); | 472 metrics.recordInterval(ImageUtil.getMetricName('DisplayTime')); |
| 473 } | 473 } |
| 474 ImageUtil.metrics.recordEnum(ImageUtil.getMetricName('LoadMode'), | 474 metrics.recordEnum(ImageUtil.getMetricName('LoadMode'), |
| 475 loadType, Object.keys(ImageView.LoadType).length); | 475 loadType, Object.keys(ImageView.LoadType).length); |
| 476 | 476 |
| 477 if (loadType === ImageView.LoadType.ERROR && | 477 if (loadType === ImageView.LoadType.ERROR && |
| 478 !navigator.onLine && !item.getMetadataItem().present) { | 478 !navigator.onLine && !item.getMetadataItem().present) { |
| 479 loadType = ImageView.LoadType.OFFLINE; | 479 loadType = ImageView.LoadType.OFFLINE; |
| 480 } | 480 } |
| 481 if (loadCallback) loadCallback(loadType, animationDuration, opt_error); | 481 if (loadCallback) loadCallback(loadType, animationDuration, opt_error); |
| 482 } | 482 } |
| 483 }; | 483 }; |
| 484 | 484 |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 | 966 |
| 967 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; | 967 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; |
| 968 | 968 |
| 969 /** | 969 /** |
| 970 * @override | 970 * @override |
| 971 */ | 971 */ |
| 972 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { | 972 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { |
| 973 return viewport.getRotatingTransformation( | 973 return viewport.getRotatingTransformation( |
| 974 element.width, element.height, this.orientation_ ? -1 : 1); | 974 element.width, element.height, this.orientation_ ? -1 : 1); |
| 975 }; | 975 }; |
| OLD | NEW |