1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 11:17:44 +00:00

LibWeb: Use Performance for animation time instead of MonotonicTime

Performance handles the document origin time correctly, and prevents
these times from being unusually large. Also initialize the
DocumentTimeline time in the constructor, since these can be created
from JS.
This commit is contained in:
Matthew Olsson 2024-03-09 14:58:10 -07:00 committed by Andreas Kling
parent bdbc21c52d
commit e91f4dcd79
3 changed files with 10 additions and 7 deletions

View file

@ -9,6 +9,7 @@
#include <LibWeb/Animations/DocumentTimeline.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HighResolutionTime/Performance.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::Animations {
@ -17,7 +18,9 @@ JS_DEFINE_ALLOCATOR(DocumentTimeline);
JS::NonnullGCPtr<DocumentTimeline> DocumentTimeline::create(JS::Realm& realm, DOM::Document& document, HighResolutionTime::DOMHighResTimeStamp origin_time)
{
return realm.heap().allocate<DocumentTimeline>(realm, realm, document, origin_time);
auto timeline = realm.heap().allocate<DocumentTimeline>(realm, realm, document, origin_time);
timeline->set_current_time(document.window().performance()->now());
return timeline;
}
// https://www.w3.org/TR/web-animations-1/#dom-documenttimeline-documenttimeline