Philip Chee wrote:
I've emulated these methods in js and they seem to work. Anybody want to see if
I've missed out anything? I don't really know C++ at all.
// from FF nsBookmarksService.cpp (translated into js)
getParentChain : function (aResource) {
var parentArray = new Array();
if (aResource) {
var parent = xsbBookmarks.getParent(aResource);
while (parent) {
parentArray.unshift(parent);
parent = xsbBookmarks.getParent(parent);
}
}
return parentArray;
},
I'd consider writing selectResource to do something along the lines of
SelectFolder in msgMail3PaneWindow.js which uses a recursive helper
function EnsureFolderIndex (although of course in that case the parent
operation is trivial).
var containerArc;
while (arcsIn.hasMoreElements()) {
containerArc = arcsIn.getNext();
Nit: var containerArc = arcsIn.getNext();
return BMDS.GetSources(containerArc, aResource, true).getNext()
.QueryInterface(kRDFRSCIID);
The original C++ translates to
return BMDS.GetSource(containerArc, aResource, true);
[Note for the interested: due to the way XPConnect works it is not
necessary to manually call containerArc.QueryInterface(kRDFRSCIID)
because XPConnect will do that as part of preparing the function call.
QueryInterface/instanceof are only necessary if you wish to invoke
methods or get or set properties on the interface.]
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners