зеркало из https://github.com/mozilla/gecko-dev.git
Bug 103959. Maintain nsTemplateMatch::mBindingDependencies so that we don't leave dangling references in the nsConflictSet::mBindingDependencies table. r=tingley@sundell.net, sr=shaver@mozilla.org
This commit is contained in:
Родитель
f40a3018a4
Коммит
38bf272e33
|
@ -107,6 +107,28 @@ nsResourceSet::Add(nsIRDFResource* aResource)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsResourceSet::Remove(nsIRDFResource* aProperty)
|
||||
{
|
||||
PRBool found = PR_FALSE;
|
||||
|
||||
nsIRDFResource** res = mResources;
|
||||
nsIRDFResource** limit = mResources + mCount;
|
||||
while (res < limit) {
|
||||
if (found) {
|
||||
*(res - 1) = *res;
|
||||
}
|
||||
else if (*res == aProperty) {
|
||||
NS_RELEASE(*res);
|
||||
found = PR_TRUE;
|
||||
}
|
||||
++res;
|
||||
}
|
||||
|
||||
if (found)
|
||||
--mCount;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsResourceSet::Contains(nsIRDFResource* aResource) const
|
||||
{
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
|
||||
nsresult Clear();
|
||||
nsresult Add(nsIRDFResource* aProperty);
|
||||
void Remove(nsIRDFResource* aProperty);
|
||||
|
||||
PRBool Contains(nsIRDFResource* aProperty) const;
|
||||
|
||||
|
|
|
@ -179,8 +179,11 @@ nsTemplateRule::InitBindings(nsConflictSet& aConflictSet, nsTemplateMatch* aMatc
|
|||
PRBool hasBinding =
|
||||
aMatch->mInstantiation.mAssignments.GetAssignmentFor(binding->mSourceVariable, &sourceValue);
|
||||
|
||||
if (hasBinding)
|
||||
aConflictSet.AddBindingDependency(aMatch, VALUE_TO_IRDFRESOURCE(sourceValue));
|
||||
if (hasBinding) {
|
||||
nsIRDFResource* source = VALUE_TO_IRDFRESOURCE(sourceValue);
|
||||
aMatch->mBindingDependencies.Add(source);
|
||||
aConflictSet.AddBindingDependency(aMatch, source);
|
||||
}
|
||||
|
||||
// If this binding is dependant on another binding, then we
|
||||
// need to eagerly compute its source variable's assignment.
|
||||
|
@ -254,7 +257,9 @@ nsTemplateRule::RecomputeBindings(nsConflictSet& aConflictSet,
|
|||
// The assignment's variable depends on the
|
||||
// binding's target variable, which is
|
||||
// changing. Rip it out.
|
||||
aConflictSet.RemoveBindingDependency(aMatch, VALUE_TO_IRDFRESOURCE(dependent->mValue));
|
||||
nsIRDFResource* target = VALUE_TO_IRDFRESOURCE(dependent->mValue);
|
||||
aMatch->mBindingDependencies.Remove(target);
|
||||
aConflictSet.RemoveBindingDependency(aMatch, target);
|
||||
|
||||
delete dependent;
|
||||
assignments.RemoveElementAt(j--);
|
||||
|
@ -335,6 +340,7 @@ nsTemplateRule::ComputeAssignmentFor(nsConflictSet& aConflictSet,
|
|||
|
||||
// Add a dependency on the source, so we'll recompute the
|
||||
// assignment if somebody tweaks it.
|
||||
aMatch->mBindingDependencies.Add(source);
|
||||
aConflictSet.AddBindingDependency(aMatch, source);
|
||||
}
|
||||
|
||||
|
|
|
@ -1284,8 +1284,8 @@ nsXULTemplateBuilder::SynchronizeAll(nsIRDFResource* aSource,
|
|||
|
||||
#ifdef PR_LOGGING
|
||||
PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
|
||||
("xultemplate[%p] %d modified binding(s)",
|
||||
this, modified.GetCount()));
|
||||
("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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче