From d8d65a6e55300196bbf6d84a66d06cbf9f8fface Mon Sep 17 00:00:00 2001 From: "dietrich@mozilla.com" Date: Mon, 10 Sep 2007 11:08:21 -0700 Subject: [PATCH] Bug 393464 Bookmarks manager doesn't search in tags field (reverting) --- .../places/public/nsITaggingService.idl | 6 -- .../components/places/src/nsNavHistory.cpp | 55 +------------------ toolkit/components/places/src/nsNavHistory.h | 2 - .../places/tests/bookmarks/test_395101.js | 1 + 4 files changed, 2 insertions(+), 62 deletions(-) diff --git a/toolkit/components/places/public/nsITaggingService.idl b/toolkit/components/places/public/nsITaggingService.idl index de99adc33dff..cbf048f18bf7 100644 --- a/toolkit/components/places/public/nsITaggingService.idl +++ b/toolkit/components/places/public/nsITaggingService.idl @@ -91,9 +91,3 @@ interface nsITaggingService : nsISupports */ readonly attribute nsIVariant allTags; }; - -%{C++ - -#define TAGGING_SERVICE_CID "@mozilla.org/browser/tagging-service;1" - -%} diff --git a/toolkit/components/places/src/nsNavHistory.cpp b/toolkit/components/places/src/nsNavHistory.cpp index db548a602063..1af84fad8d67 100644 --- a/toolkit/components/places/src/nsNavHistory.cpp +++ b/toolkit/components/places/src/nsNavHistory.cpp @@ -69,9 +69,6 @@ #include "prtime.h" #include "prprf.h" #include "nsEscape.h" -#include "nsITaggingService.h" -#include "nsIVariant.h" -#include "nsVariant.h" #include "mozIStorageService.h" #include "mozIStorageConnection.h" @@ -4099,45 +4096,6 @@ nsNavHistory::GroupByHost(nsNavHistoryQueryResultNode *aResultNode, return NS_OK; } -PRBool -nsNavHistory::URIHasTag(nsIURI* aURI, const nsAString& aTag) -{ - nsresult rv; - nsCOMPtr tagService = - do_GetService(TAGGING_SERVICE_CID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr tagsV; - rv = tagService->GetTagsForURI(aURI, getter_AddRefs(tagsV)); - NS_ENSURE_SUCCESS(rv, rv); - - // confirm that type is array, and has elements - // (data type is different for empty array) - PRUint16 dataType; - tagsV->GetDataType(&dataType); - if (dataType != nsIDataType::VTYPE_ARRAY) - return PR_FALSE; - - // get tags as array - PRUint16 type; - nsIID iid; - PRUint32 count; - PRUnichar** tags; - rv = tagsV->GetAsArray(&type, &iid, &count, (void**)&tags); - NS_ENSURE_SUCCESS(rv, rv); - - for (PRUint32 i = 0; i < count; i++) { - nsAutoString tag(tags[i]); - PRInt32 position = Compare(tag, aTag, nsCaseInsensitiveStringComparator()); - if (position == 0) { - nsMemory::Free(tags); - return PR_TRUE; - } - } - nsMemory::Free(tags); - return PR_FALSE; -} - // nsNavHistory::FilterResultSet // @@ -4203,7 +4161,6 @@ nsNavHistory::FilterResultSet(nsNavHistoryQueryResultNode* aParentNode, if (terms.Count() == 0) { allTermsFound = PR_TRUE; } else { - for (PRInt32 termIndex = 0; termIndex < terms.Count(); termIndex ++) { PRBool termFound = PR_FALSE; // title and URL @@ -4213,7 +4170,6 @@ nsNavHistory::FilterResultSet(nsNavHistoryQueryResultNode* aParentNode, CaseInsensitiveFindInReadable(*terms[termIndex], NS_ConvertUTF8toUTF16(aSet[nodeIndex]->mURI)))) termFound = PR_TRUE; - // searchable annotations /*if (! termFound) { for (PRInt32 annotIndex = 0; annotIndex < curAnnotations.Count(); annotIndex ++) { @@ -4222,16 +4178,7 @@ nsNavHistory::FilterResultSet(nsNavHistoryQueryResultNode* aParentNode, termFound = PR_TRUE; } }*/ - - // search tags - if (!termFound) { - nsCOMPtr itemURI; - rv = NS_NewURI(getter_AddRefs(itemURI), aSet[nodeIndex]->mURI); - NS_ENSURE_SUCCESS(rv, rv); - termFound = URIHasTag(itemURI, *terms[termIndex]); - } - - if (!termFound) { + if (! termFound) { allTermsFound = PR_FALSE; break; } diff --git a/toolkit/components/places/src/nsNavHistory.h b/toolkit/components/places/src/nsNavHistory.h index d287b576b09e..8ee244608a7d 100644 --- a/toolkit/components/places/src/nsNavHistory.h +++ b/toolkit/components/places/src/nsNavHistory.h @@ -511,8 +511,6 @@ protected: nsCOMArray* aDest, PRBool aIsDomain); - PRBool URIHasTag(nsIURI* aURI, const nsAString& aTag); - nsresult FilterResultSet(nsNavHistoryQueryResultNode *aParentNode, const nsCOMArray& aSet, nsCOMArray* aFiltered, diff --git a/toolkit/components/places/tests/bookmarks/test_395101.js b/toolkit/components/places/tests/bookmarks/test_395101.js index 50d04f69a053..6f8f9e7cdeb0 100644 --- a/toolkit/components/places/tests/bookmarks/test_395101.js +++ b/toolkit/components/places/tests/bookmarks/test_395101.js @@ -63,6 +63,7 @@ var root = bmsvc.bookmarksRoot; // main function run_test() { + return true; // test searching for tagged bookmarks // test folder