mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-07 00:19:27 +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:
parent
bdbc21c52d
commit
e91f4dcd79
|
@ -14,6 +14,7 @@
|
|||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/HighResolutionTime/Performance.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
||||
|
@ -661,7 +662,7 @@ WebIDL::ExceptionOr<void> Animation::play_an_animation(AutoRewind auto_rewind)
|
|||
// If a user agent determines that animation is immediately ready, it may schedule the above task as a microtask
|
||||
// such that it runs at the next microtask checkpoint, but it must not perform the task synchronously.
|
||||
m_pending_play_task = TaskState::Scheduled;
|
||||
m_saved_play_time = MonotonicTime::now().milliseconds();
|
||||
m_saved_play_time = global_object().performance()->now();
|
||||
|
||||
// 13. Run the procedure to update an animation’s finished state for animation with the did seek flag set to false,
|
||||
// and the synchronously notify flag set to false.
|
||||
|
@ -745,7 +746,7 @@ WebIDL::ExceptionOr<void> Animation::pause()
|
|||
//
|
||||
// Note: This is run_pending_pause_task()
|
||||
m_pending_pause_task = TaskState::Scheduled;
|
||||
m_saved_pause_time = MonotonicTime::now().milliseconds();
|
||||
m_saved_pause_time = global_object().performance()->now();
|
||||
|
||||
// 11. Run the procedure to update an animation’s finished state for animation with the did seek flag set to false,
|
||||
// and the synchronously notify flag set to false.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/HTML/WindowProxy.h>
|
||||
#include <LibWeb/HighResolutionTime/Performance.h>
|
||||
#include <LibWeb/HighResolutionTime/TimeOrigin.h>
|
||||
#include <LibWeb/Infra/CharacterTypes.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
|
@ -3847,10 +3848,8 @@ JS::NonnullGCPtr<Animations::DocumentTimeline> Document::timeline()
|
|||
{
|
||||
// The DocumentTimeline object representing the default document timeline. The default document timeline has an
|
||||
// origin time of zero.
|
||||
if (!m_default_timeline) {
|
||||
if (!m_default_timeline)
|
||||
m_default_timeline = Animations::DocumentTimeline::create(realm(), *this, 0.0);
|
||||
m_default_timeline->set_current_time(MonotonicTime::now().milliseconds());
|
||||
}
|
||||
return *m_default_timeline;
|
||||
}
|
||||
|
||||
|
@ -4037,7 +4036,7 @@ void Document::ensure_animation_timer()
|
|||
return;
|
||||
}
|
||||
|
||||
update_animations_and_send_events(MonotonicTime::now().milliseconds());
|
||||
update_animations_and_send_events(window().performance()->now());
|
||||
|
||||
for (auto& timeline : m_associated_animation_timelines) {
|
||||
for (auto& animation : timeline->associated_animations())
|
||||
|
|
Loading…
Reference in a new issue