mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 04:59:23 +00:00
LibWeb: Take a ColorResolutionContext in color_or_fallback
Taking a ColorResolutionContext directly instead of creating one from a layout node allows us to call this from places where we don't have a layout node.
This commit is contained in:
parent
46153910ec
commit
a19a6deaa4
Notes:
github-actions[bot]
2025-08-04 10:30:45 +00:00
Author: https://github.com/Calme1709
Commit: a19a6deaa4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5517
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/gmta
3 changed files with 8 additions and 8 deletions
|
@ -393,7 +393,7 @@ void NodeWithStyle::apply_style(CSS::ComputedProperties const& computed_style)
|
|||
|
||||
// NOTE: color must be set after color-scheme to ensure currentColor can be resolved in other properties (e.g. background-color).
|
||||
// NOTE: color must be set after font_size as `CalculatedStyleValue`s can rely on it being set for resolving lengths.
|
||||
computed_values.set_color(computed_style.color_or_fallback(CSS::PropertyID::Color, *this, CSS::InitialValues::color()));
|
||||
computed_values.set_color(computed_style.color_or_fallback(CSS::PropertyID::Color, CSS::ColorResolutionContext::for_layout_node_with_style(*this), CSS::InitialValues::color()));
|
||||
|
||||
computed_values.set_vertical_align(computed_style.vertical_align());
|
||||
|
||||
|
@ -527,7 +527,7 @@ void NodeWithStyle::apply_style(CSS::ComputedProperties const& computed_style)
|
|||
|
||||
computed_values.set_background_layers(move(layers));
|
||||
}
|
||||
computed_values.set_background_color(computed_style.color_or_fallback(CSS::PropertyID::BackgroundColor, *this, CSS::InitialValues::background_color()));
|
||||
computed_values.set_background_color(computed_style.color_or_fallback(CSS::PropertyID::BackgroundColor, CSS::ColorResolutionContext::for_layout_node_with_style(*this), CSS::InitialValues::background_color()));
|
||||
|
||||
computed_values.set_box_sizing(computed_style.box_sizing());
|
||||
|
||||
|
@ -738,11 +738,11 @@ void NodeWithStyle::apply_style(CSS::ComputedProperties const& computed_style)
|
|||
// FIXME: The default text decoration color value is `currentcolor`, but since we can't resolve that easily,
|
||||
// we just manually grab the value from `color`. This makes it dependent on `color` being
|
||||
// specified first, so it's far from ideal.
|
||||
computed_values.set_text_decoration_color(computed_style.color_or_fallback(CSS::PropertyID::TextDecorationColor, *this, computed_values.color()));
|
||||
computed_values.set_text_decoration_color(computed_style.color_or_fallback(CSS::PropertyID::TextDecorationColor, CSS::ColorResolutionContext::for_layout_node_with_style(*this), computed_values.color()));
|
||||
if (auto maybe_text_decoration_thickness = computed_style.length_percentage(CSS::PropertyID::TextDecorationThickness); maybe_text_decoration_thickness.has_value())
|
||||
computed_values.set_text_decoration_thickness(maybe_text_decoration_thickness.release_value());
|
||||
|
||||
computed_values.set_webkit_text_fill_color(computed_style.color_or_fallback(CSS::PropertyID::WebkitTextFillColor, *this, computed_values.color()));
|
||||
computed_values.set_webkit_text_fill_color(computed_style.color_or_fallback(CSS::PropertyID::WebkitTextFillColor, CSS::ColorResolutionContext::for_layout_node_with_style(*this), computed_values.color()));
|
||||
|
||||
computed_values.set_text_shadow(computed_style.text_shadow(*this));
|
||||
|
||||
|
@ -817,7 +817,7 @@ void NodeWithStyle::apply_style(CSS::ComputedProperties const& computed_style)
|
|||
// FIXME: The default border color value is `currentcolor`, but since we can't resolve that easily,
|
||||
// we just manually grab the value from `color`. This makes it dependent on `color` being
|
||||
// specified first, so it's far from ideal.
|
||||
border.color = computed_style.color_or_fallback(color_property, *this, computed_values.color());
|
||||
border.color = computed_style.color_or_fallback(color_property, CSS::ColorResolutionContext::for_layout_node_with_style(*this), computed_values.color());
|
||||
border.line_style = computed_style.line_style(style_property);
|
||||
|
||||
// https://w3c.github.io/csswg-drafts/css-backgrounds/#border-style
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue