mRules.GetRoot()->Propogate(instantiations, &newkeys);
mRules.GetRoot()->Propagate(instantiations, &newkeys);
nsXULOutlinerBuilder::OpenSubtreeOf(nsOutlinerRows::Subtree* aSubtree,                                    nsIRDFResource* aContainer,                                    PRInt32* aDelta){    Instantiation seed;    seed.AddAssignment(mContainerVar, Value(aContainer));#ifdef PR_LOGGING    static PRInt32 gNest;    nsCAutoString space;    {        for (PRInt32 i = 0; i < gNest; ++i)            space += "  ";    }    if (PR_LOG_TEST(gXULTemplateLog, PR_LOG_DEBUG)) {        const char* res;        aContainer->GetValueConst(&res);        PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,               ("xultemplate[%p] %sopening subtree for %s", this, space.get(), res));    }    ++gNest;#endif    InstantiationSet instantiations;    instantiations.Append(seed);    // Propogate the assignments through the network    nsClusterKeySet newkeys;    mRules.GetRoot()->Propogate(instantiations, &newkeys);    nsAutoVoidArray open;    PRInt32 count = 0;    // Iterate through newly added keys to determine which rules fired    nsClusterKeySet::ConstIterator last = newkeys.Last();    for (nsClusterKeySet::ConstIterator key = newkeys.First(); key != last; ++key) {        nsConflictSet::MatchCluster* matches =            mConflictSet.GetMatchesForClusterKey(*key);        if (! matches)            continue;        nsTemplateMatch* match =             mConflictSet.GetMatchWithHighestPriority(matches);        NS_ASSERTION(match != nsnull, "no best match in match set");        if (! match)            continue;#ifdef PR_LOGGING        PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,               ("xultemplate[%p] %smatch=%p", this, space.get(), match));#endif        // Remember that this match applied to this row        mRows.InsertRowAt(match, aSubtree, count);        // Remember this as the "last" match        matches->mLastMatch = match;        // If this is open, then remember it so we can recursively add        // *its* rows to the tree.        Value val;        match->GetAssignmentFor(mConflictSet,                                match->mRule->GetMemberVariable(),                                &val);        PRBool isOpen = PR_FALSE;        IsContainerOpen(VALUE_TO_IRDFRESOURCE(val), &isOpen);        if (isOpen)            open.AppendElement((void*) count);        ++count;    }    // Now recursively deal with any open sub-containers that just got    // inserted    for (PRInt32 i = 0; i < open.Count(); ++i) {        PRInt32 index = NS_PTR_TO_INT32(open[i]);        nsOutlinerRows::Subtree* child =            mRows.EnsureSubtreeFor(aSubtree, index);        nsTemplateMatch* match = (*aSubtree)[index].mMatch;        Value val;        match->GetAssignmentFor(mConflictSet, match->mRule->GetMemberVariable(), &val);                PRInt32 delta;        OpenSubtreeOf(child, VALUE_TO_IRDFRESOURCE(val), &delta);        count += delta;    }#ifdef PR_LOGGING    --gNest;#endif    // Sort the container.    if (mSortVariable) {        NS_QuickSort(mRows.GetRowsFor(aSubtree),                     aSubtree->Count(),                     sizeof(nsOutlinerRows::Row),                     Compare,                     this);    }    *aDelta = count;    return NS_OK;}