Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/AnimationCollection.h
Line
Count
Source (jump to first uncovered line)
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/dom/Animation.h"
11
#include "mozilla/dom/Element.h"
12
#include "mozilla/Assertions.h"
13
#include "mozilla/LinkedList.h"
14
#include "mozilla/RefPtr.h"
15
#include "nsCSSPseudoElements.h"
16
#include "nsDOMMutationObserver.h"
17
#include "nsTArray.h"
18
19
class nsAtom;
20
class nsIFrame;
21
class nsPresContext;
22
23
namespace mozilla {
24
25
// Traits class to define the specific atoms used when storing specializations
26
// of AnimationCollection as a property on an Element (e.g. which atom
27
// to use when storing an AnimationCollection<CSSAnimation> for a ::before
28
// pseudo-element).
29
template <class AnimationType>
30
struct AnimationTypeTraits { };
31
32
template <class AnimationType>
33
class AnimationCollection
34
  : public LinkedListElement<AnimationCollection<AnimationType>>
35
{
36
  typedef AnimationCollection<AnimationType> SelfType;
37
  typedef AnimationTypeTraits<AnimationType> TraitsType;
38
39
  AnimationCollection(dom::Element* aElement, nsAtom* aElementProperty)
40
    : mElement(aElement)
41
    , mElementProperty(aElementProperty)
42
#ifdef DEBUG
43
    , mCalledPropertyDtor(false)
44
#endif
45
0
  {
46
0
    MOZ_COUNT_CTOR(AnimationCollection);
47
0
  }
Unexecuted instantiation: mozilla::AnimationCollection<mozilla::dom::CSSAnimation>::AnimationCollection(mozilla::dom::Element*, nsAtom*)
Unexecuted instantiation: mozilla::AnimationCollection<mozilla::dom::CSSTransition>::AnimationCollection(mozilla::dom::Element*, nsAtom*)
48
49
public:
50
  ~AnimationCollection()
51
0
  {
52
0
    MOZ_ASSERT(mCalledPropertyDtor,
53
0
               "must call destructor through element property dtor");
54
0
    MOZ_COUNT_DTOR(AnimationCollection);
55
0
    LinkedListElement<SelfType>::remove();
56
0
  }
Unexecuted instantiation: mozilla::AnimationCollection<mozilla::dom::CSSAnimation>::~AnimationCollection()
Unexecuted instantiation: mozilla::AnimationCollection<mozilla::dom::CSSTransition>::~AnimationCollection()
57
58
  void Destroy()
59
0
  {
60
0
    // This will call our destructor.
61
0
    mElement->DeleteProperty(mElementProperty);
62
0
  }
Unexecuted instantiation: mozilla::AnimationCollection<mozilla::dom::CSSAnimation>::Destroy()
Unexecuted instantiation: mozilla::AnimationCollection<mozilla::dom::CSSTransition>::Destroy()
63
64
  static void PropertyDtor(void *aObject, nsAtom *aPropertyName,
65
                           void *aPropertyValue, void *aData);
66
67
  // Get the collection of animations for the given |aElement| and
68
  // |aPseudoType|.
69
  static AnimationCollection<AnimationType>*
70
    GetAnimationCollection(const dom::Element* aElement,
71
                           CSSPseudoElementType aPseudoType);
72
73
  // Given the frame |aFrame| with possibly animated content, finds its
74
  // associated collection of animations. If |aFrame| is a generated content
75
  // frame, this function may examine the parent frame to search for such
76
  // animations.
77
  static AnimationCollection<AnimationType>* GetAnimationCollection(
78
    const nsIFrame* aFrame);
79
80
  // Get the collection of animations for the given |aElement| and
81
  // |aPseudoType| or create it if it does not already exist.
82
  //
83
  // We'll set the outparam |aCreatedCollection| to true if we have
84
  // to create the collection and we successfully do so. Otherwise,
85
  // we'll set it to false.
86
  static AnimationCollection<AnimationType>*
87
    GetOrCreateAnimationCollection(dom::Element* aElement,
88
                                   CSSPseudoElementType aPseudoType,
89
                                   bool* aCreatedCollection);
90
91
  dom::Element *mElement;
92
93
  // the atom we use in mElement's prop table (must be a static atom,
94
  // i.e., in an atom list)
95
  nsAtom *mElementProperty;
96
97
  InfallibleTArray<RefPtr<AnimationType>> mAnimations;
98
99
100
private:
101
  static nsAtom* GetPropertyAtomForPseudoType(
102
    CSSPseudoElementType aPseudoType);
103
104
#ifdef DEBUG
105
  bool mCalledPropertyDtor;
106
#endif
107
};
108
109
} // namespace mozilla
110
111
#endif // mozilla_AnimationCollection_h