mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 11:37:16 +02:00
In level 2 of the web animations spec, times are no longer always measures in milliseconds, they can also be percents when dealing with progress-based (i.e. scroll-based) timelines. We don't actually support percent times yet but this change will make it easier to implement when we do.
44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2024, Matthew Olsson <mattco@serenityos.org>.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/Bindings/InternalAnimationTimelinePrototype.h>
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
|
#include <LibWeb/DOM/Document.h>
|
|
#include <LibWeb/HTML/Window.h>
|
|
#include <LibWeb/Internals/InternalAnimationTimeline.h>
|
|
|
|
namespace Web::Internals {
|
|
|
|
GC_DEFINE_ALLOCATOR(InternalAnimationTimeline);
|
|
|
|
void InternalAnimationTimeline::update_current_time(double)
|
|
{
|
|
// Do nothing
|
|
}
|
|
|
|
void InternalAnimationTimeline::set_time(Optional<double> time)
|
|
{
|
|
set_current_time(time.map([](double value) -> Animations::TimeValue { return { Animations::TimeValue::Type::Milliseconds, value }; }));
|
|
}
|
|
|
|
InternalAnimationTimeline::InternalAnimationTimeline(JS::Realm& realm)
|
|
: AnimationTimeline(realm)
|
|
{
|
|
m_current_time = { Animations::TimeValue::Type::Milliseconds, 0.0 };
|
|
m_is_monotonically_increasing = true;
|
|
|
|
auto& document = as<HTML::Window>(HTML::relevant_global_object(*this)).associated_document();
|
|
document.associate_with_timeline(*this);
|
|
}
|
|
|
|
void InternalAnimationTimeline::initialize(JS::Realm& realm)
|
|
{
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(InternalAnimationTimeline);
|
|
Base::initialize(realm);
|
|
}
|
|
|
|
}
|