[tbb-commits] [Git][tpo/applications/tor-browser][tor-browser-115.9.0esr-13.5-1] Bug 42443: Shrink window to match letterboxing size when the emtpy area is clicked.

ma1 (@ma1) git at gitlab.torproject.org
Wed Mar 13 15:41:57 UTC 2024



ma1 pushed to branch tor-browser-115.9.0esr-13.5-1 at The Tor Project / Applications / Tor Browser


Commits:
c99204f2 by hackademix at 2024-03-13T16:39:27+01:00
Bug 42443: Shrink window to match letterboxing size when the emtpy area is clicked.

- - - - -


1 changed file:

- toolkit/components/resistfingerprinting/RFPHelper.sys.mjs


Changes:

=====================================
toolkit/components/resistfingerprinting/RFPHelper.sys.mjs
=====================================
@@ -750,8 +750,27 @@ class _RFPHelper {
     });
   }
 
+  // We will attach this method to each browser window. When called
+  // it will instantly resize the window to exactly fit the selected
+  // (possibly letterboxed) browser.
+  shrinkToLetterbox() {
+    let { selectedBrowser } = this.gBrowser;
+    let stack = selectedBrowser.closest(".browserStack");
+    const outer = stack.getBoundingClientRect();
+    const inner = selectedBrowser.getBoundingClientRect();
+    this.resizeBy(inner.width - outer.width, inner.height - outer.height);
+  }
+
+  _onWindowDoubleClick(e) {
+    if (e.target.classList.contains("browserStack")) {
+      e.currentTarget.shrinkToLetterbox();
+    }
+  }
+
   _attachWindow(aWindow) {
     aWindow.addEventListener("sizemodechange", windowResizeHandler);
+    aWindow.shrinkToLetterbox = this.shrinkToLetterbox;
+    aWindow.addEventListener("dblclick", this._onWindowDoubleClick);
     aWindow.gBrowser.addTabsProgressListener(this);
     aWindow.addEventListener("TabOpen", this);
     const resizeObserver = (aWindow._rfpResizeObserver =
@@ -783,9 +802,12 @@ class _RFPHelper {
       let browser = tab.linkedBrowser;
       this._resetContentSize(browser);
     }
+    aWindow.removeEventListener("dblclick", this._onWindowDoubleClick);
+    delete aWindow.shrinkToLetterbox;
     aWindow.removeEventListener("sizemodechange", windowResizeHandler);
   }
 
+
   _handleDOMWindowOpened(win) {
     let self = this;
 



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/c99204f2656a665e7cc90ac3a1b1760f41e63168

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/c99204f2656a665e7cc90ac3a1b1760f41e63168
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20240313/c414e7d7/attachment-0001.htm>


More information about the tbb-commits mailing list