Chromium Code Reviews| Index: ui/file_manager/gallery/js/image_editor/image_view.js |
| diff --git a/ui/file_manager/gallery/js/image_editor/image_view.js b/ui/file_manager/gallery/js/image_editor/image_view.js |
| index 6e7b8287181a08ab6390ee087352acc80080100b..1076ef649403e1409cfb61ac4e37e2c29868a888 100644 |
| --- a/ui/file_manager/gallery/js/image_editor/image_view.js |
| +++ b/ui/file_manager/gallery/js/image_editor/image_view.js |
| @@ -5,17 +5,25 @@ |
| /** |
| * The overlay displaying the image. |
| * |
| - * @param {HTMLElement} container The container element. |
| - * @param {Viewport} viewport The viewport. |
| + * @param {!HTMLElement} container The container element. |
| + * @param {!Viewport} viewport The viewport. |
| * @constructor |
| * @extends {ImageBuffer.Overlay} |
| + * @struct |
| */ |
| function ImageView(container, viewport) { |
| ImageBuffer.Overlay.call(this); |
| this.container_ = container; |
| + |
| + /** |
| + * The viewport. |
| + * @type {!Viewport} |
| + * @private |
| + */ |
| this.viewport_ = viewport; |
| - this.document_ = container.ownerDocument; |
| + |
| + this.document_ = assertInstanceof(container.ownerDocument, HTMLDocument); |
| this.contentGeneration_ = 0; |
| this.displayedContentGeneration_ = 0; |
| @@ -28,53 +36,93 @@ function ImageView(container, viewport) { |
| /** |
| * The element displaying the current content. |
| - * |
| * @type {HTMLCanvasElement} |
| * @private |
| */ |
| this.screenImage_ = null; |
| + |
| + /** |
| + * The content canvas element. |
| + * @type {(HTMLCanvasElement|Image)} |
| + * @private |
| + */ |
| + this.contentCanvas_ = null; |
| + |
| + /** |
| + * True if the image is a preview (not full res). |
| + * @type {boolean} |
| + * @private |
| + */ |
| + this.preview_ = false; |
| + |
| + /** |
| + * Cached thumbnail image. |
| + * @type {HTMLCanvasElement} |
| + * @private |
| + */ |
| + this.thumbnailCanvas_ = null; |
| + |
| + /** |
| + * The content revision number. |
| + * @type {number} |
| + * @private |
| + */ |
| + this.contentRevision_ = -1; |
| + |
| + /** |
| + * The last load time. |
| + * @type {?number} |
| + * @private |
| + */ |
| + this.lastLoadTime_ = null; |
| + |
| + /** |
| + * Gallery item which is loaded. |
| + * @type {Gallery.Item} |
| + * @private |
| + */ |
| + this.contentItem_ = null; |
| + |
| + /** |
| + * Timer to unload. |
| + * @type {?number} |
| + * @private |
| + */ |
| + this.unloadTimer_ = null; |
| } |
| /** |
| * Duration of transition between modes in ms. |
| + * @type {number} |
| + * @const |
| */ |
| ImageView.MODE_TRANSITION_DURATION = 350; |
| /** |
| * If the user flips though images faster than this interval we do not apply |
| * the slide-in/slide-out transition. |
| + * @type {number} |
| + * @const |
| */ |
| ImageView.FAST_SCROLL_INTERVAL = 300; |
| -/** |
| - * Image load type: full resolution image loaded from cache. |
| - */ |
| -ImageView.LOAD_TYPE_CACHED_FULL = 0; |
| - |
| -/** |
| - * Image load type: screen resolution preview loaded from cache. |
| - */ |
| -ImageView.LOAD_TYPE_CACHED_SCREEN = 1; |
| - |
| -/** |
| - * Image load type: image read from file. |
| - */ |
| -ImageView.LOAD_TYPE_IMAGE_FILE = 2; |
| - |
| -/** |
| - * Image load type: error occurred. |
| - */ |
| -ImageView.LOAD_TYPE_ERROR = 3; |
| - |
| -/** |
| - * Image load type: the file contents is not available offline. |
| - */ |
| -ImageView.LOAD_TYPE_OFFLINE = 4; |
| /** |
| - * The total number of load types. |
| + * Enum for image load types. |
| + * @enum {number} |
| */ |
| -ImageView.LOAD_TYPE_TOTAL = 5; |
| +ImageView.LoadType = { |
| + // Full resolution image loaded from cache. |
| + CACHED_FULL: 0, |
| + // Screen resolution preview loaded from cache. |
| + CACHED_SCREEN: 1, |
| + // Image read from file. |
| + IMAGE_FILE: 2, |
| + // Error occurred. |
| + ERROR: 3, |
| + // The file contents is not available offline. |
| + OFFLINE: 4 |
| +}; |
| ImageView.prototype = {__proto__: ImageBuffer.Overlay.prototype}; |
| @@ -89,12 +137,12 @@ ImageView.prototype.getZIndex = function() { return -1; }; |
| ImageView.prototype.draw = function() { |
| if (!this.contentCanvas_) // Do nothing if the image content is not set. |
| return; |
| - if (this.setupDeviceBuffer(this.screenImage_) || |
| + if ((this.screenImage_ && this.setupDeviceBuffer(this.screenImage_)) || |
| this.displayedContentGeneration_ !== this.contentGeneration_) { |
| this.displayedContentGeneration_ = this.contentGeneration_; |
| ImageUtil.trace.resetTimer('paint'); |
| this.paintDeviceRect( |
| - this.contentCanvas_, new ImageRect(this.contentCanvas_)); |
| + this.contentCanvas_, ImageRect.createFromCanvas(this.contentCanvas_)); |
| ImageUtil.trace.reportTimer('paint'); |
| } |
| }; |
| @@ -136,7 +184,7 @@ ImageView.prototype.getCanvas = function() { return this.contentCanvas_; }; |
| * @return {boolean} True if the a valid image is currently loaded. |
| */ |
| ImageView.prototype.hasValidImage = function() { |
| - return !this.preview_ && this.contentCanvas_ && this.contentCanvas_.width; |
| + return !!(!this.preview_ && this.contentCanvas_ && this.contentCanvas_.width); |
| }; |
| /** |
| @@ -158,9 +206,9 @@ ImageView.prototype.getContentRevision = function() { |
| * Copies an image fragment from a full resolution canvas to a device resolution |
| * canvas. |
| * |
| - * @param {HTMLCanvasElement} canvas Canvas containing whole image. The canvas |
| + * @param {!HTMLCanvasElement} canvas Canvas containing whole image. The canvas |
| * may not be full resolution (scaled). |
| - * @param {ImageRect} imageRect Rectangle region of the canvas to be rendered. |
| + * @param {!ImageRect} imageRect Rectangle region of the canvas to be rendered. |
| */ |
| ImageView.prototype.paintDeviceRect = function(canvas, imageRect) { |
| // Map the rectangle in full resolution image to the rectangle in the device |
| @@ -168,7 +216,7 @@ ImageView.prototype.paintDeviceRect = function(canvas, imageRect) { |
| var deviceBounds = this.viewport_.getDeviceBounds(); |
| var scaleX = deviceBounds.width / canvas.width; |
| var scaleY = deviceBounds.height / canvas.height; |
| - var deviceRect = new ImageRect( |
| + var deviceRect = ImageRect.createWith( |
| imageRect.left * scaleX, |
| imageRect.top * scaleY, |
| imageRect.width * scaleX, |
| @@ -182,10 +230,11 @@ ImageView.prototype.paintDeviceRect = function(canvas, imageRect) { |
| * Creates an overlay canvas with properties similar to the screen canvas. |
| * Useful for showing quick feedback when editing. |
| * |
| - * @return {HTMLCanvasElement} Overlay canvas. |
| + * @return {!HTMLCanvasElement} Overlay canvas. |
| */ |
| ImageView.prototype.createOverlayCanvas = function() { |
| - var canvas = this.document_.createElement('canvas'); |
| + var canvas = assertInstanceof(this.document_.createElement('canvas'), |
| + HTMLCanvasElement); |
| canvas.className = 'image'; |
| this.container_.appendChild(canvas); |
| return canvas; |
| @@ -194,7 +243,7 @@ ImageView.prototype.createOverlayCanvas = function() { |
| /** |
| * Sets up the canvas as a buffer in the device resolution. |
| * |
| - * @param {HTMLCanvasElement} canvas The buffer canvas. |
| + * @param {!HTMLCanvasElement} canvas The buffer canvas. |
| * @return {boolean} True if the canvas needs to be rendered. |
| */ |
| ImageView.prototype.setupDeviceBuffer = function(canvas) { |
| @@ -223,7 +272,7 @@ ImageView.prototype.setupDeviceBuffer = function(canvas) { |
| }; |
| /** |
| - * @return {ImageData} A new ImageData object with a copy of the content. |
| + * @return {!ImageData} A new ImageData object with a copy of the content. |
| */ |
| ImageView.prototype.copyScreenImageData = function() { |
| return this.screenImage_.getContext('2d').getImageData( |
| @@ -250,12 +299,12 @@ ImageView.prototype.cancelLoad = function() { |
| * Loads the thumbnail first, then replaces it with the main image. |
| * Takes into account the image orientation encoded in the metadata. |
| * |
| - * @param {Gallery.Item} item Gallery item to be loaded. |
| - * @param {Object} effect Transition effect object. |
| - * @param {function(number)} displayCallback Called when the image is displayed |
| + * @param {!Gallery.Item} item Gallery item to be loaded. |
| + * @param {ImageView.Effect} effect Transition effect object. |
| + * @param {function()} displayCallback Called when the image is displayed |
| * (possibly as a preview). |
| - * @param {function(number, number, *=)} loadCallback Called when the image is |
| - * fully loaded. The first parameter is the load type. |
| + * @param {function(ImageView.LoadType, number, *=)} loadCallback Called when |
| + * the image is fully loaded. The first parameter is the load type. |
| */ |
| ImageView.prototype.load = |
| function(item, effect, displayCallback, loadCallback) { |
| @@ -281,7 +330,7 @@ ImageView.prototype.load = |
| var cached = item.contentImage; |
| if (cached) { |
| - displayMainImage(ImageView.LOAD_TYPE_CACHED_FULL, |
| + displayMainImage(ImageView.LoadType.CACHED_FULL, |
| false /* no preview */, cached); |
| } else { |
| var cachedScreen = item.screenImage; |
| @@ -291,7 +340,7 @@ ImageView.prototype.load = |
| metadata.external && metadata.external.imageHeight; |
| if (cachedScreen) { |
| // We have a cached screen-scale canvas, use it instead of a thumbnail. |
| - displayThumbnail(ImageView.LOAD_TYPE_CACHED_SCREEN, cachedScreen); |
| + displayThumbnail(ImageView.LoadType.CACHED_SCREEN, cachedScreen); |
| // As far as the user can tell the image is loaded. We still need to load |
| // the full res image to make editing possible, but we can report now. |
| ImageUtil.metrics.recordInterval(ImageUtil.getMetricName('DisplayTime')); |
| @@ -304,15 +353,19 @@ ImageView.prototype.load = |
| ThumbnailLoader.LoaderType.CANVAS, |
| metadata); |
| thumbnailLoader.loadDetachedImage(function(success) { |
| - displayThumbnail(ImageView.LOAD_TYPE_IMAGE_FILE, |
| + displayThumbnail(ImageView.LoadType.IMAGE_FILE, |
| success ? thumbnailLoader.getImage() : null); |
| }); |
| } else { |
| - loadMainImage(ImageView.LOAD_TYPE_IMAGE_FILE, entry, |
| + loadMainImage(ImageView.LoadType.IMAGE_FILE, entry, |
| false /* no preview*/, 0 /* delay */); |
| } |
| } |
| + /** |
| + * @param {ImageView.LoadType} loadType A load type. |
| + * @param {(HTMLCanvasElement|Image)} canvas A canvas. |
| + */ |
| function displayThumbnail(loadType, canvas) { |
| if (canvas) { |
| var width = null; |
| @@ -340,6 +393,12 @@ ImageView.prototype.load = |
| (effect && canvas) ? effect.getSafeInterval() : 0); |
| } |
| + /** |
| + * @param {ImageView.LoadType} loadType Load type. |
| + * @param {Entry} contentEntry A content entry. |
| + * @param {boolean} previewShown A preview is shown or not. |
| + * @param {number} delay Load delay. |
| + */ |
| function loadMainImage(loadType, contentEntry, previewShown, delay) { |
| if (self.prefetchLoader_.isLoading(contentEntry)) { |
| // The image we need is already being prefetched. Initiating another load |
| @@ -361,30 +420,36 @@ ImageView.prototype.load = |
| delay); |
| } |
| + /** |
| + * @param {ImageView.LoadType} loadType Load type. |
| + * @param {boolean} previewShown A preview is shown or not. |
| + * @param {!(HTMLCanvasElement|Image)} content A content. |
| + * @param {string=} opt_error Error message. |
| + */ |
| function displayMainImage(loadType, previewShown, content, opt_error) { |
| if (opt_error) |
| - loadType = ImageView.LOAD_TYPE_ERROR; |
| + loadType = ImageView.LoadType.ERROR; |
| // If we already displayed the preview we should not replace the content if |
| // the full content failed to load. |
| var animationDuration = 0; |
| - if (!(previewShown && loadType === ImageView.LOAD_TYPE_ERROR)) { |
| + if (!(previewShown && loadType === ImageView.LoadType.ERROR)) { |
| var replaceEffect = previewShown ? null : effect; |
| animationDuration = replaceEffect ? replaceEffect.getSafeInterval() : 0; |
| self.replace(content, replaceEffect); |
| if (!previewShown && displayCallback) displayCallback(); |
| } |
| - if (loadType !== ImageView.LOAD_TYPE_ERROR && |
| - loadType !== ImageView.LOAD_TYPE_CACHED_SCREEN) { |
| + if (loadType !== ImageView.LoadType.ERROR && |
| + loadType !== ImageView.LoadType.CACHED_SCREEN) { |
| ImageUtil.metrics.recordInterval(ImageUtil.getMetricName('DisplayTime')); |
| } |
| ImageUtil.metrics.recordEnum(ImageUtil.getMetricName('LoadMode'), |
| - loadType, ImageView.LOAD_TYPE_TOTAL); |
| + loadType, Object.keys(ImageView.LoadType).length); |
| - if (loadType === ImageView.LOAD_TYPE_ERROR && |
| + if (loadType === ImageView.LoadType.ERROR && |
| !navigator.onLine && !metadata.external.present) { |
| - loadType = ImageView.LOAD_TYPE_OFFLINE; |
| + loadType = ImageView.LoadType.OFFLINE; |
| } |
| if (loadCallback) loadCallback(loadType, animationDuration, opt_error); |
| } |
| @@ -392,7 +457,7 @@ ImageView.prototype.load = |
| /** |
| * Prefetches an image. |
| - * @param {Gallery.Item} item The image item. |
| + * @param {!Gallery.Item} item The image item. |
| * @param {number=} opt_delay Image load delay in ms. |
| */ |
| ImageView.prototype.prefetch = function(item, opt_delay) { |
| @@ -429,7 +494,7 @@ ImageView.prototype.unload = function(opt_zoomToRect) { |
| }; |
| /** |
| - * @param {HTMLCanvasElement} content The image element. |
| + * @param {!(HTMLCanvasElement|Image)} content The image element. |
| * @param {number=} opt_width Image width. |
| * @param {number=} opt_height Image height. |
| * @param {boolean=} opt_preview True if the image is a preview (not full res). |
| @@ -441,7 +506,8 @@ ImageView.prototype.replaceContent_ = function( |
| if (this.contentCanvas_ && this.contentCanvas_.parentNode === this.container_) |
| this.container_.removeChild(this.contentCanvas_); |
| - this.screenImage_ = this.document_.createElement('canvas'); |
| + this.screenImage_ = assertInstanceof(this.document_.createElement('canvas'), |
| + HTMLCanvasElement); |
| this.screenImage_.className = 'image'; |
| this.contentCanvas_ = content; |
| @@ -453,7 +519,7 @@ ImageView.prototype.replaceContent_ = function( |
| this.container_.appendChild(this.screenImage_); |
| - this.preview_ = opt_preview; |
| + this.preview_ = opt_preview || false; |
| // If this is not a thumbnail, cache the content and the screen-scale image. |
| if (this.hasValidImage()) { |
| // Insert the full resolution canvas into DOM so that it can be printed. |
| @@ -490,7 +556,7 @@ ImageView.prototype.addContentCallback = function(callback) { |
| /** |
| * Updates the cached thumbnail image. |
| * |
| - * @param {HTMLCanvasElement} canvas The source canvas. |
| + * @param {!HTMLCanvasElement} canvas The source canvas. |
| * @private |
| */ |
| ImageView.prototype.updateThumbnail_ = function(canvas) { |
| @@ -509,8 +575,8 @@ ImageView.prototype.updateThumbnail_ = function(canvas) { |
| /** |
| * Replaces the displayed image, possibly with slide-in animation. |
| * |
| - * @param {HTMLCanvasElement} content The image element. |
| - * @param {Object=} opt_effect Transition effect object. |
| + * @param {!(HTMLCanvasElement|Image)} content The image element. |
| + * @param {ImageView.Effect=} opt_effect Transition effect object. |
| * @param {number=} opt_width Image width. |
| * @param {number=} opt_height Image height. |
| * @param {boolean=} opt_preview True if the image is a preview (not full res). |
| @@ -527,6 +593,7 @@ ImageView.prototype.replace = function( |
| return; |
| } |
| + assert(this.screenImage_); |
| var newScreenImage = this.screenImage_; |
| this.viewport_.resetView(); |
| @@ -544,20 +611,20 @@ ImageView.prototype.replace = function( |
| if (oldScreenImage) { |
| ImageUtil.setAttribute(newScreenImage, 'fade', false); |
| ImageUtil.setAttribute(oldScreenImage, 'fade', true); |
| - console.assert(opt_effect.getReverse, 'Cannot revert an effect.'); |
| var reverse = opt_effect.getReverse(); |
| + assert(reverse); |
| this.setTransform_(oldScreenImage, oldViewport, reverse); |
| setTimeout(function() { |
| if (oldScreenImage.parentNode) |
| oldScreenImage.parentNode.removeChild(oldScreenImage); |
| }, reverse.getSafeInterval()); |
| } |
| - }.bind(this)); |
| + }.bind(this), 0); |
| }; |
| /** |
| - * @param {HTMLCanvasElement} element The element to transform. |
| - * @param {Viewport} viewport Viewport to be used for calculating |
| + * @param {!HTMLCanvasElement} element The element to transform. |
| + * @param {!Viewport} viewport Viewport to be used for calculating |
| * transformation. |
| * @param {ImageView.Effect=} opt_effect The effect to apply. |
| * @param {number=} opt_duration Transition duration. |
| @@ -575,8 +642,8 @@ ImageView.prototype.setTransform_ = function( |
| }; |
| /** |
| - * @param {ImageRect} screenRect Target rectangle in screen coordinates. |
| - * @return {ImageView.Effect.Zoom} Zoom effect object. |
| + * @param {!ImageRect} screenRect Target rectangle in screen coordinates. |
| + * @return {!ImageView.Effect.ZoomToScreen} Zoom effect object. |
| */ |
| ImageView.prototype.createZoomEffect = function(screenRect) { |
| return new ImageView.Effect.ZoomToScreen( |
| @@ -588,14 +655,16 @@ ImageView.prototype.createZoomEffect = function(screenRect) { |
| * Visualizes crop or rotate operation. Hide the old image instantly, animate |
| * the new image to visualize the operation. |
| * |
| - * @param {HTMLCanvasElement} canvas New content canvas. |
| - * @param {ImageRect} imageCropRect The crop rectangle in image coordinates. |
| - * Null for rotation operations. |
| + * @param {!HTMLCanvasElement} canvas New content canvas. |
| + * @param {!ImageRect} imageCropRect The crop rectangle in image coordinates. |
| + * Null for rotation operations. |
| * @param {number} rotate90 Rotation angle in 90 degree increments. |
| * @return {number} Animation duration. |
| */ |
| ImageView.prototype.replaceAndAnimate = function( |
| canvas, imageCropRect, rotate90) { |
| + assert(this.screenImage_); |
| + |
| var oldImageBounds = { |
| width: this.viewport_.getImageBounds().width, |
| height: this.viewport_.getImageBounds().height |
| @@ -626,8 +695,8 @@ ImageView.prototype.replaceAndAnimate = function( |
| * Visualizes "undo crop". Shrink the current image to the given crop rectangle |
| * while fading in the new image. |
| * |
| - * @param {HTMLCanvasElement} canvas New content canvas. |
| - * @param {ImageRect} imageCropRect The crop rectangle in image coordinates. |
| + * @param {!HTMLCanvasElement} canvas New content canvas. |
| + * @param {!ImageRect} imageCropRect The crop rectangle in image coordinates. |
| * @return {number} Animation duration. |
| */ |
| ImageView.prototype.animateAndReplace = function(canvas, imageCropRect) { |
| @@ -661,6 +730,7 @@ ImageView.prototype.animateAndReplace = function(canvas, imageCropRect) { |
| * @param {number} duration Duration in ms. |
| * @param {string=} opt_timing CSS transition timing function name. |
| * @constructor |
| + * @struct |
| */ |
| ImageView.Effect = function(duration, opt_timing) { |
| this.duration_ = duration; |
| @@ -668,12 +738,16 @@ ImageView.Effect = function(duration, opt_timing) { |
| }; |
| /** |
| - * |
| + * Default duration of an effect. |
| + * @type {number} |
| + * @const |
| */ |
| ImageView.Effect.DEFAULT_DURATION = 180; |
| /** |
| - * |
| + * Effect margin. |
| + * @type {number} |
| + * @const |
| */ |
| ImageView.Effect.MARGIN = 100; |
| @@ -691,20 +765,28 @@ ImageView.Effect.prototype.getSafeInterval = function() { |
| }; |
| /** |
| + * Reverses the effect. |
| + * @return {?ImageView.Effect} Reversed effect. Null is returned if this |
|
fukino
2014/12/10 02:54:19
'?' is redundant
yawano
2014/12/10 06:02:49
Done.
|
| + * is not supported in the effect. |
| + */ |
| +ImageView.Effect.prototype.getReverse = function() { |
| + return null; |
| +}; |
| + |
| +/** |
| * @return {string} CSS transition timing function name. |
| */ |
| ImageView.Effect.prototype.getTiming = function() { return this.timing_; }; |
| /** |
| * Obtains the CSS transformation string of the effect. |
| - * @param {HTMLCanvasElement} element Canvas element to be applied the |
| + * @param {!HTMLCanvasElement} element Canvas element to be applied the |
| * transformation. |
| - * @param {Viewport} viewport Current viewport. |
| + * @param {!Viewport} viewport Current viewport. |
| * @return {string} CSS transformation description. |
| */ |
| ImageView.Effect.prototype.transform = function(element, viewport) { |
| throw new Error('Not implemented.'); |
| - return ''; |
| }; |
| /** |
| @@ -712,6 +794,7 @@ ImageView.Effect.prototype.transform = function(element, viewport) { |
| * |
| * @constructor |
| * @extends {ImageView.Effect} |
| + * @struct |
| */ |
| ImageView.Effect.None = function() { |
| ImageView.Effect.call(this, 0, 'easy-out'); |
| @@ -723,8 +806,8 @@ ImageView.Effect.None = function() { |
| ImageView.Effect.None.prototype = { __proto__: ImageView.Effect.prototype }; |
| /** |
| - * @param {HTMLCanvasElement} element Element. |
| - * @param {Viewport} viewport Current viewport. |
| + * @param {!HTMLCanvasElement} element Element. |
| + * @param {!Viewport} viewport Current viewport. |
| * @return {string} Transform string. |
| */ |
| ImageView.Effect.None.prototype.transform = function(element, viewport) { |
| @@ -738,6 +821,7 @@ ImageView.Effect.None.prototype.transform = function(element, viewport) { |
| * @param {boolean=} opt_slow True if slow (as in slideshow). |
| * @constructor |
| * @extends {ImageView.Effect} |
| + * @struct |
| */ |
| ImageView.Effect.Slide = function Slide(direction, opt_slow) { |
| ImageView.Effect.call(this, |
| @@ -751,8 +835,7 @@ ImageView.Effect.Slide = function Slide(direction, opt_slow) { |
| ImageView.Effect.Slide.prototype = { __proto__: ImageView.Effect.prototype }; |
| /** |
| - * Reverses the slide effect. |
| - * @return {ImageView.Effect.Slide} Reversed effect. |
| + * @override |
| */ |
| ImageView.Effect.Slide.prototype.getReverse = function() { |
| return new ImageView.Effect.Slide(-this.direction_, this.slow_); |
| @@ -772,10 +855,12 @@ ImageView.Effect.Slide.prototype.transform = function(element, viewport) { |
| * |
| * @param {number} previousImageWidth Width of the full resolution image. |
| * @param {number} previousImageHeight Height of the full resolution image. |
| - * @param {ImageRect} imageCropRect Crop rectangle in the full resolution image. |
| + * @param {!ImageRect} imageCropRect Crop rectangle in the full resolution |
| + * image. |
| * @param {number=} opt_duration Duration of the effect. |
| * @constructor |
| * @extends {ImageView.Effect} |
| + * @struct |
| */ |
| ImageView.Effect.Zoom = function( |
| previousImageWidth, previousImageHeight, imageCropRect, opt_duration) { |
| @@ -799,14 +884,16 @@ ImageView.Effect.Zoom.prototype.transform = function(element, viewport) { |
| /** |
| * Effect to zoom to a screen rectangle. |
| * |
| - * @param {ImageRect} screenRect Rectangle in the application window's |
| + * @param {!ImageRect} screenRect Rectangle in the application window's |
| * coordinate. |
| * @param {number=} opt_duration Duration of effect. |
| * @constructor |
| * @extends {ImageView.Effect} |
| + * @struct |
| */ |
| ImageView.Effect.ZoomToScreen = function(screenRect, opt_duration) { |
| - ImageView.Effect.call(this, opt_duration); |
| + ImageView.Effect.call(this, opt_duration || |
| + ImageView.Effect.DEFAULT_DURATION); |
| this.screenRect_ = screenRect; |
| }; |
| @@ -829,6 +916,7 @@ ImageView.Effect.ZoomToScreen.prototype.transform = function( |
| * and false is for counterclockwise. |
| * @constructor |
| * @extends {ImageView.Effect} |
| + * @struct |
| */ |
| ImageView.Effect.Rotate = function(orientation) { |
| ImageView.Effect.call(this, ImageView.Effect.DEFAULT_DURATION); |