Bug 1455462 - Part 2. Use the rounded zoom value of devtool panel. r=jdescottes, a=RyanVM
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Mon, 14 May 2018 17:17:00 -0400
changeset 473343 69dec209ab576d4c6af7fe85b3fa16cca495a89a
parent 473342 d234aa23f84f8c13a301c95787c06f60a4ed8ba0
child 473344 fa0085fa3c49f482d5734aa8800508a5dd3615a1
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes, RyanVM
bugs1455462
milestone61.0
Bug 1455462 - Part 2. Use the rounded zoom value of devtool panel. r=jdescottes, a=RyanVM This patch will use rounded zoom value of dev tool panel. This changes will ensure the zoom value test.
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);