зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 80e6be24260d (bug 1654962
) for causing bc failures in browser_modal_print.js
CLOSED TREE
This commit is contained in:
Родитель
0d84d6441b
Коммит
3e266b539c
|
@ -1363,16 +1363,11 @@ toolbarpaletteitem > toolbaritem {
|
|||
}
|
||||
|
||||
/* Print pending */
|
||||
.printSettingsBrowser {
|
||||
width: 250px !important;
|
||||
}
|
||||
|
||||
.previewStack {
|
||||
background-color: #f9f9fa;
|
||||
color: #0c0c0d;
|
||||
}
|
||||
|
||||
.previewRendering {
|
||||
width: 500px;
|
||||
height: 600px;
|
||||
color: #0c0c0d;
|
||||
background-color: #f9f9fa;
|
||||
background-image: url("chrome://browser/skin/tabbrowser/pendingpaint.png");
|
||||
background-repeat: no-repeat;
|
||||
background-size: 60px 60px;
|
||||
|
@ -1403,7 +1398,7 @@ toolbarpaletteitem > toolbaritem {
|
|||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.previewStack {
|
||||
.previewRendering {
|
||||
background-color: #2A2A2E;
|
||||
color: rgb(249, 249, 250);
|
||||
}
|
||||
|
@ -1471,45 +1466,6 @@ toolbar[keyNav=true]:not([collapsed=true]):not([customizing=true]) toolbartabsto
|
|||
min-width: 66ch;
|
||||
}
|
||||
|
||||
.dialogBox[sizeto="available"] {
|
||||
--box-inline-margin: 4px;
|
||||
--box-block-margin: 4px;
|
||||
--box-ideal-width: 1000;
|
||||
--box-ideal-height: 650;
|
||||
--box-max-width-margin: calc(100vw - 2 * var(--box-inline-margin));
|
||||
--box-max-height-margin: calc(100vh - var(--box-top-px) - var(--box-block-margin));
|
||||
--box-max-width-ratio: 70vw;
|
||||
--box-max-height-ratio: calc(var(--box-ideal-height) / var(--box-ideal-width) * var(--box-max-width-ratio));
|
||||
max-width: min(max(var(--box-ideal-width) * 1px, var(--box-max-width-ratio)), var(--box-max-width-margin));
|
||||
max-height: min(max(var(--box-ideal-height) * 1px, var(--box-max-height-ratio)), var(--box-max-height-margin));
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
@media (min-width: 550px) {
|
||||
.dialogBox[sizeto="available"] {
|
||||
--box-inline-margin: min(calc(4px + (100vw - 550px) / 4), 16px);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 800px) {
|
||||
.dialogBox[sizeto="available"] {
|
||||
--box-inline-margin: min(calc(16px + (100vw - 800px) / 4), 32px);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-height: 350px) {
|
||||
.dialogBox[sizeto="available"] {
|
||||
--box-block-margin: min(calc(4px + (100vh - 350px) / 4), 16px);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-height: 550px) {
|
||||
.dialogBox[sizeto="available"] {
|
||||
--box-block-margin: min(calc(16px + (100vh - 550px) / 4), 32px);
|
||||
}
|
||||
}
|
||||
|
||||
.dialogFrame {
|
||||
margin: 0;
|
||||
-moz-box-flex: 1;
|
||||
|
|
|
@ -8906,10 +8906,9 @@ class TabDialogBox {
|
|||
* @param {String} aURL - URL of the dialog to load in the tab box.
|
||||
* @param {String} [aFeatures] - Comma separated list of window features.
|
||||
* @param {*} [aParams] - Parameters to pass to dialog window.
|
||||
* @param {Object} [aOpenOptions] - Parameters to pass to dialog open method.
|
||||
* @returns {Promise} - Resolves once the dialog has been closed.
|
||||
*/
|
||||
open(aURL, aFeatures = null, aParams = null, aOpenOptions = null) {
|
||||
open(aURL, aFeatures = null, aParams = null) {
|
||||
return new Promise(resolve => {
|
||||
if (!this._dialogManager.hasDialogs) {
|
||||
this._onFirstDialogOpen();
|
||||
|
@ -8927,8 +8926,7 @@ class TabDialogBox {
|
|||
}
|
||||
},
|
||||
// Resolve on closed callback
|
||||
resolve,
|
||||
aOpenOptions
|
||||
resolve
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -272,8 +272,8 @@
|
|||
</menulist>
|
||||
|
||||
<html:template id="printPreviewStackTemplate">
|
||||
<stack class="previewStack" rendering="true" flex="1">
|
||||
<vbox class="previewRendering" flex="1">
|
||||
<stack class="previewStack" rendering="true">
|
||||
<vbox class="previewRendering">
|
||||
<h1 class="print-pending-label" data-l10n-id="printui-loading"></h1>
|
||||
</vbox>
|
||||
</stack>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
html, body {
|
||||
width: 250px;
|
||||
height: 100vh;
|
||||
height: 600px;
|
||||
}
|
||||
|
||||
body {
|
||||
|
|
|
@ -20,10 +20,6 @@ document.addEventListener(
|
|||
"DOMContentLoaded",
|
||||
e => {
|
||||
document.mozSubdialogReady = PrintEventHandler.init();
|
||||
let ourBrowser = window.docShell.chromeEventHandler;
|
||||
ourBrowser.setAttribute("flex", "0");
|
||||
ourBrowser.classList.add("printSettingsBrowser");
|
||||
ourBrowser.closest(".dialogBox").classList.add("printDialogBox");
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
|
@ -131,7 +127,6 @@ var PrintEventHandler = {
|
|||
skipLoad: false,
|
||||
});
|
||||
printPreviewBrowser.classList.add("printPreviewBrowser");
|
||||
printPreviewBrowser.setAttribute("flex", "1");
|
||||
|
||||
// Create the stack for the loading indicator.
|
||||
let ourBrowser = window.docShell.chromeEventHandler;
|
||||
|
@ -314,16 +309,10 @@ var PrintEventHandler = {
|
|||
const printerList = Cc["@mozilla.org/gfx/printerlist;1"].createInstance(
|
||||
Ci.nsIPrinterList
|
||||
);
|
||||
let printers;
|
||||
|
||||
if (Cu.isInAutomation) {
|
||||
printers = [];
|
||||
} else {
|
||||
printers = await printerList.printers;
|
||||
}
|
||||
|
||||
const lastUsedPrinterName = PrintUtils._getLastUsedPrinterName();
|
||||
const defaultPrinterName = printerList.systemDefaultPrinterName;
|
||||
const printers = await printerList.printers;
|
||||
|
||||
let lastUsedPrinter;
|
||||
let defaultPrinter;
|
||||
|
|
|
@ -152,9 +152,7 @@ var PrintUtils = {
|
|||
let dialogBox = gBrowser.getTabDialogBox(sourceBrowser);
|
||||
dialogBox.open(
|
||||
`chrome://global/content/print.html?browsingContextId=${aBrowsingContext.id}`,
|
||||
"resizable=no",
|
||||
null,
|
||||
{ sizeTo: "available" }
|
||||
"resizable=no"
|
||||
);
|
||||
},
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
[DEFAULT]
|
||||
support-files =
|
||||
head.js
|
||||
simplifyArticleSample.html
|
||||
|
||||
[browser_modal_print.js]
|
||||
|
||||
[browser_modal_resize.js]
|
||||
support-files =
|
||||
simplifyArticleSample.html
|
||||
skip-if = true # Bug 1656688
|
||||
|
||||
[browser_page_change_print_original.js]
|
||||
support-files =
|
||||
|
@ -24,4 +24,6 @@ support-files =
|
|||
file_coop_header.html^headers^
|
||||
|
||||
[browser_preview_switch_print_selected.js]
|
||||
support-files =
|
||||
simplifyArticleSample.html
|
||||
skip-if = os == "mac" || (verify && !debug && (os == 'linux'))
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function assertExpectedPrintPage(helper) {
|
||||
let printBrowser = helper.win.PrintEventHandler.sourceBrowser;
|
||||
is(
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
function waitForAnimationFrames() {
|
||||
// Wait for 2 animation frames in hopes it's actually done resizing.
|
||||
return new Promise(resolve =>
|
||||
window.requestAnimationFrame(() => window.requestAnimationFrame(resolve))
|
||||
);
|
||||
}
|
||||
|
||||
function closeEnough(actual, expected) {
|
||||
return expected - 1 < actual && actual < expected + 1;
|
||||
}
|
||||
|
||||
async function resizeWindow(x, y) {
|
||||
window.innerWidth = x;
|
||||
window.innerHeight = y;
|
||||
|
||||
await waitForAnimationFrames();
|
||||
|
||||
await TestUtils.waitForCondition(
|
||||
() => {
|
||||
info(`window is ${window.innerWidth} x ${window.innerHeight}`);
|
||||
if (
|
||||
closeEnough(window.innerWidth, x) &&
|
||||
closeEnough(window.innerHeight, y)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
window.innerWidth = x;
|
||||
window.innerHeight = y;
|
||||
return false;
|
||||
},
|
||||
`Wait for ${x}x${y}`,
|
||||
250
|
||||
);
|
||||
}
|
||||
|
||||
async function waitForExpectedSize(helper, x, y) {
|
||||
// Wait a few frames, this is generally enough for the resize to happen.
|
||||
await waitForAnimationFrames();
|
||||
|
||||
let isExpectedSize = () => {
|
||||
let box = helper.dialog._box;
|
||||
info(`Dialog is ${box.clientWidth}x${box.clientHeight}`);
|
||||
if (closeEnough(box.clientWidth, x) && closeEnough(box.clientHeight, y)) {
|
||||
// Make sure there's an assertion so the test passes.
|
||||
ok(`${box.clientWidth} close enough to ${x}`);
|
||||
ok(`${box.clientHeight} close enough to ${y}`);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if (isExpectedSize()) {
|
||||
// We can stop now if we hit the expected size.
|
||||
return;
|
||||
}
|
||||
|
||||
// In verify and debug runs sometimes this takes longer than expected,
|
||||
// fallback to the slow method.
|
||||
await TestUtils.waitForCondition(isExpectedSize, `Wait for ${x}x${y}`);
|
||||
}
|
||||
|
||||
add_task(async function testResizing() {
|
||||
await PrintHelper.withTestPage(async helper => {
|
||||
let { innerWidth, innerHeight } = window;
|
||||
|
||||
await resizeWindow(500, 400);
|
||||
|
||||
await helper.startPrint();
|
||||
|
||||
let chromeHeight = window.windowUtils.getBoundsWithoutFlushing(
|
||||
document.getElementById("browser")
|
||||
).top;
|
||||
|
||||
let initialWidth = 500 - 8;
|
||||
let initialHeight = 400 - 16 - chromeHeight + 5;
|
||||
|
||||
await waitForExpectedSize(helper, initialWidth, initialHeight);
|
||||
|
||||
await resizeWindow(600, 500);
|
||||
|
||||
// 100 wider for window, add back the old 4px padding, it's now 16px * 2.
|
||||
let updatedWidth = initialWidth + 100 + 8 - 32;
|
||||
await waitForExpectedSize(helper, updatedWidth, initialHeight + 100);
|
||||
|
||||
await resizeWindow(1100, 900);
|
||||
|
||||
await waitForExpectedSize(helper, 1000, 650);
|
||||
|
||||
await helper.closeDialog();
|
||||
|
||||
await resizeWindow(innerWidth, innerHeight);
|
||||
});
|
||||
});
|
|
@ -32,21 +32,17 @@ class PrintHelper {
|
|||
|
||||
async startPrint() {
|
||||
document.getElementById("cmd_print").doCommand();
|
||||
let dialog = await TestUtils.waitForCondition(
|
||||
() => this.dialog,
|
||||
"Wait for dialog"
|
||||
);
|
||||
await dialog._dialogReady;
|
||||
let dialog = await TestUtils.waitForCondition(() => this._dialogs[0]);
|
||||
await dialog._dialog._dialogReady;
|
||||
}
|
||||
|
||||
async withClosingFn(closeFn) {
|
||||
let { dialog } = this;
|
||||
await closeFn();
|
||||
await dialog._closingPromise;
|
||||
await this._dialogs[0]._dialog._closingPromise;
|
||||
}
|
||||
|
||||
async closeDialog() {
|
||||
await this.withClosingFn(() => this.dialog.close());
|
||||
await this.withClosingFn(() => this._dialogs[0]._dialog.close());
|
||||
}
|
||||
|
||||
assertDialogHidden() {
|
||||
|
@ -55,29 +51,25 @@ class PrintHelper {
|
|||
|
||||
assertDialogVisible() {
|
||||
is(this._dialogs.length, 1, "There is one print dialog");
|
||||
BrowserTestUtils.is_visible(this.dialog._box, "The dialog is visible");
|
||||
BrowserTestUtils.is_visible(this._dialogs[0], "The dialog is visible");
|
||||
}
|
||||
|
||||
get _tabDialogBox() {
|
||||
return this.sourceBrowser.ownerGlobal.gBrowser.getTabDialogBox(
|
||||
get _container() {
|
||||
return this.sourceBrowser.ownerGlobal.gBrowser.getBrowserContainer(
|
||||
this.sourceBrowser
|
||||
);
|
||||
}
|
||||
|
||||
get _dialogs() {
|
||||
return this._tabDialogBox._dialogManager._dialogs;
|
||||
}
|
||||
|
||||
get dialog() {
|
||||
return this._dialogs.find(dlg =>
|
||||
dlg._box.querySelector(".printSettingsBrowser")
|
||||
);
|
||||
return this._container.querySelectorAll(".printDialogContainer");
|
||||
}
|
||||
|
||||
get _printBrowser() {
|
||||
let dialog = this.dialog;
|
||||
ok(dialog, "The dialog exists");
|
||||
return dialog._frame;
|
||||
let dialogs = this._dialogs;
|
||||
is(dialogs.length, 1, "There's one dialog");
|
||||
let frame = dialogs[0].querySelector(".dialogFrame");
|
||||
ok(frame, "Found the print dialog frame");
|
||||
return frame;
|
||||
}
|
||||
|
||||
get doc() {
|
||||
|
|
|
@ -91,3 +91,8 @@ tabmodalprompt label[value=""] {
|
|||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.printPreviewBrowser {
|
||||
width: 500px;
|
||||
height: 600px;
|
||||
}
|
||||
|
|
|
@ -108,13 +108,8 @@ SubDialog.prototype = {
|
|||
aFeatures = null,
|
||||
aParams = null,
|
||||
aClosingCallback = null,
|
||||
aClosedCallback = null,
|
||||
aOptions = {}
|
||||
aClosedCallback = null
|
||||
) {
|
||||
if (aOptions.sizeTo == "available") {
|
||||
this._box.setAttribute("sizeto", "available");
|
||||
}
|
||||
|
||||
// Create a promise so consumers can tell when we're done setting up.
|
||||
this._dialogReady = new Promise(resolve => {
|
||||
this._resolveDialogReady = resolve;
|
||||
|
@ -423,10 +418,7 @@ SubDialog.prototype = {
|
|||
let frameWidth = docEl.getAttribute("width")
|
||||
? docEl.getAttribute("width") + "px"
|
||||
: frameMinWidth;
|
||||
|
||||
if (this._box.getAttribute("sizeto") != "available") {
|
||||
this._frame.style.width = frameWidth;
|
||||
}
|
||||
this._frame.style.width = frameWidth;
|
||||
|
||||
let boxMinWidth = `calc(${boxHorizontalBorder +
|
||||
frameHorizontalMargin}px + ${frameMinWidth})`;
|
||||
|
@ -488,13 +480,6 @@ SubDialog.prototype = {
|
|||
let frameSizeDifference =
|
||||
frameRect.top - boxRect.top + (boxRect.bottom - frameRect.bottom);
|
||||
|
||||
if (this._box.getAttribute("sizeto") == "available") {
|
||||
// Inform the CSS of the toolbar height so the bottom padding can be
|
||||
// correctly calculated.
|
||||
this._box.style.setProperty("--box-top-px", `${boxRect.top}px`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Now do the same but for the height. We need to do this afterwards because otherwise
|
||||
// XUL assumes we'll optimize for height and gives us "wrong" values which then are no
|
||||
// longer correct after we set the width:
|
||||
|
@ -833,8 +818,7 @@ class SubDialogManager {
|
|||
aFeatures = null,
|
||||
aParams = null,
|
||||
aClosingCallback = null,
|
||||
aClosedCallback = null,
|
||||
aOpenOptions
|
||||
aClosedCallback = null
|
||||
) {
|
||||
// If we're already open/opening on this URL, do nothing.
|
||||
if (!this._allowDuplicateDialogs && this._topDialog?._openedURL == aURL) {
|
||||
|
@ -871,8 +855,7 @@ class SubDialogManager {
|
|||
aFeatures,
|
||||
aParams,
|
||||
aClosingCallback,
|
||||
aClosedCallback,
|
||||
aOpenOptions
|
||||
aClosedCallback
|
||||
);
|
||||
this._dialogs.push(this._preloadDialog);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче