CSSKeyframeRule.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSKeyframeRule>> CSSKeyframeRule::create(JS::Realm& realm, CSS::Percentage key, Web::CSS::CSSStyleDeclaration& declarations)
  12. {
  13. return MUST_OR_THROW_OOM(realm.heap().allocate<CSSKeyframeRule>(realm, realm, key, declarations));
  14. }
  15. void CSSKeyframeRule::visit_edges(Visitor& visitor)
  16. {
  17. Base::visit_edges(visitor);
  18. visitor.visit(m_declarations);
  19. }
  20. JS::ThrowCompletionOr<void> CSSKeyframeRule::initialize(JS::Realm& realm)
  21. {
  22. MUST_OR_THROW_OOM(Base::initialize(realm));
  23. set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSKeyframeRulePrototype>(realm, "CSSKeyframeRule"));
  24. return {};
  25. }
  26. DeprecatedString CSSKeyframeRule::serialized() const
  27. {
  28. StringBuilder builder;
  29. builder.appendff("{}% {{ {} }}", key().value(), style()->serialized());
  30. return builder.to_deprecated_string();
  31. }
  32. }