Loading toolkit/components/resistfingerprinting/RFPHelper.sys.mjs +19 −63 Original line number Diff line number Diff line Loading @@ -17,16 +17,17 @@ const kPrefLetterboxingTesting = "privacy.resistFingerprinting.letterboxing.testing"; const kTopicDOMWindowOpened = "domwindowopened"; var logConsole; function log(msg) { if (!logConsole) { logConsole = console.createInstance({ const lazy = {}; ChromeUtils.defineLazyGetter(lazy, "logConsole", () => console.createInstance({ prefix: "RFPHelper", maxLogLevelPref: "privacy.resistFingerprinting.jsmloglevel", }); } }) ); logConsole.log(msg); function log(...args) { lazy.logConsole.log(...args); } class _RFPHelper { Loading Loading @@ -421,8 +422,8 @@ class _RFPHelper { * content viewport. */ async _roundContentView(aBrowser) { let logId = Math.random(); log("_roundContentView[" + logId + "]"); let logPrefix = `_roundContentView[${Math.random()}]`; log(logPrefix); let win = aBrowser.ownerGlobal; let browserContainer = aBrowser .getTabBrowser() Loading Loading @@ -456,30 +457,12 @@ class _RFPHelper { }); log( "_roundContentView[" + logId + "] contentWidth=" + contentWidth + " contentHeight=" + contentHeight + " containerWidth=" + containerWidth + " containerHeight=" + containerHeight + " " `${logPrefix} contentWidth=${contentWidth} contentHeight=${contentHeight} containerWidth=${containerWidth} containerHeight=${containerHeight}.` ); let calcMargins = (aWidth, aHeight) => { let result; log( "_roundContentView[" + logId + "] calcMargins(" + aWidth + ", " + aHeight + ")" ); log(`${logPrefix} calcMargins(${aWidth}, ${aHeight})`); // If the set is empty, we will round the content with the default // stepping size. if (!this._letterboxingDimensions.length) { Loading @@ -488,16 +471,7 @@ class _RFPHelper { height: this.steppedRange(aHeight), }; log( "_roundContentView[" + logId + "] calcMargins(" + aWidth + ", " + aHeight + ") = " + result.width + " x " + result.height `${logPrefix} calcMargins(${aWidth}, ${aHeight}) = ${result.width} x ${result.height}` ); return result; } Loading Loading @@ -538,16 +512,7 @@ class _RFPHelper { } log( "_roundContentView[" + logId + "] calcMargins(" + aWidth + ", " + aHeight + ") = " + result.width + " x " + result.height `${logPrefix} calcMargins(${aWidth}, ${aHeight}) = ${result.width} x ${result.height}` ); return result; }; Loading @@ -559,12 +524,10 @@ class _RFPHelper { // If the size of the content is already quantized, we do nothing. if (aBrowser.style.margin == `${margins.height}px ${margins.width}px`) { log("_roundContentView[" + logId + "] is_rounded == true"); log(`${logPrefix} is_rounded == true`); if (this._isLetterboxingTesting) { log( "_roundContentView[" + logId + "] is_rounded == true test:letterboxing:update-margin-finish" `${logPrefix} is_rounded == true test:letterboxing:update-margin-finish` ); Services.obs.notifyObservers( null, Loading @@ -575,14 +538,7 @@ class _RFPHelper { } win.requestAnimationFrame(() => { log( "_roundContentView[" + logId + "] setting margins to " + margins.width + " x " + margins.height ); log(`${logPrefix} setting margins to ${margins.width} x ${margins.height}`); // One cannot (easily) control the color of a margin unfortunately. // An initial attempt to use a border instead of a margin resulted // in offset event dispatching; so for now we use a colorless margin. Loading Loading
toolkit/components/resistfingerprinting/RFPHelper.sys.mjs +19 −63 Original line number Diff line number Diff line Loading @@ -17,16 +17,17 @@ const kPrefLetterboxingTesting = "privacy.resistFingerprinting.letterboxing.testing"; const kTopicDOMWindowOpened = "domwindowopened"; var logConsole; function log(msg) { if (!logConsole) { logConsole = console.createInstance({ const lazy = {}; ChromeUtils.defineLazyGetter(lazy, "logConsole", () => console.createInstance({ prefix: "RFPHelper", maxLogLevelPref: "privacy.resistFingerprinting.jsmloglevel", }); } }) ); logConsole.log(msg); function log(...args) { lazy.logConsole.log(...args); } class _RFPHelper { Loading Loading @@ -421,8 +422,8 @@ class _RFPHelper { * content viewport. */ async _roundContentView(aBrowser) { let logId = Math.random(); log("_roundContentView[" + logId + "]"); let logPrefix = `_roundContentView[${Math.random()}]`; log(logPrefix); let win = aBrowser.ownerGlobal; let browserContainer = aBrowser .getTabBrowser() Loading Loading @@ -456,30 +457,12 @@ class _RFPHelper { }); log( "_roundContentView[" + logId + "] contentWidth=" + contentWidth + " contentHeight=" + contentHeight + " containerWidth=" + containerWidth + " containerHeight=" + containerHeight + " " `${logPrefix} contentWidth=${contentWidth} contentHeight=${contentHeight} containerWidth=${containerWidth} containerHeight=${containerHeight}.` ); let calcMargins = (aWidth, aHeight) => { let result; log( "_roundContentView[" + logId + "] calcMargins(" + aWidth + ", " + aHeight + ")" ); log(`${logPrefix} calcMargins(${aWidth}, ${aHeight})`); // If the set is empty, we will round the content with the default // stepping size. if (!this._letterboxingDimensions.length) { Loading @@ -488,16 +471,7 @@ class _RFPHelper { height: this.steppedRange(aHeight), }; log( "_roundContentView[" + logId + "] calcMargins(" + aWidth + ", " + aHeight + ") = " + result.width + " x " + result.height `${logPrefix} calcMargins(${aWidth}, ${aHeight}) = ${result.width} x ${result.height}` ); return result; } Loading Loading @@ -538,16 +512,7 @@ class _RFPHelper { } log( "_roundContentView[" + logId + "] calcMargins(" + aWidth + ", " + aHeight + ") = " + result.width + " x " + result.height `${logPrefix} calcMargins(${aWidth}, ${aHeight}) = ${result.width} x ${result.height}` ); return result; }; Loading @@ -559,12 +524,10 @@ class _RFPHelper { // If the size of the content is already quantized, we do nothing. if (aBrowser.style.margin == `${margins.height}px ${margins.width}px`) { log("_roundContentView[" + logId + "] is_rounded == true"); log(`${logPrefix} is_rounded == true`); if (this._isLetterboxingTesting) { log( "_roundContentView[" + logId + "] is_rounded == true test:letterboxing:update-margin-finish" `${logPrefix} is_rounded == true test:letterboxing:update-margin-finish` ); Services.obs.notifyObservers( null, Loading @@ -575,14 +538,7 @@ class _RFPHelper { } win.requestAnimationFrame(() => { log( "_roundContentView[" + logId + "] setting margins to " + margins.width + " x " + margins.height ); log(`${logPrefix} setting margins to ${margins.width} x ${margins.height}`); // One cannot (easily) control the color of a margin unfortunately. // An initial attempt to use a border instead of a margin resulted // in offset event dispatching; so for now we use a colorless margin. Loading