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 this.scale * PixelsPerInch.PDF_TO_CSS_UNITS
); );
if (this.pageColors?.background) {
container?.style.setProperty(
"--page-bg-color",
this.pageColors.background
);
}
const { optionalContentConfigPromise } = options; const { optionalContentConfigPromise } = options;
if (optionalContentConfigPromise) { if (optionalContentConfigPromise) {
// Ensure that the thumbnails always display the *initial* document // 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 /* Define this variable here and not in :root to avoid to reflow all the UI
when scaling (see #15929). */ when scaling (see #15929). */
--scale-factor: 1; --scale-factor: 1;
--page-bg-color: unset;
padding-bottom: var(--pdfViewer-padding-bottom); padding-bottom: var(--pdfViewer-padding-bottom);
@ -114,7 +115,7 @@
overflow: visible; overflow: visible;
border: var(--page-border); border: var(--page-border);
background-clip: content-box; background-clip: content-box;
background-color: rgb(255 255 255); background-color: var(--page-bg-color, rgb(255 255 255));
} }
.pdfViewer .dummyPage { .pdfViewer .dummyPage {

View File

@ -927,6 +927,10 @@ class PDFViewer {
// Ensure that the various layers always get the correct initial size, // Ensure that the various layers always get the correct initial size,
// see issue 15795. // see issue 15795.
viewer.style.setProperty("--scale-factor", viewport.scale); viewer.style.setProperty("--scale-factor", viewport.scale);
if (pageColors?.background) {
viewer.style.setProperty("--page-bg-color", pageColors.background);
}
if ( if (
pageColors?.foreground === "CanvasText" || pageColors?.foreground === "CanvasText" ||
pageColors?.background === "Canvas" pageColors?.background === "Canvas"