mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
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:
parent
39251c5789
commit
472a1f9c91
1 changed files with 13 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue