Motivation
Follow-up to #4434 and #4435.
MapLibre Native’s vendored CSS color parser supports a narrower syntax than the current MapLibre Style Spec parser. PR #4435 addresses the immediate four-argument hsl() issue, but several related syntax differences remain.
It would be useful to align Native with the specific CSS Color 4 subset already implemented and tested by MapLibre Style Spec.
Proposed syntax support
HSL/HSLA
- Space-separated components:
- Optional slash alpha:
hsl(120 100% 50% / 0.25)
hsl(120 100% 50% / 25%)
- Identical grammar for the
hsl() and legacy hsla() aliases.
- Percentage alpha values.
- Hue numbers with an optional
deg suffix.
- Decimal and scientific-notation numeric values.
RGB/RGBA
- Space-separated number or percentage components:
rgb(255 0 0)
rgb(100% 0% 0%)
- Optional slash alpha:
rgb(255 0 0 / 0.25)
rgb(100% 0% 0% / 25%)
- Identical grammar for the
rgb() and legacy rgba() aliases.
- Four-argument comma syntax for either alias.
MapLibre Style Spec references
The supported subset is documented here:
Relevant CSS Color 4 sections:
Out of scope
This would target parity with MapLibre Style Spec rather than complete CSS Color 4 support. The Style Spec parser currently does not support:
grad, rad, or turn hue units
- The
none keyword
- Comments inside color functions
Acceptance criteria
- Native accepts the HSL and RGB forms listed above.
hsl/hsla and rgb/rgba behave as aliases for the supported grammar.
- Equivalent syntaxes produce the same premultiplied native color.
- Existing invalid mixed-separator and mixed-number/percentage cases remain invalid.
- Native unit tests cover representative cases from the Style Spec test suite.
Motivation
Follow-up to #4434 and #4435.
MapLibre Native’s vendored CSS color parser supports a narrower syntax than the current MapLibre Style Spec parser. PR #4435 addresses the immediate four-argument
hsl()issue, but several related syntax differences remain.It would be useful to align Native with the specific CSS Color 4 subset already implemented and tested by MapLibre Style Spec.
Proposed syntax support
HSL/HSLA
hsl(120 100% 50%)hsl(120 100% 50% / 0.25)hsl(120 100% 50% / 25%)hsl()and legacyhsla()aliases.degsuffix.RGB/RGBA
rgb(255 0 0)rgb(100% 0% 0%)rgb(255 0 0 / 0.25)rgb(100% 0% 0% / 25%)rgb()and legacyrgba()aliases.MapLibre Style Spec references
The supported subset is documented here:
Relevant CSS Color 4 sections:
Out of scope
This would target parity with MapLibre Style Spec rather than complete CSS Color 4 support. The Style Spec parser currently does not support:
grad,rad, orturnhue unitsnonekeywordAcceptance criteria
hsl/hslaandrgb/rgbabehave as aliases for the supported grammar.