Bug 1927077 - test(webgpu): update CTS to d473d09475bffec9569fe5c45834bb6aaad44818...
[gecko.git] / dom / animation / DocumentTimeline.h
blobe6515381e226c08c7010327c47e65c3076f3e0fb
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_DocumentTimeline_h
8 #define mozilla_dom_DocumentTimeline_h
10 #include "mozilla/dom/Document.h"
11 #include "mozilla/dom/DocumentTimelineBinding.h"
12 #include "mozilla/LinkedList.h"
13 #include "mozilla/TimeStamp.h"
14 #include "AnimationTimeline.h"
15 #include "nsDOMNavigationTiming.h" // for DOMHighResTimeStamp
16 #include "nsRefreshDriver.h"
18 struct JSContext;
20 namespace mozilla::dom {
22 class DocumentTimeline final : public AnimationTimeline,
23 public LinkedListElement<DocumentTimeline> {
24 public:
25 DocumentTimeline(Document* aDocument, const TimeDuration& aOriginTime);
27 protected:
28 virtual ~DocumentTimeline();
30 public:
31 NS_DECL_ISUPPORTS_INHERITED
32 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DocumentTimeline,
33 AnimationTimeline)
35 JSObject* WrapObject(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
37 static already_AddRefed<DocumentTimeline> Constructor(
38 const GlobalObject& aGlobal, const DocumentTimelineOptions& aOptions,
39 ErrorResult& aRv);
41 // AnimationTimeline methods
43 // This is deliberately _not_ called GetCurrentTime since that would clash
44 // with a macro defined in winbase.h
45 Nullable<TimeDuration> GetCurrentTimeAsDuration() const override;
47 bool TracksWallclockTime() const override;
48 Nullable<TimeDuration> ToTimelineTime(
49 const TimeStamp& aTimeStamp) const override;
50 TimeStamp ToTimeStamp(const TimeDuration& aTimelineTime) const override;
52 void NotifyAnimationUpdated(Animation& aAnimation) override;
54 void NotifyAnimationContentVisibilityChanged(Animation* aAnimation,
55 bool aIsVisible) override;
57 void TriggerAllPendingAnimationsNow();
59 void WillRefresh();
61 Document* GetDocument() const override { return mDocument; }
63 void UpdateLastRefreshDriverTime();
65 bool IsMonotonicallyIncreasing() const override { return true; }
67 protected:
68 TimeStamp GetCurrentTimeStamp() const;
69 nsRefreshDriver* GetRefreshDriver() const;
71 RefPtr<Document> mDocument;
73 // The most recently used refresh driver time. This is used in cases where
74 // we don't have a refresh driver (e.g. because we are in a display:none
75 // iframe).
76 TimeStamp mLastRefreshDriverTime;
77 TimeDuration mOriginTime;
80 } // namespace mozilla::dom
82 #endif // mozilla_dom_DocumentTimeline_h