1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 11:27:34 +00:00

LibWeb: Remove CalculatedStyleValue from Length

This commit is contained in:
Sam Atkins 2023-03-30 15:46:05 +01:00 committed by Andreas Kling
parent 62a8cf2bb8
commit 53a4a31af2
8 changed files with 25 additions and 70 deletions

View file

@ -57,14 +57,13 @@ size_t GridFormattingContext::count_of_gap_rows()
CSSPixels GridFormattingContext::resolve_size(CSS::Size const& size, AvailableSize const& available_size, Box const& box)
{
if (size.is_length() && size.length().is_calculated()) {
if (size.length().calculated_style_value()->contains_percentage()) {
if (size.is_calculated()) {
if (size.calculated().contains_percentage()) {
if (!available_size.is_definite())
return 0;
auto& calc_value = *size.length().calculated_style_value();
return calc_value.resolve_length_percentage(box, CSS::Length::make_px(available_size.to_px())).value_or(CSS::Length::make_auto()).to_px(box);
return size.calculated().resolve_length_percentage(box, CSS::Length::make_px(available_size.to_px())).value_or(CSS::Length::make_auto()).to_px(box);
}
return size.length().to_px(box);
return size.calculated().resolve_length(box)->to_px(box);
}
if (size.is_length()) {
return size.length().to_px(box);

View file

@ -263,24 +263,22 @@ void LayoutState::UsedValues::set_node(NodeWithStyleAndBoxModelMetrics& node, Us
return false;
}
if (size.is_length() && size.length().is_calculated()) {
if (size.length().calculated_style_value()->contains_percentage()) {
if (size.is_calculated()) {
if (size.calculated().contains_percentage()) {
if (!containing_block_has_definite_size)
return false;
auto& calc_value = *size.length().calculated_style_value();
auto containing_block_size_as_length = width
? CSS::Length::make_px(containing_block_used_values->content_width())
: CSS::Length::make_px(containing_block_used_values->content_height());
resolved_definite_size = calc_value.resolve_length_percentage(node, containing_block_size_as_length).value_or(CSS::Length::make_auto()).to_px(node);
resolved_definite_size = size.calculated().resolve_length_percentage(node, containing_block_size_as_length).value_or(CSS::Length::make_auto()).to_px(node);
return true;
}
resolved_definite_size = size.length().to_px(node);
resolved_definite_size = size.calculated().resolve_length(node)->to_px(node);
return true;
}
if (size.is_length()) {
VERIFY(!size.is_auto()); // This should have been covered by the Size::is_auto() branch above.
VERIFY(!size.length().is_calculated()); // Covered above.
VERIFY(!size.is_auto()); // This should have been covered by the Size::is_auto() branch above.
resolved_definite_size = size.length().to_px(node);
return true;
}

View file

@ -603,7 +603,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
auto resolve_border_width = [&]() {
auto value = computed_style.property(width_property);
if (value->is_calculated())
return CSS::Length::make_calculated(const_cast<CSS::CalculatedStyleValue&>(value->as_calculated())).to_px(*this).value();
return value->as_calculated().resolve_length(*this)->to_px(*this).value();
if (value->has_length())
return value->to_length().to_px(*this).value();
if (value->is_identifier()) {