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

Side by Side Diff: chrome/browser/resources/print_preview/data/measurement_system.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: revert movement of enums: now handle in compiler pass 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 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 cr.define('print_preview', function() { 5 cr.define('print_preview', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Measurement system of the print preview. Used to parse and serialize point 9 * Measurement system of the print preview. Used to parse and serialize point
10 * measurements into the system's local units (e.g. millimeters, inches). 10 * measurements into the system's local units (e.g. millimeters, inches).
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 /** 117 /**
118 * Rounds a value in the local system's units to the appropriate precision. 118 * Rounds a value in the local system's units to the appropriate precision.
119 * @param {number} value Value to round. 119 * @param {number} value Value to round.
120 * @return {number} Rounded value. 120 * @return {number} Rounded value.
121 */ 121 */
122 roundValue: function(value) { 122 roundValue: function(value) {
123 var precision = MeasurementSystem.Precision_[this.unitType_]; 123 var precision = MeasurementSystem.Precision_[this.unitType_];
124 var roundedValue = Math.round(value / precision) * precision; 124 var roundedValue = Math.round(value / precision) * precision;
125 // Truncate 125 // Truncate
126 return roundedValue.toFixed( 126 return +roundedValue.toFixed(
127 MeasurementSystem.DecimalPlaces_[this.unitType_]); 127 MeasurementSystem.DecimalPlaces_[this.unitType_]);
128 }, 128 },
129 129
130 /** 130 /**
131 * @param {number} pts Value in points to convert to local units. 131 * @param {number} pts Value in points to convert to local units.
132 * @return {number} Value in local units. 132 * @return {number} Value in local units.
133 */ 133 */
134 convertFromPoints: function(pts) { 134 convertFromPoints: function(pts) {
135 if (this.unitType_ == MeasurementSystem.UnitType.METRIC) { 135 if (this.unitType_ == MeasurementSystem.UnitType.METRIC) {
136 return pts / MeasurementSystem.PTS_PER_MM_; 136 return pts / MeasurementSystem.PTS_PER_MM_;
(...skipping 13 matching lines...) Expand all
150 return localUnits * MeasurementSystem.PTS_PER_INCH_; 150 return localUnits * MeasurementSystem.PTS_PER_INCH_;
151 } 151 }
152 } 152 }
153 }; 153 };
154 154
155 // Export 155 // Export
156 return { 156 return {
157 MeasurementSystem: MeasurementSystem 157 MeasurementSystem: MeasurementSystem
158 }; 158 };
159 }); 159 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698