зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1652627
- Setup a pref for tab modal print UI r=Gijs,sfoster
This creates the print.modal_print_preview.enabled pref to manage whether the tab modal print UI should be used and creates some files we'll need for the UI to use. Differential Revision: https://phabricator.services.mozilla.com/D83445
This commit is contained in:
Родитель
9ebf2f339d
Коммит
2027ee64c6
|
@ -28,7 +28,7 @@
|
|||
oncommand="MailIntegration.sendLinkForBrowser(gBrowser.selectedBrowser);"/>
|
||||
|
||||
<command id="cmd_pageSetup" oncommand="PrintUtils.showPageSetup();"/>
|
||||
<command id="cmd_print" oncommand="PrintUtils.printWindow(window.gBrowser.selectedBrowser.browsingContext);"/>
|
||||
<command id="cmd_print" oncommand="PrintUtils.startPrintWindow(window.gBrowser.selectedBrowser.browsingContext);"/>
|
||||
<command id="cmd_printPreview" oncommand="PrintUtils.printPreview(PrintPreviewListener);"/>
|
||||
<command id="cmd_file_importFromAnotherBrowser" oncommand="MigrationUtils.showMigrationWizard(window, [MigrationUtils.MIGRATION_ENTRYPOINT_FILE_MENU]);"/>
|
||||
<command id="cmd_help_importFromAnotherBrowser" oncommand="MigrationUtils.showMigrationWizard(window, [MigrationUtils.MIGRATION_ENTRYPOINT_HELP_MENU]);"/>
|
||||
|
|
|
@ -347,6 +347,9 @@ pref("print.shrink-to-fit.scale-limit-percent", 20);
|
|||
// Whether we should display simplify page checkbox on print preview UI
|
||||
pref("print.use_simplify_page", false);
|
||||
|
||||
// The tab modal print dialog is currently only for testing/experiments.
|
||||
pref("print.tab_modal.enabled", false);
|
||||
|
||||
// Disable support for MathML
|
||||
pref("mathml.disabled", false);
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
@ -0,0 +1,17 @@
|
|||
<!doctype html>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
- You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="chrome://global/content/print.css">
|
||||
<link rel="stylesheet" href="chrome://global/skin/in-content/common.css">
|
||||
<script defer src="chrome://global/content/print.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Print</h1>
|
||||
<h2 id="tab-title"></h2>
|
||||
<a href="#" id="open-dialog-link">Open Native Dialog...</a>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,34 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const { gBrowser, PrintUtils } = window.docShell.chromeEventHandler.ownerGlobal;
|
||||
|
||||
function initialize(sourceBrowser) {
|
||||
document.getElementById("tab-title").textContent = sourceBrowser.contentTitle;
|
||||
document.getElementById("open-dialog-link").addEventListener("click", e => {
|
||||
PrintUtils.printWindow(sourceBrowser.browsingContext);
|
||||
});
|
||||
}
|
||||
|
||||
function getSourceBrowser() {
|
||||
let params = new URLSearchParams(location.search);
|
||||
let browsingContextId = params.get("browsingContextId");
|
||||
if (!browsingContextId) {
|
||||
return null;
|
||||
}
|
||||
let browsingContext = BrowsingContext.get(browsingContextId);
|
||||
if (!browsingContext) {
|
||||
return null;
|
||||
}
|
||||
return browsingContext.embedderElement;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", e => {
|
||||
let sourceBrowser = getSourceBrowser();
|
||||
if (sourceBrowser) {
|
||||
initialize(sourceBrowser);
|
||||
} else {
|
||||
console.error("No source browser");
|
||||
}
|
||||
});
|
|
@ -58,6 +58,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"PRINT_TAB_MODAL",
|
||||
"print.tab_modal.enabled",
|
||||
false
|
||||
);
|
||||
|
||||
var gFocusedElement = null;
|
||||
|
||||
var PrintUtils = {
|
||||
|
@ -106,6 +113,39 @@ var PrintUtils = {
|
|||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Opens the tab modal version of the print UI for the current tab.
|
||||
*
|
||||
* @param aBrowsingContext
|
||||
* The BrowsingContext of the window to print.
|
||||
*/
|
||||
_openTabModalPrint(aBrowsingContext) {
|
||||
let printPath = "chrome://global/content/print.html";
|
||||
gBrowser.loadOneTab(
|
||||
`${printPath}?browsingContextId=${aBrowsingContext.id}`,
|
||||
{
|
||||
inBackground: false,
|
||||
relatedToCurrent: true,
|
||||
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Initialize a print, this will open the tab modal UI if it is enabled or
|
||||
* defer to the native dialog/silent print.
|
||||
*
|
||||
* @param aBrowsingContext
|
||||
* The BrowsingContext of the window to print.
|
||||
*/
|
||||
startPrintWindow(aBrowsingContext) {
|
||||
if (PRINT_TAB_MODAL) {
|
||||
this._openTabModalPrint(aBrowsingContext);
|
||||
} else {
|
||||
this.printWindow(aBrowsingContext);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Starts the process of printing the contents of a window.
|
||||
*
|
||||
|
@ -192,6 +232,11 @@ var PrintUtils = {
|
|||
* to it will be used).
|
||||
*/
|
||||
printPreview(aListenerObj) {
|
||||
if (PRINT_TAB_MODAL) {
|
||||
this._openTabModalPrint(aListenerObj.getSourceBrowser().browsingContext);
|
||||
return;
|
||||
}
|
||||
|
||||
// If we already have a toolbar someone is calling printPreview() to get us
|
||||
// to refresh the display and aListenerObj won't be passed.
|
||||
let printPreviewTB = document.getElementById("print-preview-toolbar");
|
||||
|
|
|
@ -15,4 +15,7 @@ toolkit.jar:
|
|||
#endif
|
||||
content/global/printPreviewToolbar.js (content/printPreviewToolbar.js)
|
||||
content/global/printUtils.js (content/printUtils.js)
|
||||
content/global/print.js (content/print.js)
|
||||
content/global/print.html (content/print.html)
|
||||
content/global/print.css (content/print.css)
|
||||
content/global/simplifyMode.css (content/simplifyMode.css)
|
||||
|
|
Загрузка…
Ссылка в новой задаче