SynchronizeMatch(match.operator->(), modified);
Value parentValue; match->mAssignments.GetAssignmentFor(mContentVar, &parentValue);  nsIContent* parent = VALUE_TO_ICONTENT(parentValue);    nsCOMPtr<nsISupportsArray> elements; rv = NS_NewISupportsArray(getter_AddRefs(elements)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create new ISupportsArray"); if (NS_FAILED(rv)) return rv;  rv = GetElementsForResource(resource, elements); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource"); if (NS_FAILED(rv)) return rv;  PRUint32 cnt; rv = elements->Count(&cnt); if (NS_FAILED(rv)) return rv;  #ifdef PR_LOGGING if (PR_LOG_TEST(gLog, PR_LOG_DEBUG) && cnt == 0) { const char* uri; resource->GetValueConst(&uri);  PR_LOG(gLog, PR_LOG_DEBUG, ("xultemplate[%p] synchronize-all [%s] is not in element map", this, uri)); } #endif  for (PRInt32 i = PRInt32(cnt) - 1; i >= 0; --i) { nsISupports* isupports = elements->ElementAt(i); nsCOMPtr<nsIContent> element( do_QueryInterface(isupports) ); NS_IF_RELEASE(isupports);    if (! IsElementContainedBy(element, parent)) continue;  nsAutoString templateID; rv = element->GetAttribute(kNameSpaceID_None, nsXULAtoms::Template, templateID); if (NS_FAILED(rv)) return rv;  if (rv != NS_CONTENT_ATTR_HAS_VALUE) continue;  nsCOMPtr<nsIDOMXULDocument>    xulDoc; xulDoc = do_QueryInterface(mDocument); if (! xulDoc) return NS_ERROR_UNEXPECTED;  nsCOMPtr<nsIDOMElement>    domElement; rv = xulDoc->GetElementById(templateID, getter_AddRefs(domElement)); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find template node"); if (NS_FAILED(rv)) return rv;  nsCOMPtr<nsIContent> templateNode = do_QueryInterface(domElement); if (! templateNode) return NS_ERROR_UNEXPECTED;   rv = SynchronizeUsingTemplate(templateNode, element, rule, modified); if (NS_FAILED(rv)) return rv; }  #ifdef PR_LOGGING if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) { const char* uri; resource->GetValueConst(&uri);  PR_LOG(gLog, PR_LOG_DEBUG, ("xultemplate[%p] synchronize-all [%s] end", this, uri)); } #endif
nsXULTemplateBuilder::SynchronizeAll(nsIRDFResource* aSource,                                     nsIRDFResource* aProperty,                                     nsIRDFNode* aOldTarget,                                     nsIRDFNode* aNewTarget){    // Update each match that contains <aSource, aProperty, aOldTarget>.    // Get all the matches whose assignments are currently supported    // by aSource and aProperty: we'll need to recompute them.    const nsTemplateMatchRefSet* matches =        mConflictSet.GetMatchesWithBindingDependency(aSource);    if (! matches || matches->Empty())        return NS_OK;    // Since we'll actually be manipulating the match set as we    // iterate through it, we need to copy it into our own private    // area before performing the iteration.    nsTemplateMatchRefSet copy = *matches;    nsTemplateMatchRefSet::ConstIterator last = copy.Last();    for (nsTemplateMatchRefSet::ConstIterator match = copy.First(); match != last; ++match) {        const nsTemplateRule* rule = match->mRule;        // Recompute the assignments. This will replace aOldTarget with        // aNewTarget, which will disrupt the match set.        VariableSet modified;        rule->RecomputeBindings(mConflictSet, match.operator->(),                                aSource, aProperty, aOldTarget, aNewTarget,                                modified);        // If nothing changed, then continue on to the next match.        if (0 == modified.GetCount())            continue;#ifdef PR_LOGGING        PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,               ("xultemplate[%p] match %p, %d modified binding(s)",                this, match.operator->(), modified.GetCount()));        for (PRInt32 i = 0; i < modified.GetCount(); ++i) {            PRInt32 var = modified.GetVariableAt(i);            Value val;            match->GetAssignmentFor(mConflictSet, var, &val);            nsCAutoString str;            val.ToCString(str);            PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,                   ("xultemplate[%p]   %d <= %s", this, var, str.get()));        }#endif        SynchronizeMatch(match.operator->(), modified);    }    return NS_OK;}