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
--- 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 () {