Skip to content

Commit 5d079c1

Browse files
committed
[Editor] When in HCM, don't apply light/dark color in the comment buttons (bug 1977269)
Add fix the color name to use in HCM.
1 parent 44affa7 commit 5d079c1

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
@@ -445,14 +445,15 @@ const PDFViewerApplication = {
445445
const container = appConfig.mainContainer,
446446
viewer = appConfig.viewerContainer;
447447
const annotationEditorMode = AppOptions.get("annotationEditorMode");
448-
const pageColors =
448+
const hasForcedColors =
449449
AppOptions.get("forcePageColors") ||
450-
window.matchMedia("(forced-colors: active)").matches
451-
? {
452-
background: AppOptions.get("pageColorsBackground"),
453-
foreground: AppOptions.get("pageColorsForeground"),
454-
}
455-
: null;
450+
window.matchMedia("(forced-colors: active)").matches;
451+
const pageColors = hasForcedColors
452+
? {
453+
background: AppOptions.get("pageColorsBackground"),
454+
foreground: AppOptions.get("pageColorsForeground"),
455+
}
456+
: null;
456457

457458
let altTextManager;
458459
if (AppOptions.get("enableUpdatedAddImage")) {
@@ -521,7 +522,8 @@ const PDFViewerApplication = {
521522
eventBus,
522523
linkService,
523524
overlayManager,
524-
ltr
525+
ltr,
526+
hasForcedColors
525527
)
526528
: null;
527529

web/comment_manager.css

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

8686
@media screen and (forced-colors: active) {
87-
--comment-button-bg: Canvas;
87+
--comment-button-bg: ButtonFace;
8888
--comment-button-fg: ButtonText;
89-
--comment-button-hover-bg: Canvas;
90-
--comment-button-hover-fg: Highlight;
91-
--comment-button-active-bg: Canvas;
92-
--comment-button-active-fg: Highlight;
89+
--comment-button-hover-bg: SelectedItemText;
90+
--comment-button-hover-fg: SelectedItem;
91+
--comment-button-active-bg: SelectedItemText;
92+
--comment-button-active-fg: SelectedItem;
9393
--comment-button-border-color: ButtonBorder;
9494
--comment-button-active-border-color: ButtonBorder;
95-
--comment-button-hover-border-color: Highlight;
95+
--comment-button-hover-border-color: SelectedItem;
9696
--comment-button-box-shadow: none;
9797
--comment-button-focus-outline-color: CanvasText;
9898
--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)