Hello Project Owners and assorted sophonts. I've been busy porting the functionality of the "Locate in Bookmark Folders" Firefox extension <http://alex.muntean.name/projects/mozilla/Locate_in_Bookmark_Folders/> to SeaMonkey.
This extension calls selectResource() which is not a method available in the SeaMonkey version of the bookmarks-tree xbl. So I've extracted the javascript into my extension. Now selectResource() calls getParentChain() which however isn't in the SeaMonkey version of nsBookmarksService.cpp. And then of course getParentChain() calls getParent() -ditto-. Firefox version: <http://lxr.mozilla.org/seamonkey/source/browser/components/bookmarks/src/nsBookmarksService.cpp#3020> 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; }, // from FF nsBookmarksService.cpp (translated into js) getParent : function (aResource) { var arcsIn = BMDS.ArcLabelsIn(aResource); var containerArc; while (arcsIn.hasMoreElements()) { containerArc = arcsIn.getNext(); // Test if the arc is ordinal. We will assume that the parent is determined // by the first ordinal arc that points to the resource. // That's not bullet-proof, since several ordinal arcs can point to the same // resource. However, this will be sufficient for most of the cases. if (RDFCU.IsOrdinalProperty(containerArc)) { return BMDS.GetSources(containerArc, aResource, true).getNext() .QueryInterface(kRDFRSCIID); } } return null; } Phil -- Philip Chee <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> http://flashblock.mozdev.org/ http://xsidebar.mozdev.org Guard us from the she-wolf and the wolf, and guard us from the thief, oh Night, and so be good for us to pass. [ ]I saw Elvis. He sat between me and Bigfoot on the UFO. * TagZilla 0.059 _______________________________________________ Project_owners mailing list [email protected] http://mozdev.org/mailman/listinfo/project_owners
