зеркало из 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;
|
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
|
PRBool
|
||||||
nsResourceSet::Contains(nsIRDFResource* aResource) const
|
nsResourceSet::Contains(nsIRDFResource* aResource) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
|
|
||||||
nsresult Clear();
|
nsresult Clear();
|
||||||
nsresult Add(nsIRDFResource* aProperty);
|
nsresult Add(nsIRDFResource* aProperty);
|
||||||
|
void Remove(nsIRDFResource* aProperty);
|
||||||
|
|
||||||
PRBool Contains(nsIRDFResource* aProperty) const;
|
PRBool Contains(nsIRDFResource* aProperty) const;
|
||||||
|
|
||||||
|
|
|
@ -179,8 +179,11 @@ nsTemplateRule::InitBindings(nsConflictSet& aConflictSet, nsTemplateMatch* aMatc
|
||||||
PRBool hasBinding =
|
PRBool hasBinding =
|
||||||
aMatch->mInstantiation.mAssignments.GetAssignmentFor(binding->mSourceVariable, &sourceValue);
|
aMatch->mInstantiation.mAssignments.GetAssignmentFor(binding->mSourceVariable, &sourceValue);
|
||||||
|
|
||||||
if (hasBinding)
|
if (hasBinding) {
|
||||||
aConflictSet.AddBindingDependency(aMatch, VALUE_TO_IRDFRESOURCE(sourceValue));
|
nsIRDFResource* source = VALUE_TO_IRDFRESOURCE(sourceValue);
|
||||||
|
aMatch->mBindingDependencies.Add(source);
|
||||||
|
aConflictSet.AddBindingDependency(aMatch, source);
|
||||||
|
}
|
||||||
|
|
||||||
// If this binding is dependant on another binding, then we
|
// If this binding is dependant on another binding, then we
|
||||||
// need to eagerly compute its source variable's assignment.
|
// need to eagerly compute its source variable's assignment.
|
||||||
|
@ -254,7 +257,9 @@ nsTemplateRule::RecomputeBindings(nsConflictSet& aConflictSet,
|
||||||
// The assignment's variable depends on the
|
// The assignment's variable depends on the
|
||||||
// binding's target variable, which is
|
// binding's target variable, which is
|
||||||
// changing. Rip it out.
|
// 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;
|
delete dependent;
|
||||||
assignments.RemoveElementAt(j--);
|
assignments.RemoveElementAt(j--);
|
||||||
|
@ -335,6 +340,7 @@ nsTemplateRule::ComputeAssignmentFor(nsConflictSet& aConflictSet,
|
||||||
|
|
||||||
// Add a dependency on the source, so we'll recompute the
|
// Add a dependency on the source, so we'll recompute the
|
||||||
// assignment if somebody tweaks it.
|
// assignment if somebody tweaks it.
|
||||||
|
aMatch->mBindingDependencies.Add(source);
|
||||||
aConflictSet.AddBindingDependency(aMatch, source);
|
aConflictSet.AddBindingDependency(aMatch, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1284,8 +1284,8 @@ nsXULTemplateBuilder::SynchronizeAll(nsIRDFResource* aSource,
|
||||||
|
|
||||||
#ifdef PR_LOGGING
|
#ifdef PR_LOGGING
|
||||||
PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
|
PR_LOG(gXULTemplateLog, PR_LOG_DEBUG,
|
||||||
("xultemplate[%p] %d modified binding(s)",
|
("xultemplate[%p] match %p, %d modified binding(s)",
|
||||||
this, modified.GetCount()));
|
this, match.operator->(), modified.GetCount()));
|
||||||
|
|
||||||
for (PRInt32 i = 0; i < modified.GetCount(); ++i) {
|
for (PRInt32 i = 0; i < modified.GetCount(); ++i) {
|
||||||
PRInt32 var = modified.GetVariableAt(i);
|
PRInt32 var = modified.GetVariableAt(i);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче