However if anyone decides to do this in Tor browser then I suggest that you also add some kind of soft pattern to the letterboxing space to make the separation from the page content clear at a glance. Right now it's hard to distinguish on pages that use white background, so on most pages.
The pattern could be even something Tor-related, such as little onion watermarks. This will also more clearly signal to users that this space around the page content is very much intentional and is part of Tor browser's mission to fight against fingerprinting. Right now there's a lot of users confused by the letterboxing, mistaking it for a bug.
When I tried doing this before, it seemed like it was going to be really difficult. But as we've refactored a bunch of XBL stuff I think it might have gotten easier.
If use the browser toolbox to select the with class 'browserStack' that has the window, and manipulate that element's bgcolor - that's what I would try to get working but I can't dig into this for the next several months.
This and other features relating to letterboxing should be made a bigger priority. Most people don't know what letterboxing is and many think it is a bug introduced in the new browser version. The current letterboxing affects the browsing experience more than you would expect and will make users search for the preference to turn off the feature completely which is not a good outcome.
Ok, I spent today working out an improved UX with letterboxing and present the following prototypes.
This change gives the appearance of extending down the browser chrome to the content area, and the content itself being nested within it. A border is added that is the same color as the border currently used to separate the toolbars and the content area. It's currently 1px wide to match the rest of the chrome borders, but it can be tweaked.
The patch to do this unfortunately does require a bit of fiddling with the actual fingerprinting code. The letterbox size calculation needed to be updated to take border width into account (and can be further tweaked to also take into account margin if we wish). I also discovered (and hopefully fixed/avoided) a neat little race condition that would result in over-vigorous letter-boxing when opening a new-tab.
I like the idea, thanks! Two things I realized while testing which should get fixed:
Suddenly letterboxing is applied even to my default screen size which is properly rounded. That should not happen. Users should only see letterboxing in effect if the windows is a) not properly rounded on start-up (which is happening without your patch on my system) or b) getting resized.
For some reason the color next to the scrollbar is still the old one on the about:tor page (that is white as before) in non-dark mode while all the other parts do get the chrome color. Can you see that as well on your system?
It makes me a bit nervous to see the CSS changed unconditionally while Letterboxing itself is bound to a pref. It seems to work as far as I can tell but we should think harder about an upstreamable solution as I suspect Mozilla would not take the approach you have chosen.
Trac: Keywords: TorBrowserTeam201910R deleted, TorBrowserTeam201910 added Status: needs_review to needs_revision
gk: Letterboxing now only occurs when necessary and there are no more unconditional CSS changes (each rule is now behind a 'letterbox' class). I haven't seen the scrollbar color issue you've described with the most recent patch.
The browser content is now anchored to the toolbar, but the toolbar's horizontal border must remain. If we end up not liking that horizontal line, we can go further in and modify the global styles a bit.
gk: Letterboxing now only occurs when necessary and there are no more unconditional CSS changes (each rule is now behind a 'letterbox' class). I haven't seen the scrollbar color issue you've described with the most recent patch.
I am inclined to think that's been a local glitch in my setup. Sorry for the noise.
The browser content is now anchored to the toolbar, but the toolbar's horizontal border must remain. If we end up not liking that horizontal line, we can go further in and modify the global styles a bit.
Thanks! Nice work. I am not sure whether we like that but let's give it a try. I tested the code on Linux, Windows, and macOS and it is working for me as expected.
Some code questions:
// 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.- aBrowser.style.margin = `${margins.height}px ${margins.width}px`;+ aBrowser.classList.add("letterboxing");
Is that commit still accurate? I mean we do now deal with the margin color thanks to your patch.
Why are you calling aBrowser.classList.add("letterboxing"); here and in other places after you called this._resolveBorderDimensions(aBrowser); which already adds letterboxing? Wouldn't it be enough to just do it once? If not could you add a comment as to why this is needed (again)? Maybe that's for the case that someone is flipping the pref in the browser without reloading a page or restarting the browser?
Ok I've updated the patch with a fixup commit which makes the tabpanel color change conditional to letterboxing being enabled, and I've removed the redundant addition of "letterboxing" to the browser element class list and am now only doing it on one place.
And here's a followup/optional commit which adds about:tor to the set of pages that do not need letterboxing (like about:blank). It's our built-in page, so I don't see any reason why it needs to be letterboxed, but I left it out of the fixup commit just in case we do want it letterboxed.
Ok I've updated the patch with a fixup commit which makes the tabpanel color change conditional to letterboxing being enabled, and I've removed the redundant addition of "letterboxing" to the browser element class list and am now only doing it on one place.
Thanks this looks good now. The fixup idea is good (and confused me at first because I was not used to it from you ;) ) as it makes reviewing eas(y)(ier). I squashed it (please do that the next time as this saves some time on the reviewer's/merger's side) and applied it to tor-browser-68.2.0esr-9.5-1 (commit ff808390).
And here's a followup/optional commit which adds about:tor to the set of pages that do not need letterboxing (like about:blank). It's our built-in page, so I don't see any reason why it needs to be letterboxed, but I left it out of the fixup commit just in case we do want it letterboxed.
I am a bit reluctant here and think we should discussing how we want to deal with privileged pages and about:tor in particular. Here is my concern I had:
18:46 <+GeKo> for the about:tor page exemption18:47 <+GeKo> i had been thinking about mentioning that in my review18:47 <+GeKo> but then thought it might be confusing to users when the window is suddenly starting "to do" things18:47 <+GeKo> while they just tried to visit a page18:48 <+GeKo> users don't have the concept of priviledged vs. non-priviledged pages
pospeselr: could you open a ticket for that discussion including your idea to generally apply letterboxing to privileged sites, too?
Trac: Status: needs_review to closed Resolution: N/Ato fixed
This change is a large one so that letting it bake another 4 weeks does not sound unreasonable. In particular as the fix has only seen testing two weeks in the alpha series so far. Additionally, we might be able to pick up the fix for 1594455 directly that way.
Just wanted to mention here that setting ui.systemUsesDarkTheme: 1 and browser.in-content.dark-mode: true in about:config will change the latest Tor Browser to use a dark letterbox border (as well as dark Preferences page, Add-ons page, etc). Since these settings may also enable the CSS prefers-color-scheme feature, these settings may make you fingerprintable.