2023-05-26 23:30:54 +03:30
|
|
|
/*
|
|
|
|
* Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org>
|
2024-06-14 17:04:56 +02:00
|
|
|
* Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
|
2023-05-26 23:30:54 +03:30
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2023-06-25 14:06:11 -06:00
|
|
|
#include <LibWeb/Bindings/CSSKeyframesRulePrototype.h>
|
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2024-06-14 17:04:56 +02:00
|
|
|
#include <LibWeb/CSS/CSSKeyframesRule.h>
|
|
|
|
#include <LibWeb/CSS/CSSRuleList.h>
|
2023-05-26 23:30:54 +03:30
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
2023-11-19 19:47:52 +01:00
|
|
|
JS_DEFINE_ALLOCATOR(CSSKeyframesRule);
|
|
|
|
|
2024-06-14 17:04:56 +02:00
|
|
|
JS::NonnullGCPtr<CSSKeyframesRule> CSSKeyframesRule::create(JS::Realm& realm, FlyString name, JS::NonnullGCPtr<CSSRuleList> css_rules)
|
2023-07-09 11:40:17 +03:30
|
|
|
{
|
2024-06-14 17:04:56 +02:00
|
|
|
return realm.heap().allocate<CSSKeyframesRule>(realm, realm, move(name), move(css_rules));
|
2023-07-09 11:40:17 +03:30
|
|
|
}
|
|
|
|
|
2023-05-26 23:30:54 +03:30
|
|
|
void CSSKeyframesRule::visit_edges(Visitor& visitor)
|
|
|
|
{
|
|
|
|
Base::visit_edges(visitor);
|
2024-06-14 17:04:56 +02:00
|
|
|
visitor.visit(m_rules);
|
2023-05-26 23:30:54 +03:30
|
|
|
}
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
void CSSKeyframesRule::initialize(JS::Realm& realm)
|
2023-05-26 23:30:54 +03:30
|
|
|
{
|
2023-08-07 08:41:28 +02:00
|
|
|
Base::initialize(realm);
|
2024-03-16 13:13:08 +01:00
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(CSSKeyframesRule);
|
2023-05-26 23:30:54 +03:30
|
|
|
}
|
|
|
|
|
2023-11-20 23:16:39 +13:00
|
|
|
String CSSKeyframesRule::serialized() const
|
2023-05-26 23:30:54 +03:30
|
|
|
{
|
|
|
|
StringBuilder builder;
|
|
|
|
builder.appendff("@keyframes \"{}\"", name());
|
|
|
|
builder.append(" { "sv);
|
2024-06-14 17:04:56 +02:00
|
|
|
for (auto const& keyframe : *m_rules) {
|
2023-05-26 23:30:54 +03:30
|
|
|
builder.append(keyframe->css_text());
|
|
|
|
builder.append(' ');
|
|
|
|
}
|
|
|
|
builder.append('}');
|
2023-11-20 23:16:39 +13:00
|
|
|
return MUST(builder.to_string());
|
2023-05-26 23:30:54 +03:30
|
|
|
}
|
|
|
|
|
2024-06-14 17:04:56 +02:00
|
|
|
WebIDL::UnsignedLong CSSKeyframesRule::length() const
|
|
|
|
{
|
|
|
|
return m_rules->length();
|
|
|
|
}
|
|
|
|
|
2023-05-26 23:30:54 +03:30
|
|
|
}
|