LibWeb: Add the CSSAnimation IDL object

This commit is contained in:
Matthew Olsson 2023-11-04 13:57:57 -07:00 committed by Andrew Kaster
parent 3721a1a81c
commit 3a87c000c4
Notes: sideshowbarker 2024-07-16 21:42:29 +09:00
7 changed files with 88 additions and 1 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>.
* Copyright (c) 2023-2024, Matthew Olsson <mattco@serenityos.org>.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -67,6 +67,8 @@ public:
void effect_timing_changed(Badge<AnimationEffect>);
virtual bool is_css_animation() const { return false; }
protected:
Animation(JS::Realm&);

View file

@ -32,6 +32,7 @@ set(SOURCES
CSS/CalculatedOr.cpp
CSS/Clip.cpp
CSS/CSS.cpp
CSS/CSSAnimation.cpp
CSS/CSSConditionRule.cpp
CSS/CSSGroupingRule.cpp
CSS/CSSImportRule.cpp

View file

@ -0,0 +1,36 @@
/*
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Animations/KeyframeEffect.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/CSSAnimation.h>
#include <LibWeb/DOM/Element.h>
namespace Web::CSS {
JS::NonnullGCPtr<CSSAnimation> CSSAnimation::create(JS::Realm& realm)
{
return realm.heap().allocate<CSSAnimation>(realm, realm);
}
CSSAnimation::CSSAnimation(JS::Realm& realm)
: Animations::Animation(realm)
{
}
void CSSAnimation::initialize(JS::Realm& realm)
{
Base::initialize(realm);
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSAnimationPrototype>(realm, "CSSAnimation"_fly_string));
}
void CSSAnimation::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_owning_element);
}
}

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Animations/Animation.h>
#include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/CSS/StyleValue.h>
namespace Web::CSS {
// https://www.w3.org/TR/css-animations-2/#cssanimation
class CSSAnimation : public Animations::Animation {
WEB_PLATFORM_OBJECT(CSSAnimation, Animations::Animation);
public:
static JS::NonnullGCPtr<CSSAnimation> create(JS::Realm&);
JS::GCPtr<DOM::Element> owning_element() const { return m_owning_element; }
void set_owning_element(JS::GCPtr<DOM::Element> value) { m_owning_element = value; }
FlyString const& animation_name() const { return id(); }
private:
explicit CSSAnimation(JS::Realm&);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
virtual bool is_css_animation() const override { return true; }
// https://www.w3.org/TR/css-animations-2/#owning-element-section
JS::GCPtr<DOM::Element> m_owning_element;
};
}

View file

@ -0,0 +1,7 @@
#import <Animations/Animation.idl>
// https://www.w3.org/TR/css-animations-2/#cssanimation
[Exposed=Window]
interface CSSAnimation : Animation {
readonly attribute CSSOMString animationName;
};

View file

@ -92,6 +92,7 @@ class AngleStyleValue;
class BackgroundRepeatStyleValue;
class BackgroundSizeStyleValue;
class BorderRadiusStyleValue;
class CSSAnimation;
class CSSConditionRule;
class CSSFontFaceRule;
class CSSGroupingRule;

View file

@ -11,6 +11,7 @@ libweb_js_bindings(Clipboard/Clipboard)
libweb_js_bindings(Crypto/Crypto)
libweb_js_bindings(Crypto/CryptoKey)
libweb_js_bindings(Crypto/SubtleCrypto)
libweb_js_bindings(CSS/CSSAnimation)
libweb_js_bindings(CSS/CSSConditionRule)
libweb_js_bindings(CSS/CSSFontFaceRule)
libweb_js_bindings(CSS/CSSGroupingRule)