From 85254ada94cb06779b90453ffc403f733c5c438d Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 23 Sep 2021 14:49:00 +0100 Subject: [PATCH] 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. --- Userland/Libraries/LibWeb/CSS/StyleValue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 2b89d927a5..80ac058a63 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -1145,7 +1145,7 @@ private: inline CSS::ValueID StyleValue::to_identifier() const { - if (is_identifier()) + if (type() == Type::Identifier) return static_cast(*this).id(); if (is_auto()) return CSS::ValueID::Auto;