Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Attributes
nsTreeStyleCache Class Reference

#include <nsTreeStyleCache.h>

List of all members.

Public Member Functions

 nsTreeStyleCache ()
 ~nsTreeStyleCache ()
void Clear ()
nsStyleContextGetStyleContext (nsICSSPseudoComparator *aComparator, nsPresContext *aPresContext, nsIContent *aContent, nsStyleContext *aContext, nsIAtom *aPseudoElement, nsISupportsArray *aInputWord)

Static Public Member Functions

static PRBool PR_CALLBACK DeleteDFAState (nsHashKey *aKey, void *aData, void *closure)
static PRBool PR_CALLBACK ReleaseStyleContext (nsHashKey *aKey, void *aData, void *closure)

Protected Attributes

nsObjectHashtable * mTransitionTable
nsObjectHashtable * mCache
PRUint32 mNextState

Detailed Description

Definition at line 96 of file nsTreeStyleCache.h.


Constructor & Destructor Documentation

Definition at line 99 of file nsTreeStyleCache.h.

Definition at line 100 of file nsTreeStyleCache.h.

{ Clear(); };

Here is the call graph for this function:


Member Function Documentation

Definition at line 102 of file nsTreeStyleCache.h.

Here is the caller graph for this function:

PRBool PR_CALLBACK nsTreeStyleCache::DeleteDFAState ( nsHashKey *  aKey,
void aData,
void closure 
) [static]

Definition at line 120 of file nsTreeStyleCache.cpp.

Here is the caller graph for this function:

nsStyleContext * nsTreeStyleCache::GetStyleContext ( nsICSSPseudoComparator aComparator,
nsPresContext aPresContext,
nsIContent aContent,
nsStyleContext aContext,
nsIAtom aPseudoElement,
nsISupportsArray aInputWord 
)

Definition at line 46 of file nsTreeStyleCache.cpp.

{
  PRUint32 count;
  aInputWord->Count(&count);
  nsDFAState startState(0);
  nsDFAState* currState = &startState;

  // Go ahead and init the transition table.
  if (!mTransitionTable) {
    // Automatic miss. Build the table
    mTransitionTable =
      new nsObjectHashtable(nsnull, nsnull, DeleteDFAState, nsnull);
    if (!mTransitionTable)
      return nsnull;
  }

  // The first transition is always made off the supplied pseudo-element.
  nsTransitionKey key(currState->GetStateID(), aPseudoElement);
  currState = NS_STATIC_CAST(nsDFAState*, mTransitionTable->Get(&key));

  if (!currState) {
    // We had a miss. Make a new state and add it to our hash.
    currState = new nsDFAState(mNextState);
    if (!currState)
      return nsnull;
    mNextState++;
    mTransitionTable->Put(&key, currState);
  }

  for (PRUint32 i = 0; i < count; i++) {
    nsCOMPtr<nsIAtom> pseudo = getter_AddRefs(NS_STATIC_CAST(nsIAtom*, aInputWord->ElementAt(i)));
    nsTransitionKey key(currState->GetStateID(), pseudo);
    currState = NS_STATIC_CAST(nsDFAState*, mTransitionTable->Get(&key));

    if (!currState) {
      // We had a miss. Make a new state and add it to our hash.
      currState = new nsDFAState(mNextState);
      if (!currState)
        return nsnull;

      mNextState++;
      mTransitionTable->Put(&key, currState);
    }
  }

  // We're in a final state.
  // Look up our style context for this state.
  nsStyleContext* result = nsnull;
  if (mCache)
    result = NS_STATIC_CAST(nsStyleContext*, mCache->Get(currState));
  if (!result) {
    // We missed the cache. Resolve this pseudo-style.
    result = aPresContext->StyleSet()->
      ResolvePseudoStyleFor(aContent, aPseudoElement,
                            aContext, aComparator).get();

    // Put the style context in our table, transferring the owning reference to the table.
    if (!mCache) {
      mCache = new nsObjectHashtable(nsnull, nsnull, ReleaseStyleContext, nsnull);
      if (!mCache)
        return nsnull;
    }
    mCache->Put(currState, result);
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool PR_CALLBACK nsTreeStyleCache::ReleaseStyleContext ( nsHashKey *  aKey,
void aData,
void closure 
) [static]

Definition at line 130 of file nsTreeStyleCache.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

nsObjectHashtable* nsTreeStyleCache::mCache [protected]

Definition at line 134 of file nsTreeStyleCache.h.

Definition at line 138 of file nsTreeStyleCache.h.

nsObjectHashtable* nsTreeStyleCache::mTransitionTable [protected]

Definition at line 130 of file nsTreeStyleCache.h.


The documentation for this class was generated from the following files: