Bug 1455462 - Part 2. Use the rounded zoom value of devtool panel. r=jdescottes
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 11 May 2018 09:08:09 +0900
changeset 794439 0530a537719787cedb59bdb1081d008f4a4f4efe
parent 794438 8e3a5591905b44021bd2d4ff28b8ce2e46b1ab97
child 794440 6d6065b44f12b5781088628414ad0356960316d9
push id109697
push userbmo:sledru@mozilla.com
push dateSat, 12 May 2018 10:04:34 +0000
reviewersjdescottes
bugs1455462
milestone62.0a1
Bug 1455462 - Part 2. Use the rounded zoom value of devtool panel. r=jdescottes This patch will use rounded zoom value of dev tool panel. This changes will ensure the zoom value test. MozReview-Commit-ID: JvSdZUbpeCH
devtools/client/shared/zoom-keys.js
--- a/devtools/client/shared/zoom-keys.js
+++ b/devtools/client/shared/zoom-keys.js
@@ -45,16 +45,18 @@ exports.register = function(window) {
     setZoom(1);
     event.preventDefault();
   };
 
   let setZoom = function(newValue) {
     // cap zoom value
     zoomValue = Math.max(newValue, MIN_ZOOM);
     zoomValue = Math.min(zoomValue, MAX_ZOOM);
+    // Prevent the floating-point error. (e.g. 1.1 + 0.1 = 1.2000000000000002)
+    zoomValue = Math.round(zoomValue * 10) / 10;
 
     contViewer.fullZoom = zoomValue;
 
     Services.prefs.setCharPref(ZOOM_PREF, zoomValue);
   };
 
   // Set zoom to whatever the last setting was.
   setZoom(zoomValue);