Back to index

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

The nsContentSupportMap maintains a mapping from a "resource element" in the content tree to the nsTemplateMatch that was used to instantiate it. More...

#include <nsContentSupportMap.h>

Collaboration diagram for nsContentSupportMap:
Collaboration graph
[legend]

List of all members.

Classes

struct  Entry

Public Member Functions

 nsContentSupportMap ()
 ~nsContentSupportMap ()
nsresult Put (nsIContent *aElement, nsTemplateMatch *aMatch)
PRBool Get (nsIContent *aElement, nsTemplateMatch **aMatch)
nsresult Remove (nsIContent *aElement)
void Clear ()

Protected Member Functions

void Init ()
void Finish ()

Static Protected Member Functions

static void PR_CALLBACK ClearEntry (PLDHashTable *aTable, PLDHashEntryHdr *aHdr)

Protected Attributes

PLDHashTable mMap

Static Protected Attributes

static PLDHashTableOps gOps

Detailed Description

The nsContentSupportMap maintains a mapping from a "resource element" in the content tree to the nsTemplateMatch that was used to instantiate it.

This is necessary to allow the XUL content to be built lazily. Specifically, when building "resumes" on a partially-built content element, the builder will walk upwards in the content tree to find the first element with an 'id' attribute. This element is assumed to be the "resource element", and allows the content builder to access the nsTemplateMatch (variable assignments and rule information).

Definition at line 56 of file nsContentSupportMap.h.


Class Documentation

struct nsContentSupportMap::Entry

Definition at line 97 of file nsContentSupportMap.h.

Collaboration diagram for nsContentSupportMap::Entry:
Class Members
nsIContent * mContent
PLDHashEntryHdr mHdr
nsTemplateMatch * mMatch

Constructor & Destructor Documentation

Definition at line 58 of file nsContentSupportMap.h.

{ Init(); }

Here is the call graph for this function:

Definition at line 59 of file nsContentSupportMap.h.

{ Finish(); }

Here is the call graph for this function:


Member Function Documentation

Definition at line 89 of file nsContentSupportMap.h.

{ Finish(); Init(); }

Here is the call graph for this function:

Here is the caller graph for this function:

void PR_CALLBACK nsContentSupportMap::ClearEntry ( PLDHashTable aTable,
PLDHashEntryHdr aHdr 
) [static, protected]

Definition at line 54 of file nsContentSupportMap.cpp.

{
    PL_DHashClearEntryStub(aTable, aHdr);
}

Here is the call graph for this function:

Definition at line 67 of file nsContentSupportMap.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsContentSupportMap::Get ( nsIContent aElement,
nsTemplateMatch **  aMatch 
) [inline]

Definition at line 75 of file nsContentSupportMap.h.

                                                               {
        if (!mMap.ops)
            return PR_FALSE;

        PLDHashEntryHdr* hdr = PL_DHashTableOperate(&mMap, aElement, PL_DHASH_LOOKUP);
        if (PL_DHASH_ENTRY_IS_FREE(hdr))
            return PR_FALSE;

        Entry* entry = NS_REINTERPRET_CAST(Entry*, hdr);
        *aMatch = entry->mMatch;
        return PR_TRUE; }

Here is the call graph for this function:

Here is the caller graph for this function:

void nsContentSupportMap::Init ( void  ) [protected]

Definition at line 60 of file nsContentSupportMap.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsContentSupportMap::Put ( nsIContent aElement,
nsTemplateMatch aMatch 
) [inline]

Definition at line 61 of file nsContentSupportMap.h.

                                                                {
        if (!mMap.ops)
            return NS_ERROR_NOT_INITIALIZED;

        PLDHashEntryHdr* hdr = PL_DHashTableOperate(&mMap, aElement, PL_DHASH_ADD);
        if (!hdr)
            return NS_ERROR_OUT_OF_MEMORY;

        Entry* entry = NS_REINTERPRET_CAST(Entry*, hdr);
        NS_ASSERTION(entry->mMatch == nsnull, "over-writing entry");
        entry->mContent = aElement;
        entry->mMatch   = aMatch;
        return NS_OK; }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 74 of file nsContentSupportMap.cpp.

{
    if (!mMap.ops)
        return NS_ERROR_NOT_INITIALIZED;

    PL_DHashTableOperate(&mMap, aElement, PL_DHASH_REMOVE);

    PRUint32 count;

    // If possible, use the special nsXULElement interface to "peek"
    // at the child count without accidentally creating children as a
    // side effect, since we're about to rip 'em outta the map anyway.
    nsXULElement *xulcontent = nsXULElement::FromContent(aElement);
    if (xulcontent) {
        count = xulcontent->PeekChildCount();
    }
    else {
        count = aElement->GetChildCount();
    }

    for (PRUint32 i = 0; i < count; ++i) {
        Remove(aElement->GetChildAt(i));
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 92 of file nsContentSupportMap.h.


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