1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 10:44:57 +00:00
serenity/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.h
Sam Atkins c449cabae3 LibWeb: Move CSS Parser into new Web::CSS::Parser namespace
The goal here is to move the parser-internal classes into this namespace
so they can have more convenient names without causing collisions. The
Parser itself won't collide, and would be more convenient to just
remain `CSS::Parser`, but having a namespace and a class with the same
name makes C++ unhappy.
2022-04-12 23:03:46 +02:00

50 lines
1 KiB
C++

/*
* Copyright (c) 2020-2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/CSS/Parser/Declaration.h>
#include <LibWeb/CSS/Parser/StyleRule.h>
namespace Web::CSS {
class DeclarationOrAtRule {
friend class Parser::Parser;
public:
explicit DeclarationOrAtRule(RefPtr<StyleRule> at);
explicit DeclarationOrAtRule(Declaration declaration);
~DeclarationOrAtRule();
enum class DeclarationType {
At,
Declaration,
};
bool is_at_rule() const { return m_type == DeclarationType::At; }
bool is_declaration() const { return m_type == DeclarationType::Declaration; }
StyleRule const& at_rule() const
{
VERIFY(is_at_rule());
return *m_at;
}
Declaration const& declaration() const
{
VERIFY(is_declaration());
return m_declaration;
}
String to_string() const;
private:
DeclarationType m_type;
RefPtr<StyleRule> m_at;
Declaration m_declaration;
};
}