mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 18:19:03 +00:00
LibWeb: Ensure all DocumentTimeline objects have the same time value
The DocumentTimeline constructor used the current millisecond time to initialize its currentTime, but that means that a newly created timeline would always have a different time value than other timelines that have been through the update_animations_and_send_events function.
This commit is contained in:
parent
4e9480b719
commit
37322baf54
Notes:
sideshowbarker
2024-07-17 05:02:35 +09:00
Author: https://github.com/mattco98
Commit: 37322baf54
Pull-request: https://github.com/SerenityOS/serenity/pull/24530
5 changed files with 32 additions and 3 deletions
|
@ -20,9 +20,14 @@ JS_DEFINE_ALLOCATOR(DocumentTimeline);
|
|||
JS::NonnullGCPtr<DocumentTimeline> DocumentTimeline::create(JS::Realm& realm, DOM::Document& document, HighResolutionTime::DOMHighResTimeStamp origin_time)
|
||||
{
|
||||
auto timeline = realm.heap().allocate<DocumentTimeline>(realm, realm, document, origin_time);
|
||||
auto* window_or_worker = dynamic_cast<HTML::WindowOrWorkerGlobalScopeMixin*>(&realm.global_object());
|
||||
VERIFY(window_or_worker);
|
||||
timeline->set_current_time(window_or_worker->performance()->now());
|
||||
auto current_time = document.last_animation_frame_timestamp();
|
||||
if (!current_time.has_value()) {
|
||||
// The document hasn't processed an animation frame yet, so just use the exact current time
|
||||
auto* window_or_worker = dynamic_cast<HTML::WindowOrWorkerGlobalScopeMixin*>(&realm.global_object());
|
||||
VERIFY(window_or_worker);
|
||||
current_time = window_or_worker->performance()->now();
|
||||
}
|
||||
timeline->set_current_time(current_time);
|
||||
return timeline;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue