mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 12:23:15 +00:00
LibWeb: Add an InternalAnimationTimeline object
This will allow fine grained control over animation times, which will allow us to write timing tests that can reliably pass on the much slower CI machines.
This commit is contained in:
parent
8d765f1084
commit
a1f4d1875e
|
@ -435,6 +435,7 @@ set(SOURCES
|
|||
Infra/JSON.cpp
|
||||
Infra/Strings.cpp
|
||||
Internals/Inspector.cpp
|
||||
Internals/InternalAnimationTimeline.cpp
|
||||
Internals/Internals.cpp
|
||||
IntersectionObserver/IntersectionObserver.cpp
|
||||
IntersectionObserver/IntersectionObserverEntry.cpp
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Internals/InternalAnimationTimeline.h>
|
||||
|
||||
namespace Web::Internals {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(InternalAnimationTimeline);
|
||||
|
||||
void InternalAnimationTimeline::set_current_time(Optional<double> current_time)
|
||||
{
|
||||
// Do nothing
|
||||
(void)current_time;
|
||||
}
|
||||
|
||||
void InternalAnimationTimeline::set_time(Optional<double> time)
|
||||
{
|
||||
Base::set_current_time(time);
|
||||
}
|
||||
|
||||
InternalAnimationTimeline::InternalAnimationTimeline(JS::Realm& realm)
|
||||
: AnimationTimeline(realm)
|
||||
{
|
||||
m_current_time = 0.0;
|
||||
}
|
||||
|
||||
void InternalAnimationTimeline::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(InternalAnimationTimeline);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Animations/AnimationTimeline.h>
|
||||
|
||||
namespace Web::Internals {
|
||||
|
||||
class InternalAnimationTimeline : public Web::Animations::AnimationTimeline {
|
||||
public:
|
||||
WEB_PLATFORM_OBJECT(InternalAnimationTimeline, Web::Animations::AnimationTimeline);
|
||||
JS_DECLARE_ALLOCATOR(InternalAnimationTimeline);
|
||||
|
||||
virtual void set_current_time(Optional<double> current_time) override;
|
||||
|
||||
void set_time(Optional<double> time);
|
||||
|
||||
private:
|
||||
explicit InternalAnimationTimeline(JS::Realm&);
|
||||
virtual ~InternalAnimationTimeline() override = default;
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#import <Animations/AnimationTimeline.idl>
|
||||
|
||||
[Exposed=Nobody]
|
||||
interface InternalAnimationTimeline : AnimationTimeline {
|
||||
undefined setTime(double? time);
|
||||
};
|
|
@ -101,4 +101,10 @@ WebIDL::ExceptionOr<bool> Internals::dispatch_user_activated_event(DOM::EventTar
|
|||
return target.dispatch_event(event);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<InternalAnimationTimeline> Internals::create_internal_animation_timeline()
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
return realm.heap().allocate<InternalAnimationTimeline>(realm, realm);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Internals/InternalAnimationTimeline.h>
|
||||
|
||||
namespace Web::Internals {
|
||||
|
||||
|
@ -31,6 +32,8 @@ public:
|
|||
|
||||
WebIDL::ExceptionOr<bool> dispatch_user_activated_event(DOM::EventTarget&, DOM::Event& event);
|
||||
|
||||
JS::NonnullGCPtr<InternalAnimationTimeline> create_internal_animation_timeline();
|
||||
|
||||
private:
|
||||
explicit Internals(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#import <DOM/EventTarget.idl>
|
||||
#import <HTML/HTMLElement.idl>
|
||||
#import <Internals/InternalAnimationTimeline.idl>
|
||||
|
||||
[Exposed=Nobody] interface Internals {
|
||||
[Exposed=Nobody]
|
||||
interface Internals {
|
||||
|
||||
undefined signalTextTestIsDone();
|
||||
undefined gc();
|
||||
|
@ -16,4 +18,5 @@
|
|||
|
||||
boolean dispatchUserActivatedEvent(EventTarget target, Event event);
|
||||
|
||||
InternalAnimationTimeline createInternalAnimationTimeline();
|
||||
};
|
||||
|
|
|
@ -209,6 +209,7 @@ libweb_js_bindings(HTML/WorkerLocation)
|
|||
libweb_js_bindings(HTML/WorkerNavigator)
|
||||
libweb_js_bindings(HighResolutionTime/Performance)
|
||||
libweb_js_bindings(Internals/Inspector)
|
||||
libweb_js_bindings(Internals/InternalAnimationTimeline)
|
||||
libweb_js_bindings(Internals/Internals)
|
||||
libweb_js_bindings(IntersectionObserver/IntersectionObserver)
|
||||
libweb_js_bindings(IntersectionObserver/IntersectionObserverEntry)
|
||||
|
|
Loading…
Reference in a new issue