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

LibWeb: Add vertical-align to ComputedValues

This commit is contained in:
Andreas Kling 2022-02-26 01:34:07 +01:00
parent c9f4759329
commit 1cdbd377e7
6 changed files with 89 additions and 0 deletions

View file

@ -403,6 +403,29 @@ static CSS::ValueID to_css_value_id(CSS::Overflow value)
VERIFY_NOT_REACHED();
}
static CSS::ValueID to_css_value_id(CSS::VerticalAlign value)
{
switch (value) {
case CSS::VerticalAlign::Baseline:
return CSS::ValueID::Baseline;
case CSS::VerticalAlign::Bottom:
return CSS::ValueID::Bottom;
case CSS::VerticalAlign::Middle:
return CSS::ValueID::Middle;
case CSS::VerticalAlign::Sub:
return CSS::ValueID::Sub;
case CSS::VerticalAlign::Super:
return CSS::ValueID::Super;
case CSS::VerticalAlign::TextBottom:
return CSS::ValueID::TextBottom;
case CSS::VerticalAlign::TextTop:
return CSS::ValueID::TextTop;
case CSS::VerticalAlign::Top:
return CSS::ValueID::Top;
}
VERIFY_NOT_REACHED();
}
static CSS::ValueID to_css_value_id(CSS::ListStyleType value)
{
switch (value) {
@ -716,6 +739,15 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
value_or_default(maybe_background_origin, IdentifierStyleValue::create(CSS::ValueID::PaddingBox)),
value_or_default(maybe_background_clip, IdentifierStyleValue::create(CSS::ValueID::BorderBox)));
}
case CSS::PropertyID::VerticalAlign:
if (auto const* length_percentage = layout_node.computed_values().vertical_align().get_pointer<CSS::LengthPercentage>()) {
if (length_percentage->is_length())
return LengthStyleValue::create(length_percentage->length());
if (length_percentage->is_percentage())
return PercentageStyleValue::create(length_percentage->percentage());
VERIFY_NOT_REACHED();
}
return IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().vertical_align().get<CSS::VerticalAlign>()));
case CSS::PropertyID::ListStyleType:
return IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().list_style_type()));
case CSS::PropertyID::BoxSizing: