LibWeb: Handle special cases of PseudoElement::Type correctly

There are some special values for CSS::Selector::PseudoElement::Type
which are after `KnownPseudoElementCount` and therefore not present in
various arrays of pseudo elements, this leads to some errors, if a type
after `KnownPseudoElementCount` is used without checking first. This
adds explicit checks to all usages
This commit is contained in:
Totto16 2024-12-19 19:15:02 +01:00 committed by Sam Atkins
commit d21bfda900
Notes: github-actions[bot] 2024-12-19 19:37:02 +00:00
4 changed files with 59 additions and 7 deletions

View file

@ -55,7 +55,7 @@ public:
explicit PseudoElement(Type type)
: m_type(type)
{
VERIFY(type != Type::UnknownWebKit);
VERIFY(is_known_pseudo_element_type(type));
}
PseudoElement(Type type, String name)
@ -68,6 +68,11 @@ public:
static Optional<PseudoElement> from_string(FlyString const&);
[[nodiscard]] static bool is_known_pseudo_element_type(Type type)
{
return to_underlying(type) < to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount);
}
static StringView name(Selector::PseudoElement::Type pseudo_element);
StringView name() const