mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-05 23:59:53 +00:00
LibWeb: Update to_color
to take ColorResolutionContext
Using a generic context argument will allow us to resolve colors in places where we have all the required information but not in the form of a layout node as was expected previously.
This commit is contained in:
parent
b0508fb39a
commit
46153910ec
Notes:
github-actions[bot]
2025-08-04 10:30:51 +00:00
Author: https://github.com/Calme1709
Commit: 46153910ec
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5517
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/gmta
31 changed files with 129 additions and 127 deletions
|
@ -27,12 +27,12 @@ bool CSSLCHLike::equals(CSSStyleValue const& other) const
|
|||
return m_properties == other_oklch_like.m_properties;
|
||||
}
|
||||
|
||||
Optional<Color> CSSLCH::to_color(Optional<Layout::NodeWithStyle const&>, CalculationResolutionContext const& resolution_context) const
|
||||
Optional<Color> CSSLCH::to_color(ColorResolutionContext color_resolution_context) const
|
||||
{
|
||||
auto raw_l_val = resolve_with_reference_value(m_properties.l, 100, resolution_context);
|
||||
auto c_val = resolve_with_reference_value(m_properties.c, 150, resolution_context);
|
||||
auto raw_h_val = resolve_hue(m_properties.h, resolution_context);
|
||||
auto alpha_val = resolve_alpha(m_properties.alpha, resolution_context);
|
||||
auto raw_l_val = resolve_with_reference_value(m_properties.l, 100, color_resolution_context.calculation_resolution_context);
|
||||
auto c_val = resolve_with_reference_value(m_properties.c, 150, color_resolution_context.calculation_resolution_context);
|
||||
auto raw_h_val = resolve_hue(m_properties.h, color_resolution_context.calculation_resolution_context);
|
||||
auto alpha_val = resolve_alpha(m_properties.alpha, color_resolution_context.calculation_resolution_context);
|
||||
|
||||
if (!raw_l_val.has_value() || !c_val.has_value() || !raw_h_val.has_value() || !alpha_val.has_value())
|
||||
return {};
|
||||
|
@ -63,12 +63,12 @@ String CSSLCH::to_string(SerializationMode mode) const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
Optional<Color> CSSOKLCH::to_color(Optional<Layout::NodeWithStyle const&>, CalculationResolutionContext const& resolution_context) const
|
||||
Optional<Color> CSSOKLCH::to_color(ColorResolutionContext color_resolution_context) const
|
||||
{
|
||||
auto raw_l_val = resolve_with_reference_value(m_properties.l, 1.0, resolution_context);
|
||||
auto raw_c_val = resolve_with_reference_value(m_properties.c, 0.4, resolution_context);
|
||||
auto raw_h_val = resolve_hue(m_properties.h, resolution_context);
|
||||
auto alpha_val = resolve_alpha(m_properties.alpha, resolution_context);
|
||||
auto raw_l_val = resolve_with_reference_value(m_properties.l, 1.0, color_resolution_context.calculation_resolution_context);
|
||||
auto raw_c_val = resolve_with_reference_value(m_properties.c, 0.4, color_resolution_context.calculation_resolution_context);
|
||||
auto raw_h_val = resolve_hue(m_properties.h, color_resolution_context.calculation_resolution_context);
|
||||
auto alpha_val = resolve_alpha(m_properties.alpha, color_resolution_context.calculation_resolution_context);
|
||||
|
||||
if (!raw_l_val.has_value() || !raw_c_val.has_value() || !raw_h_val.has_value() || !alpha_val.has_value())
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue