[Project_owners] bookmarks-tree: SeaMonkey vs Firefox.

Philip Chee philip.chee at gmail.com
Mon May 15 23:14:10 EDT 2006

Hello Project Owners and assorted sophonts.

I've been busy porting the functionality of the "Locate in Bookmark
Folders" Firefox extension
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:

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) {
        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
      // 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()
    return null;


Philip Chee <philip at aleytys.pc.my>, <philip.chee at gmail.com>
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

More information about the Project_owners mailing list