Commit c0759236 authored by ma1's avatar ma1 Committed by clairehurst
Browse files

BB 41918: Option to reuse last window size when letterboxing is enabled.

parent 8d06ca4d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -469,6 +469,8 @@ pref("privacy.resistFingerprinting.randomDataOnCanvasExtract", true, locked);
pref("privacy.resistFingerprinting", true);
pref("privacy.resistFingerprinting.exemptedDomains", "");
#endif
// tor-browser#43904: Enable this so we skip the blank window if user is resisting fingerprinting.
pref("privacy.resistFingerprinting.skipEarlyBlankFirstPaint", true);
// tor-browser#18603: failIfMajorPerformanceCaveat is an optional attribute that
// can be used when creating a WebGL context if the browser detects that the
// performance would be low. That could be used to fingerpting users with a not
@@ -512,6 +514,8 @@ pref("privacy.resistFingerprinting.letterboxing", true);
pref("privacy.resistFingerprinting.letterboxing.vcenter", true);
// tor-browser#41917: Letterboxing gradient background
pref("privacy.resistFingerprinting.letterboxing.gradient", true);
// tor-browser#41918: Should we reuse last window sizes if letterboxing is enabled
pref("privacy.resistFingerprinting.letterboxing.rememberSize", false);
// tor-browser#43402: Avoid a resize from the skeleton to the newwin size.
// Should be fixed in ESR-140 with Bug 1448423.
pref("browser.startup.blankWindow", false);
+12 −0
Original line number Diff line number Diff line
@@ -2939,6 +2939,18 @@ void nsContentUtils::CalcRoundedWindowSizeForResistingFingerprinting(
  *aOutputHeight = resultHeight;
}

bool nsContentUtils::ShouldRoundWindowSizeForResistingFingerprinting() {
  return !(
      Preferences::GetBool("privacy.resistFingerprinting.letterboxing",
                           false) &&
      // We want to round window size at least once in the browser's life time:
      // AppWindow::ForceRoundedDimensions() will set this preference to true.
      Preferences::GetBool(
          "privacy.resistFingerprinting.letterboxing.didForceSize", false) &&
      Preferences::GetBool(
          "privacy.resistFingerprinting.letterboxing.rememberSize", false));
}

bool nsContentUtils::ThreadsafeIsCallerChrome() {
  return NS_IsMainThread() ? IsCallerChrome()
                           : IsCurrentThreadRunningChromeWorker();
+4 −0
Original line number Diff line number Diff line
@@ -420,6 +420,10 @@ class nsContentUtils {
      bool aSetOuterWidth, bool aSetOuterHeight, int32_t* aOutputWidth,
      int32_t* aOutputHeight);

  // Tell if we actually want to round size of new windows for RFP,
  // depending on letterboxing status and user's preference.
  static bool ShouldRoundWindowSizeForResistingFingerprinting();

  /**
   * Returns the parent node of aChild crossing document boundaries, but skips
   * any cross-process parent frames and continues with the nearest in-process
+11 −1
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@ const kPrefLetterboxingTesting =
  "privacy.resistFingerprinting.letterboxing.testing";
const kPrefLetterboxingVcenter =
  "privacy.resistFingerprinting.letterboxing.vcenter";
const kPrefLetterboxingDidForceSize =
  "privacy.resistFingerprinting.letterboxing.didForceSize";
const kPrefLetterboxingRememberSize =
  "privacy.resistFingerprinting.letterboxing.rememberSize";

const kTopicDOMWindowOpened = "domwindowopened";
const kTopicDOMWindowClosed = "domwindowclosed";
@@ -173,6 +177,7 @@ class _RFPHelper {
  _handlePrefChanged(data) {
    switch (data) {
      case kPrefResistFingerprinting:
        Services.prefs.clearUserPref(kPrefLetterboxingDidForceSize);
        this._handleResistFingerprintingChanged();
        break;
      case kPrefSpoofEnglish:
@@ -180,6 +185,8 @@ class _RFPHelper {
        this._handleSpoofEnglishChanged();
        break;
      case kPrefLetterboxing:
        Services.prefs.clearUserPref(kPrefLetterboxingDidForceSize);
      // fall-through
      case kPrefLetterboxingVcenter:
        this._handleLetterboxingPrefChanged();
        break;
@@ -1061,7 +1068,10 @@ class _RFPHelper {
  }

  _fixRounding(aWindow) {
    if (!this.rfpEnabled) {
    if (
      !this.rfpEnabled ||
      Services.prefs.getBoolPref(kPrefLetterboxingRememberSize, false)
    ) {
      return;
    }

+2 −1
Original line number Diff line number Diff line
@@ -2366,7 +2366,8 @@ static void SizeOpenedWindow(nsIDocShellTreeOwner* aTreeOwner,
                "complicated, and this is a conservative behavior to avoid "
                "exempting something that shouldn't be. It also presents a "
                "uniform behavior for something that's very browser-related.",
                RFPTarget::RoundWindowSize)) {
                RFPTarget::RoundWindowSize) &&
            nsContentUtils::ShouldRoundWindowSizeForResistingFingerprinting()) {
          /* Unlike position, force size out-of-bounds check only if
             size actually was specified. Otherwise, intrinsically sized
             windows are broken. */
Loading