Skip to content
Snippets Groups Projects
Commit a16d2804 authored by ma1's avatar ma1 Committed by Pier Angelo Vendrame
Browse files

BB 41434: Letterboxing, improve logging.

parent bc1c063f
No related branches found
No related tags found
1 merge request!1503TB 43415, part 3: Shuffle commits
......@@ -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 {
......@@ -391,8 +392,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()
......@@ -426,30 +427,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) {
......@@ -458,16 +441,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;
}
......@@ -508,16 +482,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;
};
......@@ -529,12 +494,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,
......@@ -545,14 +508,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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment