Back to index

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

Maintains the set of active matches, and the stuff that the matches depend on. More...

#include <nsConflictSet.h>

Collaboration diagram for nsConflictSet:
Collaboration graph
[legend]

List of all members.

Classes

class  BindingEntry
class  ClusterEntry
class  MatchCluster
 A ``cluster'' of matches, all with the same nsClusterKey (that is, matches with the same <container, member> tuple). More...
class  SupportEntry

Public Member Functions

 nsConflictSet ()
 ~nsConflictSet ()
nsresult Add (nsTemplateMatch *aMatch)
 Add a match to the conflict set.
MatchClusterGetMatchesForClusterKey (const nsClusterKey &aKey)
 Given a cluster key, which is a container-member pair, return the set of matches that are currently "active" for that cluster.
nsTemplateMatchGetMatchWithHighestPriority (const MatchCluster *aMatchCluster) const
 Retrieve the match from the set with the ``highest priority'' (that is, the lowest value returned by nsTemplateMatch::GetPriority()).
const nsTemplateMatchRefSetGetMatchesWithBindingDependency (nsIRDFResource *aSource)
 Given a "source" in the RDF graph, return the set of matches that currently depend on the source in some way.
void Remove (const MemoryElement &aMemoryElement, nsTemplateMatchSet &aNewMatches, nsTemplateMatchSet &aRetractedMatches)
 Remove a memory element from the conflict set.
nsresult AddBindingDependency (nsTemplateMatch *aMatch, nsIRDFResource *aResource)
 Add a binding dependency for aMatch on aResource.
nsresult RemoveBindingDependency (nsTemplateMatch *aMatch, nsIRDFResource *aResource)
 Remove the binding dependency on aResource from aMatch.
void Clear ()
 Remove all match support information currently stored in the conflict set, and re-initialize the set.
nsFixedSizeAllocator & GetPool ()
 Get the fixed-size arena allocator used by the conflict set.

Protected Member Functions

nsresult Init ()
nsresult Destroy ()
nsresult ComputeNewMatches (nsTemplateMatchSet &aNewMatches, nsTemplateMatchSet &aRetractedMatches)

Static Protected Member Functions

static void *PR_CALLBACK AllocClusterTable (void *aPool, PRSize aSize)
static void PR_CALLBACK FreeClusterTable (void *aPool, void *aItem)
static PLHashEntry *PR_CALLBACK AllocClusterEntry (void *aPool, const void *aKey)
static void PR_CALLBACK FreeClusterEntry (void *aPool, PLHashEntry *aHashEntry, PRUintn aFlag)
static void *PR_CALLBACK AllocSupportTable (void *aPool, PRSize aSize)
static void PR_CALLBACK FreeSupportTable (void *aPool, void *aItem)
static PLHashEntry *PR_CALLBACK AllocSupportEntry (void *aPool, const void *aKey)
static void PR_CALLBACK FreeSupportEntry (void *aPool, PLHashEntry *aHashEntry, PRUintn aFlag)
static PLHashNumber PR_CALLBACK HashMemoryElement (const void *aBinding)
static PRIntn PR_CALLBACK CompareMemoryElements (const void *aLeft, const void *aRight)
static void *PR_CALLBACK AllocBindingTable (void *aPool, PRSize aSize)
static void PR_CALLBACK FreeBindingTable (void *aPool, void *aItem)
static PLHashEntry *PR_CALLBACK AllocBindingEntry (void *aPool, const void *aKey)
static void PR_CALLBACK FreeBindingEntry (void *aPool, PLHashEntry *aHashEntry, PRUintn aFlag)
static PLHashNumber PR_CALLBACK HashBindingElement (const void *aSupport)
static PRIntn PR_CALLBACK CompareBindingElements (const void *aLeft, const void *aRight)

Protected Attributes

PLHashTablemClusters
 "Clusters" of matched rules for the same <content, member> pair.
PLHashTablemSupport
 Maps a MemoryElement to the nsTemplateMatch objects that it supports.
PLHashTablemBindingDependencies
 Maps a MemoryElement to the nsTemplateMatch objects whose bindings it participates in.
nsFixedSizeAllocator mPool

Static Protected Attributes

static PLHashAllocOps gClusterAllocOps
static PLHashAllocOps gSupportAllocOps
static PLHashAllocOps gBindingAllocOps

Detailed Description

Maintains the set of active matches, and the stuff that the matches depend on.

An entity-relationship diagram of the situation might look something like this:

                    nsIRDFResource objects
                    (mBindingDependencies)
                             |
                             | [1]
                             | 
                 [2]         ^         [3]

Match ``clusters'' ---< nsTemplateMatch >--- MemoryElement objects (mClusters) objects (mSupport)

[1] Each match object may ``depend'' on one or more RDF resources; that is, if an assertion about a resource changes, will the match's bindings need to be updated? By maintaing a map from nsIRDFResource objects to match objects, we can quickly determine which matches will be affected when the datasource notifies us of new assertions about a resource.

The AddBindingDependency() and RemoveBindingDependency() methods are used to add and remove dependencies from an nsIRDFResource object to a match. The GetMatchesWithBindingDependency() method is used to retrieve the matches that depend upon a particular nsIRDFResource object.

[2] Each match is a ``grouped' by into a cluster for conflict resolution. If the template has more than one rule, then it's possible that more than one of the rules may match. If that's the case, we need to choose amongst the matched rules to select which one gets activated''. By maintaining a map from cluster key'' (really just a <container, member> tuple) to the set of matches that are active for that key, we can quickly select amongst the matches to determine which one should be activated.

When a match is first added to the conflict set using the Add() method, it is automatically placed in the appropriate group. The GetMatchesForClusterKey() method is used to retrieve all the active matches in a match cluster; the GetMatchWithHighestPriority() method is used to select among these to determine which match should be activated.

[3] Each match is ``supported'' by one or more MemoryElement objects. These objects represent the values that were bound to variables in the match's rule's conditions. If one of these MemoryElements is removed, then the match is no longer valid. We maintain a mapping from memory elements to the matches that they support so that we can quickly determine which matches will be affected by the removal of a memory element object.

When a match is first added to the conflict set using the Add() method, the memory element dependencies are automatically computed. The Remove() method is used to notify the conflict set that a memory element has been removed; the method computes the matches that have been ``retracted'' because the memory element is gone, as well as any new matches that may have ``fired'' because they were blocked by the presence of the memory element.

Definition at line 111 of file nsConflictSet.h.


Constructor & Destructor Documentation

Definition at line 126 of file nsConflictSet.h.

Here is the call graph for this function:

Definition at line 133 of file nsConflictSet.h.

Here is the call graph for this function:


Member Function Documentation

Add a match to the conflict set.

Parameters:
aMatchthe match to add to the conflict set
Returns:
NS_OK if no errors occurred

Definition at line 120 of file nsConflictSet.cpp.

{
    // Add a match to the conflict set. This involves adding it to
    // the cluster table, the support table, and the binding table.

    // add the match to a table indexed by instantiation key
    {
        nsClusterKey key(aMatch->mInstantiation, aMatch->mRule);

        PLHashNumber hash = key.Hash();
        PLHashEntry** hep = PL_HashTableRawLookup(mClusters, hash, &key);

        MatchCluster* cluster;

        if (hep && *hep) {
            cluster = NS_REINTERPRET_CAST(MatchCluster*, (*hep)->value);
        }
        else {
            PLHashEntry* he = PL_HashTableRawAdd(mClusters, hep, hash, &key, nsnull);
            if (! he)
                return NS_ERROR_OUT_OF_MEMORY;

            ClusterEntry* entry = NS_REINTERPRET_CAST(ClusterEntry*, he);

            // Fixup the key in the hashentry to point to the value
            // that the specially-allocated entry contains (rather
            // than the value on the stack). Do the same for its
            // value.
            entry->mHashEntry.key   = &entry->mKey;
            entry->mHashEntry.value = cluster = &entry->mCluster;
        }

        nsTemplateMatchRefSet& set = cluster->mMatches;
        if (! set.Contains(aMatch))
            set.Add(aMatch);
    }


    // Add the match to a table indexed by supporting MemoryElement
    {
        MemoryElementSet::ConstIterator last = aMatch->mInstantiation.mSupport.Last();
        for (MemoryElementSet::ConstIterator element = aMatch->mInstantiation.mSupport.First(); element != last; ++element) {
            PLHashNumber hash = element->Hash();
            PLHashEntry** hep = PL_HashTableRawLookup(mSupport, hash, element.operator->());

            nsTemplateMatchRefSet* set;

            if (hep && *hep) {
                set = NS_STATIC_CAST(nsTemplateMatchRefSet*, (*hep)->value);
            }
            else {
                PLHashEntry* he = PL_HashTableRawAdd(mSupport, hep, hash, element.operator->(), nsnull);

                SupportEntry* entry = NS_REINTERPRET_CAST(SupportEntry*, he);
                if (! entry)
                    return NS_ERROR_OUT_OF_MEMORY;

                // Fixup the key and value.
                entry->mHashEntry.key   = entry->mElement;
                entry->mHashEntry.value = &entry->mMatchSet;

                set = &entry->mMatchSet;
            }

            if (! set->Contains(aMatch)) {
                set->Add(aMatch);
                aMatch->AddRef();
            }
        }
    }

    // Add the match to a table indexed by bound MemoryElement
    nsResourceSet::ConstIterator last = aMatch->mBindingDependencies.Last();
    for (nsResourceSet::ConstIterator dep = aMatch->mBindingDependencies.First(); dep != last; ++dep)
        AddBindingDependency(aMatch, *dep);

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Add a binding dependency for aMatch on aResource.

Definition at line 282 of file nsConflictSet.cpp.

{
    // Note a match's dependency on a source resource
    PLHashNumber hash = HashBindingElement(aResource);
    PLHashEntry** hep = PL_HashTableRawLookup(mBindingDependencies, hash, aResource);

    nsTemplateMatchRefSet* set;

    if (hep && *hep) {
        set = NS_STATIC_CAST(nsTemplateMatchRefSet*, (*hep)->value);
    }
    else {
        PLHashEntry* he = PL_HashTableRawAdd(mBindingDependencies, hep, hash, aResource, nsnull);

        BindingEntry* entry = NS_REINTERPRET_CAST(BindingEntry*, he);
        if (! entry)
            return NS_ERROR_OUT_OF_MEMORY;

        // Fixup the value.
        entry->mHashEntry.value = set = &entry->mMatchSet;
        
    }

    if (! set->Contains(aMatch))
        set->Add(aMatch);

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PLHashEntry* PR_CALLBACK nsConflictSet::AllocBindingEntry ( void aPool,
const void aKey 
) [inline, static, protected]

Definition at line 387 of file nsConflictSet.h.

                                                                                     {
        nsFixedSizeAllocator* pool = NS_STATIC_CAST(nsFixedSizeAllocator*, aPool);

        BindingEntry* entry = BindingEntry::Create(*pool);
        if (! entry)
            return nsnull;

        nsIRDFResource* key = NS_STATIC_CAST(nsIRDFResource*, NS_CONST_CAST(void*, aKey));
        NS_ADDREF(key);

        return NS_REINTERPRET_CAST(PLHashEntry*, entry); }

Here is the call graph for this function:

static void* PR_CALLBACK nsConflictSet::AllocBindingTable ( void aPool,
PRSize  aSize 
) [inline, static, protected]

Definition at line 381 of file nsConflictSet.h.

                                                                          {
        return new char[aSize]; }
static PLHashEntry* PR_CALLBACK nsConflictSet::AllocClusterEntry ( void aPool,
const void aKey 
) [inline, static, protected]

Definition at line 263 of file nsConflictSet.h.

                                                                                     {
        nsFixedSizeAllocator* pool = NS_STATIC_CAST(nsFixedSizeAllocator*, aPool);

        ClusterEntry* entry = ClusterEntry::Create(*pool);
        if (! entry)
            return nsnull;

        entry->mKey = *NS_STATIC_CAST(const nsClusterKey*, aKey);
        return NS_REINTERPRET_CAST(PLHashEntry*, entry); }

Here is the call graph for this function:

static void* PR_CALLBACK nsConflictSet::AllocClusterTable ( void aPool,
PRSize  aSize 
) [inline, static, protected]

Definition at line 257 of file nsConflictSet.h.

                                                                          {
        return new char[aSize]; }
static PLHashEntry* PR_CALLBACK nsConflictSet::AllocSupportEntry ( void aPool,
const void aKey 
) [inline, static, protected]

Definition at line 323 of file nsConflictSet.h.

                                                                                     {
        nsFixedSizeAllocator* pool = NS_STATIC_CAST(nsFixedSizeAllocator*, aPool);

        SupportEntry* entry = SupportEntry::Create(*pool);
        if (! entry)
            return nsnull;

        const MemoryElement* element = NS_STATIC_CAST(const MemoryElement*, aKey);
        entry->mElement = element->Clone(aPool);

        return NS_REINTERPRET_CAST(PLHashEntry*, entry); }

Here is the call graph for this function:

static void* PR_CALLBACK nsConflictSet::AllocSupportTable ( void aPool,
PRSize  aSize 
) [inline, static, protected]

Definition at line 317 of file nsConflictSet.h.

                                                                          {
        return new char[aSize]; }

Remove all match support information currently stored in the conflict set, and re-initialize the set.

Definition at line 378 of file nsConflictSet.cpp.

{
    Destroy();
    Init();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRIntn PR_CALLBACK nsConflictSet::CompareBindingElements ( const void aLeft,
const void aRight 
) [inline, static, protected]

Definition at line 410 of file nsConflictSet.h.

                                                                                            {
        return aLeft == aRight; }

Here is the caller graph for this function:

PRIntn PR_CALLBACK nsConflictSet::CompareMemoryElements ( const void aLeft,
const void aRight 
) [static, protected]

Definition at line 394 of file nsConflictSet.cpp.

{
    const MemoryElement* left =
        NS_STATIC_CAST(const MemoryElement*, aLeft);

    const MemoryElement* right =
        NS_STATIC_CAST(const MemoryElement*, aRight);

    return *left == *right;
}

Here is the caller graph for this function:

nsresult nsConflictSet::ComputeNewMatches ( nsTemplateMatchSet aNewMatches,
nsTemplateMatchSet aRetractedMatches 
) [protected]

Definition at line 331 of file nsConflictSet.cpp.

{
    // Given a set of just-retracted matches, compute the set of new
    // matches that have been revealed, updating the key-to-match map
    // as we go.
    nsTemplateMatchSet::ConstIterator last = aRetractedMatches.Last();
    for (nsTemplateMatchSet::ConstIterator retraction = aRetractedMatches.First();
         retraction != last;
         ++retraction) {
        nsClusterKey key(retraction->mInstantiation, retraction->mRule);
        PLHashEntry** hep = PL_HashTableRawLookup(mClusters, key.Hash(), &key);

        // XXXwaterson I'd managed to convince myself that this was really
        // okay, but now I can't remember why.
        //NS_ASSERTION(hep && *hep, "mClusters corrupted");
        if (!hep || !*hep)
            continue;

        MatchCluster* cluster = NS_REINTERPRET_CAST(MatchCluster*, (*hep)->value);
        nsTemplateMatchRefSet& set = cluster->mMatches;

        nsTemplateMatchRefSet::ConstIterator last = set.Last();
        for (nsTemplateMatchRefSet::ConstIterator match = set.First(); match != last; ++match) {
            if (match->mRule == retraction->mRule) {
                set.Remove(match.operator->()); // N.B., iterator no longer valid!

                // See if we've revealed another rule that's applicable
                nsTemplateMatch* newmatch =
                    GetMatchWithHighestPriority(cluster);

                if (newmatch)
                    aNewMatches.Add(newmatch);

                break;
            }
        }

        if (set.Empty())
            PL_HashTableRawRemove(mClusters, hep, *hep);
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 111 of file nsConflictSet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void PR_CALLBACK nsConflictSet::FreeBindingEntry ( void aPool,
PLHashEntry aHashEntry,
PRUintn  aFlag 
) [inline, static, protected]

Definition at line 399 of file nsConflictSet.h.

                                                                                                  {
        if (aFlag == HT_FREE_ENTRY) {
            nsIRDFResource* key = NS_STATIC_CAST(nsIRDFResource*, NS_CONST_CAST(void*, aHashEntry->key));
            NS_RELEASE(key);
            nsFixedSizeAllocator* pool = NS_STATIC_CAST(nsFixedSizeAllocator*, aPool);
            BindingEntry::Destroy(*pool, NS_REINTERPRET_CAST(BindingEntry*, aHashEntry));
        } }

Here is the call graph for this function:

static void PR_CALLBACK nsConflictSet::FreeBindingTable ( void aPool,
void aItem 
) [inline, static, protected]

Definition at line 384 of file nsConflictSet.h.

                                                                       {
        delete[] NS_STATIC_CAST(char*, aItem); }
static void PR_CALLBACK nsConflictSet::FreeClusterEntry ( void aPool,
PLHashEntry aHashEntry,
PRUintn  aFlag 
) [inline, static, protected]

Definition at line 273 of file nsConflictSet.h.

                                                                                                  {
        nsFixedSizeAllocator* pool = NS_STATIC_CAST(nsFixedSizeAllocator*, aPool);
        if (aFlag == HT_FREE_ENTRY)
            ClusterEntry::Destroy(*pool, NS_REINTERPRET_CAST(ClusterEntry*, aHashEntry)); }

Here is the call graph for this function:

static void PR_CALLBACK nsConflictSet::FreeClusterTable ( void aPool,
void aItem 
) [inline, static, protected]

Definition at line 260 of file nsConflictSet.h.

                                                                       {
        delete[] NS_STATIC_CAST(char*, aItem); }
static void PR_CALLBACK nsConflictSet::FreeSupportEntry ( void aPool,
PLHashEntry aHashEntry,
PRUintn  aFlag 
) [inline, static, protected]

Definition at line 335 of file nsConflictSet.h.

                                                                                                  {
        nsFixedSizeAllocator* pool = NS_STATIC_CAST(nsFixedSizeAllocator*, aPool);
        if (aFlag == HT_FREE_ENTRY)
            SupportEntry::Destroy(*pool, NS_REINTERPRET_CAST(SupportEntry*, aHashEntry)); }

Here is the call graph for this function:

static void PR_CALLBACK nsConflictSet::FreeSupportTable ( void aPool,
void aItem 
) [inline, static, protected]

Definition at line 320 of file nsConflictSet.h.

                                                                       {
        delete[] NS_STATIC_CAST(char*, aItem); }

Given a cluster key, which is a container-member pair, return the set of matches that are currently "active" for that cluster.

(The caller can the select among the active rules to determine which should actually be applied.)

Parameters:
aKeythe cluster key to search for
aMatchSetthe set of matches that are currently active for the key.

Definition at line 201 of file nsConflictSet.cpp.

{
    // Retrieve all the matches in a cluster
    return NS_STATIC_CAST(MatchCluster*, PL_HashTableLookup(mClusters, &aKey));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Given a "source" in the RDF graph, return the set of matches that currently depend on the source in some way.

Parameters:
aSourcean RDF resource that is a "source" in the graph.
aMatchSetthe set of matches that depend on aSource.

Definition at line 235 of file nsConflictSet.cpp.

{
    // Retrieve all the matches whose bindings depend on the specified resource
    return NS_STATIC_CAST(nsTemplateMatchRefSet*, PL_HashTableLookup(mBindingDependencies, aResource));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Retrieve the match from the set with the ``highest priority'' (that is, the lowest value returned by nsTemplateMatch::GetPriority()).

Definition at line 209 of file nsConflictSet.cpp.

{
    // Find the rule with the "highest priority"; i.e., the rule with
    // the lowest value for GetPriority().
    //
    // XXX if people start writing more than a few matches, we should
    // rewrite this to maintain the matches in sorted order, and then
    // just pluck the match off the top of the list.
    nsTemplateMatch* result = nsnull;
    PRInt32 max = PRInt32(PR_BIT(31) - 1);

    const nsTemplateMatchRefSet& set = aMatchCluster->mMatches;
    nsTemplateMatchRefSet::ConstIterator last = set.Last();

    for (nsTemplateMatchRefSet::ConstIterator match = set.First(); match != last; ++match) {
        PRInt32 priority = match->mRule->GetPriority();
        if (priority < max) {
            result = NS_CONST_CAST(nsTemplateMatch*, match.operator->());
            max = priority;
        }
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsFixedSizeAllocator& nsConflictSet::GetPool ( ) [inline]

Get the fixed-size arena allocator used by the conflict set.

Returns:
the fixed-size arena allocator used by the conflict set

Definition at line 211 of file nsConflictSet.h.

{ return mPool; }

Here is the caller graph for this function:

static PLHashNumber PR_CALLBACK nsConflictSet::HashBindingElement ( const void aSupport) [inline, static, protected]

Definition at line 407 of file nsConflictSet.h.

                                                                             {
        return PLHashNumber(NS_PTR_TO_INT32(aSupport)) >> 3; }

Here is the caller graph for this function:

Definition at line 385 of file nsConflictSet.cpp.

{
    const MemoryElement* element =
        NS_STATIC_CAST(const MemoryElement*, aMemoryElement);

    return element->Hash();
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsConflictSet::Init ( void  ) [protected]

Definition at line 60 of file nsConflictSet.cpp.

{
#ifdef PR_LOGGING
    if (! gLog)
        gLog = PR_NewLogModule("nsConflictSet");
#endif

    static const size_t kBucketSizes[] = {
        sizeof(ClusterEntry),
        sizeof(SupportEntry),
        sizeof(BindingEntry),
    };

    static const PRInt32 kNumBuckets = sizeof(kBucketSizes) / sizeof(size_t);

    static const PRInt32 kNumResourceElements = 64;

    // Per news://news.mozilla.org/39BEC105.5090206%40netscape.com
    static const PRInt32 kInitialSize = 256;

    mPool.Init("nsConflictSet", kBucketSizes, kNumBuckets, kInitialSize);

    mClusters =
        PL_NewHashTable(kNumResourceElements /* XXXwaterson we need a way to give a hint? */,
                        nsClusterKey::HashClusterKey,
                        nsClusterKey::CompareClusterKeys,
                        PL_CompareValues,
                        &gClusterAllocOps,
                        &mPool);

    mSupport =
        PL_NewHashTable(kNumResourceElements, /* XXXwaterson need hint */
                        HashMemoryElement,
                        CompareMemoryElements,
                        PL_CompareValues,
                        &gSupportAllocOps,
                        &mPool);

    mBindingDependencies =
        PL_NewHashTable(kNumResourceElements /* XXX arbitrary */,
                        HashBindingElement,
                        CompareBindingElements,
                        PL_CompareValues,
                        &gBindingAllocOps,
                        &mPool);

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsConflictSet::Remove ( const MemoryElement aMemoryElement,
nsTemplateMatchSet aNewMatches,
nsTemplateMatchSet aRetractedMatches 
)

Remove a memory element from the conflict set.

This may potentially retract matches that depended on the memory element, as well as trigger previously masked matches that are now "revealed".

Parameters:
aMemoryElementthe memory element that is being removed.
aNewMatchesnew matches that have been revealed.
aRetractedMatchesmatches whose validity depended on aMemoryElement and have been retracted.

Definition at line 243 of file nsConflictSet.cpp.

{
    // Use the memory-element-to-match map to figure out what matches
    // will be affected.
    PLHashEntry** hep = PL_HashTableRawLookup(mSupport, aMemoryElement.Hash(), &aMemoryElement);

    if (!hep || !*hep)
        return;

    // 'set' gets the set of all matches containing the first binding.
    nsTemplateMatchRefSet* set =
        NS_STATIC_CAST(nsTemplateMatchRefSet*, (*hep)->value);

    // We'll iterate through these matches, only paying attention to
    // matches that strictly contain the MemoryElement we're about to
    // remove.
    nsTemplateMatchRefSet::ConstIterator last = set->Last();
    for (nsTemplateMatchRefSet::ConstIterator match = set->First(); match != last; ++match) {
        // Note the retraction, so we can compute new matches, later.
        aRetractedMatches.Add(match.operator->());

        // Keep the bindings table in sync, as well. Since this match
        // is getting nuked, we need to nuke its bindings as well.
        nsResourceSet::ConstIterator last = match->mBindingDependencies.Last();
        for (nsResourceSet::ConstIterator dep = match->mBindingDependencies.First(); dep != last; ++dep)
            RemoveBindingDependency(match.operator->(), *dep);
    }

    // Unhash it
    PL_HashTableRawRemove(mSupport, hep, *hep);

    // Update the key-to-match map, and see if any new rules have been
    // fired as a result of the retraction.
    ComputeNewMatches(aNewMatches, aRetractedMatches);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Remove the binding dependency on aResource from aMatch.

Definition at line 312 of file nsConflictSet.cpp.

{
    // Remove a match's dependency on a source resource
    PLHashNumber hash = HashBindingElement(aResource);
    PLHashEntry** hep = PL_HashTableRawLookup(mBindingDependencies, hash, aResource);

    if (hep && *hep) {
        nsTemplateMatchRefSet* set = NS_STATIC_CAST(nsTemplateMatchRefSet*, (*hep)->value);

        set->Remove(aMatch);

        if (set->Empty())
            PL_HashTableRawRemove(mBindingDependencies, hep, *hep);
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Initial value:

Definition at line 379 of file nsConflictSet.h.

Initial value:

Definition at line 255 of file nsConflictSet.h.

Initial value:

Definition at line 315 of file nsConflictSet.h.

Maps a MemoryElement to the nsTemplateMatch objects whose bindings it participates in.

This makes it possible to efficiently update a match when a binding changes.

Definition at line 349 of file nsConflictSet.h.

"Clusters" of matched rules for the same <content, member> pair.

This table makes it O(1) to lookup all of the matches that are active for a cluster, so determining which is active is efficient.

Definition at line 227 of file nsConflictSet.h.

nsFixedSizeAllocator nsConflictSet::mPool [protected]

Definition at line 414 of file nsConflictSet.h.

Maps a MemoryElement to the nsTemplateMatch objects that it supports.

This map allows us to efficiently remove matches from the conflict set when a MemoryElement is removed. Conceptually, a support element is what ``owns'' the match.

Definition at line 284 of file nsConflictSet.h.


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