CSSPropertyRule.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2024, Alex Ungurianu <alex@ungurianu.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/FlyString.h>
  8. #include <AK/NonnullRefPtr.h>
  9. #include <AK/Optional.h>
  10. #include <AK/String.h>
  11. #include <LibWeb/CSS/CSSRule.h>
  12. #include <LibWeb/Forward.h>
  13. namespace Web::CSS {
  14. // https://drafts.css-houdini.org/css-properties-values-api/#the-css-property-rule-interface
  15. class CSSPropertyRule final : public CSSRule {
  16. WEB_PLATFORM_OBJECT(CSSPropertyRule, CSSRule);
  17. JS_DECLARE_ALLOCATOR(CSSPropertyRule);
  18. public:
  19. static JS::NonnullGCPtr<CSSPropertyRule> create(JS::Realm&, FlyString name, FlyString syntax, bool inherits, Optional<String> initial_value);
  20. virtual ~CSSPropertyRule() = default;
  21. FlyString const& name() const { return m_name; }
  22. FlyString const& syntax() const { return m_syntax; }
  23. bool inherits() const { return m_inherits; }
  24. Optional<String> initial_value() const { return m_initial_value; }
  25. private:
  26. CSSPropertyRule(JS::Realm&, FlyString name, FlyString syntax, bool inherits, Optional<String> initial_value);
  27. virtual void initialize(JS::Realm&) override;
  28. virtual String serialized() const override;
  29. FlyString m_name;
  30. FlyString m_syntax;
  31. bool m_inherits;
  32. // FIXME: This should hold an actual CSS value, matching the syntax
  33. Optional<String> m_initial_value;
  34. };
  35. template<>
  36. inline bool CSSRule::fast_is<CSSPropertyRule>() const { return type() == CSSRule::Type::Property; }
  37. }