Skip to content

Commit ae3c23e

Browse files
authored
Merge pull request #20291 from calixteman/bug1977269
[Editor] When in HCM, don't apply light/dark color in the comment buttons (bug 1977269)
2 parents 48c10d8 + 5d079c1 commit ae3c23e

3 files changed

Lines changed: 27 additions & 19 deletions

File tree

web/app.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -447,14 +447,15 @@ const PDFViewerApplication = {
447447
const container = appConfig.mainContainer,
448448
viewer = appConfig.viewerContainer;
449449
const annotationEditorMode = AppOptions.get("annotationEditorMode");
450-
const pageColors =
450+
const hasForcedColors =
451451
AppOptions.get("forcePageColors") ||
452-
window.matchMedia("(forced-colors: active)").matches
453-
? {
454-
background: AppOptions.get("pageColorsBackground"),
455-
foreground: AppOptions.get("pageColorsForeground"),
456-
}
457-
: null;
452+
window.matchMedia("(forced-colors: active)").matches;
453+
const pageColors = hasForcedColors
454+
? {
455+
background: AppOptions.get("pageColorsBackground"),
456+
foreground: AppOptions.get("pageColorsForeground"),
457+
}
458+
: null;
458459

459460
let altTextManager;
460461
if (AppOptions.get("enableUpdatedAddImage")) {
@@ -523,7 +524,8 @@ const PDFViewerApplication = {
523524
eventBus,
524525
linkService,
525526
overlayManager,
526-
ltr
527+
ltr,
528+
hasForcedColors
527529
)
528530
: null;
529531

web/comment_manager.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@
8585
--comment-button-focus-outline-color: light-dark(#0062fa, #00cadb);
8686

8787
@media screen and (forced-colors: active) {
88-
--comment-button-bg: Canvas;
88+
--comment-button-bg: ButtonFace;
8989
--comment-button-fg: ButtonText;
90-
--comment-button-hover-bg: Canvas;
91-
--comment-button-hover-fg: Highlight;
92-
--comment-button-active-bg: Canvas;
93-
--comment-button-active-fg: Highlight;
90+
--comment-button-hover-bg: SelectedItemText;
91+
--comment-button-hover-fg: SelectedItem;
92+
--comment-button-active-bg: SelectedItemText;
93+
--comment-button-active-fg: SelectedItem;
9494
--comment-button-border-color: ButtonBorder;
9595
--comment-button-active-border-color: ButtonBorder;
96-
--comment-button-hover-border-color: Highlight;
96+
--comment-button-hover-border-color: SelectedItem;
9797
--comment-button-box-shadow: none;
9898
--comment-button-focus-outline-color: CanvasText;
9999
--comment-button-selected-bg: ButtonBorder;

web/comment_manager.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@ class CommentManager {
3434

3535
#sidebar;
3636

37+
static #hasForcedColors = null;
38+
3739
constructor(
3840
commentDialog,
3941
sidebar,
4042
eventBus,
4143
linkService,
4244
overlayManager,
43-
ltr
45+
ltr,
46+
hasForcedColors
4447
) {
4548
const dateFormat = new Intl.DateTimeFormat(undefined, {
4649
dateStyle: "long",
@@ -56,6 +59,7 @@ class CommentManager {
5659
dateFormat
5760
);
5861
this.#popup.sidebar = this.#sidebar;
62+
CommentManager.#hasForcedColors = hasForcedColors;
5963
}
6064

6165
setSidebarUiManager(uiManager) {
@@ -110,10 +114,12 @@ class CommentManager {
110114
}
111115

112116
static _makeCommentColor(color, opacity) {
113-
return findContrastColor(
114-
applyOpacity(...color, opacity ?? 1),
115-
CSSConstants.commentForegroundColor
116-
);
117+
return this.#hasForcedColors
118+
? null
119+
: findContrastColor(
120+
applyOpacity(...color, opacity ?? 1),
121+
CSSConstants.commentForegroundColor
122+
);
117123
}
118124

119125
destroy() {

0 commit comments

Comments
 (0)