LCOV - code coverage report
Current view: directory - content/smil - nsSMILCSSValueType.h (source / functions) Found Hit Coverage
Test: app.info Lines: 2 2 100.0 %
Date: 2012-06-02 Functions: 2 2 100.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) 2009
      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                 : /* representation of a value for a SMIL-animated CSS property */
      39                 : 
      40                 : #ifndef NS_SMILCSSVALUETYPE_H_
      41                 : #define NS_SMILCSSVALUETYPE_H_
      42                 : 
      43                 : #include "nsISMILType.h"
      44                 : #include "nsCSSProperty.h"
      45                 : #include "nscore.h" // For NS_OVERRIDE
      46                 : 
      47                 : class nsAString;
      48                 : 
      49                 : namespace mozilla {
      50                 : namespace dom {
      51                 : class Element;
      52                 : } // namespace dom
      53                 : } // namespace mozilla
      54                 : 
      55                 : /*
      56                 :  * nsSMILCSSValueType: Represents a SMIL-animated CSS value.
      57                 :  */
      58                 : class nsSMILCSSValueType : public nsISMILType
      59                 : {
      60                 : public:
      61                 :   typedef mozilla::dom::Element Element;
      62                 : 
      63                 :   // Singleton for nsSMILValue objects to hold onto.
      64                 :   static nsSMILCSSValueType sSingleton;
      65                 : 
      66                 : protected:
      67                 :   // nsISMILType Methods
      68                 :   // -------------------
      69                 :   NS_OVERRIDE virtual void     Init(nsSMILValue& aValue) const;
      70                 :   NS_OVERRIDE virtual void     Destroy(nsSMILValue&) const;
      71                 :   NS_OVERRIDE virtual nsresult Assign(nsSMILValue& aDest,
      72                 :                                       const nsSMILValue& aSrc) const;
      73                 :   NS_OVERRIDE virtual bool     IsEqual(const nsSMILValue& aLeft,
      74                 :                                        const nsSMILValue& aRight) const;
      75                 :   NS_OVERRIDE virtual nsresult Add(nsSMILValue& aDest,
      76                 :                                    const nsSMILValue& aValueToAdd,
      77                 :                                    PRUint32 aCount) const;
      78                 :   NS_OVERRIDE virtual nsresult ComputeDistance(const nsSMILValue& aFrom,
      79                 :                                                const nsSMILValue& aTo,
      80                 :                                                double& aDistance) const;
      81                 :   NS_OVERRIDE virtual nsresult Interpolate(const nsSMILValue& aStartVal,
      82                 :                                            const nsSMILValue& aEndVal,
      83                 :                                            double aUnitDistance,
      84                 :                                            nsSMILValue& aResult) const;
      85                 : 
      86                 : public:
      87                 :   // Helper Methods
      88                 :   // --------------
      89                 :   /**
      90                 :    * Sets up the given nsSMILValue to represent the given string value.  The
      91                 :    * string is interpreted as a value for the given property on the given
      92                 :    * element.
      93                 :    *
      94                 :    * On failure, this method leaves aValue.mType == nsSMILNullType::sSingleton.
      95                 :    * Otherwise, this method leaves aValue.mType == this class's singleton.
      96                 :    *
      97                 :    * @param       aPropID         The property for which we're parsing a value.
      98                 :    * @param       aTargetElement  The target element to whom the property/value
      99                 :    *                              setting applies.
     100                 :    * @param       aString         The string to be parsed as a CSS value.
     101                 :    * @param [out] aValue          The nsSMILValue to be populated. Should
     102                 :    *                              initially be null-typed.
     103                 :    * @param [out] aIsContextSensitive Set to true if |aString| may produce
     104                 :    *                                  a different |aValue| depending on other
     105                 :    *                                  CSS properties on |aTargetElement|
     106                 :    *                                  or its ancestors (e.g. 'inherit).
     107                 :    *                                  false otherwise. May be nsnull.
     108                 :    *                                  Not set if the method fails.
     109                 :    * @pre  aValue.IsNull()
     110                 :    * @post aValue.IsNull() || aValue.mType == nsSMILCSSValueType::sSingleton
     111                 :    */
     112                 :   static void ValueFromString(nsCSSProperty aPropID,
     113                 :                               Element* aTargetElement,
     114                 :                               const nsAString& aString,
     115                 :                               nsSMILValue& aValue,
     116                 :                               bool* aIsContextSensitive);
     117                 : 
     118                 :   /**
     119                 :    * Creates a string representation of the given nsSMILValue.
     120                 :    *
     121                 :    * Note: aValue is expected to be of this type (that is, it's expected to
     122                 :    * have been initialized by nsSMILCSSValueType::sSingleton).  If aValue is a
     123                 :    * freshly-initialized value, this method will succeed, though the resulting
     124                 :    * string will be empty.
     125                 :    *
     126                 :    * @param       aValue   The nsSMILValue to be converted into a string.
     127                 :    * @param [out] aString  The string to be populated with the given value.
     128                 :    * @return               true on success, false on failure.
     129                 :    */
     130                 :   static bool ValueToString(const nsSMILValue& aValue, nsAString& aString);
     131                 : 
     132                 : private:
     133                 :   // Private constructor & destructor: prevent instances beyond my singleton,
     134                 :   // and prevent others from deleting my singleton.
     135            1464 :   nsSMILCSSValueType()  {}
     136            1487 :   ~nsSMILCSSValueType() {}
     137                 : };
     138                 : 
     139                 : #endif // NS_SMILCSSVALUETYPE_H_

Generated by: LCOV version 1.7