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

Side by Side Diff: chrome/browser/resources/print_preview/print_preview_utils.js

Issue 575333002: Compile print_preview, part 2: reduce down to 260 errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@I_print_preview
Patch Set: Created 6 years, 3 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
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 /** 5 /**
6 * @param {string} toTest The string to be tested. 6 * @param {string} toTest The string to be tested.
7 * @return {boolean} True if |toTest| contains only digits. Leading and trailing 7 * @return {boolean} True if |toTest| contains only digits. Leading and trailing
8 * whitespace is allowed. 8 * whitespace is allowed.
9 */ 9 */
10 function isInteger(toTest) { 10 function isInteger(toTest) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 if (array1[i].from != array2[i].from || 49 if (array1[i].from != array2[i].from ||
50 array1[i].to != array2[i].to) { 50 array1[i].to != array2[i].to) {
51 return false; 51 return false;
52 } 52 }
53 return true; 53 return true;
54 } 54 }
55 55
56 /** 56 /**
57 * Removes duplicate elements from |inArray| and returns a new array. 57 * Removes duplicate elements from |inArray| and returns a new array.
58 * |inArray| is not affected. It assumes that |inArray| is already sorted. 58 * |inArray| is not affected. It assumes that |inArray| is already sorted.
59 * @param {Array.<number>} inArray The array to be processed. 59 * @param {!Array.<number>} inArray The array to be processed.
60 * @return {Array.<number>} The array after processing. 60 * @return {!Array.<number>} The array after processing.
61 */ 61 */
62 function removeDuplicates(inArray) { 62 function removeDuplicates(inArray) {
63 var out = []; 63 var out = [];
64 64
65 if (inArray.length == 0) 65 if (inArray.length == 0)
66 return out; 66 return out;
67 67
68 out.push(inArray[0]); 68 out.push(inArray[0]);
69 for (var i = 1; i < inArray.length; ++i) 69 for (var i = 1; i < inArray.length; ++i)
70 if (inArray[i] != inArray[i - 1]) 70 if (inArray[i] != inArray[i - 1])
(...skipping 15 matching lines...) Expand all
86 * Wildcard the second number must be larger then the first number. If it's 86 * Wildcard the second number must be larger then the first number. If it's
87 * missed then |totalPageCount| is used as the second number. 87 * missed then |totalPageCount| is used as the second number.
88 * Example: "1-4, 9, 3-6, 10, 11" is valid, assuming |totalPageCount| >= 11. 88 * Example: "1-4, 9, 3-6, 10, 11" is valid, assuming |totalPageCount| >= 11.
89 * Example: "1-4, -6" is valid, assuming |totalPageCount| >= 6. 89 * Example: "1-4, -6" is valid, assuming |totalPageCount| >= 6.
90 * Example: "2-" is valid, assuming |totalPageCount| >= 2, means from 2 to the 90 * Example: "2-" is valid, assuming |totalPageCount| >= 2, means from 2 to the
91 * end. 91 * end.
92 * Example: "4-2, 11, -6" is invalid. 92 * Example: "4-2, 11, -6" is invalid.
93 * Example: "-" is valid, assuming |totalPageCount| >= 1. 93 * Example: "-" is valid, assuming |totalPageCount| >= 1.
94 * Example: "1-4dsf, 11" is invalid regardless of |totalPageCount|. 94 * Example: "1-4dsf, 11" is invalid regardless of |totalPageCount|.
95 * @param {string} pageRangeText The text to be checked. 95 * @param {string} pageRangeText The text to be checked.
96 * @param {number} totalPageCount The total number of pages. 96 * @param {?number} totalPageCount The total number of pages.
Aleksey Shlyapnikov 2014/09/19 18:54:42 Maybe {number=} makes more sense here?
Vitaly Pavlenko 2014/09/19 20:33:09 You are right. Done.
97 * @return {Array.<{from: number, to: number}>} An array of page range objects. 97 * @return {Array.<{from: number, to: number}>} An array of page range objects.
98 */ 98 */
99 function pageRangeTextToPageRanges(pageRangeText, totalPageCount) { 99 function pageRangeTextToPageRanges(pageRangeText, totalPageCount) {
100 if (pageRangeText == '') { 100 if (pageRangeText == '') {
101 return []; 101 return [];
102 } 102 }
103 103
104 var MAX_PAGE_NUMBER = 1000000000; 104 var MAX_PAGE_NUMBER = 1000000000;
105 totalPageCount = totalPageCount ? totalPageCount : MAX_PAGE_NUMBER; 105 totalPageCount = totalPageCount ? totalPageCount : MAX_PAGE_NUMBER;
106 106
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 154 }
155 } 155 }
156 if (pageList.length == 0) { 156 if (pageList.length == 0) {
157 for (var j = 1; j <= totalPageCount; ++j) 157 for (var j = 1; j <= totalPageCount; ++j)
158 pageList.push(j); 158 pageList.push(j);
159 } 159 }
160 return pageList; 160 return pageList;
161 } 161 }
162 162
163 /** 163 /**
164 * @param {Array.<number>} pageList The list to be processed. 164 * @param {!Array.<number>} pageList The list to be processed.
165 * @return {Array.<number>} The contents of |pageList| in ascending order and 165 * @return {!Array.<number>} The contents of |pageList| in ascending order and
166 * without any duplicates. |pageList| is not affected. 166 * without any duplicates. |pageList| is not affected.
167 */ 167 */
168 function pageListToPageSet(pageList) { 168 function pageListToPageSet(pageList) {
169 var pageSet = []; 169 var pageSet = [];
170 if (pageList.length == 0) 170 if (pageList.length == 0)
171 return pageSet; 171 return pageSet;
172 pageSet = pageList.slice(0); 172 pageSet = pageList.slice(0);
173 pageSet.sort(function(a, b) { 173 pageSet.sort(function(a, b) {
174 return (/** @type {number} */ a) - (/** @type {number} */ b); 174 return (/** @type {number} */ a) - (/** @type {number} */ b);
175 }); 175 });
(...skipping 19 matching lines...) Expand all
195 } 195 }
196 196
197 /** 197 /**
198 * @param {!Array} array Array to check for item. 198 * @param {!Array} array Array to check for item.
199 * @param {*} item Item to look for in array. 199 * @param {*} item Item to look for in array.
200 * @return {boolean} Whether the item is in the array. 200 * @return {boolean} Whether the item is in the array.
201 */ 201 */
202 function arrayContains(array, item) { 202 function arrayContains(array, item) {
203 return array.indexOf(item) != -1; 203 return array.indexOf(item) != -1;
204 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698