LCOV - code coverage report
Current view: directory - content/smil - nsSMILTargetIdentifier.h (source / functions) Found Hit Coverage
Test: app.info Lines: 18 0 0.0 %
Date: 2012-06-02 Functions: 7 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is the Mozilla SMIL module.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is the Mozilla Corporation.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *   Daniel Holbert <dholbert@mozilla.com>
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : #ifndef NS_SMILTARGETIDENTIFIER_H_
      39                 : #define NS_SMILTARGETIDENTIFIER_H_
      40                 : 
      41                 : #include "mozilla/dom/Element.h"
      42                 : #include "nsAutoPtr.h"
      43                 : #include "prtypes.h"
      44                 : 
      45                 : /**
      46                 :  * Struct: nsSMILTargetIdentifier
      47                 :  *
      48                 :  * Tuple of: { Animated Element, Attribute Name, Attribute Type (CSS vs. XML) }
      49                 :  *
      50                 :  * Used in nsSMILAnimationController as hash key for mapping an animation
      51                 :  * target to the nsSMILCompositor for that target.
      52                 :  *
      53                 :  * NOTE: Need a nsRefPtr for the element & attribute name, because
      54                 :  * nsSMILAnimationController retain its hash table for one sample into the
      55                 :  * future, and we need to make sure their target isn't deleted in that time.
      56                 :  */
      57                 : 
      58                 : struct nsSMILTargetIdentifier
      59               0 : {
      60               0 :   nsSMILTargetIdentifier()
      61                 :     : mElement(nsnull), mAttributeName(nsnull),
      62               0 :       mAttributeNamespaceID(kNameSpaceID_Unknown), mIsCSS(false) {}
      63                 : 
      64               0 :   inline bool Equals(const nsSMILTargetIdentifier& aOther) const
      65                 :   {
      66               0 :     return (aOther.mElement              == mElement &&
      67               0 :             aOther.mAttributeName        == mAttributeName &&
      68                 :             aOther.mAttributeNamespaceID == mAttributeNamespaceID &&
      69               0 :             aOther.mIsCSS                == mIsCSS);
      70                 :   }
      71                 : 
      72                 :   nsRefPtr<mozilla::dom::Element> mElement;
      73                 :   nsRefPtr<nsIAtom>    mAttributeName;
      74                 :   PRInt32              mAttributeNamespaceID;
      75                 :   bool                 mIsCSS;
      76                 : };
      77                 : 
      78                 : /**
      79                 :  * Class: nsSMILWeakTargetIdentifier
      80                 :  *
      81                 :  * Version of the above struct that uses non-owning pointers.  These are kept
      82                 :  * private, to ensure that they aren't ever dereferenced (or used at all,
      83                 :  * outside of Equals()).
      84                 :  *
      85                 :  * This is solely for comparisons to determine if a target has changed
      86                 :  * from one sample to the next.
      87                 :  */
      88                 : class nsSMILWeakTargetIdentifier
      89                 : {
      90                 : public:
      91                 :   // Trivial constructor
      92               0 :   nsSMILWeakTargetIdentifier()
      93               0 :     : mElement(nsnull), mAttributeName(nsnull), mIsCSS(false) {}
      94                 : 
      95                 :   // Allow us to update a weak identifier to match a given non-weak identifier
      96                 :   nsSMILWeakTargetIdentifier&
      97               0 :     operator=(const nsSMILTargetIdentifier& aOther)
      98                 :   {
      99               0 :     mElement = aOther.mElement;
     100               0 :     mAttributeName = aOther.mAttributeName;
     101               0 :     mIsCSS = aOther.mIsCSS;
     102               0 :     return *this;
     103                 :   }
     104                 : 
     105                 :   // Allow for comparison vs. non-weak identifier
     106               0 :   inline bool Equals(const nsSMILTargetIdentifier& aOther) const
     107                 :   {
     108               0 :     return (aOther.mElement       == mElement &&
     109               0 :             aOther.mAttributeName == mAttributeName &&
     110               0 :             aOther.mIsCSS         == mIsCSS);
     111                 :   }
     112                 : 
     113                 : private:
     114                 :   const nsIContent* mElement;
     115                 :   const nsIAtom*    mAttributeName;
     116                 :   bool              mIsCSS;
     117                 : };
     118                 : 
     119                 : #endif // NS_SMILTARGETIDENTIFIER_H_

Generated by: LCOV version 1.7