Bug 1377879 - adjusted `areValuesDifferent` calculation for quads; r=pbro draft
authorZER0 <zer0.kaos@gmail.com>
Tue, 12 Sep 2017 02:24:35 +0200
changeset 662712 184b8afceebcb0fe151461035c63bebd7e2dc7b5
parent 662290 f9a5e9ed62103c84e4cde915f4d08f1ce71be83e
child 730950 4242034b7be891917303b25baf70872b4c68a951
push id79169
push userbmo:zer0@mozilla.com
push dateTue, 12 Sep 2017 00:29:53 +0000
reviewerspbro
bugs1377879
milestone57.0a1
Bug 1377879 - adjusted `areValuesDifferent` calculation for quads; r=pbro The previous calculation was actually wrong, the `delta` is calculated between logical pixels. The previous calculation allowed half pixel movement to be ignored: with "fluid" elements, a slow window resizing was making this half pixel stack each time. MozReview-Commit-ID: nhDSpbg6RT
devtools/server/actors/highlighters/auto-refresh.js
--- a/devtools/server/actors/highlighters/auto-refresh.js
+++ b/devtools/server/actors/highlighters/auto-refresh.js
@@ -2,42 +2,41 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const { Cu } = require("chrome");
 const EventEmitter = require("devtools/shared/old-event-emitter");
 const { isNodeValid } = require("./utils/markup");
-const { getAdjustedQuads, getCurrentZoom,
-        getWindowDimensions } = require("devtools/shared/layout/utils");
+const { getAdjustedQuads, getWindowDimensions } = require("devtools/shared/layout/utils");
 
 // Note that the order of items in this array is important because it is used
 // for drawing the BoxModelHighlighter's path elements correctly.
 const BOX_MODEL_REGIONS = ["margin", "border", "padding", "content"];
 const QUADS_PROPS = ["p1", "p2", "p3", "p4", "bounds"];
 
-function areValuesDifferent(oldValue, newValue, zoom) {
+function areValuesDifferent(oldValue, newValue) {
   let delta = Math.abs(oldValue.toFixed(4) - newValue.toFixed(4));
-  return delta / zoom > 1 / zoom;
+  return delta >= .5;
 }
 
-function areQuadsDifferent(oldQuads, newQuads, zoom) {
+function areQuadsDifferent(oldQuads, newQuads) {
   for (let region of BOX_MODEL_REGIONS) {
     if (oldQuads[region].length !== newQuads[region].length) {
       return true;
     }
 
     for (let i = 0; i < oldQuads[region].length; i++) {
       for (let prop of QUADS_PROPS) {
         let oldProp = oldQuads[region][i][prop];
         let newProp = newQuads[region][i][prop];
 
         for (let key of Object.keys(oldProp)) {
-          if (areValuesDifferent(oldProp[key], newProp[key], zoom)) {
+          if (areValuesDifferent(oldProp[key], newProp[key])) {
             return true;
           }
         }
       }
     }
   }
 
   return false;
@@ -185,17 +184,17 @@ AutoRefreshHighlighter.prototype = {
    * Update the knowledge we have of the current node's boxquads and return true
    * if any of the points x/y or bounds have change since.
    * @return {Boolean}
    */
   _hasMoved: function () {
     let oldQuads = this.currentQuads;
     this._updateAdjustedQuads();
 
-    return areQuadsDifferent(oldQuads, this.currentQuads, getCurrentZoom(this.win));
+    return areQuadsDifferent(oldQuads, this.currentQuads);
   },
 
   /**
    * Update the knowledge we have of the current window's scrolling offset, both
    * horizontal and vertical, and return `true` if they have changed since.
    * @return {Boolean}
    */
   _hasWindowScrolled: function () {