Repository navigation
Restore native checkbox rendering under Windows contrast themes - #18496
Merged
Merged
Conversation
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.
RStudio E2E - all platforms1 test(s) failed
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 overridesbackground-color,border-colorandcolor, but leaves background images at their authored color. On a contrast theme with a black background the box becameCanvas(black) while the checkmark stayed black, so the checked state disappeared. It stayed legible under Desert only because that theme'sCanvasis tan.The same applies to radio buttons where RStudio restyles them, which on Windows is the desktop client at >= 192 DPI (
windows-highdpi, seeBrowseCap.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
@supportsbecause GWT's legacyCssResourceparser (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:
@externalclass 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@externalat lines 23 and 56.@supportscondition 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 theforced-colorsmedia 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 draftsucceeds; the block reaches the compiled bundle immediately after the rules it overrides, so the cascade order is correct.gwt-user.jarparser over the stylesheet produces no new warnings (7 before, 7 after).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.pngmeasures 1.42:1 against a blackCanvas) and the cell-table tri-state checkboxes in the Packages pane, VCS changelist and unsaved-changes dialog.