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:
Matthew Olsson 2024-03-27 15:30:54 +00:00 committed by Andreas Kling
parent 8d765f1084
commit a1f4d1875e
Notes: sideshowbarker 2024-07-18 03:23:00 +09:00
8 changed files with 87 additions and 1 deletions

View file

@ -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

View file

@ -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);
}
}

View file

@ -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;
};
}

View file

@ -0,0 +1,6 @@
#import <Animations/AnimationTimeline.idl>
[Exposed=Nobody]
interface InternalAnimationTimeline : AnimationTimeline {
undefined setTime(double? time);
};

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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();
};

View file

@ -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)