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/. */
7 #ifndef DOM_SMIL_SMILTARGETIDENTIFIER_H_
8 #define DOM_SMIL_SMILTARGETIDENTIFIER_H_
10 // XXX Avoid including this here by moving function bodies to the cpp file
12 #include "nsIContent.h"
13 #include "mozilla/dom/Element.h"
23 * Struct: SMILTargetIdentifier
25 * Tuple of: { Animated Element, Attribute Name }
27 * Used in SMILAnimationController as hash key for mapping an animation
28 * target to the SMILCompositor for that target.
30 * NOTE: Need a nsRefPtr for the element & attribute name, because
31 * SMILAnimationController retain its hash table for one sample into the
32 * future, and we need to make sure their target isn't deleted in that time.
35 struct SMILTargetIdentifier
{
36 SMILTargetIdentifier()
38 mAttributeName(nullptr),
39 mAttributeNamespaceID(kNameSpaceID_Unknown
) {}
41 inline bool Equals(const SMILTargetIdentifier
& aOther
) const {
42 return (aOther
.mElement
== mElement
&&
43 aOther
.mAttributeName
== mAttributeName
&&
44 aOther
.mAttributeNamespaceID
== mAttributeNamespaceID
);
47 RefPtr
<mozilla::dom::Element
> mElement
;
48 RefPtr
<nsAtom
> mAttributeName
;
49 int32_t mAttributeNamespaceID
;
53 * Class: SMILWeakTargetIdentifier
55 * Version of the above struct that uses non-owning pointers. These are kept
56 * private, to ensure that they aren't ever dereferenced (or used at all,
57 * outside of Equals()).
59 * This is solely for comparisons to determine if a target has changed
60 * from one sample to the next.
62 class SMILWeakTargetIdentifier
{
64 // Trivial constructor
65 SMILWeakTargetIdentifier() : mElement(nullptr), mAttributeName(nullptr) {}
67 // Allow us to update a weak identifier to match a given non-weak identifier
68 SMILWeakTargetIdentifier
& operator=(const SMILTargetIdentifier
& aOther
) {
69 mElement
= aOther
.mElement
;
70 mAttributeName
= aOther
.mAttributeName
;
74 // Allow for comparison vs. non-weak identifier
75 inline bool Equals(const SMILTargetIdentifier
& aOther
) const {
76 return (aOther
.mElement
== mElement
&&
77 aOther
.mAttributeName
== mAttributeName
);
81 const nsIContent
* mElement
;
82 const nsAtom
* mAttributeName
;
85 } // namespace mozilla
87 #endif // DOM_SMIL_SMILTARGETIDENTIFIER_H_