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

LibWeb: Support obsolete but required -webkit- CSS parsing quirk

As outlined in: https://www.w3.org/TR/selectors-4/#compat

We now do not treat unknown webkit pseudo-elements as invalid at parse
time, and also support serializing these elements.

Fixes: #21959
This commit is contained in:
Shannon Booth 2023-12-10 22:06:55 +13:00 committed by Alexander Kalenik
parent 83758d4cdd
commit ed97946975
9 changed files with 76 additions and 6 deletions

View file

@ -39,15 +39,26 @@ public:
Selection,
// Keep this last.
PseudoElementCount,
KnownPseudoElementCount,
// https://www.w3.org/TR/selectors-4/#compat
// NOTE: This is not last as the 'unknown -webkit- pseudo-elements' are not stored as part of any Element.
UnknownWebKit,
};
explicit PseudoElement(Type type)
: m_type(type)
{
VERIFY(type != Type::UnknownWebKit);
}
constexpr bool operator==(PseudoElement const&) const = default;
PseudoElement(Type type, String name)
: m_type(type)
, m_name(move(name))
{
}
bool operator==(PseudoElement const&) const = default;
static Optional<PseudoElement> from_string(FlyString const&);
@ -55,6 +66,9 @@ public:
StringView name() const
{
if (!m_name.is_empty())
return m_name;
return name(m_type);
}
@ -62,6 +76,7 @@ public:
private:
Type m_type;
String m_name;
};
struct SimpleSelector {