/work/obj-fuzz/dist/include/mozilla/AnimationTarget.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_AnimationTarget_h |
8 | | #define mozilla_AnimationTarget_h |
9 | | |
10 | | #include "mozilla/Attributes.h" // For MOZ_NON_OWNING_REF |
11 | | #include "mozilla/Maybe.h" |
12 | | #include "mozilla/RefPtr.h" |
13 | | #include "nsCSSPseudoElements.h" |
14 | | |
15 | | namespace mozilla { |
16 | | |
17 | | namespace dom { |
18 | | class Element; |
19 | | } // namespace dom |
20 | | |
21 | | struct OwningAnimationTarget |
22 | | { |
23 | | OwningAnimationTarget(dom::Element* aElement, CSSPseudoElementType aType) |
24 | 0 | : mElement(aElement), mPseudoType(aType) { } |
25 | | |
26 | | explicit OwningAnimationTarget(dom::Element* aElement) |
27 | 0 | : mElement(aElement) { } |
28 | | |
29 | | bool operator==(const OwningAnimationTarget& aOther) const |
30 | 0 | { |
31 | 0 | return mElement == aOther.mElement && |
32 | 0 | mPseudoType == aOther.mPseudoType; |
33 | 0 | } |
34 | | |
35 | | // mElement represents the parent element of a pseudo-element, not the |
36 | | // generated content element. |
37 | | RefPtr<dom::Element> mElement; |
38 | | CSSPseudoElementType mPseudoType = CSSPseudoElementType::NotPseudo; |
39 | | }; |
40 | | |
41 | | struct NonOwningAnimationTarget |
42 | | { |
43 | 0 | NonOwningAnimationTarget() = default; |
44 | | |
45 | | NonOwningAnimationTarget(dom::Element* aElement, CSSPseudoElementType aType) |
46 | 0 | : mElement(aElement), mPseudoType(aType) { } |
47 | | |
48 | | explicit NonOwningAnimationTarget(const OwningAnimationTarget& aOther) |
49 | 0 | : mElement(aOther.mElement), mPseudoType(aOther.mPseudoType) { } |
50 | | |
51 | | bool operator==(const NonOwningAnimationTarget& aOther) const |
52 | 0 | { |
53 | 0 | return mElement == aOther.mElement && |
54 | 0 | mPseudoType == aOther.mPseudoType; |
55 | 0 | } |
56 | | |
57 | | // mElement represents the parent element of a pseudo-element, not the |
58 | | // generated content element. |
59 | | dom::Element* MOZ_NON_OWNING_REF mElement = nullptr; |
60 | | CSSPseudoElementType mPseudoType = CSSPseudoElementType::NotPseudo; |
61 | | }; |
62 | | |
63 | | |
64 | | // Helper functions for cycle-collecting Maybe<OwningAnimationTarget> |
65 | | inline void |
66 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, |
67 | | Maybe<OwningAnimationTarget>& aTarget, |
68 | | const char* aName, |
69 | | uint32_t aFlags = 0) |
70 | 0 | { |
71 | 0 | if (aTarget) { |
72 | 0 | ImplCycleCollectionTraverse(aCallback, aTarget->mElement, aName, aFlags); |
73 | 0 | } |
74 | 0 | } |
75 | | |
76 | | inline void |
77 | | ImplCycleCollectionUnlink(Maybe<OwningAnimationTarget>& aTarget) |
78 | 0 | { |
79 | 0 | if (aTarget) { |
80 | 0 | ImplCycleCollectionUnlink(aTarget->mElement); |
81 | 0 | } |
82 | 0 | } |
83 | | |
84 | | } // namespace mozilla |
85 | | |
86 | | #endif // mozilla_AnimationTarget_h |