Skip to content

Redraw image checkmarks in Windows contrast theme colors - #19329

Merged
gtritchie merged 5 commits into
mainfrom
bugfix/18494-image-checkmarks-contrast
Oct 28, 2026
Merged

gtritchie merged 5 commits into
mainfrom
bugfix/18494-image-checkmarks-contrast

Conversation

@gtritchie

@gtritchie gtritchie commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Fixes #18494.

Menu checkmarks and the Git/SVN changelist checkboxes are <img> bitmaps, which CSS forced colors mode does not recolor. Under a black contrast theme the menu checkmark was nearly invisible (about 1.4:1), and the changelist checkboxes kept their light box and blue check.

Changes

  • AppCommand.createMenuImageHtml tags the menu checkmark image (normal or inverted) with rstudio-forced-colors-glyph rstudio-glyph-menu-check. Every menu checkmark goes through it: AppCommand, CheckableMenuItem, DeploymentMenuItem, Panmirror menu items, and the worktree menu.
  • TriStateCheckboxCell.render tags its image with the matching rstudio-glyph-checkbox-on/off/indeterminate class.
  • themeStyles.css: under @media (forced-colors: active), a tagged image hides its bitmap and is masked to an SVG of the glyph filled with CanvasText. The fill uses CanvasText rather than currentColor, because in Chromium an element with forced-color-adjust: none resolves currentColor to the unforced author color. The rule also cancels the dark-menus filter: invert. Checkmarks in disabled menu items are filled with GrayText at full opacity, instead of the faded normal rendering, which drops a white checkmark on black to 2.5:1.
  • The block is wrapped in @supports (forced-color-adjust: none) and (mask-image: none). As with the Checkbox state invisible with Windows Contrast Themes enabled #18493 rules, the @supports wrapper is what gets the media query past GWT's CSS2 parser. Its condition also leaves browsers without those features on the current rendering, instead of painting a solid square or nothing.

Rendering with contrast themes off is unchanged.

The issue also lists the Packages pane and the unsaved-changes dialog, but those use native <input type="checkbox">, which #18493 already covers.

Testing

  • New GWT unit tests, AppCommandMenuImageTests and TriStateCheckboxCellTests, check the tagging. The tagging tests fail without the change; ant unittest passes.
  • ant draft: the new block reaches the compiled CSS unchanged.
  • New e2e test, tests/panes/misc/contrast_theme_checkmarks.test.ts, emulates forced colors. It checks that the Environment pane's memory menu checkmark, and an <img> tagged for each changelist checkbox state, is masked to an SVG glyph filled with CanvasText, and that the menu checkmark is unmasked with forced colors off. Both tests fail without this change and pass with it, on Windows Desktop.
  • Headless Chromium with forced colors emulated, in dark and light palettes: menu checkmarks, including dark menus and disabled items, and all three checkbox states follow CanvasText.
  • Manual, Windows Desktop with a contrast theme: menu checkmarks with light and dark RStudio themes, and checked, unchecked and partly staged files in the Git pane.

The changelist checkbox is still not exposed to screen readers; that predates this change and is tracked in #19328.

Menu checkmarks and the Git/SVN changelist checkboxes are <img> bitmaps,
which CSS forced colors mode does not recolor. Tag those images with
classes, and under forced colors mask each one to an SVG of its glyph
filled with CanvasText.

Addresses #18494.
Keep checkmarks in disabled menu items at full contrast, matching their
forced label color; omit the class attribute on menu icons that aren't
checkmarks; look up the checkmark URIs once; shorten the CSS comment.

Addresses #18494.
@gtritchie

Copy link
Copy Markdown
Member Author

Code review findings

Actionable items from an automated review. Nothing here is a current bug.

Suggestions

  1. src/gwt/src/org/rstudio/core/client/command/AppCommand.java:833: isMenuCheck identifies the checkmark by comparing the rendered src with two cached resource URIs, even though the callers know they are passing a checkmark. Four call sites build new ImageResource2x(ThemeResources.INSTANCE.menuCheck2x()) on their own (AppCommand.java:502/507, CheckableMenuItem.java:85, DeploymentMenuItem.java:95, BranchToolbarButton.java:402). A checkmark from any other resource would go untagged, and nothing would catch it. Fix: a shared menuCheckImage() factory, or a marker subtype of ImageResource2x checked with instanceof.

  2. src/gwt/src/org/rstudio/core/client/theme/res/themeStyles.css:2350: opacity: 1 makes a checked disabled menu item (from AppMenuItem.java:58 or DisabledMenuItem.java:32) look identical to a checked enabled one, because the label is also forced to CanvasText. Fix: fill .gwt-MenuItem.disabled img.rstudio-forced-colors-glyph with GrayText. The image already has forced-color-adjust: none, so the color applies.

  3. src/gwt/src/org/rstudio/core/client/cellview/TriStateCheckboxCell.java:141: the cell no longer uses ImageResource2x.getSafeHtml() and builds the <img> by hand only to add a class. The two now emit different markup (alt vs alt="", different attribute order). Fix: add a class parameter to getSafeHtml. Its html_ cache ignores the arguments, so the cache needs fixing at the same time.

  4. src/gwt/src/org/rstudio/core/client/command/AppCommand.java:819: both branches of the ternary repeat the full createOpenTag argument list and differ only in the class pair. Fix: build the attribute array once and prepend "class", ... when isMenuCheck(src) is true. createOpenTag takes varargs.

  5. src/gwt/test/org/rstudio/core/client/command/AppCommandMenuImageTests.java:33: the tests only check that the classes are present. Nothing checks that the forced-colors block survives GWT's CSS handling and applies in the browser. Fix: a Playwright test under e2e/rstudio that calls page.emulateMedia({ forcedColors: 'active' }) and checks the computed mask-image of a menu checkmark and of a changelist checkbox.

Full-opacity CanvasText made a checked disabled item look the same as an enabled one, since the label is forced to CanvasText too.

Addresses #18494.
Emulates forced colors and checks that the Environment pane's memory menu checkmark, and each changelist checkbox state, is masked to an SVG glyph filled with CanvasText; and that the menu checkmark is unmasked with forced colors off.

Addresses #18494.
@gtritchie

gtritchie commented Oct 28, 2026 •

Copy link
Copy Markdown
Member Author

Response to the review findings above:

Applied

  • 2. Disabled checkmarks: they are now filled with GrayText at full opacity under forced colors (ab0d27c), so a checked disabled item looks different from a checked enabled one, and its checkmark stays legible.
  • 5. e2e coverage: tests/panes/misc/contrast_theme_checkmarks.test.ts (72600a0) emulates forced colors. It checks the computed mask and fill of the Environment pane's memory menu checkmark, and that the checkmark is unmasked with forced colors off. For the changelist checkboxes it checks an <img> tagged for each state instead of a real changelist, which would need a version-controlled project and a session restart; TriStateCheckboxCellTests covers the cell's tagging. Both tests fail without this PR and pass with it.

Not applied

  • 1. Explicit checkmark tagging: a menuCheckImage() factory would not enforce anything, since formatMenuLabel still accepts any ImageResource. A marker subtype checked with instanceof would, at the cost of changing five call sites to guard against a checkmark image that does not exist. Matching the URI covers every current use and any future use of the same two images.
  • 3. Route through ImageResource2x.getSafeHtml(): alt and alt="" are equivalent in HTML, so the markup difference has no effect. Adding a class parameter to a shared method, and reworking its cache, is more change than one class attribute needs. The cache does have a real bug, though: it keeps the first alt text and ignores later ones, so ImageButtonColumn gives every row's icon the alt text of the first row rendered (the Packages pane's Help and Browse columns). Filed as ImageResource2x.getSafeHtml caches the first alt text, so image button columns repeat one row's alt text #19332.
  • 4. Build the attribute array once: AppCommand has no java.util imports, and prepending to a Java array is clunkier than the current two branches, which repeat one short line.

@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

#################### 100% pass rate

Passed Failed Skipped Flaky
4597 0 230 4
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 4 0 16 0
✅ desktop-linux 1151 0 43 0
✅ desktop-macos 1154 0 38 3
✅ desktop-windows 1150 0 50 0
✅ server-linux 1090 0 51 1
✅ setup 48 0 32 0
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit 72600a0296e7f6b8bac784151bda7a5dd6f1968a - Run #1802

@gtritchie
gtritchie merged commit 5f7c605 into main Oct 28, 2026
45 checks passed
@gtritchie
gtritchie deleted the bugfix/18494-image-checkmarks-contrast branch October 28, 2026 22:25
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.

Image-based checkmarks ignore Windows contrast themes

1 participant