diff --git a/xpfe/components/bookmarks/resources/bookmarks.js b/xpfe/components/bookmarks/resources/bookmarks.js index 96f12ce34d00..470eadba06a3 100644 --- a/xpfe/components/bookmarks/resources/bookmarks.js +++ b/xpfe/components/bookmarks/resources/bookmarks.js @@ -612,12 +612,6 @@ function doContextCmd(cmdName) cmdResource = cmdResource.QueryInterface(Components.interfaces.nsIRDFResource); if (!cmdResource) return(false); - var select_list = treeNode.selectedItems; - if (!select_list) return(false); - if (select_list.length < 1) return(false); - - debug("# of Nodes selected: " + select_list.length); - // set up selection nsISupportsArray var selectionInstance = Components.classes["component://netscape/supports-array"].createInstance(); var selectionArray = selectionInstance.QueryInterface(Components.interfaces.nsISupportsArray); @@ -630,7 +624,22 @@ function doContextCmd(cmdName) var parentArc = rdf.GetResource("http://home.netscape.com/NC-rdf#parent"); if (!parentArc) return(false); - for (var nodeIndex=0; nodeIndexGetPreferred(charset, charsetName))) + { + if (charsetName.Length() > 0) + { + charset = charsetName; + } + } + } + // found a charset, now try and get a decoder from it to Unicode nsICharsetConverterManager *charsetConv = nsnull; rv = nsServiceManager::GetService(kCharsetConverterManagerCID, @@ -3273,12 +3286,19 @@ nsresult nsBookmarksService::insertBookmarkItem(nsIRDFResource *src, nsISupportsArray *aArguments, PRInt32 parentArgIndex, nsIRDFResource *objType) { nsresult rv; - + PRInt32 srcIndex = 0; nsCOMPtr argParent; - if (NS_FAILED(rv = getArgumentN(aArguments, kNC_Parent, - parentArgIndex, getter_AddRefs(argParent)))) - return(rv); + if (src == kNC_BookmarksRoot) + { + argParent = src; + } + else + { + if (NS_FAILED(rv = getArgumentN(aArguments, kNC_Parent, + parentArgIndex, getter_AddRefs(argParent)))) + return(rv); + } nsCOMPtr container; if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRDFContainerCID, nsnull, NS_GET_IID(nsIRDFContainer), getter_AddRefs(container)))) @@ -3286,9 +3306,11 @@ nsBookmarksService::insertBookmarkItem(nsIRDFResource *src, nsISupportsArray *aA if (NS_FAILED(rv = container->Init(mInner, argParent))) return(rv); - PRInt32 srcIndex; - if (NS_FAILED(rv = container->IndexOf(src, &srcIndex))) - return(rv); + if (src != kNC_BookmarksRoot) + { + if (NS_FAILED(rv = container->IndexOf(src, &srcIndex))) + return(rv); + } nsCOMPtr newElement; if (NS_FAILED(rv = BookmarkParser::CreateAnonymousResource(&newElement))) @@ -3324,9 +3346,8 @@ nsBookmarksService::insertBookmarkItem(nsIRDFResource *src, nsISupportsArray *aA if (NS_FAILED(rv = mInner->Assert(newElement, kNC_BookmarkAddDate, dateLiteral, PR_TRUE))) return(rv); - if (NS_FAILED(rv = container->InsertElementAt(newElement, srcIndex + 1, PR_TRUE))) + if (NS_FAILED(rv = container->InsertElementAt(newElement, ((srcIndex == 0) ? 1 : srcIndex), PR_TRUE))) return(rv); - return(rv); }