Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default colors only in forced-colors mode (bug 1778068) #15135

Merged
merged 1 commit into from
Jul 7, 2022

Conversation

calixteman
Copy link
Contributor

@calixteman calixteman commented Jul 6, 2022

There is a patch in review for Firefox:
https://phabricator.services.mozilla.com/D151158

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see questions inline.

web/app.js Outdated
Comment on lines 524 to 527
: {
background: null,
foreground: null,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is overkill, since all code should already be able to deal with pageColors being unset/undefined.

Suggested change
: {
background: null,
foreground: null,
};
: null;

web/app.js Outdated
background: AppOptions.get("pageColorsBackground"),
foreground: AppOptions.get("pageColorsForeground"),
};
const pageColors = window.matchMedia("(forced-colors: active)").matches
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally speaking, it seems a little bit unfortunate to essentially make it impossible for users to specify custom values for these PDF.js-specific color preferences.

Looking at the bug, could we perhaps only disable this functionality when the "problematic" (general) Firefox preferences have been set?
For context: Years ago we had code which checked the browser.display.document_color_use preference; this was removed (since it'd become unused) in a977882 and mozilla/gecko-dev@7015ab6

Would it make (any) sense to re-instate similar checks here, and do something like this instead?

Suggested change
const pageColors = window.matchMedia("(forced-colors: active)").matches
const pageColors =
window.matchMedia("(forced-colors: active)").matches || this.supportsDocumentColors

web/app.js Outdated
background: AppOptions.get("pageColorsBackground"),
foreground: AppOptions.get("pageColorsForeground"),
};
const pageColors = PDFViewerApplication.useUserDefinedColors
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the following work here?

Suggested change
const pageColors = PDFViewerApplication.useUserDefinedColors
const pageColors = this.useUserDefinedColors

Comment on lines 432 to 436
static get documentColorUse() {
const support = FirefoxCom.requestSync("documentColorUse");
return shadow(this, "documentColorUse", support);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remember to add a suitable method here as well, such that the GENERIC viewer works as intended:

Also, what is an appropriate value to use in the DefaultExternalServices-class; perhaps 2 in that case?

web/app.js Outdated
@@ -730,6 +732,21 @@ const PDFViewerApplication = {
return this.externalServices.supportedMouseWheelZoomModifierKeys;
},

get useUserDefinedColors() {
Copy link
Collaborator

@Snuffleupagus Snuffleupagus Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe allowDocumentColorUse instead here, to have slightly more consistent method names between the app.js, firefoxcom.js, and PdfStreamConverter.jsm files?

@calixteman
Copy link
Contributor Author

My idea with the color change was to change the colors only in HCM (color choice in canvas is binary: either on the CanvasText side or on the Canvas one, there is no shade).
Hence I still wonder if we should just change them when in HCM whatever the setting is in Firefox.

@Snuffleupagus
Copy link
Collaborator

Hence I still wonder if we should just change them when in HCM whatever the setting is in Firefox.

Right, the situation here is a bit messy since we "advertised" the pageColors feature in the release notes of version 2.14.305 and we might not want to outright break that!?

How about we try to limit the scope of things here to address the Firefox bug, but still support the HCM-case properly, while also allowing users to override things if desired/needed?
My, very simply, idea would be something like the following (which limits the changes needed here):

  • Add a new boolean option/preference, e.g. forcePageColors, set to false by default.
  • In app.js we replace this code with
    const pageColors =
       AppOptions.get("forcePageColors") ||
       window.matchMedia("(forced-colors: active)").matches
         ? {
             background: AppOptions.get("pageColorsBackground"),
             foreground: AppOptions.get("pageColorsForeground"),
           }
         : null;

@calixteman
Copy link
Contributor Author

Yes I thinks it's the right solution here.
When I read stuff about Canvas & CanvasText, it was always about a11y and I considered that those values were always set to non-default values in HCM.

@calixteman
Copy link
Contributor Author

@Snuffleupagus, I wrote what you proposed.
Once it's merged I'll uplift the patch in beta and release.
It's so painful to not have discovered this issue in nightly & beta.

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me, with missing doc-comment added; thank you!

web/app_options.js Show resolved Hide resolved
@calixteman
Copy link
Contributor Author

/botio integrationtest

1 similar comment
@calixteman
Copy link
Contributor Author

/botio integrationtest

@pdfjsbot
Copy link

pdfjsbot commented Jul 7, 2022

From: Bot.io (Linux m4)


Received

Command cmd_integrationtest from @calixteman received. Current queue size: 1

Live output at: http://54.241.84.105:8877/33b8d1be01c00ab/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jul 7, 2022

From: Bot.io (Windows)


Received

Command cmd_integrationtest from @calixteman received. Current queue size: 1

Live output at: http://54.193.163.58:8877/ebaee8a9721103f/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jul 7, 2022

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/33b8d1be01c00ab/output.txt

Total script time: 4.71 mins

  • Integration Tests: Passed

@pdfjsbot
Copy link

pdfjsbot commented Jul 7, 2022

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/ebaee8a9721103f/output.txt

Total script time: 7.33 mins

  • Integration Tests: FAILED

@calixteman calixteman merged commit b0a3c9e into mozilla:master Jul 7, 2022
@calixteman calixteman deleted the forced_colors branch July 7, 2022 18:30
@Snuffleupagus Snuffleupagus linked an issue Jul 9, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coloured image displaying in black-white
3 participants