mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
LibWeb: Allow passing a resolution context to CSSStyleValue::to_color
This will be used for resolving any calculated style values within the various `CSSColorValue` sub-classes. No functionality changes.
This commit is contained in:
parent
b468923372
commit
62d138ebf7
Notes:
github-actions[bot]
2025-07-04 12:20:15 +00:00
Author: https://github.com/Calme1709
Commit: 62d138ebf7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5284
Reviewed-by: https://github.com/AtkinsSJ ✅
33 changed files with 105 additions and 105 deletions
|
@ -7,15 +7,16 @@
|
|||
#include "CSSHSL.h"
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
Color CSSHSL::to_color(Optional<Layout::NodeWithStyle const&>) const
|
||||
Color CSSHSL::to_color(Optional<Layout::NodeWithStyle const&>, CalculationResolutionContext const& resolution_context) const
|
||||
{
|
||||
auto const h_val = resolve_hue(m_properties.h).value_or(0);
|
||||
auto const s_val = resolve_with_reference_value(m_properties.s, 100.0).value_or(0);
|
||||
auto const l_val = resolve_with_reference_value(m_properties.l, 100.0).value_or(0);
|
||||
auto const alpha_val = resolve_alpha(m_properties.alpha).value_or(1);
|
||||
auto const h_val = resolve_hue(m_properties.h, resolution_context).value_or(0);
|
||||
auto const s_val = resolve_with_reference_value(m_properties.s, 100.0, resolution_context).value_or(0);
|
||||
auto const l_val = resolve_with_reference_value(m_properties.l, 100.0, resolution_context).value_or(0);
|
||||
auto const alpha_val = resolve_alpha(m_properties.alpha, resolution_context).value_or(1);
|
||||
|
||||
return Color::from_hsla(h_val, s_val / 100.0f, l_val / 100.0f, alpha_val);
|
||||
}
|
||||
|
@ -35,7 +36,7 @@ bool CSSHSL::equals(CSSStyleValue const& other) const
|
|||
String CSSHSL::to_string(SerializationMode) const
|
||||
{
|
||||
// FIXME: Do this properly, taking unresolved calculated values into account.
|
||||
return serialize_a_srgb_value(to_color({}));
|
||||
return serialize_a_srgb_value(to_color({}, {}));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue