Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Applications
Tor Browser
Commits
16c5a240
Verified
Commit
16c5a240
authored
Mar 23, 2023
by
ma1
Browse files
Options
Downloads
Patches
Plain Diff
Bug 41631: Prevent weird initial window dimensions caused by subpixel computations
parent
c1b352e3
Loading
Loading
1 merge request
!594
Non-letterboxed window management migration to the RFPHelper
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
toolkit/components/resistfingerprinting/RFPHelper.jsm
+59
-43
59 additions, 43 deletions
toolkit/components/resistfingerprinting/RFPHelper.jsm
with
59 additions
and
43 deletions
toolkit/components/resistfingerprinting/RFPHelper.jsm
+
59
−
43
View file @
16c5a240
...
...
@@ -22,16 +22,29 @@ const kPrefLetterboxingTesting =
"privacy.resistFingerprinting.letterboxing.testing";
const kTopicDOMWindowOpened = "domwindowopened";
var logConsole;
function log(msg) {
if (!logConsole) {
logConsole = console.createInstance({
XPCOMUtils.defineLazyGetter(this, "logConsole", () =>
console.createInstance({
prefix: "RFPHelper.jsm",
maxLogLevelPref: "privacy.resistFingerprinting.jsmloglevel",
});
})
);
function log(...args) {
logConsole.log(...args);
}
logConsole.log(msg);
function forEachWindow(callback) {
const windowList = Services.wm.getEnumerator("navigator:browser");
while (windowList.hasMoreElements()) {
const win = windowList.getNext();
if (win.gBrowser && !win.closed) {
try {
callback(win);
} catch (e) {
logConsole.error(e);
}
}
}
}
class _RFPHelper {
...
...
@@ -158,7 +171,11 @@ class _RFPHelper {
_handleResistFingerprintingChanged() {
if (Services.prefs.getBoolPref(kPrefResistFingerprinting)) {
this._addRFPObservers();
Services.ww.registerNotification(this);
forEachWindow(win => this._attachWindow(win));
} else {
forEachWindow(win => this._detachWindow(win));
Services.ww.unregisterNotification(this);
this._removeRFPObservers();
}
}
...
...
@@ -295,13 +312,11 @@ class _RFPHelper {
}
_handleLetterboxingPrefChanged() {
if (Services.prefs.getBoolPref(kPrefLetterboxing, false)) {
Services.ww.registerNotification(this);
this._attachAllWindows();
} else {
this._detachAllWindows();
Services.ww.unregisterNotification(this);
}
this.letterboxingEnabled = Services.prefs.getBoolPref(
kPrefLetterboxing,
false
);
forEachWindow(win => this._updateSizeForTabsInWindow(win));
}
// The function to parse the dimension set from the pref value. The pref value
...
...
@@ -402,11 +417,13 @@ class _RFPHelper {
let logPrefix = `_roundContentSize[${Math.random()}]`;
log(logPrefix);
let win = aBrowser.ownerGlobal;
let browserContainer = aBrowser
.getTabBrowser()
.getBrowserContainer(aBrowser);
let browserParent = aBrowser.parentElement;
browserParent.classList.remove("exclude-letterboxing");
let [
[contentWidth, contentHeight],
[parentWidth, parentHeight],
...
...
@@ -419,6 +436,22 @@ class _RFPHelper {
])
);
if (!win._rfpSizeOffset) {
const BASELINE_ROUNDING = 10;
const offset = s =>
s - Math.round(s / BASELINE_ROUNDING) * BASELINE_ROUNDING;
win._rfpSizeOffset = {
width: offset(parentWidth),
height: offset(parentHeight),
};
log(
`${logPrefix} Window size offsets %o (from %s, %s)`,
win._rfpSizeOffset,
parentWidth,
parentHeight
);
}
log(
`${logPrefix} contentWidth=${contentWidth} contentHeight=${contentHeight} parentWidth=${parentWidth} parentHeight=${parentHeight} containerWidth=${containerWidth} containerHeight=${containerHeight}${
isNewTab ? " (new tab)." : "."
...
...
@@ -437,6 +470,16 @@ class _RFPHelper {
});
let result;
if (!this.letterboxingEnabled) {
const offset = win._rfpSizeOffset;
result = r(aWidth - offset.width, aHeight - offset.height);
log(
`${logPrefix} Letterboxing disabled, applying baseline rounding offsets: (${aWidth}, ${aHeight}) => ${result.width} x ${result.height})`
);
return result;
}
log(`${logPrefix} roundDimensions(${aWidth}, ${aHeight})`);
// If the set is empty, we will round the content with the default
// stepping size.
...
...
@@ -554,7 +597,6 @@ class _RFPHelper {
_updateSizeForTabsInWindow(aWindow) {
let tabBrowser = aWindow.gBrowser;
tabBrowser.tabpanels?.classList.add("letterboxing");
for (let tab of tabBrowser.tabs) {
...
...
@@ -585,19 +627,7 @@ class _RFPHelper {
this._updateSizeForTabsInWindow(aWindow);
}
_attachAllWindows() {
let windowList = Services.wm.getEnumerator("navigator:browser");
while (windowList.hasMoreElements()) {
let win = windowList.getNext();
if (win.closed || !win.gBrowser) {
continue;
}
this._attachWindow(win);
}
}
_detachWindow(aWindow) {
let tabBrowser = aWindow.gBrowser;
...
...
@@ -616,20 +646,6 @@ class _RFPHelper {
}
}
_detachAllWindows() {
let windowList = Services.wm.getEnumerator("navigator:browser");
while (windowList.hasMoreElements()) {
let win = windowList.getNext();
if (win.closed || !win.gBrowser) {
continue;
}
this._detachWindow(win);
}
}
_handleDOMWindowOpened(win) {
let self = this;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment