summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-24 00:14:31 +0000
committerdpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-24 00:14:31 +0000
commit665c90d0fd758913b3af2e6f30617bc975020b2a (patch)
treef4bd6a50c0790ac3dfd0b607adb6ab0cfa063277 /chrome
parent1a01f956f43bae136878cea7bb786bc95741fb49 (diff)
downloadchromium_src-665c90d0fd758913b3af2e6f30617bc975020b2a.zip
chromium_src-665c90d0fd758913b3af2e6f30617bc975020b2a.tar.gz
chromium_src-665c90d0fd758913b3af2e6f30617bc975020b2a.tar.bz2
Print Preview: Fixing issues reported by closure compiler and gjslint.
The types of errors that were caught are - Use of undeclared variables (silently becoming global vars). - Missing/Incomplete JSDoc comments. - Commas at end of object literals. - Missing semicolons. - One case of wrong use of "else". - Styling (missing spaces). BUG=NONE TEST=NONE Review URL: http://codereview.chromium.org/9138040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118763 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/resources/print_preview/color_settings.js6
-rw-r--r--chrome/browser/resources/print_preview/copies_settings.js4
-rw-r--r--chrome/browser/resources/print_preview/header_footer_settings.js11
-rw-r--r--chrome/browser/resources/print_preview/layout_settings.js4
-rw-r--r--chrome/browser/resources/print_preview/margin_settings.js13
-rw-r--r--chrome/browser/resources/print_preview/margin_textbox.js2
-rw-r--r--chrome/browser/resources/print_preview/margin_utils.js10
-rw-r--r--chrome/browser/resources/print_preview/margins_ui.js15
-rw-r--r--chrome/browser/resources/print_preview/margins_ui_pair.js6
-rw-r--r--chrome/browser/resources/print_preview/page_settings.js9
-rw-r--r--chrome/browser/resources/print_preview/preview_area.js4
-rw-r--r--chrome/browser/resources/print_preview/print_header.js4
-rw-r--r--chrome/browser/resources/print_preview/print_preview_animations.js6
-rw-r--r--chrome/browser/resources/print_preview/print_preview_utils.js41
14 files changed, 72 insertions, 63 deletions
diff --git a/chrome/browser/resources/print_preview/color_settings.js b/chrome/browser/resources/print_preview/color_settings.js
index b389d6b..c1d38cb 100644
--- a/chrome/browser/resources/print_preview/color_settings.js
+++ b/chrome/browser/resources/print_preview/color_settings.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -103,11 +103,11 @@ cr.define('print_preview', function() {
*/
onPDFLoaded_: function() {
setColor(this.colorRadioButton_.checked);
- },
+ }
};
return {
- ColorSettings: ColorSettings,
+ ColorSettings: ColorSettings
};
});
diff --git a/chrome/browser/resources/print_preview/copies_settings.js b/chrome/browser/resources/print_preview/copies_settings.js
index de0f938..09c6e83 100644
--- a/chrome/browser/resources/print_preview/copies_settings.js
+++ b/chrome/browser/resources/print_preview/copies_settings.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -232,6 +232,6 @@ cr.define('print_preview', function() {
};
return {
- CopiesSettings: CopiesSettings,
+ CopiesSettings: CopiesSettings
};
});
diff --git a/chrome/browser/resources/print_preview/header_footer_settings.js b/chrome/browser/resources/print_preview/header_footer_settings.js
index be5cef4..f1155d0 100644
--- a/chrome/browser/resources/print_preview/header_footer_settings.js
+++ b/chrome/browser/resources/print_preview/header_footer_settings.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -51,7 +51,7 @@ cr.define('print_preview', function() {
onMarginsSelectionChanged_: function(event) {
this.headerFooterApplies_ = event.selectedMargins !=
- print_preview.MarginSettings.MARGINS_VALUE_NO_MARGINS
+ print_preview.MarginSettings.MARGINS_VALUE_NO_MARGINS;
this.setVisible_(this.headerFooterApplies_);
},
@@ -75,7 +75,8 @@ cr.define('print_preview', function() {
/**
* Hides or shows |this.headerFooterOption|.
- * @{param} visible True if |this.headerFooterOption| should be shown.
+ * @param {boolean} visible True if |this.headerFooterOption| should be
+ * shown.
* @private
*/
setVisible_: function(visible) {
@@ -83,10 +84,10 @@ cr.define('print_preview', function() {
fadeInOption(this.headerFooterOption_);
else
fadeOutOption(this.headerFooterOption_);
- },
+ }
};
return {
- HeaderFooterSettings: HeaderFooterSettings,
+ HeaderFooterSettings: HeaderFooterSettings
};
});
diff --git a/chrome/browser/resources/print_preview/layout_settings.js b/chrome/browser/resources/print_preview/layout_settings.js
index 7a9b187..e6cc097 100644
--- a/chrome/browser/resources/print_preview/layout_settings.js
+++ b/chrome/browser/resources/print_preview/layout_settings.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -115,6 +115,6 @@ cr.define('print_preview', function() {
};
return {
- LayoutSettings: LayoutSettings,
+ LayoutSettings: LayoutSettings
};
});
diff --git a/chrome/browser/resources/print_preview/margin_settings.js b/chrome/browser/resources/print_preview/margin_settings.js
index bd81d70..9faa640 100644
--- a/chrome/browser/resources/print_preview/margin_settings.js
+++ b/chrome/browser/resources/print_preview/margin_settings.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,7 +31,7 @@ cr.define('print_preview', function() {
Margins.roundToPrecision = function(value, precision) {
return Math.round(value * Math.pow(10, precision)) /
Math.pow(10, precision);
- }
+ };
Margins.prototype = {
/**
@@ -80,7 +80,7 @@ cr.define('print_preview', function() {
print_preview.convertPointsToLocaleUnitsAndBack(
this[indicesAsArray[i]]);
}
- },
+ }
};
/**
@@ -185,8 +185,9 @@ cr.define('print_preview', function() {
MarginSettings.prototype = {
/**
- * Returns a dictionary of the four custom margin values.
- * @return {object}
+ * Returns a dictionary containing the four custom margin values.
+ * @return {{marginLeft: number, marginTop: number, marginRight: number,
+ * marginBottom: number}} The dictionary.
*/
get customMargins() {
var margins = {};
@@ -708,6 +709,6 @@ cr.define('print_preview', function() {
return {
MarginSettings: MarginSettings,
- PageLayout: PageLayout,
+ PageLayout: PageLayout
};
});
diff --git a/chrome/browser/resources/print_preview/margin_textbox.js b/chrome/browser/resources/print_preview/margin_textbox.js
index 6d1798a..f0496f5 100644
--- a/chrome/browser/resources/print_preview/margin_textbox.js
+++ b/chrome/browser/resources/print_preview/margin_textbox.js
@@ -3,7 +3,7 @@
// found in the LICENSE file.
cr.define('print_preview', function() {
- 'strict';
+ 'use strict';
function MarginTextbox(groupName) {
var box = document.createElement('input');
diff --git a/chrome/browser/resources/print_preview/margin_utils.js b/chrome/browser/resources/print_preview/margin_utils.js
index 08feb94..a93ef0e 100644
--- a/chrome/browser/resources/print_preview/margin_utils.js
+++ b/chrome/browser/resources/print_preview/margin_utils.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -61,12 +61,12 @@ cr.define('print_preview', function() {
return marginValidationStates.WITHIN_RANGE;
else if (value < 0)
return marginValidationStates.TOO_SMALL;
- else (value > limit)
+ else
return marginValidationStates.TOO_BIG;
}
/**
- * @param {sting} text The text to check in user's locale units.
+ * @param {string} text The text to check in user's locale units.
* @param {number} limit The upper bound of the valid margin range (in
* points).
* @return {number} An appropriate value from enum |marginValidationStates|.
@@ -120,7 +120,7 @@ cr.define('print_preview', function() {
}
/**
- * @param {number} toConvert The value to convert in points.
+ * @param {number} value The value to convert in points.
* @return {string} The equivalent text in user locale units with precision
* of two digits.
*/
@@ -182,6 +182,6 @@ cr.define('print_preview', function() {
marginValidationStates: marginValidationStates,
Rect: Rect,
validateMarginText: validateMarginText,
- validateMarginValue: validateMarginValue,
+ validateMarginValue: validateMarginValue
};
});
diff --git a/chrome/browser/resources/print_preview/margins_ui.js b/chrome/browser/resources/print_preview/margins_ui.js
index 994c4660..bb2714c 100644
--- a/chrome/browser/resources/print_preview/margins_ui.js
+++ b/chrome/browser/resources/print_preview/margins_ui.js
@@ -1,9 +1,9 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('print_preview', function() {
- 'strict';
+ 'use strict';
function MarginsUI() {
var marginsUI = document.createElement('div');
@@ -45,7 +45,7 @@ cr.define('print_preview', function() {
/**
* @param {{x: number, y: number}} point The point with respect to the top
* left corner of the webpage.
- * @return {{x: number: y: number}} The point with respect to the top left
+ * @return {{x: number, y: number}} The point with respect to the top left
* corner of the plugin area.
*/
MarginsUI.convert = function(point) {
@@ -79,9 +79,12 @@ cr.define('print_preview', function() {
/**
* Updates the state of the margins UI.
- * @param {print_preview.Rect} marginsRectangle
+ * @param {print_preview.Rect} marginsRectangle A rectangle describing the
+ * four margins.
* @param {Margins} marginValues
- * @param {array} valueLimits
+ * @param {Array.<number>} valueLimits
+ * @param {boolean} keepDisplayedValue
+ * @param {Array.<number>} valueLimitsInPercent
*/
update: function(marginsRectangle, marginValues, valueLimits,
keepDisplayedValue, valueLimitsInPercent) {
@@ -198,7 +201,7 @@ cr.define('print_preview', function() {
this.lastClickedMarginsUIPair.getDragDisplacementFrom(point);
dragEvent.destinationPoint = point;
this.dispatchEvent(dragEvent);
- },
+ }
};
return {
diff --git a/chrome/browser/resources/print_preview/margins_ui_pair.js b/chrome/browser/resources/print_preview/margins_ui_pair.js
index 0d0eb4b..e35e9f2 100644
--- a/chrome/browser/resources/print_preview/margins_ui_pair.js
+++ b/chrome/browser/resources/print_preview/margins_ui_pair.js
@@ -1,9 +1,9 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('print_preview', function() {
- 'strict';
+ 'use strict';
/**
* @constructor
@@ -287,7 +287,7 @@ cr.define('print_preview', function() {
this.rectangle = this.getCoordinates_(newMarginsRectangle);
this.drawDraggableArea_();
- },
+ }
};
return {
diff --git a/chrome/browser/resources/print_preview/page_settings.js b/chrome/browser/resources/print_preview/page_settings.js
index d69f6e7..b03306c 100644
--- a/chrome/browser/resources/print_preview/page_settings.js
+++ b/chrome/browser/resources/print_preview/page_settings.js
@@ -96,7 +96,7 @@ cr.define('print_preview', function() {
/**
* Returns the selected pages in ascending order without any duplicates.
*
- * @return {Array}
+ * @return {Array.<number>} The selected pages.
*/
get selectedPagesSet() {
var selectedPagesText = this.selectedPagesText;
@@ -113,7 +113,7 @@ cr.define('print_preview', function() {
* Returns the previously selected pages in ascending order without any
* duplicates.
*
- * @return {Array}
+ * @return {Array.<number>} The previously selected pages.
*/
get previouslySelectedPages() {
return this.previouslySelectedPages_;
@@ -122,7 +122,8 @@ cr.define('print_preview', function() {
/**
* Returns an array of objects describing the selected page ranges. See
* documentation of pageSetToPageRanges() for more details.
- * @return {Array}
+ * @return {Array.<{from: number, to: number}>} An array of page range
+ * objects.
*/
get selectedPageRanges() {
return pageSetToPageRanges(this.selectedPagesSet);
@@ -372,6 +373,6 @@ cr.define('print_preview', function() {
};
return {
- PageSettings: PageSettings,
+ PageSettings: PageSettings
};
});
diff --git a/chrome/browser/resources/print_preview/preview_area.js b/chrome/browser/resources/print_preview/preview_area.js
index 13a2760..e2e6a1e9 100644
--- a/chrome/browser/resources/print_preview/preview_area.js
+++ b/chrome/browser/resources/print_preview/preview_area.js
@@ -3,7 +3,7 @@
// found in the LICENSE file.
cr.define('print_preview', function() {
- 'strict';
+ 'use strict';
/**
* Creates a PreviewArea object. It represents the area where the preview
@@ -294,6 +294,6 @@ cr.define('print_preview', function() {
};
return {
- PreviewArea: PreviewArea,
+ PreviewArea: PreviewArea
};
});
diff --git a/chrome/browser/resources/print_preview/print_header.js b/chrome/browser/resources/print_preview/print_header.js
index 1c17c83..67b2be7 100644
--- a/chrome/browser/resources/print_preview/print_header.js
+++ b/chrome/browser/resources/print_preview/print_header.js
@@ -161,10 +161,10 @@ cr.define('print_preview', function() {
// Removing extra spaces from within the string.
html = html.replace(/\s{2,}/g, ' ');
this.summary_.innerHTML = html;
- },
+ }
};
return {
- PrintHeader: PrintHeader,
+ PrintHeader: PrintHeader
};
});
diff --git a/chrome/browser/resources/print_preview/print_preview_animations.js b/chrome/browser/resources/print_preview/print_preview_animations.js
index 46aac35..7455a38 100644
--- a/chrome/browser/resources/print_preview/print_preview_animations.js
+++ b/chrome/browser/resources/print_preview/print_preview_animations.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -79,6 +79,7 @@ function fadeOutElement(el) {
* @param {EventTracker} eventTracker The |EventTracker| object that was used
* for adding this listener.
* @param {WebkitTransitionEvent} event The event that triggered this listener.
+ * @this {HTMLElement} The element where the transition occurred.
*/
function onFadeOutTransitionEnd(animationName, eventTracker, event) {
if (event.propertyName != 'height')
@@ -93,6 +94,7 @@ function onFadeOutTransitionEnd(animationName, eventTracker, event) {
* @param {EventTracker} eventTracker The |EventTracker| object that was used
* for adding this listener.
* @param {WebkitAnimationEvent} event The event that triggered this listener.
+ * @this {HTMLElement} The element where the transition occurred.
*/
function onFadeInAnimationEnd(eventTracker, event) {
this.style.height = '';
@@ -106,7 +108,7 @@ function onFadeInAnimationEnd(eventTracker, event) {
* @param {string} animationName The name of the animation to be removed.
*/
function fadeInOutCleanup(animationName) {
- animEl = document.getElementById(animationName);
+ var animEl = document.getElementById(animationName);
if (animEl)
animEl.parentNode.removeChild(animEl);
}
diff --git a/chrome/browser/resources/print_preview/print_preview_utils.js b/chrome/browser/resources/print_preview/print_preview_utils.js
index 81d8488..c567b51 100644
--- a/chrome/browser/resources/print_preview/print_preview_utils.js
+++ b/chrome/browser/resources/print_preview/print_preview_utils.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -41,8 +41,8 @@ function areArraysEqual(array1, array2) {
/**
* Removes duplicate elements from |inArray| and returns a new array.
* |inArray| is not affected. It assumes that |inArray| is already sorted.
- * @param {array} inArray The array to be processed.
- * @return {array} The array after processing.
+ * @param {Array.<number>} inArray The array to be processed.
+ * @return {Array.<number>} The array after processing.
*/
function removeDuplicates(inArray) {
var out = [];
@@ -116,7 +116,7 @@ function isPageRangeTextValid(pageRangeText, totalPageCount) {
* returned.
* @param {string} pageRangeText The text to be checked.
* @param {number} totalPageCount The total number of pages.
- * @return {array} A list of all pages.
+ * @return {Array.<number>} A list of all pages.
*/
function pageRangeTextToPageList(pageRangeText, totalPageCount) {
var pageList = [];
@@ -139,9 +139,9 @@ function pageRangeTextToPageList(pageRangeText, totalPageCount) {
pageList.push(j);
} else {
var singlePageNumber = parseInt(parts[i], 10);
- if (isPositiveInteger(singlePageNumber) &&
+ if (isPositiveInteger(singlePageNumber.toString()) &&
singlePageNumber <= totalPageCount) {
- pageList.push(singlePageNumber);
+ pageList.push(singlePageNumber.toString());
}
}
}
@@ -149,16 +149,18 @@ function pageRangeTextToPageList(pageRangeText, totalPageCount) {
}
/**
- * @param {array} pageList The list to be processed.
- * @return {array} The contents of |pageList| in ascending order and without any
- * duplicates. |pageList| is not affected.
+ * @param {Array.<number>} pageList The list to be processed.
+ * @return {Array.<number>} The contents of |pageList| in ascending order and
+ * without any duplicates. |pageList| is not affected.
*/
function pageListToPageSet(pageList) {
var pageSet = [];
if (pageList.length == 0)
return pageSet;
pageSet = pageList.slice(0);
- pageSet.sort(function(a, b) { return a - b; });
+ pageSet.sort(function(a, b) {
+ return (/** @type {number} */ a) - (/** @type {number} */ b);
+ });
pageSet = removeDuplicates(pageSet);
return pageSet;
}
@@ -167,18 +169,17 @@ function pageListToPageSet(pageList) {
* Converts |pageSet| to page ranges. It squashes whenever possible.
* Example: '1-2,3,5-7' becomes 1-3,5-7.
*
- * @param {array} pageSet The set of pages to be processed. Callers should
- * ensure that no duplicates exist.
- * @return {Array} an array of page range objects. A page range object has
- * fields 'from' and 'to'.
+ * @param {Array.<number>} pageSet The set of pages to be processed. Callers
+ * should ensure that no duplicates exist.
+ * @return {Array.<{from: number, to: number}>} An array of page range objects.
*/
function pageSetToPageRanges(pageSet) {
var pageRanges = [];
for (var i = 0; i < pageSet.length; ++i) {
- tempFrom = pageSet[i];
+ var tempFrom = pageSet[i];
while (i + 1 < pageSet.length && pageSet[i + 1] == pageSet[i] + 1)
++i;
- tempTo = pageSet[i];
+ var tempTo = pageSet[i];
pageRanges.push({'from': tempFrom, 'to': tempTo});
}
return pageRanges;
@@ -202,8 +203,8 @@ function getPageSrcURL(id, pageNumber) {
* @return {number} The random integer.
*/
function randomInteger(endPointA, endPointB) {
- from = Math.min(endPointA, endPointB);
- to = Math.max(endPointA, endPointB);
+ var from = Math.min(endPointA, endPointB);
+ var to = Math.max(endPointA, endPointB);
return Math.floor(Math.random() * (to - from + 1) + from);
}
@@ -252,7 +253,7 @@ function convertPointsToMillimeters(value) {
* Parses |numberFormat| and extracts the symbols used for the thousands point
* and decimal point.
* @param {string} numberFormat The formatted version of the number 12345678.
- * @return {!array.<string>} The extracted symbols in the order
+ * @return {!Array.<string>} The extracted symbols in the order
* [thousandsSymbol, decimalSymbol]]. For example
* parseNumberFormat("123,456.78") returns [",", "."].
*/
@@ -260,6 +261,6 @@ function parseNumberFormat(numberFormat) {
if (!numberFormat)
numberFormat = '';
var regex = /^(\d+)(\W{0,1})(\d+)(\W{0,1})(\d+)$/;
- var matches = numberFormat.match(regex) || ['','',',','','.'];
+ var matches = numberFormat.match(regex) || ['', '', ',', '', '.'];
return [matches[2], matches[4]];
}