LCOV - code coverage report
Current view: directory - content/smil - nsSMILParserUtils.h (source / functions) Found Hit Coverage
Test: app.info Lines: 1 0 0.0 %
Date: 2012-06-02 Functions: 1 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 Brian Birtles.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2005
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *   Brian Birtles <birtles@gmail.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_SMILPARSERUTILS_H_
      39                 : #define NS_SMILPARSERUTILS_H_
      40                 : 
      41                 : #include "nscore.h"
      42                 : #include "nsTArray.h"
      43                 : #include "nsString.h"
      44                 : 
      45                 : class nsISMILAttr;
      46                 : class nsISMILAnimationElement;
      47                 : class nsSMILTimeValue;
      48                 : class nsSMILValue;
      49                 : class nsSMILRepeatCount;
      50                 : class nsSMILTimeValueSpecParams;
      51                 : 
      52                 : /**
      53                 :  * Common parsing utilities for the SMIL module. There is little re-use here; it
      54                 :  * simply serves to simplify other classes by moving parsing outside and to aid
      55                 :  * unit testing.
      56                 :  */
      57                 : class nsSMILParserUtils
      58                 : {
      59                 : public:
      60                 :   // Abstract helper-class for assisting in parsing |values| attribute
      61               0 :   class GenericValueParser {
      62                 :   public:
      63                 :     virtual nsresult Parse(const nsAString& aValueStr) = 0;
      64                 :   };
      65                 : 
      66                 :   static nsresult ParseKeySplines(const nsAString& aSpec,
      67                 :                                   nsTArray<double>& aSplineArray);
      68                 : 
      69                 :   // Used for parsing the |keyTimes| and |keyPoints| attributes.
      70                 :   static nsresult ParseSemicolonDelimitedProgressList(const nsAString& aSpec,
      71                 :                                                       bool aNonDecreasing,
      72                 :                                                       nsTArray<double>& aArray);
      73                 : 
      74                 :   static nsresult ParseValues(const nsAString& aSpec,
      75                 :                               const nsISMILAnimationElement* aSrcElement,
      76                 :                               const nsISMILAttr& aAttribute,
      77                 :                               nsTArray<nsSMILValue>& aValuesArray,
      78                 :                               bool& aPreventCachingOfSandwich);
      79                 : 
      80                 :   // Generic method that will run some code on each sub-section of an animation
      81                 :   // element's "values" list.
      82                 :   static nsresult ParseValuesGeneric(const nsAString& aSpec,
      83                 :                                      GenericValueParser& aParser);
      84                 : 
      85                 :   static nsresult ParseRepeatCount(const nsAString& aSpec,
      86                 :                                    nsSMILRepeatCount& aResult);
      87                 : 
      88                 :   static nsresult ParseTimeValueSpecParams(const nsAString& aSpec,
      89                 :                                            nsSMILTimeValueSpecParams& aResult);
      90                 : 
      91                 : 
      92                 :   // Used with ParseClockValue. Allow + or - before a clock value.
      93                 :   static const PRInt8 kClockValueAllowSign       = 1;
      94                 :   // Used with ParseClockValue. Allow "indefinite" in a clock value
      95                 :   static const PRInt8 kClockValueAllowIndefinite = 2;
      96                 : 
      97                 :   /*
      98                 :    * This method can actually parse more than a clock value as defined in the
      99                 :    * SMIL Animation specification. It can also parse:
     100                 :    *  - the + or - before an offset
     101                 :    *  - the special value "indefinite"
     102                 :    *  - the special value "media"
     103                 :    *
     104                 :    * Because the value "media" cannot be represented as part of an
     105                 :    * nsSMILTimeValue and has different meanings depending on where it is used,
     106                 :    * it is passed out as a separate parameter (which can be set to nsnull if the
     107                 :    * media attribute is not allowed).
     108                 :    *
     109                 :    * @param aSpec    The string containing a clock value, e.g. "10s"
     110                 :    * @param aResult  The parsed result. May be NULL (e.g. if this method is
     111                 :    *                 being called just to test if aSpec is a valid clock value).
     112                 :    *                 [OUT]
     113                 :    * @param aFlags   A combination of the kClockValue* bit flags OR'ed together
     114                 :    *                 to define what additional syntax is allowed.
     115                 :    * @param aIsMedia Optional out parameter which, if not null, will be set to
     116                 :    *                 true if the value is the string "media", false
     117                 :    *                 otherwise. If it is null, the string "media" is not
     118                 :    *                 allowed.
     119                 :    *
     120                 :    * @return NS_OK if aSpec was successfully parsed as a valid clock value
     121                 :    * (according to aFlags), an error code otherwise.
     122                 :    */
     123                 :   static nsresult ParseClockValue(const nsAString& aSpec,
     124                 :                                   nsSMILTimeValue* aResult,
     125                 :                                   PRUint32 aFlags = 0,
     126                 :                                   bool* aIsMedia = nsnull);
     127                 : 
     128                 :   /*
     129                 :    * This method checks whether the given string looks like a negative number.
     130                 :    * Specifically, it checks whether the string looks matches the pattern
     131                 :    * "[whitespace]*-[numeral].*" If the string matches this pattern, this
     132                 :    * method returns the index of the first character after the '-' sign
     133                 :    * (i.e. the index of the absolute value).  If not, this method returns -1.
     134                 :    */
     135                 :   static PRInt32 CheckForNegativeNumber(const nsAString& aStr);
     136                 : };
     137                 : 
     138                 : #endif // NS_SMILPARSERUTILS_H_

Generated by: LCOV version 1.7