Ignore pageColors when the background/foreground is identical (PR 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.
This commit is contained in:
Jonas Jenwald 2022-05-08 11:06:18 +02:00
parent 39251c5789
commit 472a1f9c91

View File

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