Merge pull request #20291 from calixteman/bug1977269

[Editor] When in HCM, don't apply light/dark color in the comment buttons (bug 1977269)
This commit is contained in:
calixteman 2025-09-23 20:27:01 +02:00 committed by GitHub
commit ae3c23e28a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 19 deletions

View File

@ -447,9 +447,10 @@ const PDFViewerApplication = {
const container = appConfig.mainContainer, const container = appConfig.mainContainer,
viewer = appConfig.viewerContainer; viewer = appConfig.viewerContainer;
const annotationEditorMode = AppOptions.get("annotationEditorMode"); const annotationEditorMode = AppOptions.get("annotationEditorMode");
const pageColors = const hasForcedColors =
AppOptions.get("forcePageColors") || AppOptions.get("forcePageColors") ||
window.matchMedia("(forced-colors: active)").matches window.matchMedia("(forced-colors: active)").matches;
const pageColors = hasForcedColors
? { ? {
background: AppOptions.get("pageColorsBackground"), background: AppOptions.get("pageColorsBackground"),
foreground: AppOptions.get("pageColorsForeground"), foreground: AppOptions.get("pageColorsForeground"),
@ -523,7 +524,8 @@ const PDFViewerApplication = {
eventBus, eventBus,
linkService, linkService,
overlayManager, overlayManager,
ltr ltr,
hasForcedColors
) )
: null; : null;

View File

@ -85,15 +85,15 @@
--comment-button-focus-outline-color: light-dark(#0062fa, #00cadb); --comment-button-focus-outline-color: light-dark(#0062fa, #00cadb);
@media screen and (forced-colors: active) { @media screen and (forced-colors: active) {
--comment-button-bg: Canvas; --comment-button-bg: ButtonFace;
--comment-button-fg: ButtonText; --comment-button-fg: ButtonText;
--comment-button-hover-bg: Canvas; --comment-button-hover-bg: SelectedItemText;
--comment-button-hover-fg: Highlight; --comment-button-hover-fg: SelectedItem;
--comment-button-active-bg: Canvas; --comment-button-active-bg: SelectedItemText;
--comment-button-active-fg: Highlight; --comment-button-active-fg: SelectedItem;
--comment-button-border-color: ButtonBorder; --comment-button-border-color: ButtonBorder;
--comment-button-active-border-color: ButtonBorder; --comment-button-active-border-color: ButtonBorder;
--comment-button-hover-border-color: Highlight; --comment-button-hover-border-color: SelectedItem;
--comment-button-box-shadow: none; --comment-button-box-shadow: none;
--comment-button-focus-outline-color: CanvasText; --comment-button-focus-outline-color: CanvasText;
--comment-button-selected-bg: ButtonBorder; --comment-button-selected-bg: ButtonBorder;

View File

@ -34,13 +34,16 @@ class CommentManager {
#sidebar; #sidebar;
static #hasForcedColors = null;
constructor( constructor(
commentDialog, commentDialog,
sidebar, sidebar,
eventBus, eventBus,
linkService, linkService,
overlayManager, overlayManager,
ltr ltr,
hasForcedColors
) { ) {
const dateFormat = new Intl.DateTimeFormat(undefined, { const dateFormat = new Intl.DateTimeFormat(undefined, {
dateStyle: "long", dateStyle: "long",
@ -56,6 +59,7 @@ class CommentManager {
dateFormat dateFormat
); );
this.#popup.sidebar = this.#sidebar; this.#popup.sidebar = this.#sidebar;
CommentManager.#hasForcedColors = hasForcedColors;
} }
setSidebarUiManager(uiManager) { setSidebarUiManager(uiManager) {
@ -110,7 +114,9 @@ class CommentManager {
} }
static _makeCommentColor(color, opacity) { static _makeCommentColor(color, opacity) {
return findContrastColor( return this.#hasForcedColors
? null
: findContrastColor(
applyOpacity(...color, opacity ?? 1), applyOpacity(...color, opacity ?? 1),
CSSConstants.commentForegroundColor CSSConstants.commentForegroundColor
); );