mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1439875: Fire MozBeforeInitialXULLayout before sizing the window. r=florian,smaug
This gives the chance to code that relies on setting the XUL window attributes to run before we actually size the window. This should prevent the resizing on OSX and fix some other untested stuff that the first commit probably broke... MozReview-Commit-ID: DhCWgmCppek --HG-- extra : rebase_source : 253bea4c4e90727c0e8cce4726bf7a695ca26d9d extra : source : 4d6f855ea529f6043b3ca886f53901e16a3d6405 extra : histedit_source : b0aa76063dca7a85e43b3bf670aab8f185a57915%2C760885a660c4fd92e7ae777614ad3cdc84dc9b31
This commit is contained in:
parent
c41e281661
commit
3beb2dc514
@ -1174,7 +1174,14 @@ function RedirectLoad({ target: browser, data }) {
|
||||
}
|
||||
|
||||
if (document.documentElement.getAttribute("windowtype") == "navigator:browser") {
|
||||
addEventListener("DOMContentLoaded", function() {
|
||||
window.addEventListener("MozBeforeInitialXULLayout", () => {
|
||||
gBrowserInit.onBeforeInitialXULLayout();
|
||||
}, { once: true });
|
||||
// The listener of DOMContentLoaded must be set on window, rather than
|
||||
// document, because the window can go away before the event is fired.
|
||||
// In that case, we don't want to initialize anything, otherwise we
|
||||
// may be leaking things because they will never be destroyed after.
|
||||
window.addEventListener("DOMContentLoaded", () => {
|
||||
gBrowserInit.onDOMContentLoaded();
|
||||
}, { once: true });
|
||||
}
|
||||
@ -1187,6 +1194,27 @@ var delayedStartupPromise = new Promise(resolve => {
|
||||
var gBrowserInit = {
|
||||
delayedStartupFinished: false,
|
||||
|
||||
onBeforeInitialXULLayout() {
|
||||
// Set a sane starting width/height for all resolutions on new profiles.
|
||||
if (Services.prefs.getBoolPref("privacy.resistFingerprinting")) {
|
||||
// When the fingerprinting resistance is enabled, making sure that we don't
|
||||
// have a maximum window to interfere with generating rounded window dimensions.
|
||||
document.documentElement.setAttribute("sizemode", "normal");
|
||||
} else if (!document.documentElement.hasAttribute("width")) {
|
||||
const TARGET_WIDTH = 1280;
|
||||
const TARGET_HEIGHT = 1040;
|
||||
let width = Math.min(screen.availWidth * .9, TARGET_WIDTH);
|
||||
let height = Math.min(screen.availHeight * .9, TARGET_HEIGHT);
|
||||
|
||||
document.documentElement.setAttribute("width", width);
|
||||
document.documentElement.setAttribute("height", height);
|
||||
|
||||
if (width < TARGET_WIDTH && height < TARGET_HEIGHT) {
|
||||
document.documentElement.setAttribute("sizemode", "maximized");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onDOMContentLoaded() {
|
||||
gBrowser = window._gBrowser;
|
||||
delete window._gBrowser;
|
||||
@ -1230,25 +1258,6 @@ var gBrowserInit = {
|
||||
initBrowser.removeAttribute("blank");
|
||||
}
|
||||
|
||||
// Set a sane starting width/height for all resolutions on new profiles.
|
||||
if (Services.prefs.getBoolPref("privacy.resistFingerprinting")) {
|
||||
// When the fingerprinting resistance is enabled, making sure that we don't
|
||||
// have a maximum window to interfere with generating rounded window dimensions.
|
||||
document.documentElement.setAttribute("sizemode", "normal");
|
||||
} else if (!document.documentElement.hasAttribute("width")) {
|
||||
const TARGET_WIDTH = 1280;
|
||||
const TARGET_HEIGHT = 1040;
|
||||
let width = Math.min(screen.availWidth * .9, TARGET_WIDTH);
|
||||
let height = Math.min(screen.availHeight * .9, TARGET_HEIGHT);
|
||||
|
||||
document.documentElement.setAttribute("width", width);
|
||||
document.documentElement.setAttribute("height", height);
|
||||
|
||||
if (width < TARGET_WIDTH && height < TARGET_HEIGHT) {
|
||||
document.documentElement.setAttribute("sizemode", "maximized");
|
||||
}
|
||||
}
|
||||
|
||||
gBrowser.updateBrowserRemoteness(initBrowser, isRemote, {
|
||||
remoteType, sameProcessAsFrameLoader
|
||||
});
|
||||
|
@ -2661,6 +2661,13 @@ XULDocument::DoneWalking()
|
||||
|
||||
NotifyPossibleTitleChange(false);
|
||||
|
||||
nsContentUtils::DispatchTrustedEvent(
|
||||
this,
|
||||
static_cast<nsIDocument*>(this),
|
||||
NS_LITERAL_STRING("MozBeforeInitialXULLayout"),
|
||||
true,
|
||||
false);
|
||||
|
||||
// Before starting layout, check whether we're a toplevel chrome
|
||||
// window. If we are, setup some state so that we don't have to restyle
|
||||
// the whole tree after StartLayout.
|
||||
@ -2677,12 +2684,6 @@ XULDocument::DoneWalking()
|
||||
}
|
||||
}
|
||||
|
||||
nsContentUtils::DispatchTrustedEvent(this,
|
||||
static_cast<nsIDocument*>(this),
|
||||
NS_LITERAL_STRING("MozBeforeInitialXULLayout"),
|
||||
true,
|
||||
false);
|
||||
|
||||
StartLayout();
|
||||
|
||||
if (mIsWritingFastLoad && IsChromeURI(mDocumentURI))
|
||||
|
Loading…
Reference in New Issue
Block a user