ladybird/Userland/Libraries/LibWeb/CSS/StyleValues
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
..
AbstractImageStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
AngleStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
AngleStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
BackgroundRepeatStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
BackgroundRepeatStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
BackgroundSizeStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
BackgroundSizeStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
BasicShapeStyleValue.cpp LibWeb: Do not allocate mask bitmap for CSS "clip-path" property 2024-08-20 20:00:56 +02:00
BasicShapeStyleValue.h LibWeb: Do not allocate mask bitmap for CSS "clip-path" property 2024-08-20 20:00:56 +02:00
BorderRadiusStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
BorderRadiusStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
ConicGradientStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
ConicGradientStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
ContentStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
ContentStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
CounterDefinitionsStyleValue.cpp LibWeb: Implement counter-[increment,reset,set] properties 2024-07-26 11:04:30 +01:00
CounterDefinitionsStyleValue.h LibWeb: Rename StyleValue -> CSSStyleValue 2024-08-15 13:58:38 +01:00
CounterStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
CounterStyleValue.h LibWeb: Rename StyleValue -> CSSStyleValue 2024-08-15 13:58:38 +01:00
CSSColorValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
CSSColorValue.h LibGfx+LibWeb/CSS: Add support for the lab() color function 2024-10-27 10:20:03 +01:00
CSSHSL.cpp LibWeb: Introduce color-function-specific style values 2024-08-21 10:51:48 +01:00
CSSHSL.h LibWeb: Introduce color-function-specific style values 2024-08-21 10:51:48 +01:00
CSSHWB.cpp LibWeb: Introduce color-function-specific style values 2024-08-21 10:51:48 +01:00
CSSHWB.h LibWeb: Introduce color-function-specific style values 2024-08-21 10:51:48 +01:00
CSSKeywordValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
CSSKeywordValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
CSSLabLike.cpp LibGfx+LibWeb/CSS: Add support for the lab() color function 2024-10-27 10:20:03 +01:00
CSSLabLike.h LibGfx+LibWeb/CSS: Add support for the lab() color function 2024-10-27 10:20:03 +01:00
CSSMathValue.cpp LibWeb: Handle calculations without a context better 2024-10-16 16:39:47 +02:00
CSSMathValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
CSSNumericValue.h LibWeb/CSS: Introduce CSSNumericValue and CSSUnitValue type stubs 2024-08-21 10:51:48 +01:00
CSSOKLCH.cpp LibWeb/CSS: Rename CalculatedStyleValue -> CSSMathValue 2024-09-18 20:38:41 +01:00
CSSOKLCH.h LibWeb: Introduce color-function-specific style values 2024-08-21 10:51:48 +01:00
CSSRGB.cpp LibWeb/CSS: Tweak in CSSRGB::to_color() to avoid floating point errors 2024-10-22 14:18:17 +01:00
CSSRGB.h LibWeb: Introduce color-function-specific style values 2024-08-21 10:51:48 +01:00
CSSUnitValue.h LibWeb/CSS: Introduce CSSNumericValue and CSSUnitValue type stubs 2024-08-21 10:51:48 +01:00
CustomIdentStyleValue.h LibWeb: Rename StyleValue -> CSSStyleValue 2024-08-15 13:58:38 +01:00
DisplayStyleValue.cpp LibWeb: Make StyleValue constructors infallible 2023-08-19 17:34:22 +02:00
DisplayStyleValue.h LibWeb: Rename StyleValue -> CSSStyleValue 2024-08-15 13:58:38 +01:00
EasingStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
EasingStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
EdgeStyleValue.cpp LibWeb: Use generated to_string() function for EdgeStyleValue edge 2023-11-07 22:00:24 +00:00
EdgeStyleValue.h LibWeb: Rename StyleValue -> CSSStyleValue 2024-08-15 13:58:38 +01:00
FilterValueListStyleValue.cpp LibWeb: Remove LibGfx-specific blur radius modification 2024-10-26 11:26:42 +02:00
FilterValueListStyleValue.h LibWeb: Parse and store filter property 2024-10-26 11:26:42 +02:00
FlexStyleValue.h LibWeb/CSS: Introduce CSSNumericValue and CSSUnitValue type stubs 2024-08-21 10:51:48 +01:00
FrequencyStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
GridAutoFlowStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
GridAutoFlowStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
GridTemplateAreaStyleValue.cpp LibWeb/CSS: Serialize empty grid-template-* values correctly 2024-10-16 08:34:02 +02:00
GridTemplateAreaStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
GridTrackPlacementStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
GridTrackPlacementStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
GridTrackSizeListStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
GridTrackSizeListStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
ImageStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
ImageStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
IntegerStyleValue.cpp AK: Make String::number() infallible 2024-10-14 20:47:35 +02:00
IntegerStyleValue.h LibWeb/CSS: Introduce CSSNumericValue and CSSUnitValue type stubs 2024-08-21 10:51:48 +01:00
LengthStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
LengthStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
LinearGradientStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
LinearGradientStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
MathDepthStyleValue.cpp LibWeb: Rename StyleValue -> CSSStyleValue 2024-08-15 13:58:38 +01:00
MathDepthStyleValue.h LibWeb: Rename StyleValue -> CSSStyleValue 2024-08-15 13:58:38 +01:00
NumberStyleValue.cpp AK: Make String::number() infallible 2024-10-14 20:47:35 +02:00
NumberStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
OpenTypeTaggedStyleValue.cpp LibWeb/CSS: Introduce OpenTypeTaggedStyleValue 2024-10-02 16:28:55 +01:00
OpenTypeTaggedStyleValue.h LibWeb/CSS: Introduce OpenTypeTaggedStyleValue 2024-10-02 16:28:55 +01:00
PercentageStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
PositionStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
PositionStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
RadialGradientStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
RadialGradientStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
RatioStyleValue.h LibWeb: Rename StyleValue -> CSSStyleValue 2024-08-15 13:58:38 +01:00
RectStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
RectStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
ResolutionStyleValue.h LibWeb/CSS: Introduce CSSNumericValue and CSSUnitValue type stubs 2024-08-21 10:51:48 +01:00
ScrollbarGutterStyleValue.h LibWeb: Rename StyleValue -> CSSStyleValue 2024-08-15 13:58:38 +01:00
ShadowStyleValue.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
ShadowStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
ShorthandStyleValue.cpp LibWeb/CSS: Make font-stretch a legacy alias for new font-width 2024-09-28 14:42:26 +02:00
ShorthandStyleValue.h LibWeb: Rename StyleValue -> CSSStyleValue 2024-08-15 13:58:38 +01:00
StringStyleValue.h LibWeb/CSS: Return StringStyleValue's FlyString by reference 2024-10-02 16:28:55 +01:00
StyleValueList.cpp Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
StyleValueList.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
TimeStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
TransformationStyleValue.cpp AK: Make String::number() infallible 2024-10-14 20:47:35 +02:00
TransformationStyleValue.h Meta: Update my e-mail address everywhere 2024-10-04 13:19:50 +02:00
TransitionStyleValue.cpp LibWeb: Parse transition style values 2024-03-29 21:58:12 +01:00
TransitionStyleValue.h LibWeb: Rename StyleValue -> CSSStyleValue 2024-08-15 13:58:38 +01:00
UnresolvedStyleValue.cpp LibWeb/CSS: Insert whitespace between tokens in serialized UnresolvedSV 2024-10-16 08:34:31 +02:00
UnresolvedStyleValue.h LibWeb/CSS: Preserve whitespace and comments in custom properties 2024-10-16 08:34:31 +02:00
URLStyleValue.h LibWeb: Rename StyleValue -> CSSStyleValue 2024-08-15 13:58:38 +01:00