ladybird/Userland/Libraries/LibWeb/CSS/Parser
Lucas CHOLLET 3406b69614 LibGfx+LibWeb/CSS: Add support for the lab() color function
The support in LibWeb is quite easy as the previous commits introduced
helpers to support lab-like colors.

Now for the methods in Color:
 - The formulas in `from_lab()` are derived from the CIEXYZ to CIELAB
   formulas the "Colorimetry" paper published by the CIE.
 - The conversion in `from_xyz50()` can be decomposed in multiple steps
   XYZ D50 -> XYZ D65 -> Linear sRGB -> sRGB. The two first conversion
   are done with a singular matrix operation. This matrix was generated
   with a Python script [1].

This commit makes us pass all the `css/css-color/lab-00*.html` WPT
tests (0 to 7 at the time of writing).

[1] Python script used to generate the XYZ D50 -> Linear sRGB
conversion:

```python
import numpy as np

# http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html
# First let's convert from D50 to D65 using the Bradford method.
m_a = np.array([
    [0.8951000, 0.2664000, -0.1614000],
    [-0.7502000, 1.7135000, 0.0367000],
    [0.0389000, -0.0685000, 1.0296000]
])

# D50
chromaticities_source = np.array([0.96422, 1, 0.82521])
# D65
chromaticities_destination = np.array([0.9505, 1, 1.0890])

cone_response_source = m_a @ chromaticities_source
cone_response_destination = m_a @ chromaticities_destination

cone_response_ratio = cone_response_destination / cone_response_source
m = np.linalg.inv(m_a) @ np.diagflat(cone_response_ratio) @ m_a

D50_to_D65 = m

# https://en.wikipedia.org/wiki/SRGB#From_CIE_XYZ_to_sRGB
# Then, the matrix to convert to linear sRGB.
xyz_65_to_srgb = np.array([
    [3.2406, - 1.5372, - 0.4986],
    [-0.9689, + 1.8758, 0.0415],
    [0.0557, - 0.2040, 1.0570]
])

# Finally, let's retrieve the final transformation.
xyz_50_to_srgb = xyz_65_to_srgb @ D50_to_D65

print(xyz_50_to_srgb)
```
2024-10-27 10:20:03 +01:00
..
ComponentValue.cpp LibWeb/CSS: Preserve original source text for ComponentValues 2024-10-16 08:34:31 +02:00
ComponentValue.h LibWeb/CSS: Preserve original source text for ComponentValues 2024-10-16 08:34:31 +02:00
Dimension.h LibWeb: Implement Flex and FlexStyleValue types 2023-09-28 20:33:20 +01:00
GradientParsing.cpp LibWeb/CSS: Rewrite CSS Parser core methods according to new spec 2024-10-14 08:08:37 +02:00
Helpers.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
MediaParsing.cpp LibWeb/CSS: Parse nested rules in style blocks 2024-10-17 20:55:55 +02:00
Parser.cpp LibGfx+LibWeb/CSS: Add support for the lab() color function 2024-10-27 10:20:03 +01:00
Parser.h LibGfx+LibWeb/CSS: Add support for the lab() color function 2024-10-27 10:20:03 +01:00
ParsingContext.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
ParsingContext.h LibWeb: Add CSS ParsingContext constructor with a realm and URL 2024-05-16 08:02:43 +02:00
SelectorParsing.cpp LibWeb/CSS: Use SelectorList type instead of Vector<NNRP<Selector>> 2024-10-17 20:55:55 +02:00
Token.cpp AK: Make String::number() infallible 2024-10-14 20:47:35 +02:00
Token.h LibWeb/CSS: Rename Token::representation() to original_source_text() 2024-10-16 08:34:31 +02:00
Tokenizer.cpp LibWeb/CSS: Tokenize comments as whitespace tokens 2024-10-16 08:34:31 +02:00
Tokenizer.h LibWeb/CSS: Remove tiny-oom propagation from CSS Tokenizer 2024-07-26 17:29:20 +02:00
TokenStream.h LibWeb/CSS: Bring TokenStream in line with spec 2024-10-09 17:29:29 +01:00
Types.cpp LibWeb/CSS: Preserve original source text for ComponentValues 2024-10-16 08:34:31 +02:00
Types.h LibWeb/CSS: Preserve original source text for ComponentValues 2024-10-16 08:34:31 +02:00