Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / smil / nsSMILTargetIdentifier.h
blobf37022d7b7a52c4589e328f138ce79c647dbd3c8
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/. */
6 #ifndef NS_SMILTARGETIDENTIFIER_H_
7 #define NS_SMILTARGETIDENTIFIER_H_
9 #include "mozilla/dom/Element.h"
10 #include "nsAutoPtr.h"
12 /**
13 * Struct: nsSMILTargetIdentifier
15 * Tuple of: { Animated Element, Attribute Name, Attribute Type (CSS vs. XML) }
17 * Used in nsSMILAnimationController as hash key for mapping an animation
18 * target to the nsSMILCompositor for that target.
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.
25 struct nsSMILTargetIdentifier
27 nsSMILTargetIdentifier()
28 : mElement(nullptr), mAttributeName(nullptr),
29 mAttributeNamespaceID(kNameSpaceID_Unknown), mIsCSS(false) {}
31 inline bool Equals(const nsSMILTargetIdentifier& aOther) const
33 return (aOther.mElement == mElement &&
34 aOther.mAttributeName == mAttributeName &&
35 aOther.mAttributeNamespaceID == mAttributeNamespaceID &&
36 aOther.mIsCSS == mIsCSS);
39 nsRefPtr<mozilla::dom::Element> mElement;
40 nsRefPtr<nsIAtom> mAttributeName;
41 int32_t mAttributeNamespaceID;
42 bool mIsCSS;
45 /**
46 * Class: nsSMILWeakTargetIdentifier
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()).
52 * This is solely for comparisons to determine if a target has changed
53 * from one sample to the next.
55 class nsSMILWeakTargetIdentifier
57 public:
58 // Trivial constructor
59 nsSMILWeakTargetIdentifier()
60 : mElement(nullptr), mAttributeName(nullptr), mIsCSS(false) {}
62 // Allow us to update a weak identifier to match a given non-weak identifier
63 nsSMILWeakTargetIdentifier&
64 operator=(const nsSMILTargetIdentifier& aOther)
66 mElement = aOther.mElement;
67 mAttributeName = aOther.mAttributeName;
68 mIsCSS = aOther.mIsCSS;
69 return *this;
72 // Allow for comparison vs. non-weak identifier
73 inline bool Equals(const nsSMILTargetIdentifier& aOther) const
75 return (aOther.mElement == mElement &&
76 aOther.mAttributeName == mAttributeName &&
77 aOther.mIsCSS == mIsCSS);
80 private:
81 const nsIContent* mElement;
82 const nsIAtom* mAttributeName;
83 bool mIsCSS;
86 #endif // NS_SMILTARGETIDENTIFIER_H_