Skip to content

Commit

Permalink
[GeckoView] Bundle the Firefox printing code in the viewer (bug 1810111)
Browse files Browse the repository at this point in the history
This may not be enough, on its own, to completely fix [bug 1810111](https://bugzilla.mozilla.org/show_bug.cgi?id=1810111) however it's impossible for printing to work in GeckoView without this patch.
  • Loading branch information
Snuffleupagus committed Apr 17, 2023
1 parent 3e08eee commit c0f4175
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
3 changes: 1 addition & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,9 @@ function createWebpackConfig(
for (const key in viewerAlias) {
viewerAlias[key] = gvAlias[key] || "web/stubs-geckoview.js";
}
} else {
viewerAlias["web-print_service"] = "web/firefox_print_service.js";
}
viewerAlias["web-com"] = "web/firefoxcom.js";
viewerAlias["web-print_service"] = "web/firefox_print_service.js";
}
const alias = { ...basicAlias, ...viewerAlias };
for (const key in alias) {
Expand Down
55 changes: 55 additions & 0 deletions web/viewer-geckoview.css
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,58 @@ dialog :link {
@page {
margin: 0;
}

#printContainer {
display: none;
}

@media print {
body {
background: rgba(0, 0, 0, 0) none;
}
body[data-pdfjsprinting] #outerContainer {
display: none;
}
body[data-pdfjsprinting] #printContainer {
display: block;
}
#printContainer {
height: 100%;
}
/* wrapper around (scaled) print canvas elements */
#printContainer > .printedPage {
page-break-after: always;
page-break-inside: avoid;

/* The wrapper always cover the whole page. */
height: 100%;
width: 100%;

display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

#printContainer > .xfaPrintedPage .xfaPage {
position: absolute;
}

#printContainer > .xfaPrintedPage {
page-break-after: always;
page-break-inside: avoid;
width: 100%;
height: 100%;
position: relative;
}

#printContainer > .printedPage canvas,
#printContainer > .printedPage img {
/* The intrinsic canvas / image size will make sure that we fit the page. */
max-width: 100%;
max-height: 100%;

direction: ltr;
display: block;
}
}
1 change: 1 addition & 0 deletions web/viewer-geckoview.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
</div> <!-- dialogContainer -->

</div> <!-- outerContainer -->
<div id="printContainer"></div>

<div id="floatingToolbar">
<button id="download" class="toolbarButton" title="Save" tabindex="31" data-l10n-id="save">
Expand Down
2 changes: 2 additions & 0 deletions web/viewer-geckoview.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

import "web-com";
import "web-print_service";
import { RenderingStates, ScrollMode, SpreadMode } from "./ui_utils.js";
import { AppOptions } from "./app_options.js";
import { LinkTarget } from "./pdf_link_service.js";
Expand Down Expand Up @@ -54,6 +55,7 @@ function getViewerConfiguration() {
submitButton: document.getElementById("passwordSubmit"),
cancelButton: document.getElementById("passwordCancel"),
},
printContainer: document.getElementById("printContainer"),
openFileInput:
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")
? document.getElementById("fileInput")
Expand Down

0 comments on commit c0f4175

Please sign in to comment.