Make sure we can handle queries for -negative- assertions. (Failure to do so was causing history title's not to show up.)

This commit is contained in:
waterson%netscape.com 2000-01-11 05:08:30 +00:00
parent 4331ad7aba
commit 89e0ac5f08

View File

@ -1068,8 +1068,14 @@ nsGlobalHistory::GetTarget(nsIRDFResource* aSource,
return NS_ERROR_NULL_POINTER;
nsresult rv;
// Initialize return value.
*aTarget = nsnull;
// Only "positive" assertions here.
if (! aTruthValue)
return NS_RDF_NO_VALUE;
if ((aSource == kNC_HistoryRoot) && (aProperty == kNC_child)) {
// If they're asking for all the children of the HistoryRoot, call
// through to GetTargets() and return the first one.
@ -1204,6 +1210,7 @@ nsGlobalHistory::GetTargets(nsIRDFResource* aSource,
if (! aProperty)
return NS_ERROR_NULL_POINTER;
if (aTruthValue) {
if ((aSource == kNC_HistoryRoot) && (aProperty == kNC_child) && (aTruthValue)) {
URLEnumerator* result = new URLEnumerator(kToken_URLColumn);
if (! result)
@ -1231,6 +1238,7 @@ nsGlobalHistory::GetTargets(nsIRDFResource* aSource,
return NS_NewSingletonEnumerator(aTargets, target);
}
}
}
return NS_NewEmptyEnumerator(aTargets);
}
@ -1279,6 +1287,24 @@ nsGlobalHistory::HasAssertion(nsIRDFResource* aSource,
PRBool aTruthValue,
PRBool* aHasAssertion)
{
NS_PRECONDITION(aSource != nsnull, "null ptr");
if (! aSource)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aProperty != nsnull, "null ptr");
if (! aProperty)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aTarget != nsnull, "null ptr");
if (! aTarget)
return NS_ERROR_NULL_POINTER;
// Only "positive" assertions here.
if (aTruthValue) {
// Do |GetTargets()| and grovel through the results to see if we
// have the assertion.
//
// XXX *AHEM*, this could be implemented much more efficiently...
nsresult rv;
nsCOMPtr<nsISimpleEnumerator> targets;
@ -1303,6 +1329,7 @@ nsGlobalHistory::HasAssertion(nsIRDFResource* aSource,
return NS_OK;
}
}
}
*aHasAssertion = PR_FALSE;
return NS_OK;