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

LibWeb: Fix auto conversion to identifier

Calling `is_identifier()` here was wrong, since it just means you can
get an Identifier from it. This meant that an `auto` LengthStyleValue
would return true, then it would get `static_cast` to the wrong class,
and return a garbage value.

Basically, I really need to tidy up the API for StyleValue, so it's
clear whether `is_foo()` means the object is a `FooStyleValue`, or it
can just return a `foo` value.
This commit is contained in:
Sam Atkins 2021-09-23 14:49:00 +01:00 committed by Andreas Kling
parent b08094bccc
commit 85254ada94

View file

@ -1145,7 +1145,7 @@ private:
inline CSS::ValueID StyleValue::to_identifier() const
{
if (is_identifier())
if (type() == Type::Identifier)
return static_cast<const IdentifierStyleValue&>(*this).id();
if (is_auto())
return CSS::ValueID::Auto;