Backed out 8 changesets (bug 1873776) for causing vendor failures. CLOSED TREE
[gecko.git] / dom / animation / ScrollTimelineAnimationTracker.h
blobfec2814ceccc6d74d7a94302b7659537e3be5806
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_ScrollTimelineAnimationTracker_h
8 #define mozilla_ScrollTimelineAnimationTracker_h
10 #include "mozilla/dom/Animation.h"
11 #include "nsCycleCollectionParticipant.h"
12 #include "nsTHashSet.h"
14 namespace mozilla {
16 namespace dom {
17 class Document;
20 /**
21 * Handle the pending animations which use scroll timeline while playing or
22 * pausing.
24 class ScrollTimelineAnimationTracker final {
25 public:
26 explicit ScrollTimelineAnimationTracker(dom::Document* aDocument)
27 : mDocument(aDocument) {}
29 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(
30 ScrollTimelineAnimationTracker)
31 NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(ScrollTimelineAnimationTracker)
33 void AddPending(dom::Animation& aAnimation) {
34 mPendingSet.Insert(&aAnimation);
37 void RemovePending(dom::Animation& aAnimation) {
38 mPendingSet.Remove(&aAnimation);
41 bool HasPendingAnimations() const { return mPendingSet.Count() > 0; }
43 bool IsWaiting(const dom::Animation& aAnimation) const {
44 return mPendingSet.Contains(const_cast<dom::Animation*>(&aAnimation));
47 void TriggerPendingAnimations();
49 private:
50 ~ScrollTimelineAnimationTracker() = default;
52 nsTHashSet<nsRefPtrHashKey<dom::Animation>> mPendingSet;
53 RefPtr<dom::Document> mDocument;
56 } // namespace mozilla
58 #endif // mozilla_ScrollTimelineAnimationTracker_h