mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +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
This commit is contained in:
parent
184558072c
commit
6c15a62ef4
@ -1194,7 +1194,10 @@ function RedirectLoad({ target: browser, data }) {
|
||||
}
|
||||
|
||||
if (document.documentElement.getAttribute("windowtype") == "navigator:browser") {
|
||||
addEventListener("DOMContentLoaded", function() {
|
||||
document.addEventListener("MozBeforeInitialXULLayout", function() {
|
||||
gBrowserInit.onBeforeInitialXULLayout();
|
||||
}, { once: true });
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
gBrowserInit.onDOMContentLoaded();
|
||||
}, { once: true });
|
||||
}
|
||||
@ -1207,6 +1210,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() {
|
||||
window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(nsIWebNavigation)
|
||||
@ -1246,25 +1270,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
|
||||
});
|
||||
|
@ -2662,6 +2662,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.
|
||||
@ -2678,12 +2685,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