mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 15:16:14 +00:00
LibWeb: Use CSS::ValueID for 'text-align' values
Let's start moving away from using raw strings for CSS identifiers. The idea here is to use IdentifierStyleValue with a CSS::ValueID inside for all CSS identifier values.
This commit is contained in:
@@ -261,19 +261,26 @@ bool StyleProperties::operator==(const StyleProperties& other) const
|
||||
return true;
|
||||
}
|
||||
|
||||
CSS::TextAlign StyleProperties::text_align() const
|
||||
Optional<CSS::TextAlign> StyleProperties::text_align() const
|
||||
{
|
||||
auto string = string_or_fallback(CSS::PropertyID::TextAlign, "left");
|
||||
if (string == "center")
|
||||
auto value = property(CSS::PropertyID::TextAlign);
|
||||
if (!value.has_value() || !value.value()->is_identifier())
|
||||
return {};
|
||||
|
||||
switch (static_cast<const IdentifierStyleValue&>(*value.value()).id()) {
|
||||
case CSS::ValueID::Left:
|
||||
return CSS::TextAlign::Left;
|
||||
case CSS::ValueID::Center:
|
||||
return CSS::TextAlign::Center;
|
||||
if (string == "right")
|
||||
case CSS::ValueID::Right:
|
||||
return CSS::TextAlign::Right;
|
||||
if (string == "justify")
|
||||
case CSS::ValueID::Justify:
|
||||
return CSS::TextAlign::Justify;
|
||||
if (string == "-libweb-center")
|
||||
case CSS::ValueID::VendorSpecificCenter:
|
||||
return CSS::TextAlign::VendorSpecificCenter;
|
||||
// Otherwise, just assume "left"..
|
||||
return CSS::TextAlign::Left;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
Optional<CSS::WhiteSpace> StyleProperties::white_space() const
|
||||
|
||||
Reference in New Issue
Block a user