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

LibWeb: Make 'auto' be both a Length and Identifier in CSS

I had accidentally parsed it in `parse_builtin_or_dynamic_value()`
instead of `parse_length()` before, which was confusing, so now it's
parsed along with other Lengths.

Whether it should be a Length is up for debate, and has been tripping me
up a few times, but a lot of code expects it to be one. For now, an
'auto' Length value (or any other value which overloads `is_auto()`)
also claims to be a `ValueID::Auto` identifier.
This commit is contained in:
Sam Atkins 2021-08-09 16:02:26 +01:00 committed by Andreas Kling
parent c8c2a8df56
commit ed962be0fa
2 changed files with 10 additions and 3 deletions

View file

@ -236,7 +236,7 @@ public:
bool is_inherit() const { return type() == Type::Inherit; }
bool is_initial() const { return type() == Type::Initial; }
bool is_color() const { return type() == Type::Color; }
bool is_identifier() const { return type() == Type::Identifier; }
bool is_identifier() const { return type() == Type::Identifier || is_auto(); }
bool is_image() const { return type() == Type::Image; }
bool is_string() const { return type() == Type::String; }
virtual bool is_length() const { return type() == Type::Length; }
@ -638,6 +638,8 @@ inline CSS::ValueID StyleValue::to_identifier() const
{
if (is_identifier())
return static_cast<const IdentifierStyleValue&>(*this).id();
if (is_auto())
return CSS::ValueID::Auto;
return CSS::ValueID::Invalid;
}
}