LibWeb: Allow the Performance object to be used by workers

This commit is contained in:
Tim Ledbetter 2024-03-30 10:04:31 +00:00 committed by Andreas Kling
commit eebdc7bc88
Notes: sideshowbarker 2024-07-17 16:42:19 +09:00
15 changed files with 49 additions and 32 deletions

View file

@ -19,7 +19,9 @@ 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);
timeline->set_current_time(document.window()->performance()->now());
auto* window_or_worker = dynamic_cast<HTML::WindowOrWorkerGlobalScopeMixin*>(&realm.global_object());
VERIFY(window_or_worker);
timeline->set_current_time(window_or_worker->performance()->now());
return timeline;
}