mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +00:00
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:
parent
8620a2af47
commit
d21bfda900
Notes:
github-actions[bot]
2024-12-19 19:37:02 +00:00
Author: https://github.com/Totto16
Commit: d21bfda900
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2908
Reviewed-by: https://github.com/AtkinsSJ ✅
4 changed files with 59 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue