Bug 1698238 return default dictionary from GetUserMediaRequest#getConstraints() if...
[gecko.git] / dom / animation / DocumentTimeline.h
bloba1569a108015303921add64d47fab1aa96187619
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"
17 #include "nsRefreshObservers.h"
19 struct JSContext;
21 namespace mozilla {
22 namespace dom {
24 class DocumentTimeline final : public AnimationTimeline,
25 public nsARefreshObserver,
26 public nsATimerAdjustmentObserver,
27 public LinkedListElement<DocumentTimeline> {
28 public:
29 DocumentTimeline(Document* aDocument, const TimeDuration& aOriginTime);
31 protected:
32 virtual ~DocumentTimeline();
34 public:
35 NS_DECL_ISUPPORTS_INHERITED
36 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DocumentTimeline,
37 AnimationTimeline)
39 virtual JSObject* WrapObject(JSContext* aCx,
40 JS::Handle<JSObject*> aGivenProto) override;
42 static already_AddRefed<DocumentTimeline> Constructor(
43 const GlobalObject& aGlobal, const DocumentTimelineOptions& aOptions,
44 ErrorResult& aRv);
46 // AnimationTimeline methods
48 // This is deliberately _not_ called GetCurrentTime since that would clash
49 // with a macro defined in winbase.h
50 virtual Nullable<TimeDuration> GetCurrentTimeAsDuration() const override;
52 bool TracksWallclockTime() const override;
53 Nullable<TimeDuration> ToTimelineTime(
54 const TimeStamp& aTimeStamp) const override;
55 TimeStamp ToTimeStamp(const TimeDuration& aTimelineTime) const override;
57 void NotifyAnimationUpdated(Animation& aAnimation) override;
59 void RemoveAnimation(Animation* aAnimation) override;
61 // nsARefreshObserver methods
62 void WillRefresh(TimeStamp aTime) override;
63 // nsATimerAdjustmentObserver methods
64 void NotifyTimerAdjusted(TimeStamp aTime) override;
66 void NotifyRefreshDriverCreated(nsRefreshDriver* aDriver);
67 void NotifyRefreshDriverDestroying(nsRefreshDriver* aDriver);
69 Document* GetDocument() const override { return mDocument; }
71 protected:
72 TimeStamp GetCurrentTimeStamp() const;
73 nsRefreshDriver* GetRefreshDriver() const;
74 void UnregisterFromRefreshDriver();
75 void MostRecentRefreshTimeUpdated();
76 void ObserveRefreshDriver(nsRefreshDriver* aDriver);
77 void DisconnectRefreshDriver(nsRefreshDriver* aDriver);
79 RefPtr<Document> mDocument;
81 // The most recently used refresh driver time. This is used in cases where
82 // we don't have a refresh driver (e.g. because we are in a display:none
83 // iframe).
84 mutable TimeStamp mLastRefreshDriverTime;
85 bool mIsObservingRefreshDriver;
87 TimeDuration mOriginTime;
90 } // namespace dom
91 } // namespace mozilla
93 #endif // mozilla_dom_DocumentTimeline_h