[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser/tor-browser-60.6.1esr-9.0-1] Bug 1548634 - Update the default letterboxing behavior to use stepped ranges r=johannh
commit 166a752ab22ef1415c250eff37e1ada3f2f24915
Author: Tom Ritter <tom@xxxxxxxxxxx>
Date: Tue May 7 16:06:43 2019 +0000
Bug 1548634 - Update the default letterboxing behavior to use stepped ranges r=johannh
Differential Revision: https://phabricator.services.mozilla.com/D29759
---
.../browser/browser_dynamical_window_rounding.js | 11 ++++------
.../components/resistfingerprinting/RFPHelper.jsm | 25 +++++++++++++++++-----
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/browser/components/resistfingerprinting/test/browser/browser_dynamical_window_rounding.js b/browser/components/resistfingerprinting/test/browser/browser_dynamical_window_rounding.js
index ae8055a49ce5..784fb42b8631 100644
--- a/browser/components/resistfingerprinting/test/browser/browser_dynamical_window_rounding.js
+++ b/browser/components/resistfingerprinting/test/browser/browser_dynamical_window_rounding.js
@@ -11,9 +11,7 @@
*/
const TEST_PATH = "http://example.net/browser/browser/components/resistfingerprinting/test/browser/";
-
-const DEFAULT_ROUNDED_WIDTH_STEP = 200;
-const DEFAULT_ROUNDED_HEIGHT_STEP = 100;
+const { RFPHelper } = ChromeUtils.import("resource://gre/modules/RFPHelper.jsm");
// A set of test cases which defines the width and the height of the outer window.
const TEST_CASES = [
@@ -50,10 +48,9 @@ function handleOSFuzziness(aContent, aTarget) {
function checkForDefaultSetting(
aContentWidth, aContentHeight, aRealWidth, aRealHeight) {
- // The default behavior for rounding is to round window with 200x100 stepping.
- // So, we can get the rounded size by subtracting the remainder.
- let targetWidth = aRealWidth - (aRealWidth % DEFAULT_ROUNDED_WIDTH_STEP);
- let targetHeight = aRealHeight - (aRealHeight % DEFAULT_ROUNDED_HEIGHT_STEP);
+ // We can get the rounded size by subtracting twice the margin.
+ let targetWidth = aRealWidth - (2 * RFPHelper.steppedRange(aRealWidth));
+ let targetHeight = aRealHeight - (2 * RFPHelper.steppedRange(aRealHeight));
// This platform-specific code is explained in the large comment below.
if (getPlatform() != "linux") {
diff --git a/toolkit/components/resistfingerprinting/RFPHelper.jsm b/toolkit/components/resistfingerprinting/RFPHelper.jsm
index 2f3a1dd0e659..5f23d0679b53 100755
--- a/toolkit/components/resistfingerprinting/RFPHelper.jsm
+++ b/toolkit/components/resistfingerprinting/RFPHelper.jsm
@@ -21,9 +21,6 @@ const kPrefLetterboxingTesting =
const kTopicDOMWindowOpened = "domwindowopened";
const kEventLetterboxingSizeUpdate = "Letterboxing:ContentSizeUpdated";
-const kDefaultWidthStepping = 200;
-const kDefaultHeightStepping = 100;
-
var logConsole;
function log(msg) {
if (!logConsole) {
@@ -338,6 +335,24 @@ class _RFPHelper {
}
/**
+ * Given a width or height, returns the appropriate margin to apply.
+ */
+ steppedRange(aDimension) {
+ let stepping;
+ if (aDimension <= 50) {
+ return 0;
+ } else if (aDimension <= 500) {
+ stepping = 50;
+ } else if (aDimension <= 1600) {
+ stepping = 100;
+ } else {
+ stepping = 200;
+ }
+
+ return (aDimension % stepping) / 2;
+ }
+
+ /**
* The function will round the given browser by adding margins around the
* content viewport.
*/
@@ -373,8 +388,8 @@ class _RFPHelper {
// stepping size.
if (!this._letterboxingDimensions.length) {
result = {
- width: (aWidth % kDefaultWidthStepping) / 2,
- height: (aHeight % kDefaultHeightStepping) / 2,
+ width: this.steppedRange(aWidth),
+ height: this.steppedRange(aHeight),
};
log("_roundContentView[" + logId + "] calcMargins(" + aWidth + ", " + aHeight + ") = " + result.width + " x " + result.height);
return result;
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits