LCOV - code coverage report
Current view: top level - layout/xul/tree - nsTreeStyleCache.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 13 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       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             : #ifndef nsTreeStyleCache_h__
       7             : #define nsTreeStyleCache_h__
       8             : 
       9             : #include "mozilla/Attributes.h"
      10             : #include "nsAutoPtr.h"
      11             : #include "nsIAtom.h"
      12             : #include "nsCOMArray.h"
      13             : #include "nsICSSPseudoComparator.h"
      14             : #include "nsRefPtrHashtable.h"
      15             : #include "nsStyleContext.h"
      16             : 
      17             : typedef nsCOMArray<nsIAtom> AtomArray;
      18             : 
      19             : class nsTreeStyleCache
      20             : {
      21             : public:
      22           0 :   nsTreeStyleCache()
      23           0 :     : mNextState(0)
      24             :   {
      25           0 :   }
      26             : 
      27           0 :   ~nsTreeStyleCache()
      28           0 :   {
      29           0 :     Clear();
      30           0 :   }
      31             : 
      32           0 :   void Clear()
      33             :   {
      34           0 :     mTransitionTable = nullptr;
      35           0 :     mCache = nullptr;
      36           0 :     mNextState = 0;
      37           0 :   }
      38             : 
      39             :   nsStyleContext* GetStyleContext(nsICSSPseudoComparator* aComparator,
      40             :                                   nsPresContext* aPresContext,
      41             :                                   nsIContent* aContent,
      42             :                                   nsStyleContext* aContext,
      43             :                                   nsICSSAnonBoxPseudo* aPseudoElement,
      44             :                                   const AtomArray & aInputWord);
      45             : 
      46             : protected:
      47             :   typedef uint32_t DFAState;
      48             : 
      49           0 :   class Transition final
      50             :   {
      51             :   public:
      52             :     Transition(DFAState aState, nsIAtom* aSymbol);
      53             :     bool operator==(const Transition& aOther) const;
      54             :     uint32_t Hash() const;
      55             : 
      56             :   private:
      57             :     DFAState mState;
      58             :     nsCOMPtr<nsIAtom> mInputSymbol;
      59             :   };
      60             : 
      61             :   typedef nsDataHashtable<nsGenericHashKey<Transition>, DFAState> TransitionTable;
      62             : 
      63             :   // A transition table for a deterministic finite automaton.  The DFA
      64             :   // takes as its input a single pseudoelement and an ordered set of properties.
      65             :   // It transitions on an input word that is the concatenation of the pseudoelement supplied
      66             :   // with the properties in the array.
      67             :   //
      68             :   // It transitions from state to state by looking up entries in the transition table (which is
      69             :   // a mapping from (S,i)->S', where S is the current state, i is the next
      70             :   // property in the input word, and S' is the state to transition to.
      71             :   //
      72             :   // If S' is not found, it is constructed and entered into the hashtable
      73             :   // under the key (S,i).
      74             :   //
      75             :   // Once the entire word has been consumed, the final state is used
      76             :   // to reference the cache table to locate the style context.
      77             :   nsAutoPtr<TransitionTable> mTransitionTable;
      78             : 
      79             :   // The cache of all active style contexts.  This is a hash from
      80             :   // a final state in the DFA, Sf, to the resultant style context.
      81             :   typedef nsRefPtrHashtable<nsUint32HashKey, nsStyleContext> StyleContextCache;
      82             :   nsAutoPtr<StyleContextCache> mCache;
      83             : 
      84             :   // An integer counter that is used when we need to make new states in the
      85             :   // DFA.
      86             :   DFAState mNextState;
      87             : };
      88             : 
      89             : #endif // nsTreeStyleCache_h__

Generated by: LCOV version 1.13