browser/actors/RFPHelperChild.jsm
author Tom Ritter <tom@mozilla.com>
Wed, 20 Feb 2019 11:24:16 -0600
changeset 460141 1490c3e6cef1f187e96f464796ad1481f3259094
child 475405 f712de0c8a7ca23a3a1bde2ecae29d900dee8b0c
permissions -rw-r--r--
Bug 1407366 - Part 3: Implementing the window letterboxing. r=johannh This patch implements the window letterboxing. The implementation is based on adding margins around the browser element to round the content viewport size. Whenever the browser content is resized, the RFPHelper will adjust margins around it. But it won't add any margins for an empty browser or a browser loads a content with the system principal. The letterboxing is hidden behind a hidden pref "privacy.resistFingerprinting.letterboxing." By default, it will use stepping size 200x100 to round content window. And we can customize the set of dimensions used for deciding the size of the rounded content viewport by the pref "privacy.resistFingerprinting.letterboxing.dimensions". This pref should be formated as 'width1xheight1, width2xheight2, ...'. We will find the dimensions which can fit into the real content size and have the smallest margins to be the rounded content viewport size. For example , given the set "400x200, 500x300, 800x500" and the real content size "600x300", we would round the content size into 500x300.

/* -*- 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/. */

var EXPORTED_SYMBOLS = ["RFPHelperChild"];

const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");

const kPrefLetterboxing = "privacy.resistFingerprinting.letterboxing";

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

class RFPHelperChild extends ActorChild {
  handleEvent() {
    if (isLetterboxingEnabled) {
      this.mm.sendAsyncMessage("Letterboxing:ContentSizeUpdated");
    }
  }
}