AnimationCollection.h (2320B)
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/. */ 6 7 #ifndef mozilla_AnimationCollection_h 8 #define mozilla_AnimationCollection_h 9 10 #include "mozilla/LinkedList.h" 11 #include "mozilla/PseudoStyleType.h" 12 #include "mozilla/RefPtr.h" 13 #include "nsCSSPseudoElements.h" 14 #include "nsTArrayForwardDeclare.h" 15 16 class nsAtom; 17 class nsIFrame; 18 class nsPresContext; 19 20 namespace mozilla { 21 namespace dom { 22 class Element; 23 } 24 25 template <class AnimationType> 26 class AnimationCollection 27 : public LinkedListElement<AnimationCollection<AnimationType>> { 28 typedef AnimationCollection<AnimationType> SelfType; 29 30 public: 31 AnimationCollection(dom::Element& aOwner, 32 const PseudoStyleRequest& aPseudoRequest) 33 : mElement(aOwner), mPseudo(aPseudoRequest) { 34 MOZ_COUNT_CTOR(AnimationCollection); 35 } 36 37 ~AnimationCollection(); 38 39 void Destroy(); 40 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 44 // animations. 45 static AnimationCollection* Get(const nsIFrame* aFrame); 46 static AnimationCollection* Get(const dom::Element* aElement, 47 const PseudoStyleRequest& aPseudoRequest); 48 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 PseudoStyleRequest mPseudo; 54 55 nsTArray<RefPtr<AnimationType>> mAnimations; 56 57 private: 58 // We distinguish between destroying this by calling Destroy() vs directly 59 // clearing the collection. 60 // 61 // The former case represents regular updating due to style changes and should 62 // trigger subsequent restyles. 63 // 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; 67 }; 68 69 } // namespace mozilla 70 71 #endif // mozilla_AnimationCollection_h