CSSKeyframeRule.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/NonnullRefPtr.h>
  8. #include <LibWeb/CSS/CSSRule.h>
  9. #include <LibWeb/CSS/CSSStyleDeclaration.h>
  10. #include <LibWeb/CSS/Percentage.h>
  11. #include <LibWeb/Forward.h>
  12. #include <LibWeb/WebIDL/ExceptionOr.h>
  13. namespace Web::CSS {
  14. // https://drafts.csswg.org/css-animations/#interface-csskeyframerule
  15. class CSSKeyframeRule final : public CSSRule {
  16. WEB_PLATFORM_OBJECT(CSSKeyframeRule, CSSRule);
  17. JS_DECLARE_ALLOCATOR(CSSKeyframeRule);
  18. public:
  19. static JS::NonnullGCPtr<CSSKeyframeRule> create(JS::Realm&, CSS::Percentage key, CSSStyleDeclaration&);
  20. virtual ~CSSKeyframeRule() = default;
  21. virtual Type type() const override { return Type::Keyframe; }
  22. CSS::Percentage key() const { return m_key; }
  23. JS::NonnullGCPtr<CSSStyleDeclaration> style() const { return m_declarations; }
  24. String key_text() const
  25. {
  26. return m_key.to_string();
  27. }
  28. void set_key_text(String const& key_text)
  29. {
  30. dbgln("FIXME: CSSKeyframeRule::set_key_text is not implemented: {}", key_text);
  31. }
  32. private:
  33. CSSKeyframeRule(JS::Realm& realm, CSS::Percentage key, CSSStyleDeclaration& declarations)
  34. : CSSRule(realm)
  35. , m_key(key)
  36. , m_declarations(declarations)
  37. {
  38. }
  39. virtual void visit_edges(Visitor&) override;
  40. virtual void initialize(JS::Realm&) override;
  41. virtual String serialized() const override;
  42. CSS::Percentage m_key;
  43. JS::NonnullGCPtr<CSSStyleDeclaration> m_declarations;
  44. };
  45. template<>
  46. inline bool CSSRule::fast_is<CSSKeyframeRule>() const { return type() == CSSRule::Type::Keyframe; }
  47. }