michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef NS_SMILTARGETIDENTIFIER_H_ michael@0: #define NS_SMILTARGETIDENTIFIER_H_ michael@0: michael@0: #include "mozilla/dom/Element.h" michael@0: #include "nsAutoPtr.h" michael@0: michael@0: /** michael@0: * Struct: nsSMILTargetIdentifier michael@0: * michael@0: * Tuple of: { Animated Element, Attribute Name, Attribute Type (CSS vs. XML) } michael@0: * michael@0: * Used in nsSMILAnimationController as hash key for mapping an animation michael@0: * target to the nsSMILCompositor for that target. michael@0: * michael@0: * NOTE: Need a nsRefPtr for the element & attribute name, because michael@0: * nsSMILAnimationController retain its hash table for one sample into the michael@0: * future, and we need to make sure their target isn't deleted in that time. michael@0: */ michael@0: michael@0: struct nsSMILTargetIdentifier michael@0: { michael@0: nsSMILTargetIdentifier() michael@0: : mElement(nullptr), mAttributeName(nullptr), michael@0: mAttributeNamespaceID(kNameSpaceID_Unknown), mIsCSS(false) {} michael@0: michael@0: inline bool Equals(const nsSMILTargetIdentifier& aOther) const michael@0: { michael@0: return (aOther.mElement == mElement && michael@0: aOther.mAttributeName == mAttributeName && michael@0: aOther.mAttributeNamespaceID == mAttributeNamespaceID && michael@0: aOther.mIsCSS == mIsCSS); michael@0: } michael@0: michael@0: nsRefPtr mElement; michael@0: nsRefPtr mAttributeName; michael@0: int32_t mAttributeNamespaceID; michael@0: bool mIsCSS; michael@0: }; michael@0: michael@0: /** michael@0: * Class: nsSMILWeakTargetIdentifier michael@0: * michael@0: * Version of the above struct that uses non-owning pointers. These are kept michael@0: * private, to ensure that they aren't ever dereferenced (or used at all, michael@0: * outside of Equals()). michael@0: * michael@0: * This is solely for comparisons to determine if a target has changed michael@0: * from one sample to the next. michael@0: */ michael@0: class nsSMILWeakTargetIdentifier michael@0: { michael@0: public: michael@0: // Trivial constructor michael@0: nsSMILWeakTargetIdentifier() michael@0: : mElement(nullptr), mAttributeName(nullptr), mIsCSS(false) {} michael@0: michael@0: // Allow us to update a weak identifier to match a given non-weak identifier michael@0: nsSMILWeakTargetIdentifier& michael@0: operator=(const nsSMILTargetIdentifier& aOther) michael@0: { michael@0: mElement = aOther.mElement; michael@0: mAttributeName = aOther.mAttributeName; michael@0: mIsCSS = aOther.mIsCSS; michael@0: return *this; michael@0: } michael@0: michael@0: // Allow for comparison vs. non-weak identifier michael@0: inline bool Equals(const nsSMILTargetIdentifier& aOther) const michael@0: { michael@0: return (aOther.mElement == mElement && michael@0: aOther.mAttributeName == mAttributeName && michael@0: aOther.mIsCSS == mIsCSS); michael@0: } michael@0: michael@0: private: michael@0: const nsIContent* mElement; michael@0: const nsIAtom* mAttributeName; michael@0: bool mIsCSS; michael@0: }; michael@0: michael@0: #endif // NS_SMILTARGETIDENTIFIER_H_