mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
LibWeb: Add ComponentValue::is_function(name) and is_ident(name) helpers
This commit is contained in:
parent
f3124c492b
commit
2ef5658f31
2 changed files with 12 additions and 0 deletions
|
@ -26,6 +26,16 @@ ComponentValue::ComponentValue(NonnullRefPtr<Block> block)
|
||||||
|
|
||||||
ComponentValue::~ComponentValue() = default;
|
ComponentValue::~ComponentValue() = default;
|
||||||
|
|
||||||
|
bool ComponentValue::is_function(StringView name) const
|
||||||
|
{
|
||||||
|
return is_function() && function().name().equals_ignoring_ascii_case(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ComponentValue::is_ident(StringView ident) const
|
||||||
|
{
|
||||||
|
return is(Token::Type::Ident) && token().ident().equals_ignoring_ascii_case(ident);
|
||||||
|
}
|
||||||
|
|
||||||
String ComponentValue::to_string() const
|
String ComponentValue::to_string() const
|
||||||
{
|
{
|
||||||
return m_value.visit(
|
return m_value.visit(
|
||||||
|
|
|
@ -27,11 +27,13 @@ public:
|
||||||
Block& block() const { return m_value.get<NonnullRefPtr<Block>>(); }
|
Block& block() const { return m_value.get<NonnullRefPtr<Block>>(); }
|
||||||
|
|
||||||
bool is_function() const { return m_value.has<NonnullRefPtr<Function>>(); }
|
bool is_function() const { return m_value.has<NonnullRefPtr<Function>>(); }
|
||||||
|
bool is_function(StringView name) const;
|
||||||
Function& function() const { return m_value.get<NonnullRefPtr<Function>>(); }
|
Function& function() const { return m_value.get<NonnullRefPtr<Function>>(); }
|
||||||
|
|
||||||
bool is_token() const { return m_value.has<Token>(); }
|
bool is_token() const { return m_value.has<Token>(); }
|
||||||
bool is(Token::Type type) const { return is_token() && token().is(type); }
|
bool is(Token::Type type) const { return is_token() && token().is(type); }
|
||||||
bool is_delim(u32 delim) const { return is(Token::Type::Delim) && token().delim() == delim; }
|
bool is_delim(u32 delim) const { return is(Token::Type::Delim) && token().delim() == delim; }
|
||||||
|
bool is_ident(StringView ident) const;
|
||||||
Token const& token() const { return m_value.get<Token>(); }
|
Token const& token() const { return m_value.get<Token>(); }
|
||||||
operator Token() const { return m_value.get<Token>(); }
|
operator Token() const { return m_value.get<Token>(); }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue