DocumentTimeline.h [plain text]
#pragma once
#include "AnimationTimeline.h"
#include "GenericTaskQueue.h"
#include "PlatformScreen.h"
#include "Timer.h"
#include <wtf/Ref.h>
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
#include "DisplayRefreshMonitorClient.h"
#endif
namespace WebCore {
class AnimationPlaybackEvent;
class RenderElement;
class DocumentTimeline final : public AnimationTimeline
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
, public DisplayRefreshMonitorClient
#endif
{
public:
static Ref<DocumentTimeline> create(Document&, PlatformDisplayID);
~DocumentTimeline();
std::optional<Seconds> currentTime() override;
void pause() override;
void animationTimingModelDidChange() override;
void windowScreenDidChange(PlatformDisplayID);
std::unique_ptr<RenderStyle> animatedStyleForRenderer(RenderElement& renderer);
void animationAcceleratedRunningStateDidChange(WebAnimation&);
bool runningAnimationsForElementAreAllAccelerated(Element&);
void detachFromDocument();
void enqueueAnimationPlaybackEvent(AnimationPlaybackEvent&);
private:
DocumentTimeline(Document&, PlatformDisplayID);
void scheduleInvalidationTaskIfNeeded();
void performInvalidationTask();
void updateAnimationSchedule();
void animationScheduleTimerFired();
void scheduleAnimationResolution();
void updateAnimations();
void performEventDispatchTask();
RefPtr<Document> m_document;
bool m_paused { false };
std::optional<Seconds> m_cachedCurrentTime;
GenericTaskQueue<Timer> m_invalidationTaskQueue;
GenericTaskQueue<Timer> m_eventDispatchTaskQueue;
bool m_needsUpdateAnimationSchedule { false };
Timer m_animationScheduleTimer;
HashSet<RefPtr<WebAnimation>> m_acceleratedAnimationsPendingRunningStateChange;
Vector<Ref<AnimationPlaybackEvent>> m_pendingAnimationEvents;
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
void displayRefreshFired() override;
RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const override;
#else
void animationResolutionTimerFired();
Timer m_animationResolutionTimer;
#endif
};
}
SPECIALIZE_TYPE_TRAITS_ANIMATION_TIMELINE(DocumentTimeline, isDocumentTimeline())