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

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

Issue 8345025: Print Preview: Adding support for localized margin units and format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing tests Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 * Returns true if |toTest| contains only digits. Leading and trailing 6 * Returns true if |toTest| contains only digits. Leading and trailing
7 * whitespace is allowed. 7 * whitespace is allowed.
8 * @param {string} toTest The string to be tested. 8 * @param {string} toTest The string to be tested.
9 */ 9 */
10 function isInteger(toTest) { 10 function isInteger(toTest) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 /** 183 /**
184 * Constructs a url for getting a specific page. 184 * Constructs a url for getting a specific page.
185 * @param {string} id The id of the preview data. 185 * @param {string} id The id of the preview data.
186 * @param {number} pageNumber The number of the desired page. 186 * @param {number} pageNumber The number of the desired page.
187 * @return {string} The constructed URL. 187 * @return {string} The constructed URL.
188 */ 188 */
189 function getPageSrcURL(id, pageNumber) { 189 function getPageSrcURL(id, pageNumber) {
190 return 'chrome://print/' + id + '/' + pageNumber + '/print.pdf'; 190 return 'chrome://print/' + id + '/' + pageNumber + '/print.pdf';
191 } 191 }
192 192
193
194 /** 193 /**
195 * Returns a random integer within the specified range, |endPointA| and 194 * Returns a random integer within the specified range, |endPointA| and
196 * |endPointB| are included. 195 * |endPointB| are included.
197 * @param {number} endPointA One end of the desired range. 196 * @param {number} endPointA One end of the desired range.
198 * @param {number} endPointB The other end of the desired range. 197 * @param {number} endPointB The other end of the desired range.
199 * @return {number} The random integer. 198 * @return {number} The random integer.
200 */ 199 */
201 function randomInteger(endPointA, endPointB) { 200 function randomInteger(endPointA, endPointB) {
202 from = Math.min(endPointA, endPointB); 201 from = Math.min(endPointA, endPointB);
203 to = Math.max(endPointA, endPointB); 202 to = Math.max(endPointA, endPointB);
204 return Math.floor(Math.random() * (to - from + 1) + from); 203 return Math.floor(Math.random() * (to - from + 1) + from);
205 } 204 }
206 205
207 // Number of points per inch. 206 // Number of points per inch.
208 POINTS_PER_INCH = 72; 207 var POINTS_PER_INCH = 72;
208 // Number of points per millimeter.
209 var POINTS_PER_MILLIMETER = 2.83464567;
209 210
210 /** 211 /**
211 * Converts |value| from inches to points. 212 * Converts |value| from inches to points.
212 * @param {number} value The number in inches. 213 * @param {number} value The number in inches.
213 * @return {number} |value| in points. 214 * @return {number} |value| in points.
214 */ 215 */
215 function convertInchesToPoints(value) { 216 function convertInchesToPoints(value) {
216 return value * POINTS_PER_INCH; 217 return value * POINTS_PER_INCH;
217 } 218 }
218 219
219 /** 220 /**
220 * Converts |value| from points to inches. 221 * Converts |value| from points to inches.
221 * @param {number} value The number in points. 222 * @param {number} value The number in points.
222 * @return {number} |value| in inches. 223 * @return {number} |value| in inches.
223 */ 224 */
224 function convertPointsToInches(value) { 225 function convertPointsToInches(value) {
225 return value / POINTS_PER_INCH; 226 return value / POINTS_PER_INCH;
226 } 227 }
228
229 /**
230 * Converts |value| from millimeters to points.
231 * @param {number} value The number in millimeters.
232 * @return {number} |value| in points.
233 */
234 function convertMillimetersToPoints(value) {
235 return value * POINTS_PER_MILLIMETER;
236 }
237
238 /**
239 * Converts |value| from points to millimeters.
240 * @param {number} value The number in points.
241 * @return {number} |value| in millimeters.
242 */
243 function convertPointsToMillimeters(value) {
244 return value / POINTS_PER_MILLIMETER;
245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698