dom/smil/nsSMILTargetIdentifier.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef NS_SMILTARGETIDENTIFIER_H_
michael@0 7 #define NS_SMILTARGETIDENTIFIER_H_
michael@0 8
michael@0 9 #include "mozilla/dom/Element.h"
michael@0 10 #include "nsAutoPtr.h"
michael@0 11
michael@0 12 /**
michael@0 13 * Struct: nsSMILTargetIdentifier
michael@0 14 *
michael@0 15 * Tuple of: { Animated Element, Attribute Name, Attribute Type (CSS vs. XML) }
michael@0 16 *
michael@0 17 * Used in nsSMILAnimationController as hash key for mapping an animation
michael@0 18 * target to the nsSMILCompositor for that target.
michael@0 19 *
michael@0 20 * NOTE: Need a nsRefPtr for the element & attribute name, because
michael@0 21 * nsSMILAnimationController retain its hash table for one sample into the
michael@0 22 * future, and we need to make sure their target isn't deleted in that time.
michael@0 23 */
michael@0 24
michael@0 25 struct nsSMILTargetIdentifier
michael@0 26 {
michael@0 27 nsSMILTargetIdentifier()
michael@0 28 : mElement(nullptr), mAttributeName(nullptr),
michael@0 29 mAttributeNamespaceID(kNameSpaceID_Unknown), mIsCSS(false) {}
michael@0 30
michael@0 31 inline bool Equals(const nsSMILTargetIdentifier& aOther) const
michael@0 32 {
michael@0 33 return (aOther.mElement == mElement &&
michael@0 34 aOther.mAttributeName == mAttributeName &&
michael@0 35 aOther.mAttributeNamespaceID == mAttributeNamespaceID &&
michael@0 36 aOther.mIsCSS == mIsCSS);
michael@0 37 }
michael@0 38
michael@0 39 nsRefPtr<mozilla::dom::Element> mElement;
michael@0 40 nsRefPtr<nsIAtom> mAttributeName;
michael@0 41 int32_t mAttributeNamespaceID;
michael@0 42 bool mIsCSS;
michael@0 43 };
michael@0 44
michael@0 45 /**
michael@0 46 * Class: nsSMILWeakTargetIdentifier
michael@0 47 *
michael@0 48 * Version of the above struct that uses non-owning pointers. These are kept
michael@0 49 * private, to ensure that they aren't ever dereferenced (or used at all,
michael@0 50 * outside of Equals()).
michael@0 51 *
michael@0 52 * This is solely for comparisons to determine if a target has changed
michael@0 53 * from one sample to the next.
michael@0 54 */
michael@0 55 class nsSMILWeakTargetIdentifier
michael@0 56 {
michael@0 57 public:
michael@0 58 // Trivial constructor
michael@0 59 nsSMILWeakTargetIdentifier()
michael@0 60 : mElement(nullptr), mAttributeName(nullptr), mIsCSS(false) {}
michael@0 61
michael@0 62 // Allow us to update a weak identifier to match a given non-weak identifier
michael@0 63 nsSMILWeakTargetIdentifier&
michael@0 64 operator=(const nsSMILTargetIdentifier& aOther)
michael@0 65 {
michael@0 66 mElement = aOther.mElement;
michael@0 67 mAttributeName = aOther.mAttributeName;
michael@0 68 mIsCSS = aOther.mIsCSS;
michael@0 69 return *this;
michael@0 70 }
michael@0 71
michael@0 72 // Allow for comparison vs. non-weak identifier
michael@0 73 inline bool Equals(const nsSMILTargetIdentifier& aOther) const
michael@0 74 {
michael@0 75 return (aOther.mElement == mElement &&
michael@0 76 aOther.mAttributeName == mAttributeName &&
michael@0 77 aOther.mIsCSS == mIsCSS);
michael@0 78 }
michael@0 79
michael@0 80 private:
michael@0 81 const nsIContent* mElement;
michael@0 82 const nsIAtom* mAttributeName;
michael@0 83 bool mIsCSS;
michael@0 84 };
michael@0 85
michael@0 86 #endif // NS_SMILTARGETIDENTIFIER_H_

mercurial