From d8d7bc0b1204165205c0cf01a6307a06c9db1ea3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 8 May 2022 11:06:18 +0200 Subject: [PATCH] Ignore `pageColors` when the background/foreground is identical (14874 follow-up) If the computed background/foreground colors are identical, the `canvas` would be rendered mostly blank with only images visible. Hence it seems reasonable to also ignore the `pageColors`-option in this case. Also, the patch tries to *briefly* outline the various cases in which we ignore the `pageColors`-option in a comment. --- src/display/canvas.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/display/canvas.js b/src/display/canvas.js index b34aba22e833e8..469cc588b68c8a 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -1302,7 +1302,19 @@ class CanvasGraphics { 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; } else { // https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_Colors_and_Luminance