searchQuery query; FindUrlToSearchQuery(uri, query);  nsCOMPtr<nsIMdbRow> row; rv = FindRow(kToken_URLColumn, uri, getter_AddRefs(row));  if (NS_FAILED(rv) || HasCell(mEnv, row, kToken_HiddenColumn)) { *aHasAssertion = PR_FALSE; return NS_OK; }  *aHasAssertion = RowMatches(row, &query); FreeSearchQuery(query); return NS_OK; }
while (1) { PRBool hasMore; rv = targets->HasMoreElements(&hasMore); if (NS_FAILED(rv)) return rv;
nsGlobalHistory::HasAssertion(nsIRDFResource* aSource,                              nsIRDFResource* aProperty,                              nsIRDFNode* aTarget,                              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) {    *aHasAssertion = PR_FALSE;    return NS_OK;  }  nsresult rv;    // answer if a specific row matches a find URI  //   // at some point, we should probably match groupby= findURIs with  // findURIs that match all their criteria  //  nsCOMPtr<nsIRDFResource> target = do_QueryInterface(aTarget);  if (target &&      aProperty == kNC_child &&      IsFindResource(aSource) &&      !IsFindResource(target)) {    const char *uri;    rv = target->GetValueConst(&uri);    if (NS_FAILED(rv)) return rv;    searchQuery query;    FindUrlToSearchQuery(uri, query);        nsCOMPtr<nsIMdbRow> row;    rv = FindRow(kToken_URLColumn, uri, getter_AddRefs(row));    // not even in history. don't bother trying    if (NS_FAILED(rv) || HasCell(mEnv, row, kToken_HiddenColumn)) {      *aHasAssertion = PR_FALSE;      return NS_OK;    }        *aHasAssertion = RowMatches(row, &query);    FreeSearchQuery(query);    return NS_OK;  }    // Do |GetTargets()| and grovel through the results to see if we  // have the assertion.  //  // XXX *AHEM*, this could be implemented much more efficiently...  nsCOMPtr<nsISimpleEnumerator> targets;  rv = GetTargets(aSource, aProperty, aTruthValue, getter_AddRefs(targets));  if (NS_FAILED(rv)) return rv;    while (1) {    PRBool hasMore;    rv = targets->HasMoreElements(&hasMore);    if (NS_FAILED(rv)) return rv;        if (! hasMore)      break;        nsCOMPtr<nsISupports> isupports;    rv = targets->GetNext(getter_AddRefs(isupports));    if (NS_FAILED(rv)) return rv;        nsCOMPtr<nsIRDFNode> node = do_QueryInterface(isupports);    if (node.get() == aTarget) {      *aHasAssertion = PR_TRUE;      return NS_OK;    }  }  *aHasAssertion = PR_FALSE;  return NS_OK;}