Stronger implementation of isBookmarked() method.

This commit is contained in:
rjc%netscape.com 2000-03-20 02:03:17 +00:00
Родитель 9e420a88b9
Коммит c2907c238c
2 изменённых файлов: 30 добавлений и 3 удалений

Просмотреть файл

@ -2683,11 +2683,38 @@ nsBookmarksService::IsBookmarked(const char *aURI, PRBool *isBookmarkedFlag)
*isBookmarkedFlag = PR_FALSE;
nsresult rv;
PRBool flag = PR_FALSE;
nsCOMPtr<nsIRDFResource> bookmark;
// check if it has the proper type
if (NS_SUCCEEDED(rv = gRDF->GetResource(aURI, getter_AddRefs(bookmark))))
{
rv = mInner->HasAssertion(bookmark, kRDF_type, kNC_Bookmark,
PR_TRUE, isBookmarkedFlag);
PR_TRUE, &flag);
}
if (flag == PR_FALSE) return(NS_OK);
// make sure it is referred to by an ordinal (i.e. is contained in a rdf seq)
nsCOMPtr<nsISimpleEnumerator> enumerator;
if (NS_FAILED(rv = mInner->ArcLabelsIn(bookmark, getter_AddRefs(enumerator))))
return(rv);
PRBool more = PR_TRUE;
while(NS_SUCCEEDED(rv = enumerator->HasMoreElements(&more))
&& (more == PR_TRUE))
{
nsCOMPtr<nsISupports> isupports;
if (NS_FAILED(rv = enumerator->GetNext(getter_AddRefs(isupports))))
break;
nsCOMPtr<nsIRDFResource> property = do_QueryInterface(isupports);
if (!property) continue;
if (NS_FAILED(rv = gRDFC->IsOrdinalProperty(property, &flag))) continue;
if (flag == PR_TRUE)
{
*isBookmarkedFlag = PR_TRUE;
break;
}
}
return(rv);
}

Просмотреть файл

@ -1804,11 +1804,11 @@ InternetSearchDataSource::RememberLastSearchText(const PRUnichar *escapedSearchS
if (NS_SUCCEEDED(rv = mInner->GetTarget(kNC_LastSearchRoot, kNC_LastText, PR_TRUE,
getter_AddRefs(textNode))) && (rv != NS_RDF_NO_VALUE))
{
Change(kNC_LastSearchRoot, kNC_LastText, textNode, textLiteral);
mInner->Change(kNC_LastSearchRoot, kNC_LastText, textNode, textLiteral);
}
else
{
Assert(kNC_LastSearchRoot, kNC_LastText, textLiteral, PR_TRUE);
mInner->Assert(kNC_LastSearchRoot, kNC_LastText, textLiteral, PR_TRUE);
}
}
return(rv);