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

Unified Diff: ui/file_manager/file_manager/foreground/js/ui/preview_panel.js

Issue 651403002: Fix trivial type-check errors in file_manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and correct a comment. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/file_manager/foreground/js/ui/preview_panel.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/preview_panel.js b/ui/file_manager/file_manager/foreground/js/ui/preview_panel.js
index 449bdcae2c37e79f56ffe27fed3fb55533d48828..8def6fbf4292138c7812b61d479f7b49e383b26a 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/preview_panel.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/preview_panel.js
@@ -6,7 +6,7 @@
/**
* PreviewPanel UI class.
- * @param {HTMLElement} element DOM Element of preview panel.
+ * @param {Element} element DOM Element of preview panel.
* @param {PreviewPanel.VisibilityType} visibilityType Initial value of the
* visibility type.
* @param {MetadataCache} metadataCache Metadata cache.
@@ -41,7 +41,7 @@ var PreviewPanel = function(element,
/**
* Dom element of the preview panel.
- * @type {HTMLElement}
+ * @type {Element}
* @private
*/
this.element_ = element;
@@ -55,7 +55,7 @@ var PreviewPanel = function(element,
volumeManager);
/**
- * @type {HTMLElement}
+ * @type {Element}
* @private
*/
this.summaryElement_ = element.querySelector('.preview-summary');
@@ -68,7 +68,7 @@ var PreviewPanel = function(element,
this.summaryElement_.querySelector('.calculating-size'));
/**
- * @type {HTMLElement}
+ * @type {Element}
* @private
*/
this.previewText_ = element.querySelector('.preview-text');
@@ -78,7 +78,8 @@ var PreviewPanel = function(element,
* @type {FileSelection}
* @private
*/
- this.selection_ = {entries: [], computeBytes: function() {}};
+ this.selection_ = /** @type {FileSelection} */
+ ({entries: [], computeBytes: function() {}});
/**
* Sequence value that is incremented by every selection update and is used to
@@ -319,13 +320,13 @@ PreviewPanel.prototype.onTransitionEnd_ = function(event) {
*
* This label shows dots and varying the number of dots every
* CalculatingSizeLabel.PERIOD milliseconds.
- * @param {HTMLElement} element DOM element of the label.
+ * @param {Element} element DOM element of the label.
* @constructor
*/
PreviewPanel.CalculatingSizeLabel = function(element) {
this.element_ = element;
this.count_ = 0;
- this.intervalID_ = null;
+ this.intervalID_ = 0;
Object.seal(this);
};
@@ -344,7 +345,7 @@ PreviewPanel.CalculatingSizeLabel.prototype = {
set hidden(hidden) {
this.element_.hidden = hidden;
if (!hidden) {
- if (this.intervalID_ != null)
+ if (this.intervalID_ !== 0)
return;
this.count_ = 2;
this.intervalID_ =
@@ -352,10 +353,10 @@ PreviewPanel.CalculatingSizeLabel.prototype = {
PreviewPanel.CalculatingSizeLabel.PERIOD);
this.onStep_();
} else {
- if (this.intervalID_ == null)
+ if (this.intervalID_ === 0)
return;
clearInterval(this.intervalID_);
- this.intervalID_ = null;
+ this.intervalID_ = 0;
}
}
};
@@ -376,7 +377,7 @@ PreviewPanel.CalculatingSizeLabel.prototype.onStep_ = function() {
/**
* Thumbnails on the preview panel.
*
- * @param {HTMLElement} element DOM Element of thumbnail container.
+ * @param {Element} element DOM Element of thumbnail container.
* @param {MetadataCache} metadataCache MetadataCache.
* @param {VolumeManagerWrapper} volumeManager Volume manager instance.
* @constructor
@@ -410,7 +411,7 @@ PreviewPanel.Thumbnails.ZOOMED_THUMBNAIL_SIZE = 200;
PreviewPanel.Thumbnails.prototype = {
/**
* Sets entries to be displayed in the view.
- * @param {Array.<Entry>} value Entries.
+ * @param {FileSelection} value Entries.
*/
set selection(value) {
this.sequence_++;
@@ -447,14 +448,14 @@ PreviewPanel.Thumbnails.prototype.loadThumbnails_ = function(selection) {
// Load the image.
if (entries[i]) {
- FileGrid.decorateThumbnailBox(box,
- entries[i],
- this.metadataCache_,
- this.volumeManager_,
- ThumbnailLoader.FillMode.FILL,
- FileGrid.ThumbnailQuality.LOW,
- i == 0 && length == 1 &&
- this.setZoomedImage_.bind(this));
+ FileGrid.decorateThumbnailBox(
+ box,
+ entries[i],
+ this.metadataCache_,
+ this.volumeManager_,
+ ThumbnailLoader.FillMode.FILL,
+ FileGrid.ThumbnailQuality.LOW,
+ i == 0 && length == 1 ? this.setZoomedImage_.bind(this) : undefined);
}
// Register the click handler.
@@ -470,11 +471,12 @@ PreviewPanel.Thumbnails.prototype.loadThumbnails_ = function(selection) {
* Create the zoomed version of image and set it to the DOM element to show the
* zoomed image.
*
- * @param {Image} image Image to be source of the zoomed image.
- * @param {Object} transform Transformation to be applied to the image.
+ * @param {HTMLImageElement} image Image to be source of the zoomed image.
+ * @param {Object=} opt_transform Transformation to be applied to the image.
* @private
*/
-PreviewPanel.Thumbnails.prototype.setZoomedImage_ = function(image, transform) {
+PreviewPanel.Thumbnails.prototype.setZoomedImage_ = function(image,
+ opt_transform) {
if (!image)
return;
var width = image.width || 0;
@@ -512,13 +514,14 @@ PreviewPanel.Thumbnails.prototype.setZoomedImage_ = function(image, transform) {
var boxWidth = Math.max(PreviewPanel.Thumbnails.THUMBNAIL_SIZE, imageWidth);
var boxHeight = Math.max(PreviewPanel.Thumbnails.THUMBNAIL_SIZE, imageHeight);
- if (transform && transform.rotate90 % 2 == 1) {
+ if (opt_transform && opt_transform.rotate90 % 2 == 1) {
var t = boxWidth;
boxWidth = boxHeight;
boxHeight = t;
}
- util.applyTransform(zoomedImage, transform);
+ if (opt_transform)
+ util.applyTransform(zoomedImage, opt_transform);
var zoomedBox = this.element_.ownerDocument.createElement('div');
zoomedBox.className = 'popup';

Powered by Google App Engine
This is Rietveld 408576698