/src/mozilla-central/dom/smil/nsSMILTargetIdentifier.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 NS_SMILTARGETIDENTIFIER_H_ |
8 | | #define NS_SMILTARGETIDENTIFIER_H_ |
9 | | |
10 | | #include "mozilla/dom/Element.h" |
11 | | |
12 | | /** |
13 | | * Struct: nsSMILTargetIdentifier |
14 | | * |
15 | | * Tuple of: { Animated Element, Attribute Name } |
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 | 0 | mAttributeNamespaceID(kNameSpaceID_Unknown) {} |
30 | | |
31 | | inline bool Equals(const nsSMILTargetIdentifier& aOther) const |
32 | 0 | { |
33 | 0 | return (aOther.mElement == mElement && |
34 | 0 | aOther.mAttributeName == mAttributeName && |
35 | 0 | aOther.mAttributeNamespaceID == mAttributeNamespaceID); |
36 | 0 | } |
37 | | |
38 | | RefPtr<mozilla::dom::Element> mElement; |
39 | | RefPtr<nsAtom> mAttributeName; |
40 | | int32_t mAttributeNamespaceID; |
41 | | }; |
42 | | |
43 | | /** |
44 | | * Class: nsSMILWeakTargetIdentifier |
45 | | * |
46 | | * Version of the above struct that uses non-owning pointers. These are kept |
47 | | * private, to ensure that they aren't ever dereferenced (or used at all, |
48 | | * outside of Equals()). |
49 | | * |
50 | | * This is solely for comparisons to determine if a target has changed |
51 | | * from one sample to the next. |
52 | | */ |
53 | | class nsSMILWeakTargetIdentifier |
54 | | { |
55 | | public: |
56 | | // Trivial constructor |
57 | | nsSMILWeakTargetIdentifier() |
58 | 0 | : mElement(nullptr), mAttributeName(nullptr) {} |
59 | | |
60 | | // Allow us to update a weak identifier to match a given non-weak identifier |
61 | | nsSMILWeakTargetIdentifier& |
62 | | operator=(const nsSMILTargetIdentifier& aOther) |
63 | 0 | { |
64 | 0 | mElement = aOther.mElement; |
65 | 0 | mAttributeName = aOther.mAttributeName; |
66 | 0 | return *this; |
67 | 0 | } |
68 | | |
69 | | // Allow for comparison vs. non-weak identifier |
70 | | inline bool Equals(const nsSMILTargetIdentifier& aOther) const |
71 | 0 | { |
72 | 0 | return (aOther.mElement == mElement && |
73 | 0 | aOther.mAttributeName == mAttributeName); |
74 | 0 | } |
75 | | |
76 | | private: |
77 | | const nsIContent* mElement; |
78 | | const nsAtom* mAttributeName; |
79 | | }; |
80 | | |
81 | | #endif // NS_SMILTARGETIDENTIFIER_H_ |