mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb: Add the CSSAnimation IDL object
This commit is contained in:
parent
3721a1a81c
commit
3a87c000c4
Notes:
sideshowbarker
2024-07-16 21:42:29 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/3a87c000c4 Pull-request: https://github.com/SerenityOS/serenity/pull/23184 Reviewed-by: https://github.com/ADKaster ✅
7 changed files with 88 additions and 1 deletions
|
@ -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&);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
36
Userland/Libraries/LibWeb/CSS/CSSAnimation.cpp
Normal file
36
Userland/Libraries/LibWeb/CSS/CSSAnimation.cpp
Normal 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);
|
||||
}
|
||||
|
||||
}
|
39
Userland/Libraries/LibWeb/CSS/CSSAnimation.h
Normal file
39
Userland/Libraries/LibWeb/CSS/CSSAnimation.h
Normal 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;
|
||||
};
|
||||
|
||||
}
|
7
Userland/Libraries/LibWeb/CSS/CSSAnimation.idl
Normal file
7
Userland/Libraries/LibWeb/CSS/CSSAnimation.idl
Normal 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;
|
||||
};
|
|
@ -92,6 +92,7 @@ class AngleStyleValue;
|
|||
class BackgroundRepeatStyleValue;
|
||||
class BackgroundSizeStyleValue;
|
||||
class BorderRadiusStyleValue;
|
||||
class CSSAnimation;
|
||||
class CSSConditionRule;
|
||||
class CSSFontFaceRule;
|
||||
class CSSGroupingRule;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue