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