LCOV - code coverage report
Current view: top level - dom/smil - nsSMILTargetIdentifier.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 17 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13