The lab() and lch() functions are finally landing in Webkit, and the other major browsers have shown interest in implementing them (although it may still take some time). So here they are in css4j.
The usage of these functions in a toolchain with the typical Java open source tools (which tend to use the sRGB default color space) could be problematic, as lab() and lch() are often specified out of that gamut, but an accurate RGB clamping method is provided.
Now you can control the serialization of computed styles thanks to a new factory method: StyleFormattingFactory.createComputedStyleFormattingContext(), which returns a DeclarationFormattingContext.
A non-default implementation of that interface, called RGBStyleFormattingFactory, is provided for the convenience of users that can only deal with RGB colors in computed styles (for example those feeding CSS4J computed styles into Apache FOP). Basically, it allows to use modern CSS with Lab, LCh or Hsl colors and then convert them to RGB at the computed-style stage.
When parsing, the library uses the same RGB format that was specified. That is, if the input was a rgba() function with commas, it serialized that way. However, when other types of colors were converted to RGB, it defaulted to the modern format without the commas. That default was not the most adequate though:
According to the 2020 Web Almanac, "99.89% of functionally specified sRGB colors are using the since-forever legacy format with commas [...] rather than the new comma-less form".
XSL:FO uses the old format with commas, see https://www.w3.org/TR/xsl/#expr-color-functions
So the default format for values converted to RGB now has commas.
This allows checking the grammar of values against specific syntaxes like <length>+, <string>#, <transform-function> or <unicode-range>#.
The rule (that currently only works in Chrome/Blink) allows to customize the behaviour of custom properties. The direct setting of property syntax through DOM is also supported.
AFAIK no other DOM implementation contains this useful method.
JCLF dependency switched to jclf-text 5.0.0
If you have the JCLF dependency explicitly set in your Maven configuration, do not forget to upgrade to 5.0.0 there as well.