Skip to content

Restore native checkbox rendering under Windows contrast themes - #18496

Merged
gtritchie merged 5 commits into
mainfrom
bugfix/18493-contrast-theme-checkboxes
Aug 10, 2026
Merged

gtritchie merged 5 commits into
mainfrom
bugfix/18493-contrast-theme-checkboxes

Conversation

@gtritchie

@gtritchie gtritchie commented Aug 10, 2026 •

Copy link
Copy Markdown
Member

Intent

Closes #18493.

With a Windows contrast theme enabled, checkbox state was invisible in RStudio dialogs such as Global Options.

RStudio replaces the native checkbox with a CSS-drawn box plus a fixed black glyph image (macCheck_2x.png). CSS forced colors mode overrides background-color, border-color and color, but leaves background images at their authored color. On a contrast theme with a black background the box became Canvas (black) while the checkmark stayed black, so the checked state disappeared. It stayed legible under Desert only because that theme's Canvas is tan.

The same applies to radio buttons where RStudio restyles them, which on Windows is the desktop client at >= 192 DPI (windows-highdpi, see BrowseCap.java:253-262). At standard DPI, and for Server in a browser, radio buttons already use native rendering and were unaffected.

Approach

While a contrast theme is active, hand the checkbox and radio button back to the browser's native rendering, which follows the system palette. Rendering with contrast themes off is untouched.

The override is wrapped in @supports because GWT's legacy CssResource parser (org.w3c.flute.parser.Parser, a CSS2 parser) accepts media types only. A bare @media (forced-colors: active) block parses as an error, is dropped from the generated CSS, and the build still succeeds with only a warning -- the fix would silently not exist. GWT passes the body of an unrecognized at-rule through untouched, so the media query reaches the browser intact.

Two constraints on that wrapper, both noted in a comment in the source:

  • Only @external class names may appear inside, since obfuscation does not run on a passed-through body. All classes used here (macintosh, linux, windows-highdpi, gwt-CheckBox, gwt-RadioButton) are declared @external at lines 23 and 56.
  • The @supports condition is trivially true. GWT ignores it, and the browser must not gate on it: naming a forced-colors property would drop the fix on browsers that shipped the forced-colors media feature before that property, as Firefox 89 through 112 did.

The block is placed after the rules it overrides, since a media query adds no specificity.

Verification

  • ant draft succeeds; the block reaches the compiled bundle immediately after the rules it overrides, so the cascade order is correct.
  • Running the checked-in gwt-user.jar parser over the stylesheet produces no new warnings (7 before, 7 after).
  • Extracted the checkbox and radio section verbatim from themeStyles.css, substituted the real image resources, and rendered it in Chromium with forced colors off and active, in both light and dark RStudio themes. With forced colors off the rendering is unchanged; with forced colors active both controls are native and the checked state is legible.

Not covered: a manual pass in the running IDE against a real Windows contrast theme, which is worth doing before merge (Left Alt+Left Shift+Print Screen). The radio button path in particular needs a display at 200% scaling to exercise at all, and was verified only through the rendering above.

Out of scope

Check states drawn as <img> elements do not participate in forced colors and are not fixed here; there is no CSS-only fix for them. Filed as #18494, covering the menu checkmarks (menuCheck_2x.png measures 1.42:1 against a black Canvas) and the cell-table tri-state checkboxes in the Packages pane, VCS changelist and unsaved-changes dialog.

RStudio replaces the native checkbox and radio button with a CSS-drawn
box plus a fixed black glyph image. Windows contrast themes (CSS forced
colors mode) force the box's background to Canvas but leave background
images at their authored color, so on the themes with a black background
the black checkmark and radio dot became invisible. They stayed legible
under Desert only because its Canvas is tan.

Hand these controls back to the browser's native rendering while a
contrast theme is active; rendering with contrast themes off is
unchanged.

The override is wrapped in @supports because GWT's legacy CssResource
parser is a CSS2 parser that accepts media types only: a bare
"@media (forced-colors: active)" block is dropped with a warning while
the build still succeeds, whereas the body of an unrecognized at-rule is
passed through to the browser untouched.

Addresses #18493
The @supports wrapper exists only to hide the media query from GWT's
legacy CSS parser, which never evaluates the condition. Naming a
forced-colors property in it also made the browser gate on that
property, so any browser that shipped the "forced-colors" media feature
before "forced-color-adjust" -- Firefox 89 through 112 -- skipped the
block and kept the invisible checkmark.

Use a trivially true condition instead.
@gtritchie gtritchie added this to the 2026.09 (Autumn Hawkbit) milestone Aug 10, 2026
@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

1 test(s) failed

###################- 99% pass rate

Passed Failed Skipped Flaky
1799 1 340 6
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 7 0
✅ desktop-linux 516 0 90 1
✅ desktop-macos 238 0 52 1
❌ desktop-windows 519 1 90 3
✅ server-linux 504 0 94 1
✅ setup 20 0 7 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 6320aeaffdc332a732cf0df16aec34d05543e919 - Run #516

@gtritchie
gtritchie merged commit 5fb5a30 into main Aug 10, 2026
@gtritchie
gtritchie deleted the bugfix/18493-contrast-theme-checkboxes branch August 10, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Checkbox state invisible with Windows Contrast Themes enabled

1 participant