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
bcbf022f11
commit
98d261390a
@ -1190,7 +1190,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 });
|
||||
}
|
||||
@ -1203,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() {
|
||||
gBrowser = window._gBrowser;
|
||||
delete window._gBrowser;
|
||||
@ -1246,25 +1274,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