Commit d0020b39 authored by ma1's avatar ma1 Committed by Pier Angelo Vendrame
Browse files

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

parent 4eb9b2c6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -377,6 +377,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#33282: new windows start at 1400x900 when there's enough screen space, otherwise down by 200x100 blocks
pref("privacy.window.maxInnerWidth", 1400);
pref("privacy.window.maxInnerHeight", 900);
+12 −0
Original line number Diff line number Diff line
@@ -2663,6 +2663,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
@@ -406,6 +406,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
+4 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ const kPrefLetterboxingVcenter =
  "privacy.resistFingerprinting.letterboxing.vcenter";
const kPrefLetterboxingGradient =
  "privacy.resistFingerprinting.letterboxing.gradient";
const  kPrefLetterboxingDidForceSize =
  "privacy.resistFingerprinting.letterboxing.didForceSize";

const kTopicDOMWindowOpened = "domwindowopened";

@@ -138,12 +140,14 @@ class _RFPHelper {
  _handlePrefChanged(data) {
    switch (data) {
      case kPrefResistFingerprinting:
        Service.prefs.clearUserPref(kPrefLetterboxingDidForceSize);
        this._handleResistFingerprintingChanged();
        break;
      case kPrefSpoofEnglish:
        this._handleSpoofEnglishChanged();
        break;
      case kPrefLetterboxing:
        Service.prefs.clearUserPref(kPrefLetterboxingDidForceSize);
      case kPrefLetterboxingVcenter:
      case kPrefLetterboxingGradient:
        this._handleLetterboxingPrefChanged();
+3 −1
Original line number Diff line number Diff line
@@ -2333,7 +2333,9 @@ static void SizeOpenedWindow(nsIDocShellTreeOwner* aTreeOwner,
          screenDesktopRect.Size() / screenCssToDesktopScale;

      if (aSizeSpec.SizeSpecified()) {
        if (!nsContentUtils::ShouldResistFingerprinting()) {
        if (!(nsContentUtils::ShouldResistFingerprinting() &&
              nsContentUtils::
                  ShouldRoundWindowSizeForResistingFingerprinting())) {
          /* Unlike position, force size out-of-bounds check only if
             size actually was specified. Otherwise, intrinsically sized
             windows are broken. */
Loading