mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-17 21:49:42 +00:00
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Our previous implementation kept track of an AnimationTimeline being monotonically increasing, by looking at new time values coming in and setting `m_monotonically_increasing` to `false` whenever a new value is before the previous known time value. As far as I can tell, the spec doesn't really ask us to do so: it just defines 'monotonically increasing' as a property of a timeline, i.e. it guarantees that returned time values from `::current_time()` are always greater than or equal to the last returned value. This fixes a common crash seen when the last render opportunity lies before the document's origin time, and `::set_current_time()` was invoked with a negative value. This was especially visible in the `Text/input/wpt-import/css/cssom/CSSStyleSheet-constructable.html` test.
55 lines
2 KiB
C++
55 lines
2 KiB
C++
/*
|
|
* Copyright (c) 2023, Matthew Olsson <mattco@serenityos.org>.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
|
|
namespace Web::Animations {
|
|
|
|
// https://www.w3.org/TR/web-animations-1/#animationtimeline
|
|
class AnimationTimeline : public Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(AnimationTimeline, Bindings::PlatformObject);
|
|
GC_DECLARE_ALLOCATOR(AnimationTimeline);
|
|
|
|
public:
|
|
Optional<double> current_time() const;
|
|
virtual void set_current_time(Optional<double>);
|
|
|
|
GC::Ptr<DOM::Document> associated_document() const { return m_associated_document; }
|
|
void set_associated_document(GC::Ptr<DOM::Document>);
|
|
|
|
virtual bool is_inactive() const;
|
|
bool is_monotonically_increasing() const { return m_is_monotonically_increasing; }
|
|
|
|
// https://www.w3.org/TR/web-animations-1/#timeline-time-to-origin-relative-time
|
|
virtual Optional<double> convert_a_timeline_time_to_an_origin_relative_time(Optional<double>) { VERIFY_NOT_REACHED(); }
|
|
virtual bool can_convert_a_timeline_time_to_an_origin_relative_time() const { return false; }
|
|
|
|
void associate_with_animation(GC::Ref<Animation> value) { m_associated_animations.set(value); }
|
|
void disassociate_with_animation(GC::Ref<Animation> value) { m_associated_animations.remove(value); }
|
|
HashTable<GC::Ref<Animation>> const& associated_animations() const { return m_associated_animations; }
|
|
|
|
protected:
|
|
AnimationTimeline(JS::Realm&);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
virtual void finalize() override;
|
|
|
|
// https://www.w3.org/TR/web-animations-1/#dom-animationtimeline-currenttime
|
|
Optional<double> m_current_time {};
|
|
|
|
// https://drafts.csswg.org/web-animations-1/#monotonically-increasing-timeline
|
|
bool m_is_monotonically_increasing { false };
|
|
|
|
// https://www.w3.org/TR/web-animations-1/#timeline-associated-with-a-document
|
|
GC::Ptr<DOM::Document> m_associated_document {};
|
|
|
|
HashTable<GC::Ref<Animation>> m_associated_animations {};
|
|
};
|
|
|
|
}
|