Bug 1455462 - Part 2. Use the rounded zoom value of devtool panel. r?jdescottes draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 11 May 2018 09:08:09 +0900
changeset 793948 2d18435b9043a4fdb2f1408c764f315d82ad5f26
parent 793947 68162efa947af904c01cc85f693bcd12f51fa2be
child 793949 65e2d48158344298ac071d29cdacfc295dd77a4d
push id109539
push userbmo:mantaroh@gmail.com
push dateFri, 11 May 2018 02:09:26 +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);