Verified Commit 0976030f authored by ma1's avatar ma1
Browse files

Bug 32308: use direct browser sizing for letterboxing.

Bug 30556: align letterboxing with 200x100 new win width stepping
parent dd5cf837
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

const kPrefLetterboxing = "privacy.resistFingerprinting.letterboxing";

const lazy = {};

XPCOMUtils.defineLazyPreferenceGetter(
  lazy,
  "isLetterboxingEnabled",
  kPrefLetterboxing,
  false
);

export class RFPHelperChild extends JSWindowActorChild {
  handleEvent(event) {
    if (lazy.isLetterboxingEnabled && event.type == "resize") {
      this.sendAsyncMessage("Letterboxing:ContentSizeUpdated");
    }
  }
}
+0 −33
Original line number Diff line number Diff line
1; /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
  RFPHelper: "resource://gre/modules/RFPHelper.sys.mjs",
});

const kPrefLetterboxing = "privacy.resistFingerprinting.letterboxing";

XPCOMUtils.defineLazyPreferenceGetter(
  lazy,
  "isLetterboxingEnabled",
  kPrefLetterboxing,
  false
);

export class RFPHelperParent extends JSWindowActorParent {
  receiveMessage(aMessage) {
    if (
      lazy.isLetterboxingEnabled &&
      aMessage.name == "Letterboxing:ContentSizeUpdated"
    ) {
      let browser = this.browsingContext.top.embedderElement;
      let window = browser.ownerGlobal;
      lazy.RFPHelper.contentSizeUpdated(window);
    }
  }
}
+0 −2
Original line number Diff line number Diff line
@@ -77,8 +77,6 @@ FINAL_TARGET_FILES.actors += [
    "PromptParent.sys.mjs",
    "RefreshBlockerChild.sys.mjs",
    "RefreshBlockerParent.sys.mjs",
    "RFPHelperChild.sys.mjs",
    "RFPHelperParent.sys.mjs",
    "ScreenshotsComponentChild.sys.mjs",
    "SearchSERPTelemetryChild.sys.mjs",
    "SearchSERPTelemetryParent.sys.mjs",
+24 −4
Original line number Diff line number Diff line
@@ -127,16 +127,36 @@ body {
  -moz-window-dragging: drag;
}

.letterboxing .browserContainer {
  /*
  From Firefox 115 on, .browserContainer layout is flex / column,
  and without this trick the .browserStack's resize observer
  doesn't get notified on horizontal shrinking.
  */
  overflow-x: hidden;
}

/**
  Never modify the following selector without synchronizing
  LETTERBOX_CSS_SELECTOR in RFPHelper.jsm!
**/
.letterboxing .browserStack > browser:not(.exclude-letterboxing) {
  margin: 0; /* to be dynamically set by RFHelper.jsm */
.letterboxing .browserContainer:not(.responsive-mode) > .browserStack:not(.exclude-letterboxing) > browser {
  /* width & height to be dynamically set by RFPHelper.jsm */
  outline: 1px solid var(--chrome-content-separator-color);
}

.exclude-letterboxing > browser {
  outline: initial;
}

:root:not([inDOMFullscreen]) .letterboxing.letterboxing-ready .browserContainer:not(.responsive-mode) > .browserStack:not(.exclude-letterboxing) {
  place-content: start center;
}

browser.exclude-letterboxing {
  margin: 0 !important;
/* extend down the toolbar's colors when letterboxing is enabled */
.letterboxing {
  background-color: var(--toolbar-bgcolor);
  background-image: var(--toolbar-bgimage);
}

#toolbar-menubar[autohide="true"] {
+4 −4
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ async function test_dynamical_window_rounding(aWindow, aCheckFunc) {
  // We need to wait for the updating the margins for the newly opened tab, or
  // it will affect the following tests.
  let promiseForTheFirstRounding = TestUtils.topicObserved(
    "test:letterboxing:update-margin-finish"
    "test:letterboxing:update-size-finish"
  );

  info("Open a content tab for testing.");
@@ -108,7 +108,7 @@ async function test_dynamical_window_rounding(aWindow, aCheckFunc) {
    let caseString = "Case " + width + "x" + height + ": ";
    // Create a promise for waiting for the margin update.
    let promiseRounding = TestUtils.topicObserved(
      "test:letterboxing:update-margin-finish"
      "test:letterboxing:update-size-finish"
    );

    let { containerWidth, containerHeight } = getContainerSize(tab);
@@ -316,7 +316,7 @@ async function test_findbar(aWindow) {
  );

  let promiseRounding = TestUtils.topicObserved(
    "test:letterboxing:update-margin-finish"
    "test:letterboxing:update-size-finish"
  );

  let findBarOpenPromise = BrowserTestUtils.waitForEvent(
@@ -330,7 +330,7 @@ async function test_findbar(aWindow) {
  ok(true, "Margin updated when findbar opened");

  promiseRounding = TestUtils.topicObserved(
    "test:letterboxing:update-margin-finish"
    "test:letterboxing:update-size-finish"
  );

  let findBarClosePromise = BrowserTestUtils.waitForEvent(
Loading