1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is the Mozilla SMIL module.
17 * The Initial Developer of the Original Code is the Mozilla Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2010
19 * the Initial Developer. All Rights Reserved.
22 * Daniel Holbert <dholbert@mozilla.com>
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef NS_SMILTARGETIDENTIFIER_H_
39 #define NS_SMILTARGETIDENTIFIER_H_
41 #include "mozilla/dom/Element.h"
42 #include "nsAutoPtr.h"
46 * Struct: nsSMILTargetIdentifier
48 * Tuple of: { Animated Element, Attribute Name, Attribute Type (CSS vs. XML) }
50 * Used in nsSMILAnimationController as hash key for mapping an animation
51 * target to the nsSMILCompositor for that target.
53 * NOTE: Need a nsRefPtr for the element & attribute name, because
54 * nsSMILAnimationController retain its hash table for one sample into the
55 * future, and we need to make sure their target isn't deleted in that time.
58 struct nsSMILTargetIdentifier
60 nsSMILTargetIdentifier()
61 : mElement(nsnull
), mAttributeName(nsnull
),
62 mAttributeNamespaceID(kNameSpaceID_Unknown
), mIsCSS(PR_FALSE
) {}
64 inline PRBool
Equals(const nsSMILTargetIdentifier
& aOther
) const
66 return (aOther
.mElement
== mElement
&&
67 aOther
.mAttributeName
== mAttributeName
&&
68 aOther
.mAttributeNamespaceID
== mAttributeNamespaceID
&&
69 aOther
.mIsCSS
== mIsCSS
);
72 nsRefPtr
<mozilla::dom::Element
> mElement
;
73 nsRefPtr
<nsIAtom
> mAttributeName
;
74 PRInt32 mAttributeNamespaceID
;
79 * Class: nsSMILWeakTargetIdentifier
81 * Version of the above struct that uses non-owning pointers. These are kept
82 * private, to ensure that they aren't ever dereferenced (or used at all,
83 * outside of Equals()).
85 * This is solely for comparisons to determine if a target has changed
86 * from one sample to the next.
88 class nsSMILWeakTargetIdentifier
91 // Trivial constructor
92 nsSMILWeakTargetIdentifier()
93 : mElement(nsnull
), mAttributeName(nsnull
), mIsCSS(PR_FALSE
) {}
95 // Allow us to update a weak identifier to match a given non-weak identifier
96 nsSMILWeakTargetIdentifier
&
97 operator=(const nsSMILTargetIdentifier
& aOther
)
99 mElement
= aOther
.mElement
;
100 mAttributeName
= aOther
.mAttributeName
;
101 mIsCSS
= aOther
.mIsCSS
;
105 // Allow for comparison vs. non-weak identifier
106 inline PRBool
Equals(const nsSMILTargetIdentifier
& aOther
) const
108 return (aOther
.mElement
== mElement
&&
109 aOther
.mAttributeName
== mAttributeName
&&
110 aOther
.mIsCSS
== mIsCSS
);
114 const nsIContent
* mElement
;
115 const nsIAtom
* mAttributeName
;
119 #endif // NS_SMILTARGETIDENTIFIER_H_