mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Implement functional pseudo-element parsing
"Functional" as in "it's a function token" and not "it works", because the behaviour for these is unimplemented. :^) This is modeled after the pseudo-class parsing, but with some changes based on things I don't like about that implementation. I've implemented the `<pt-name-selector>` parameter used by view-transitions for now, but nothing else.
This commit is contained in:
parent
5cf04a33ad
commit
88e11eea2d
Notes:
github-actions[bot]
2025-03-25 07:56:12 +00:00
Author: https://github.com/AtkinsSJ
Commit: 88e11eea2d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4063
8 changed files with 237 additions and 43 deletions
|
@ -25,15 +25,24 @@ class Selector : public RefCounted<Selector> {
|
|||
public:
|
||||
class PseudoElementSelector {
|
||||
public:
|
||||
explicit PseudoElementSelector(PseudoElement type)
|
||||
struct PTNameSelector {
|
||||
bool is_universal { false };
|
||||
FlyString value {};
|
||||
};
|
||||
|
||||
using Value = Variant<Empty, PTNameSelector>;
|
||||
|
||||
explicit PseudoElementSelector(PseudoElement type, Value value = {})
|
||||
: m_type(type)
|
||||
, m_value(move(value))
|
||||
{
|
||||
VERIFY(is_known_pseudo_element_type(type));
|
||||
}
|
||||
|
||||
PseudoElementSelector(PseudoElement type, String name)
|
||||
PseudoElementSelector(PseudoElement type, String name, Value value = {})
|
||||
: m_type(type)
|
||||
, m_name(move(name))
|
||||
, m_value(move(value))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -44,19 +53,16 @@ public:
|
|||
return to_underlying(type) < to_underlying(PseudoElement::KnownPseudoElementCount);
|
||||
}
|
||||
|
||||
StringView name() const
|
||||
{
|
||||
if (!m_name.is_empty())
|
||||
return m_name;
|
||||
|
||||
return pseudo_element_name(m_type);
|
||||
}
|
||||
String serialize() const;
|
||||
|
||||
PseudoElement type() const { return m_type; }
|
||||
|
||||
PTNameSelector const& pt_name_selector() const { return m_value.get<PTNameSelector>(); }
|
||||
|
||||
private:
|
||||
PseudoElement m_type;
|
||||
String m_name;
|
||||
Variant<Empty, PTNameSelector> m_value;
|
||||
};
|
||||
|
||||
struct SimpleSelector {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue