LCOV - code coverage report
Current view: top level - layout/style - CSSVariableDeclarations.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 1 100.0 %
Date: 2017-07-14 16:53:18 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : /* CSS Custom Property assignments for a Declaration at a given priority */
       7             : 
       8             : #ifndef mozilla_CSSVariableDeclarations_h
       9             : #define mozilla_CSSVariableDeclarations_h
      10             : 
      11             : #include "nsDataHashtable.h"
      12             : 
      13             : namespace mozilla {
      14             : class CSSVariableResolver;
      15             : } // namespace mozilla
      16             : struct nsRuleData;
      17             : 
      18             : namespace mozilla {
      19             : 
      20             : class CSSVariableDeclarations
      21             : {
      22             : public:
      23             :   CSSVariableDeclarations();
      24             :   CSSVariableDeclarations(const CSSVariableDeclarations& aOther);
      25             : #ifdef DEBUG
      26             :   ~CSSVariableDeclarations();
      27             : #endif
      28             :   CSSVariableDeclarations& operator=(const CSSVariableDeclarations& aOther);
      29             : 
      30             :   /**
      31             :    * Returns whether this set of variable declarations includes a variable
      32             :    * with a given name.
      33             :    *
      34             :    * @param aName The variable name (not including any "--" prefix that would
      35             :    *   be part of the custom property name).
      36             :    */
      37             :   bool Has(const nsAString& aName) const;
      38             : 
      39             :   /**
      40             :    * Represents the type of a variable value.
      41             :    */
      42             :   enum Type {
      43             :     eTokenStream,  // a stream of CSS tokens (the usual type for variables)
      44             :     eInitial,      // 'initial'
      45             :     eInherit,      // 'inherit'
      46             :     eUnset         // 'unset'
      47             :   };
      48             : 
      49             :   /**
      50             :    * Gets the value of a variable in this set of variable declarations.
      51             :    *
      52             :    * @param aName The variable name (not including any "--" prefix that would
      53             :    *   be part of the custom property name).
      54             :    * @param aType Out parameter into which the type of the variable value will
      55             :    *   be stored.
      56             :    * @param aValue Out parameter into which the value of the variable will
      57             :    *   be stored.  If the variable is 'initial', 'inherit' or 'unset', this will
      58             :    *   be the empty string.
      59             :    * @return Whether a variable with the given name was found.  When false
      60             :    *   is returned, aType and aValue will not be modified.
      61             :    */
      62             :   bool Get(const nsAString& aName, Type& aType, nsString& aValue) const;
      63             : 
      64             :   /**
      65             :    * Adds or modifies an existing entry in this set of variable declarations
      66             :    * to have the value 'initial'.
      67             :    *
      68             :    * @param aName The variable name (not including any "--" prefix that would
      69             :    *   be part of the custom property name) whose value is to be set.
      70             :    */
      71             :   void PutInitial(const nsAString& aName);
      72             : 
      73             :   /**
      74             :    * Adds or modifies an existing entry in this set of variable declarations
      75             :    * to have the value 'inherit'.
      76             :    *
      77             :    * @param aName The variable name (not including any "--" prefix that would
      78             :    *   be part of the custom property name) whose value is to be set.
      79             :    */
      80             :   void PutInherit(const nsAString& aName);
      81             : 
      82             :   /**
      83             :    * Adds or modifies an existing entry in this set of variable declarations
      84             :    * to have the value 'unset'.
      85             :    *
      86             :    * @param aName The variable name (not including any "--" prefix that would
      87             :    *   be part of the custom property name) whose value is to be set.
      88             :    */
      89             :   void PutUnset(const nsAString& aName);
      90             : 
      91             :   /**
      92             :    * Adds or modifies an existing entry in this set of variable declarations
      93             :    * to have a token stream value.
      94             :    *
      95             :    * @param aName The variable name (not including any "--" prefix that would
      96             :    *   be part of the custom property name) whose value is to be set.
      97             :    * @param aTokenStream The CSS token stream.
      98             :    */
      99             :   void PutTokenStream(const nsAString& aName, const nsString& aTokenStream);
     100             : 
     101             :   /**
     102             :    * Removes an entry in this set of variable declarations.
     103             :    *
     104             :    * @param aName The variable name (not including any "--" prefix that would
     105             :    *   be part of the custom property name) whose entry is to be removed.
     106             :    */
     107             :   void Remove(const nsAString& aName);
     108             : 
     109             :   /**
     110             :    * Returns the number of entries in this set of variable declarations.
     111             :    */
     112           1 :   uint32_t Count() const { return mVariables.Count(); }
     113             : 
     114             :   /**
     115             :    * Copies each variable value from this object into aRuleData, unless that
     116             :    * variable already exists on aRuleData.
     117             :    */
     118             :   void MapRuleInfoInto(nsRuleData* aRuleData);
     119             : 
     120             :   /**
     121             :    * Copies the variables from this object into aResolver, marking them as
     122             :    * specified values.
     123             :    */
     124             :   void AddVariablesToResolver(CSSVariableResolver* aResolver) const;
     125             : 
     126             :   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
     127             : 
     128             : private:
     129             :   /**
     130             :    * Adds all the variable declarations from aOther into this object.
     131             :    */
     132             :   void CopyVariablesFrom(const CSSVariableDeclarations& aOther);
     133             : 
     134             :   nsDataHashtable<nsStringHashKey, nsString> mVariables;
     135             : };
     136             : 
     137             : } // namespace mozilla
     138             : 
     139             : #endif

Generated by: LCOV version 1.13