2021-03-09 17:36:21 +01:00
|
|
|
/*
|
2021-04-28 22:46:44 +02:00
|
|
|
* Copyright (c) 2020-2021, the SerenityOS developers.
|
2021-06-30 16:27:37 +01:00
|
|
|
* Copyright (c) 2021, Sam Atkins <atkinssj@gmail.com>
|
2021-03-09 17:36:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-03-09 17:36:21 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibWeb/CSS/Parser/StyleBlockRule.h>
|
|
|
|
#include <LibWeb/CSS/Parser/StyleFunctionRule.h>
|
2021-03-09 20:06:52 +01:00
|
|
|
#include <LibWeb/CSS/Parser/Token.h>
|
2021-03-09 17:36:21 +01:00
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
class StyleComponentValueRule {
|
|
|
|
friend class Parser;
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum class ComponentType {
|
|
|
|
Token,
|
|
|
|
Function,
|
|
|
|
Block
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit StyleComponentValueRule(ComponentType);
|
|
|
|
~StyleComponentValueRule();
|
|
|
|
|
2021-06-30 16:27:37 +01:00
|
|
|
bool is_block() const { return m_type == ComponentType::Block; }
|
|
|
|
StyleBlockRule const& block() const { return m_block; }
|
|
|
|
|
|
|
|
bool is_function() const { return m_type == ComponentType::Function; }
|
|
|
|
StyleFunctionRule const& function() const { return m_function; }
|
|
|
|
|
|
|
|
bool is(Token::TokenType type) const
|
|
|
|
{
|
|
|
|
return m_type == ComponentType::Token && m_token.is(type);
|
|
|
|
}
|
|
|
|
Token const& token() const { return m_token; }
|
|
|
|
operator Token() const { return m_token; }
|
|
|
|
|
2021-03-09 17:36:21 +01:00
|
|
|
String to_string() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
ComponentType m_type;
|
|
|
|
Token m_token;
|
|
|
|
StyleFunctionRule m_function;
|
|
|
|
StyleBlockRule m_block;
|
|
|
|
};
|
|
|
|
}
|