Skip to content
Snippets Groups Projects
Verified Commit a17ec8e0 authored by ma1's avatar ma1
Browse files

fixup! Bug 41631: Prevent weird initial window dimensions caused by subpixel computations

Bug 42520: Correctly record new initial window size after auto-shrinking
parent 9eaf8f6d
No related branches found
No related tags found
No related merge requests found
......@@ -633,9 +633,16 @@ class _RFPHelper {
lazy.logConsole.error(e);
}
}
if (needToShrink) {
win.shrinkToLetterbox();
this._recordWindowSize(win);
if (needToShrink && win.shrinkToLetterbox()) {
win.addEventListener(
"resize",
() => {
// We need to record the "new" initial size in this listener
// because resized dimensions are not immediately available.
RFPHelper._recordWindowSize(win);
},
{ once: true }
);
}
});
},
......@@ -741,23 +748,30 @@ class _RFPHelper {
}
_recordWindowSize(aWindow) {
aWindow._rfpOriginalSize = {
width: aWindow.outerWidth,
height: aWindow.outerHeight,
containerHeight: aWindow.gBrowser.getBrowserContainer()?.clientHeight,
};
log("Recording original window size", aWindow._rfpOriginalSize);
aWindow.promiseDocumentFlushed(() => {
aWindow._rfpOriginalSize = {
width: aWindow.outerWidth,
height: aWindow.outerHeight,
containerHeight: aWindow.gBrowser.getBrowserContainer()?.clientHeight,
};
log("Recording original window size", aWindow._rfpOriginalSize);
});
}
// 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.
// Returns true if a window resize will occur, false otherwise.
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);
if (inner.width !== outer.witdh || inner.height !== outer.height) {
this.resizeBy(inner.width - outer.width, inner.height - outer.height);
return true;
}
return false;
}
_onWindowDoubleClick(e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment