|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef NS_SMILTARGETIDENTIFIER_H_ |
|
7 #define NS_SMILTARGETIDENTIFIER_H_ |
|
8 |
|
9 #include "mozilla/dom/Element.h" |
|
10 #include "nsAutoPtr.h" |
|
11 |
|
12 /** |
|
13 * Struct: nsSMILTargetIdentifier |
|
14 * |
|
15 * Tuple of: { Animated Element, Attribute Name, Attribute Type (CSS vs. XML) } |
|
16 * |
|
17 * Used in nsSMILAnimationController as hash key for mapping an animation |
|
18 * target to the nsSMILCompositor for that target. |
|
19 * |
|
20 * NOTE: Need a nsRefPtr for the element & attribute name, because |
|
21 * nsSMILAnimationController retain its hash table for one sample into the |
|
22 * future, and we need to make sure their target isn't deleted in that time. |
|
23 */ |
|
24 |
|
25 struct nsSMILTargetIdentifier |
|
26 { |
|
27 nsSMILTargetIdentifier() |
|
28 : mElement(nullptr), mAttributeName(nullptr), |
|
29 mAttributeNamespaceID(kNameSpaceID_Unknown), mIsCSS(false) {} |
|
30 |
|
31 inline bool Equals(const nsSMILTargetIdentifier& aOther) const |
|
32 { |
|
33 return (aOther.mElement == mElement && |
|
34 aOther.mAttributeName == mAttributeName && |
|
35 aOther.mAttributeNamespaceID == mAttributeNamespaceID && |
|
36 aOther.mIsCSS == mIsCSS); |
|
37 } |
|
38 |
|
39 nsRefPtr<mozilla::dom::Element> mElement; |
|
40 nsRefPtr<nsIAtom> mAttributeName; |
|
41 int32_t mAttributeNamespaceID; |
|
42 bool mIsCSS; |
|
43 }; |
|
44 |
|
45 /** |
|
46 * Class: nsSMILWeakTargetIdentifier |
|
47 * |
|
48 * Version of the above struct that uses non-owning pointers. These are kept |
|
49 * private, to ensure that they aren't ever dereferenced (or used at all, |
|
50 * outside of Equals()). |
|
51 * |
|
52 * This is solely for comparisons to determine if a target has changed |
|
53 * from one sample to the next. |
|
54 */ |
|
55 class nsSMILWeakTargetIdentifier |
|
56 { |
|
57 public: |
|
58 // Trivial constructor |
|
59 nsSMILWeakTargetIdentifier() |
|
60 : mElement(nullptr), mAttributeName(nullptr), mIsCSS(false) {} |
|
61 |
|
62 // Allow us to update a weak identifier to match a given non-weak identifier |
|
63 nsSMILWeakTargetIdentifier& |
|
64 operator=(const nsSMILTargetIdentifier& aOther) |
|
65 { |
|
66 mElement = aOther.mElement; |
|
67 mAttributeName = aOther.mAttributeName; |
|
68 mIsCSS = aOther.mIsCSS; |
|
69 return *this; |
|
70 } |
|
71 |
|
72 // Allow for comparison vs. non-weak identifier |
|
73 inline bool Equals(const nsSMILTargetIdentifier& aOther) const |
|
74 { |
|
75 return (aOther.mElement == mElement && |
|
76 aOther.mAttributeName == mAttributeName && |
|
77 aOther.mIsCSS == mIsCSS); |
|
78 } |
|
79 |
|
80 private: |
|
81 const nsIContent* mElement; |
|
82 const nsIAtom* mAttributeName; |
|
83 bool mIsCSS; |
|
84 }; |
|
85 |
|
86 #endif // NS_SMILTARGETIDENTIFIER_H_ |