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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_AnimationCollection_h
8 #define mozilla_AnimationCollection_h
10 #include "mozilla/Assertions.h"
11 #include "mozilla/LinkedList.h"
12 #include "mozilla/RefPtr.h"
13 #include "nsCSSPseudoElements.h"
14 #include "nsTArrayForwardDeclare.h"
24 enum class PseudoStyleType
: uint8_t;
26 template <class AnimationType
>
27 class AnimationCollection
28 : public LinkedListElement
<AnimationCollection
<AnimationType
>> {
29 typedef AnimationCollection
<AnimationType
> SelfType
;
32 AnimationCollection(dom::Element
& aOwner
, PseudoStyleType aPseudoType
)
33 : mElement(aOwner
), mPseudo(aPseudoType
) {
34 MOZ_COUNT_CTOR(AnimationCollection
);
37 ~AnimationCollection();
41 // Given the frame |aFrame| with possibly animated content, finds its
42 // associated collection of animations. If |aFrame| is a generated content
43 // frame, this function may examine the parent frame to search for such
45 static AnimationCollection
* Get(const nsIFrame
* aFrame
);
46 static AnimationCollection
* Get(const dom::Element
* aElement
,
47 PseudoStyleType aPseudoType
);
49 // The element. Weak reference is fine since it owns us.
50 // FIXME(emilio): These are only needed for Destroy(), so maybe remove and
51 // rely on the caller clearing us properly?
52 dom::Element
& mElement
;
53 const PseudoStyleType mPseudo
;
55 nsTArray
<RefPtr
<AnimationType
>> mAnimations
;
58 // We distinguish between destroying this by calling Destroy() vs directly
59 // clearing the collection.
61 // The former case represents regular updating due to style changes and should
62 // trigger subsequent restyles.
64 // The latter case represents document tear-down or other DOM surgery in
65 // which case we should not trigger restyles.
66 bool mCalledDestroy
= false;
69 } // namespace mozilla
71 #endif // mozilla_AnimationCollection_h