CSSKeyframeRule.cpp 1022 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "CSSKeyframeRule.h"
  7. #include <LibWeb/Bindings/CSSKeyframeRulePrototype.h>
  8. #include <LibWeb/Bindings/Intrinsics.h>
  9. #include <LibWeb/CSS/CSSRuleList.h>
  10. namespace Web::CSS {
  11. JS_DEFINE_ALLOCATOR(CSSKeyframeRule);
  12. JS::NonnullGCPtr<CSSKeyframeRule> CSSKeyframeRule::create(JS::Realm& realm, CSS::Percentage key, Web::CSS::CSSStyleDeclaration& declarations)
  13. {
  14. return realm.heap().allocate<CSSKeyframeRule>(realm, realm, key, declarations);
  15. }
  16. void CSSKeyframeRule::visit_edges(Visitor& visitor)
  17. {
  18. Base::visit_edges(visitor);
  19. visitor.visit(m_declarations);
  20. }
  21. void CSSKeyframeRule::initialize(JS::Realm& realm)
  22. {
  23. Base::initialize(realm);
  24. WEB_SET_PROTOTYPE_FOR_INTERFACE(CSSKeyframeRule);
  25. }
  26. String CSSKeyframeRule::serialized() const
  27. {
  28. StringBuilder builder;
  29. builder.appendff("{}% {{ {} }}", key().value(), style()->serialized());
  30. return MUST(builder.to_string());
  31. }
  32. }