mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-04 23:29:52 +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
|
@ -957,11 +957,9 @@ RefPtr<CSSStyleValue const> interpolate_box_shadow(DOM::Element& element, Calcul
|
|||
StyleValueVector result_shadows;
|
||||
result_shadows.ensure_capacity(from_shadows.size());
|
||||
|
||||
Optional<Layout::NodeWithStyle const&> layout_node;
|
||||
CalculationResolutionContext resolution_context;
|
||||
ColorResolutionContext color_resolution_context {};
|
||||
if (auto node = element.layout_node()) {
|
||||
layout_node = *node;
|
||||
resolution_context.length_resolution_context = Length::ResolutionContext::for_layout_node(*node);
|
||||
color_resolution_context = ColorResolutionContext::for_layout_node_with_style(*element.layout_node());
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < from_shadows.size(); i++) {
|
||||
|
@ -982,8 +980,8 @@ RefPtr<CSSStyleValue const> interpolate_box_shadow(DOM::Element& element, Calcul
|
|||
|
||||
// FIXME: If we aren't able to resolve the colors here, we should postpone interpolation until we can (perhaps
|
||||
// by creating something similar to a ColorMixStyleValue).
|
||||
auto from_color = from_shadow.color()->to_color(layout_node, resolution_context);
|
||||
auto to_color = to_shadow.color()->to_color(layout_node, resolution_context);
|
||||
auto from_color = from_shadow.color()->to_color(color_resolution_context);
|
||||
auto to_color = to_shadow.color()->to_color(color_resolution_context);
|
||||
|
||||
Color interpolated_color = Color::Black;
|
||||
|
||||
|
@ -1102,11 +1100,9 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
|||
return BackgroundSizeStyleValue::create(*interpolated_x, *interpolated_y);
|
||||
}
|
||||
case CSSStyleValue::Type::Color: {
|
||||
Optional<Layout::NodeWithStyle const&> layout_node;
|
||||
CalculationResolutionContext resolution_context {};
|
||||
ColorResolutionContext color_resolution_context {};
|
||||
if (auto node = element.layout_node()) {
|
||||
layout_node = *node;
|
||||
resolution_context.length_resolution_context = Length::ResolutionContext::for_layout_node(*node);
|
||||
color_resolution_context = ColorResolutionContext::for_layout_node_with_style(*element.layout_node());
|
||||
}
|
||||
|
||||
auto color_syntax = ColorSyntax::Legacy;
|
||||
|
@ -1117,8 +1113,8 @@ static RefPtr<CSSStyleValue const> interpolate_value_impl(DOM::Element& element,
|
|||
|
||||
// FIXME: If we aren't able to resolve the colors here, we should postpone interpolation until we can (perhaps
|
||||
// by creating something similar to a ColorMixStyleValue).
|
||||
auto from_color = from.to_color(layout_node, resolution_context);
|
||||
auto to_color = to.to_color(layout_node, resolution_context);
|
||||
auto from_color = from.to_color(color_resolution_context);
|
||||
auto to_color = to.to_color(color_resolution_context);
|
||||
|
||||
Color interpolated_color = Color::Black;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue