Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
nsCounterManager Class Reference

The counter manager maintains an |nsCounterList| for each named counter to keep track of all scopes with that name. More...

#include <nsCounterManager.h>

Collaboration diagram for nsCounterManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsCounterManager ()
PRBool AddCounterResetsAndIncrements (nsIFrame *aFrame)
nsCounterListCounterListFor (const nsSubstring &aCounterName)
void RecalcAll ()
PRBool DestroyNodesFor (nsIFrame *aFrame)
void Clear ()

Private Member Functions

PRBool AddResetOrIncrement (nsIFrame *aFrame, PRInt32 aIndex, const nsStyleCounterData *aCounterData, nsCounterNode::Type aType)

Private Attributes

nsClassHashtable
< nsStringHashKey,
nsCounterList
mNames

Detailed Description

The counter manager maintains an |nsCounterList| for each named counter to keep track of all scopes with that name.

Definition at line 232 of file nsCounterManager.h.


Constructor & Destructor Documentation

Definition at line 190 of file nsCounterManager.cpp.

{
    mNames.Init(16);
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 196 of file nsCounterManager.cpp.

{
    const nsStyleContent *styleContent = aFrame->GetStyleContent();
    if (!styleContent->CounterIncrementCount() &&
        !styleContent->CounterResetCount())
        return PR_FALSE;

    // Add in order, resets first, so all the comparisons will be optimized
    // for addition at the end of the list.
    PRInt32 i, i_end;
    PRBool dirty = PR_FALSE;
    for (i = 0, i_end = styleContent->CounterResetCount(); i != i_end; ++i)
        dirty |= AddResetOrIncrement(aFrame, i,
                                     styleContent->GetCounterResetAt(i),
                                     nsCounterChangeNode::RESET);
    for (i = 0, i_end = styleContent->CounterIncrementCount(); i != i_end; ++i)
        dirty |= AddResetOrIncrement(aFrame, i,
                                     styleContent->GetCounterIncrementAt(i),
                                     nsCounterChangeNode::INCREMENT);
    return dirty;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsCounterManager::AddResetOrIncrement ( nsIFrame aFrame,
PRInt32  aIndex,
const nsStyleCounterData aCounterData,
nsCounterNode::Type  aType 
) [private]

Definition at line 219 of file nsCounterManager.cpp.

{
    nsCounterChangeNode *node =
        new nsCounterChangeNode(aFrame, aType, aCounterData->mValue, aIndex);
    if (!node)
        return PR_FALSE;

    nsCounterList *counterList = CounterListFor(aCounterData->mCounter);
    if (!counterList) {
        NS_NOTREACHED("CounterListFor failed (should only happen on OOM)");
        return PR_FALSE;
    }

    counterList->Insert(node);
    if (!counterList->IsLast(node)) {
        // Tell the caller it's responsible for recalculating the entire
        // list.
        return PR_TRUE;
    }

    // Don't call Calc() if the list is already dirty -- it'll be recalculated
    // anyway, and trying to calculate with a dirty list doesn't work.
    if (NS_LIKELY(!counterList->IsDirty())) {
        node->Calc(counterList);
    }
    return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 250 of file nsCounterManager.h.

{ mNames.Clear(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 250 of file nsCounterManager.cpp.

{
    // XXX Why doesn't nsTHashtable provide an API that allows us to use
    // get/put in one hashtable lookup?
    nsCounterList *counterList;
    if (!mNames.Get(aCounterName, &counterList)) {
        counterList = new nsCounterList();
        if (!counterList)
            return nsnull;
        if (!mNames.Put(aCounterName, counterList)) {
            delete counterList;
            return nsnull;
        }
    }
    return counterList;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 304 of file nsCounterManager.cpp.

{
    DestroyNodesData data(aFrame);
    mNames.EnumerateRead(DestroyNodesInList, &data);
    return data.mDestroyedAny;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 276 of file nsCounterManager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 262 of file nsCounterManager.h.


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