Skip to content

Commit

Permalink
Ignore pageColors when the background/foreground is identical (1487…
Browse files Browse the repository at this point in the history
…4 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.
  • Loading branch information
Snuffleupagus committed May 8, 2022
1 parent 53106c0 commit 66bceed
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 66bceed

Please sign in to comment.