CSSKeyframesRule.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org>
  3. * Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/FlyString.h>
  9. #include <AK/NonnullRefPtr.h>
  10. #include <LibJS/Heap/GCPtr.h>
  11. #include <LibWeb/CSS/CSSKeyframeRule.h>
  12. #include <LibWeb/CSS/CSSRule.h>
  13. #include <LibWeb/Forward.h>
  14. #include <LibWeb/WebIDL/ExceptionOr.h>
  15. #include <LibWeb/WebIDL/Types.h>
  16. namespace Web::CSS {
  17. // https://drafts.csswg.org/css-animations/#interface-csskeyframesrule
  18. class CSSKeyframesRule final : public CSSRule {
  19. WEB_PLATFORM_OBJECT(CSSKeyframesRule, CSSRule);
  20. JS_DECLARE_ALLOCATOR(CSSKeyframesRule);
  21. public:
  22. [[nodiscard]] static JS::NonnullGCPtr<CSSKeyframesRule> create(JS::Realm&, FlyString name, JS::NonnullGCPtr<CSSRuleList>);
  23. virtual ~CSSKeyframesRule() = default;
  24. auto const& css_rules() const { return m_rules; }
  25. FlyString const& name() const { return m_name; }
  26. [[nodiscard]] WebIDL::UnsignedLong length() const;
  27. void set_name(String const& name) { m_name = name; }
  28. private:
  29. CSSKeyframesRule(JS::Realm&, FlyString name, JS::NonnullGCPtr<CSSRuleList> keyframes);
  30. virtual void visit_edges(Visitor&) override;
  31. virtual void initialize(JS::Realm&) override;
  32. virtual String serialized() const override;
  33. FlyString m_name;
  34. JS::NonnullGCPtr<CSSRuleList> m_rules;
  35. };
  36. template<>
  37. inline bool CSSRule::fast_is<CSSKeyframesRule>() const { return type() == CSSRule::Type::Keyframes; }
  38. }