Skip to content

Commit

Permalink
REGRESSION (macOS 14): Native text fields are invisible in dark mode
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270134
rdar://123658326

Reviewed by Richard Robinson.

201985@main added logic to ensure that text fields are displayed correctly in
dark mode, as they do not support "border only" painting. The detection of
dark mode was performed by checking the appearance of the cell's control view.

However, with the introduction of GPU process for DOM rendering on macOS, cells
no longer have control views. Consequently, the appearance check always fails,
and the light mode border treatment, which results in an invisible control in
dark mode, is used.

Fix by comparing against `-[NSAppearance currentDrawingAppearance]` rather than
assuming there is a control view. This is correct, as the drawing appearance is
always set (using `LocalDefaultSystemAppearance`) prior to drawing the control.

* LayoutTests/fast/forms/textfield-dark-color-scheme-expected-mismatch.html: Added.
* LayoutTests/fast/forms/textfield-dark-color-scheme.html: Added.
* Source/WebCore/platform/graphics/mac/controls/WebControlView.mm:
(-[WebControlTextFieldCell _adjustedCoreUIDrawOptionsForDrawingBordersOnly:]):

Canonical link: https://commits.webkit.org/275363@main
  • Loading branch information
pxlcoder committed Feb 27, 2024
1 parent e5936dc commit 1f547d4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<style>

:root {
color-scheme: dark;
}

</style>
<body></body>
8 changes: 8 additions & 0 deletions LayoutTests/fast/forms/textfield-dark-color-scheme.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<style>

:root {
color-scheme: dark;
}

</style>
<input>
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ - (CFDictionaryRef)_adjustedCoreUIDrawOptionsForDrawingBordersOnly:(CFDictionary
{
// Dark mode controls don't have borders, just a semi-transparent background of shadows.
// In the dark mode case we can't disable borders, or we will not paint anything for the control.
NSAppearanceName appearance = [self.controlView.effectiveAppearance bestMatchFromAppearancesWithNames:@[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]];
NSAppearanceName appearance = [[NSAppearance currentDrawingAppearance] bestMatchFromAppearancesWithNames:@[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]];
if ([appearance isEqualToString:NSAppearanceNameDarkAqua])
return defaultOptions;

Expand Down

0 comments on commit 1f547d4

Please sign in to comment.