1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00

LibWeb: Use Optional instead of undefined-lengths for widths/heights

This commit is contained in:
Sam Atkins 2022-02-18 15:10:11 +00:00 committed by Andreas Kling
parent 699b48ccc8
commit 5b2482a939
10 changed files with 126 additions and 92 deletions

View file

@ -536,25 +536,25 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
return StyleValueList::create(move(box_shadow), StyleValueList::Separator::Comma);
}
case CSS::PropertyID::Width:
return style_value_for_length_percentage(layout_node.computed_values().width());
return style_value_for_length_percentage(layout_node.computed_values().width().value_or(Length::make_auto()));
case CSS::PropertyID::MinWidth:
if (layout_node.computed_values().min_width().is_length() && layout_node.computed_values().min_width().length().is_undefined_or_auto())
if (!layout_node.computed_values().min_width().has_value())
return IdentifierStyleValue::create(CSS::ValueID::Auto);
return style_value_for_length_percentage(layout_node.computed_values().min_width());
return style_value_for_length_percentage(layout_node.computed_values().min_width().value());
case CSS::PropertyID::MaxWidth:
if (layout_node.computed_values().max_width().is_length() && layout_node.computed_values().max_width().length().is_undefined())
if (!layout_node.computed_values().max_width().has_value())
return IdentifierStyleValue::create(CSS::ValueID::None);
return style_value_for_length_percentage(layout_node.computed_values().max_width());
return style_value_for_length_percentage(layout_node.computed_values().max_width().value());
case CSS::PropertyID::Height:
return style_value_for_length_percentage(layout_node.computed_values().height());
return style_value_for_length_percentage(layout_node.computed_values().height().value_or(Length::make_auto()));
case CSS::PropertyID::MinHeight:
if (layout_node.computed_values().min_height().is_length() && layout_node.computed_values().min_height().length().is_undefined_or_auto())
if (!layout_node.computed_values().min_height().has_value())
return IdentifierStyleValue::create(CSS::ValueID::Auto);
return style_value_for_length_percentage(layout_node.computed_values().min_height());
return style_value_for_length_percentage(layout_node.computed_values().min_height().value());
case CSS::PropertyID::MaxHeight:
if (layout_node.computed_values().max_height().is_length() && layout_node.computed_values().max_height().length().is_undefined())
if (!layout_node.computed_values().max_height().has_value())
return IdentifierStyleValue::create(CSS::ValueID::None);
return style_value_for_length_percentage(layout_node.computed_values().max_height());
return style_value_for_length_percentage(layout_node.computed_values().max_height().value());
case CSS::PropertyID::Margin: {
auto margin = layout_node.computed_values().margin();
auto values = NonnullRefPtrVector<StyleValue> {};