Merge pull request #14887 from Snuffleupagus/pageColors-followup
Ignore `pageColors` when the background/foreground is identical (PR 14874 follow-up)
This commit is contained in:
commit
3d9b2c9cd5
@ -209,12 +209,12 @@
|
|||||||
],
|
],
|
||||||
"default": -1
|
"default": -1
|
||||||
},
|
},
|
||||||
"pageBackgroundColor": {
|
"pageColorsBackground": {
|
||||||
"description": "The color is a string as defined in CSS. Its goal is to help improve readability in high contrast mode",
|
"description": "The color is a string as defined in CSS. Its goal is to help improve readability in high contrast mode",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "Canvas"
|
"default": "Canvas"
|
||||||
},
|
},
|
||||||
"pageForegroundColor": {
|
"pageColorsForeground": {
|
||||||
"description": "The color is a string as defined in CSS. Its goal is to help improve readability in high contrast mode",
|
"description": "The color is a string as defined in CSS. Its goal is to help improve readability in high contrast mode",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "CanvasText"
|
"default": "CanvasText"
|
||||||
|
@ -1302,7 +1302,19 @@ class CanvasGraphics {
|
|||||||
typeof defaultBg === "string" && /^#[0-9A-Fa-f]{6}$/.test(defaultBg);
|
typeof defaultBg === "string" && /^#[0-9A-Fa-f]{6}$/.test(defaultBg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fg === "#000000" && bg === "#ffffff") || !isValidDefaultBg) {
|
if (
|
||||||
|
(fg === "#000000" && bg === "#ffffff") ||
|
||||||
|
fg === bg ||
|
||||||
|
!isValidDefaultBg
|
||||||
|
) {
|
||||||
|
// Ignore the `pageColors`-option when:
|
||||||
|
// - The computed background/foreground colors have their default
|
||||||
|
// values, i.e. white/black.
|
||||||
|
// - The computed background/foreground colors are identical,
|
||||||
|
// since that'd render the `canvas` mostly blank.
|
||||||
|
// - The `background`-option has a value that's incompatible with
|
||||||
|
// the `pageColors`-values.
|
||||||
|
//
|
||||||
this.foregroundColor = this.backgroundColor = null;
|
this.foregroundColor = this.backgroundColor = null;
|
||||||
} else {
|
} else {
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_Colors_and_Luminance
|
// https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_Colors_and_Luminance
|
||||||
|
@ -526,8 +526,8 @@ const PDFViewerApplication = {
|
|||||||
maxCanvasPixels: AppOptions.get("maxCanvasPixels"),
|
maxCanvasPixels: AppOptions.get("maxCanvasPixels"),
|
||||||
enablePermissions: AppOptions.get("enablePermissions"),
|
enablePermissions: AppOptions.get("enablePermissions"),
|
||||||
pageColors: {
|
pageColors: {
|
||||||
background: AppOptions.get("pageBackgroundColor"),
|
background: AppOptions.get("pageColorsBackground"),
|
||||||
foreground: AppOptions.get("pageForegroundColor"),
|
foreground: AppOptions.get("pageColorsForeground"),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
pdfRenderingQueue.setViewer(this.pdfViewer);
|
pdfRenderingQueue.setViewer(this.pdfViewer);
|
||||||
|
@ -129,12 +129,12 @@ const defaultOptions = {
|
|||||||
compatibility: compatibilityParams.maxCanvasPixels,
|
compatibility: compatibilityParams.maxCanvasPixels,
|
||||||
kind: OptionKind.VIEWER,
|
kind: OptionKind.VIEWER,
|
||||||
},
|
},
|
||||||
pageBackgroundColor: {
|
pageColorsBackground: {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
value: "Canvas",
|
value: "Canvas",
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
pageForegroundColor: {
|
pageColorsForeground: {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
value: "CanvasText",
|
value: "CanvasText",
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user