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

--HG--
extra : rebase_source : 9b368b110c66880730a28d4a5c07f14e52d92e4e
This commit is contained in:
ZER0 2017-09-12 02:24:35 +02:00
Родитель f703233d7b
Коммит f24fe84fb5
1 изменённых файлов: 6 добавлений и 7 удалений

Просмотреть файл

@ -7,20 +7,19 @@
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;
@ -32,7 +31,7 @@ function areQuadsDifferent(oldQuads, newQuads, zoom) {
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;
}
}
@ -190,7 +189,7 @@ AutoRefreshHighlighter.prototype = {
let oldQuads = this.currentQuads;
this._updateAdjustedQuads();
return areQuadsDifferent(oldQuads, this.currentQuads, getCurrentZoom(this.win));
return areQuadsDifferent(oldQuads, this.currentQuads);
},
/**