Skip to content

Commit

Permalink
Merge pull request mozilla#18742 from Snuffleupagus/pageColorsBackgro…
Browse files Browse the repository at this point in the history
…und-unloaded-pages

Use the "pageColorsBackground" option as background-color for non-loaded pages (issue 18680)
  • Loading branch information
Snuffleupagus authored Sep 12, 2024
2 parents b915a9c + d86f94a commit c72fb9b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions web/pdf_page_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ class PDFPageView {
this.scale * PixelsPerInch.PDF_TO_CSS_UNITS
);

if (this.pageColors?.background) {
container?.style.setProperty(
"--page-bg-color",
this.pageColors.background
);
}

const { optionalContentConfigPromise } = options;
if (optionalContentConfigPromise) {
// Ensure that the thumbnails always display the *initial* document
Expand Down
3 changes: 2 additions & 1 deletion web/pdf_viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
/* Define this variable here and not in :root to avoid to reflow all the UI
when scaling (see #15929). */
--scale-factor: 1;
--page-bg-color: unset;

padding-bottom: var(--pdfViewer-padding-bottom);

Expand Down Expand Up @@ -114,7 +115,7 @@
overflow: visible;
border: var(--page-border);
background-clip: content-box;
background-color: rgb(255 255 255);
background-color: var(--page-bg-color, rgb(255 255 255));
}

.pdfViewer .dummyPage {
Expand Down
4 changes: 4 additions & 0 deletions web/pdf_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,10 @@ class PDFViewer {
// Ensure that the various layers always get the correct initial size,
// see issue 15795.
viewer.style.setProperty("--scale-factor", viewport.scale);

if (pageColors?.background) {
viewer.style.setProperty("--page-bg-color", pageColors.background);
}
if (
pageColors?.foreground === "CanvasText" ||
pageColors?.background === "Canvas"
Expand Down

0 comments on commit c72fb9b

Please sign in to comment.