Bug 282057

Summary: Registered Custom Property of `<color>` type should not accept `initial-value: light-dark()`
Product: WebKit Reporter: David Shin <dshin>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: ahmad.saleem792, akeerthi, karlcow, koivisto, ntim, timothy, webkit-bug-importer, zach
Priority: P2 Keywords: GoodFirstBug, InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: macOS 15   
Attachments:
Description Flags
Basic Testcase none

David Shin
Reported 2024-10-24 12:28:38 PDT
Created attachment 473035 [details] Basic Testcase As in the testcase, when a registered custom property of color type has the initial value using light-dark(), it seems to resolve to the light value. However, light-dark() [depends on color-scheme](https://drafts.csswg.org/css-color-5/#light-dark), which seems to be definitionally not [computationally independent](https://drafts.css-houdini.org/css-properties-values-api/#computationally-independent), which means that the declaration should be dropped. In the testcase, referencing registered length custom property with 1em initial value uses the fallback value. Referencing a registered color property with light-dark uses the light value, instead of the fallback value.
Attachments
Basic Testcase (468 bytes, text/html)
2024-10-24 12:28 PDT, David Shin
no flags
Radar WebKit Bug Importer
Comment 1 2024-10-31 12:29:15 PDT
Ahmad Saleem
Comment 2 2024-10-31 18:41:53 PDT
I looked into it and WebKit ToT, Chrome Canary 132 and Firefox Nightly 134 are matching. Am I missing something in order to reproduce this bug?
Antti Koivisto
Comment 3 2024-11-01 01:44:46 PDT
I think this is indeed a bug as the light-dark() function depends on the color-scheme property and so is not computationally independent. Sounds like all browsers get this wrong.
Tim Nguyen (:ntim)
Comment 4 2024-11-10 23:08:53 PST
`collectComputedStyleDependencies` is the method that needs to change. `containsColorSchemeDependentColor` is a helper on CSS color types that you can use to get the relevant info.
Zach Hoffman
Comment 5 2024-11-11 11:21:44 PST
Besides light-dark(), system colors also depend on color-scheme.
Note You need to log in before you can comment on or make changes to this bug.