mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibWeb: Don't resolve colors with unresolved components
`CSSColorValue`s which have unresolved `calc` components should be able to be resolved. Previously we would always resolve them but with incorrect values. This is useful as we will now be able to now whether we should serialize colors in their normalized form or not. Slight regression in that we now serialize (RGB, HSL and HWB) colors with components that rely on compute-time information as an empty string, but that will be fixed in the next commit.
This commit is contained in:
parent
e66332c07a
commit
6a9c8d7767
Notes:
github-actions[bot]
2025-07-16 12:06:47 +00:00
Author: https://github.com/Calme1709
Commit: 6a9c8d7767
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5305
Reviewed-by: https://github.com/AtkinsSJ ✅
30 changed files with 278 additions and 129 deletions
|
@ -226,7 +226,7 @@ Color ComputedProperties::color_or_fallback(PropertyID id, Layout::NodeWithStyle
|
|||
auto const& value = property(id);
|
||||
if (!value.has_color())
|
||||
return fallback;
|
||||
return value.to_color(node, { .length_resolution_context = Length::ResolutionContext::for_layout_node(node) });
|
||||
return value.to_color(node, { .length_resolution_context = Length::ResolutionContext::for_layout_node(node) }).value();
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-color-adjust-1/#determine-the-used-color-scheme
|
||||
|
@ -447,7 +447,7 @@ Color ComputedProperties::flood_color(Layout::NodeWithStyle const& node) const
|
|||
{
|
||||
auto const& value = property(PropertyID::FloodColor);
|
||||
if (value.has_color()) {
|
||||
return value.to_color(node, { .length_resolution_context = Length::ResolutionContext::for_layout_node(node) });
|
||||
return value.to_color(node, { .length_resolution_context = Length::ResolutionContext::for_layout_node(node) }).value();
|
||||
}
|
||||
|
||||
return InitialValues::flood_color();
|
||||
|
@ -940,7 +940,7 @@ Color ComputedProperties::caret_color(Layout::NodeWithStyle const& node) const
|
|||
return node.computed_values().color();
|
||||
|
||||
if (value.has_color())
|
||||
return value.to_color(node, { .length_resolution_context = Length::ResolutionContext::for_layout_node(node) });
|
||||
return value.to_color(node, { .length_resolution_context = Length::ResolutionContext::for_layout_node(node) }).value();
|
||||
|
||||
return InitialValues::caret_color();
|
||||
}
|
||||
|
@ -1203,7 +1203,7 @@ Vector<ShadowData> ComputedProperties::shadow(PropertyID property_id, Layout::No
|
|||
maybe_offset_y.release_value(),
|
||||
maybe_blur_radius.release_value(),
|
||||
maybe_spread_distance.release_value(),
|
||||
value.color()->to_color(as<Layout::NodeWithStyle>(layout_node), { .length_resolution_context = Length::ResolutionContext::for_layout_node(layout_node) }),
|
||||
value.color()->to_color(as<Layout::NodeWithStyle>(layout_node), { .length_resolution_context = Length::ResolutionContext::for_layout_node(layout_node) }).value(),
|
||||
value.placement()
|
||||
};
|
||||
};
|
||||
|
@ -1826,7 +1826,7 @@ Color ComputedProperties::stop_color() const
|
|||
// FIXME: This is used by the SVGStopElement, which does not participate in layout, so we can't pass a layout
|
||||
// node or CalculationResolutionContext. This means we don't support all valid colors (e.g. palette
|
||||
// colors, calculated values which depend on length resolution, etc)
|
||||
return value->to_color({}, {});
|
||||
return value->to_color({}, {}).value_or(Color::Black);
|
||||
}
|
||||
return Color::Black;
|
||||
}
|
||||
|
@ -1910,8 +1910,8 @@ ScrollbarColorData ComputedProperties::scrollbar_color(Layout::NodeWithStyle con
|
|||
|
||||
if (value.is_scrollbar_color()) {
|
||||
auto& scrollbar_color_value = value.as_scrollbar_color();
|
||||
auto thumb_color = scrollbar_color_value.thumb_color()->to_color(layout_node, { .length_resolution_context = Length::ResolutionContext::for_layout_node(layout_node) });
|
||||
auto track_color = scrollbar_color_value.track_color()->to_color(layout_node, { .length_resolution_context = Length::ResolutionContext::for_layout_node(layout_node) });
|
||||
auto thumb_color = scrollbar_color_value.thumb_color()->to_color(layout_node, { .length_resolution_context = Length::ResolutionContext::for_layout_node(layout_node) }).value();
|
||||
auto track_color = scrollbar_color_value.track_color()->to_color(layout_node, { .length_resolution_context = Length::ResolutionContext::for_layout_node(layout_node) }).value();
|
||||
return { thumb_color, track_color };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue