зеркало из https://github.com/mozilla/gecko-dev.git
Bug 384336 - Firefox window should be maximized on first run on small screens. r=MattN
This commit is contained in:
Родитель
3989963e64
Коммит
f3092fa4c6
|
@ -997,35 +997,17 @@ var gBrowserInit = {
|
|||
|
||||
// Set a sane starting width/height for all resolutions on new profiles.
|
||||
if (!document.documentElement.hasAttribute("width")) {
|
||||
let defaultWidth;
|
||||
let defaultHeight;
|
||||
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);
|
||||
|
||||
// Very small: maximize the window
|
||||
// Portrait : use about full width and 3/4 height, to view entire pages
|
||||
// at once (without being obnoxiously tall)
|
||||
// Widescreen: use about half width, to suggest side-by-side page view
|
||||
// Otherwise : use 3/4 height and width
|
||||
if (screen.availHeight <= 600) {
|
||||
document.documentElement.setAttribute("width", width);
|
||||
document.documentElement.setAttribute("height", height);
|
||||
|
||||
if (width < TARGET_WIDTH && height < TARGET_HEIGHT) {
|
||||
document.documentElement.setAttribute("sizemode", "maximized");
|
||||
defaultWidth = 610;
|
||||
defaultHeight = 450;
|
||||
}
|
||||
else {
|
||||
if (screen.availWidth <= screen.availHeight) {
|
||||
defaultWidth = screen.availWidth * .9;
|
||||
defaultHeight = screen.availHeight * .75;
|
||||
}
|
||||
else if (screen.availWidth >= 2048) {
|
||||
defaultWidth = (screen.availWidth / 2) - 20;
|
||||
defaultHeight = screen.availHeight - 10;
|
||||
}
|
||||
else {
|
||||
defaultWidth = screen.availWidth * .75;
|
||||
defaultHeight = screen.availHeight * .75;
|
||||
}
|
||||
}
|
||||
document.documentElement.setAttribute("width", defaultWidth);
|
||||
document.documentElement.setAttribute("height", defaultHeight);
|
||||
}
|
||||
|
||||
if (!window.toolbar.visible) {
|
||||
|
|
|
@ -20,6 +20,25 @@ function test() {
|
|||
|
||||
waitForExplicitFinish();
|
||||
|
||||
if (window.windowState == window.STATE_MAXIMIZED) {
|
||||
registerCleanupFunction(function () {
|
||||
window.maximize();
|
||||
});
|
||||
|
||||
window.addEventListener("resize", function onResize(event) {
|
||||
if (event.target == window) {
|
||||
window.removeEventListener("resize", onResize, false);
|
||||
executeSoon(testTilt);
|
||||
}
|
||||
}, false);
|
||||
|
||||
window.restore();
|
||||
} else {
|
||||
testTilt();
|
||||
}
|
||||
}
|
||||
|
||||
function testTilt() {
|
||||
createTab(function() {
|
||||
TiltUtils.setDocumentZoom(window, ZOOM);
|
||||
|
||||
|
@ -51,10 +70,17 @@ function test() {
|
|||
ok(isApprox(contentWindow.innerHeight * ZOOM, arcball.height, 1),
|
||||
"The arcball height wasn't set correctly before the resize.");
|
||||
|
||||
|
||||
window.addEventListener("resize", onResize, false);
|
||||
window.resizeBy(-RESIZE * ZOOM, -RESIZE * ZOOM);
|
||||
|
||||
executeSoon(function() {
|
||||
function onResize(event) {
|
||||
if (event.target == window) {
|
||||
window.removeEventListener("resize", onResize, false);
|
||||
executeSoon(afterResize);
|
||||
}
|
||||
}
|
||||
|
||||
function afterResize() {
|
||||
ok(isApprox(contentWindow.innerWidth + RESIZE, initialWidth, 1),
|
||||
"The content window width wasn't set correctly after the resize.");
|
||||
ok(isApprox(contentWindow.innerHeight + RESIZE, initialHeight, 1),
|
||||
|
@ -70,13 +96,11 @@ function test() {
|
|||
ok(isApprox(contentWindow.innerHeight * ZOOM, arcball.height, 1),
|
||||
"The arcball height wasn't set correctly after the resize.");
|
||||
|
||||
|
||||
window.resizeBy(RESIZE * ZOOM, RESIZE * ZOOM);
|
||||
|
||||
|
||||
Services.obs.addObserver(cleanup, DESTROYED, false);
|
||||
Tilt.destroy(Tilt.currentWindowId);
|
||||
});
|
||||
}
|
||||
}
|
||||
}, false, function suddenDeath()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче