StyleRule.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2020-2021, the SerenityOS developers.
  3. * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/RefCounted.h>
  9. #include <AK/Vector.h>
  10. #include <LibWeb/CSS/Parser/ComponentValue.h>
  11. #include <LibWeb/CSS/Parser/StyleBlockRule.h>
  12. namespace Web::CSS {
  13. class StyleRule : public RefCounted<StyleRule> {
  14. friend class Parser::Parser;
  15. public:
  16. enum class Type {
  17. At,
  18. Qualified,
  19. };
  20. StyleRule(Type);
  21. ~StyleRule();
  22. bool is_qualified_rule() const { return m_type == Type::Qualified; }
  23. bool is_at_rule() const { return m_type == Type::At; }
  24. Vector<ComponentValue> const& prelude() const { return m_prelude; }
  25. RefPtr<StyleBlockRule const> block() const { return m_block; }
  26. String const& at_rule_name() const { return m_at_rule_name; }
  27. String to_string() const;
  28. private:
  29. Type const m_type;
  30. String m_at_rule_name;
  31. Vector<ComponentValue> m_prelude;
  32. RefPtr<StyleBlockRule> m_block;
  33. };
  34. }