1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Use the "pageColorsBackground" option as background-color for non-loaded pages (issue 18680)

This should prevent non-loaded pages from flashing white in e.g. high contrast mode (HCM).
This commit is contained in:
Jonas Jenwald 2024-09-02 10:05:09 +02:00
parent b915a9c3a5
commit d86f94a3db
3 changed files with 13 additions and 1 deletions

View file

@ -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

View file

@ -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);
@ -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 {

View file

@ -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"