Skip to content

Commit 8e6c4f3

Browse files
committed
Use default colors only in forced-colors mode (bug 1778068)
1 parent bde4663 commit 8e6c4f3

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

web/app.js

+21-4
Original file line numberDiff line numberDiff line change
@@ -516,10 +516,12 @@ const PDFViewerApplication = {
516516
const container = appConfig.mainContainer,
517517
viewer = appConfig.viewerContainer;
518518
const annotationEditorMode = AppOptions.get("annotationEditorMode");
519-
const pageColors = {
520-
background: AppOptions.get("pageColorsBackground"),
521-
foreground: AppOptions.get("pageColorsForeground"),
522-
};
519+
const pageColors = PDFViewerApplication.useUserDefinedColors
520+
? {
521+
background: AppOptions.get("pageColorsBackground"),
522+
foreground: AppOptions.get("pageColorsForeground"),
523+
}
524+
: null;
523525

524526
this.pdfViewer = new PDFViewer({
525527
container,
@@ -730,6 +732,21 @@ const PDFViewerApplication = {
730732
return this.externalServices.supportedMouseWheelZoomModifierKeys;
731733
},
732734

735+
get useUserDefinedColors() {
736+
// 0 - Only with HCM;
737+
// 1 - Never;
738+
// 2 - Always.
739+
const value = this.externalServices.documentColorUse;
740+
switch (value) {
741+
case 1:
742+
return false;
743+
case 2:
744+
return true;
745+
default:
746+
return window.matchMedia("(forced-colors: active)").matches;
747+
}
748+
},
749+
733750
initPassiveLoading() {
734751
if (
735752
typeof PDFJSDev === "undefined" ||

web/firefoxcom.js

+5
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@ class FirefoxExternalServices extends DefaultExternalServices {
429429
return shadow(this, "supportedMouseWheelZoomModifierKeys", support);
430430
}
431431

432+
static get documentColorUse() {
433+
const support = FirefoxCom.requestSync("documentColorUse");
434+
return shadow(this, "documentColorUse", support);
435+
}
436+
432437
static get isInAutomation() {
433438
// Returns the value of `Cu.isInAutomation`, which is only `true` when e.g.
434439
// various test-suites are running in mozilla-central.

0 commit comments

Comments
 (0)