2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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-21 00:13:11 +03:00
|
|
|
|
2019-01-25 11:16:09 +03:00
|
|
|
#ifndef mozilla_SMILTargetIdentifier_h
|
|
|
|
#define mozilla_SMILTargetIdentifier_h
|
2010-02-21 00:13:11 +03:00
|
|
|
|
2010-05-14 21:04:51 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2010-02-21 00:13:11 +03:00
|
|
|
|
2019-01-02 10:21:13 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
2010-02-21 00:13:11 +03:00
|
|
|
/**
|
2019-01-02 10:21:13 +03:00
|
|
|
* Struct: SMILTargetIdentifier
|
2010-02-21 00:13:11 +03:00
|
|
|
*
|
2017-03-21 09:42:17 +03:00
|
|
|
* Tuple of: { Animated Element, Attribute Name }
|
2010-02-21 00:13:11 +03:00
|
|
|
*
|
2018-12-28 14:47:58 +03:00
|
|
|
* Used in SMILAnimationController as hash key for mapping an animation
|
2019-01-01 12:16:21 +03:00
|
|
|
* target to the SMILCompositor for that target.
|
2010-02-21 00:13:11 +03:00
|
|
|
*
|
|
|
|
* NOTE: Need a nsRefPtr for the element & attribute name, because
|
2018-12-28 14:47:58 +03:00
|
|
|
* SMILAnimationController retain its hash table for one sample into the
|
2010-02-21 00:13:11 +03:00
|
|
|
* future, and we need to make sure their target isn't deleted in that time.
|
|
|
|
*/
|
|
|
|
|
2019-01-02 10:21:13 +03:00
|
|
|
struct SMILTargetIdentifier {
|
|
|
|
SMILTargetIdentifier()
|
2012-07-30 18:20:58 +04:00
|
|
|
: mElement(nullptr),
|
|
|
|
mAttributeName(nullptr),
|
2017-03-21 09:42:17 +03:00
|
|
|
mAttributeNamespaceID(kNameSpaceID_Unknown) {}
|
2010-02-21 00:13:11 +03:00
|
|
|
|
2019-01-02 10:21:13 +03:00
|
|
|
inline bool Equals(const SMILTargetIdentifier& aOther) const {
|
2010-10-07 23:19:32 +04:00
|
|
|
return (aOther.mElement == mElement &&
|
|
|
|
aOther.mAttributeName == mAttributeName &&
|
2017-03-21 09:42:17 +03:00
|
|
|
aOther.mAttributeNamespaceID == mAttributeNamespaceID);
|
2010-02-21 00:13:11 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::dom::Element> mElement;
|
2017-10-03 01:05:19 +03:00
|
|
|
RefPtr<nsAtom> mAttributeName;
|
2017-03-21 09:42:17 +03:00
|
|
|
int32_t mAttributeNamespaceID;
|
2010-02-21 00:13:11 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2019-01-25 06:24:01 +03:00
|
|
|
* Class: SMILWeakTargetIdentifier
|
2010-02-21 00:13:11 +03:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2019-01-25 06:24:01 +03:00
|
|
|
class SMILWeakTargetIdentifier {
|
2010-02-21 00:13:11 +03:00
|
|
|
public:
|
|
|
|
// Trivial constructor
|
2019-01-25 06:24:01 +03:00
|
|
|
SMILWeakTargetIdentifier() : mElement(nullptr), mAttributeName(nullptr) {}
|
2010-02-21 00:13:11 +03:00
|
|
|
|
|
|
|
// Allow us to update a weak identifier to match a given non-weak identifier
|
2019-01-25 06:24:01 +03:00
|
|
|
SMILWeakTargetIdentifier& operator=(const SMILTargetIdentifier& aOther) {
|
2010-02-21 00:13:11 +03:00
|
|
|
mElement = aOther.mElement;
|
|
|
|
mAttributeName = aOther.mAttributeName;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Allow for comparison vs. non-weak identifier
|
2019-01-02 10:21:13 +03:00
|
|
|
inline bool Equals(const SMILTargetIdentifier& aOther) const {
|
2010-02-21 00:13:11 +03:00
|
|
|
return (aOther.mElement == mElement &&
|
2017-03-21 09:42:17 +03:00
|
|
|
aOther.mAttributeName == mAttributeName);
|
2010-02-21 00:13:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const nsIContent* mElement;
|
2017-10-03 01:05:19 +03:00
|
|
|
const nsAtom* mAttributeName;
|
2010-02-21 00:13:11 +03:00
|
|
|
};
|
|
|
|
|
2019-01-02 10:21:13 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2019-01-25 11:16:09 +03:00
|
|
|
#endif // mozilla_SMILTargetIdentifier_h
|