Diff for /chimera/BookmarksService.mm between versions 1.5 and 1.22

version 1.5, 2002/02/09 08:12:33 version 1.22, 2002/04/17 08:31:11
Line 1 Line 1
/*/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 *  BookmarksService.cpp/* ***** BEGIN LICENSE BLOCK *****
 *  Chimera * Version: NPL 1.1/GPL 2.0/LGPL 2.1
  *   *
 *  Created by David Hyatt on Thu Feb 07 2002. * The contents of this file are subject to the Netscape Public License
 *  Copyright (c) 2001 __MyCompanyName__. All rights reserved. * Version 1.1 (the "License"); you may not use this file except in
  * compliance with the License. You may obtain a copy of the License at
  * http://www.mozilla.org/NPL/
  *   *
 */ * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  * The Original Code is mozilla.org code.
  * The Initial Developer of the Original Code is 
  * Netscape Communications Corporation.
  * Portions created by the Initial Developer are Copyright (C) 2002
  * the Initial Developer. All Rights Reserved.
  * Contributor(s):
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or 
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the NPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the NPL, the GPL or the LGPL.
  * ***** END LICENSE BLOCK ***** */
 #import "NSBrowserView.h"  #import "NSBrowserView.h"
 #include "BookmarksService.h"  #include "BookmarksService.h"
Line 20 Line 48
 #include "nsIFile.h"  #include "nsIFile.h"
 #include "nsAppDirectoryServiceDefs.h"  #include "nsAppDirectoryServiceDefs.h"
 #include "nsIXMLHttpRequest.h"  #include "nsIXMLHttpRequest.h"
   #include "nsIDOMSerializer.h"
 #include "nsNetUtil.h"  #include "nsNetUtil.h"
 #include "nsINamespaceManager.h"  #include "nsINamespaceManager.h"
 #include "nsIXBLService.h"  #include "nsIXBLService.h"
Line 31 Line 60
 {  {
     [super init];      [super init];
     mBookmarks = nsnull;      mBookmarks = nsnull;
       mCachedParent = nsnull;
       mCachedHref = nil;
     return self;      return self;
 }  }
 -(void) dealloc  -(void) dealloc
 {  {
    [super dealloc];  [super dealloc];
 }  }
 -(void) windowClosing  -(void) windowClosing
 {  {
    if (mBookmarks) {  if (mBookmarks) {
        mBookmarks->RemoveObserver();    mBookmarks->RemoveObserver();
        delete mBookmarks;    delete mBookmarks;
    }  }
 }  }
 -(void) ensureBookmarks  -(void) ensureBookmarks
Line 62 Line 93
 -(IBAction)addBookmark:(id)aSender  -(IBAction)addBookmark:(id)aSender
 {  {
    if (!mBookmarks)  [self addBookmark: aSender useSelection: YES];
    nsCOMPtr<nsIContent> content;-(void)addBookmark:(id)aSender useSelection:(BOOL)aUseSel
   if (!mBookmarks)
   nsCOMPtr<nsIContent> content;
   if (aUseSel) {
     int index = [mOutlineView selectedRow];      int index = [mOutlineView selectedRow];
    if (index > 0) {    if (index >= 0) {
        BookmarkItem* item = [mOutlineView itemAtRow: index];      BookmarkItem* item = [mOutlineView itemAtRow: index];
        if ([mOutlineView isExpandable: item])       if ([mOutlineView isExpandable: item])
            content = [item contentNode];        content = [item contentNode];
     }      }
    if (!content)
        mBookmarks->GetRootContent(getter_AddRefs(content));  if (!content)
    nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));
    nsCOMPtr<nsIDOMElement> elt;  nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));
                            NS_LITERAL_STRING("bookmark"),   // Fetch the title of the current page and the URL.
                            getter_AddRefs(elt));  nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([[[mBrowserWindowController getMyBrowserView] getBrowserView] getWebBrowser]);
      nsCOMPtr<nsIDOMWindow> window;
    // Fetch the title of the current page and the URL.  webBrowser->GetContentDOMWindow(getter_AddRefs(window));
    nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([[mBrowserView getBrowserView] getWebBrowser]);  nsCOMPtr<nsIDOMDocument> htmlDoc;
    nsCOMPtr<nsIDOMWindow> window;  window->GetDocument(getter_AddRefs(htmlDoc));
    webBrowser->GetContentDOMWindow(getter_AddRefs(window));  nsCOMPtr<nsIDocument> pageDoc(do_QueryInterface(htmlDoc));
    nsCOMPtr<nsIDOMDocument> htmlDoc;
    window->GetDocument(getter_AddRefs(htmlDoc));  nsAutoString href;
    nsCOMPtr<nsIDocument> pageDoc(do_QueryInterface(htmlDoc));  if (pageDoc) {
        nsCOMPtr<nsIURI> url;
    nsAutoString href;     pageDoc->GetDocumentURL(getter_AddRefs(url));
    if (pageDoc) {    nsCAutoString spec;
        nsCOMPtr<nsIURI> url;    url->GetSpec(spec);
        pageDoc->GetDocumentURL(getter_AddRefs(url));    href.AssignWithConversion(spec.get());
        nsXPIDLCString spec;  }
        href.AssignWithConversion(spec.get());  mCachedHref = [NSString stringWithCharacters: href.get() length: nsCRT::strlen(href.get())];
    }  [mCachedHref retain];
    nsAutoString title;  mCachedParent = content;
    nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(htmlDoc));  
    if (htmlDocument)  nsAutoString title;
        htmlDocument->GetTitle(title);  nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(htmlDoc));
    if (title.IsEmpty())  if (htmlDocument)
        title = href;    htmlDocument->GetTitle(title);
          if (title.IsEmpty())
    elt->SetAttribute(NS_LITERAL_STRING("name"), title);    title = href;
    elt->SetAttribute(NS_LITERAL_STRING("href"), href);      
      NSTextField* textField = [mBrowserWindowController getAddBookmarkTitle];
    nsCOMPtr<nsIDOMElement> parent(do_QueryInterface(content));  [textField setStringValue: [NSString stringWithCharacters: title.get() length: nsCRT::strlen(title.get())]];
    nsCOMPtr<nsIDOMNode> dummy;
    parent->AppendChild(elt, getter_AddRefs(dummy));  [mBrowserWindowController cacheBookmarkDS: self];
   [NSApp beginSheet:    [mBrowserWindowController getAddBookmarkSheetWindow]
      modalForWindow:    [mBrowserWindowController window]
       modalDelegate:    nil //self
      didEndSelector:    nil //@selector(sheetDidEnd:)
         contextInfo:    nil];
 -(void)endAddBookmark: (int)aCode
   if (aCode == 0)
   const char* titleC = [[[mBrowserWindowController getAddBookmarkTitle] stringValue] cString];
   nsAutoString title; title.AssignWithConversion(titleC);
   nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks));
   nsCOMPtr<nsIDOMElement> elt;
   elt->SetAttribute(NS_LITERAL_STRING("name"), title);
   nsAutoString href; href.AssignWithConversion([mCachedHref cString]);
   [mCachedHref release];
   elt->SetAttribute(NS_LITERAL_STRING("href"), href);
    mBookmarks->NotifyObservers(content, PR_TRUE);  nsCOMPtr<nsIDOMElement> parent(do_QueryInterface(mCachedParent));
   nsCOMPtr<nsIDOMNode> dummy;
   parent->AppendChild(elt, getter_AddRefs(dummy));
   nsCOMPtr<nsIContent> childContent(do_QueryInterface(elt));
   mBookmarks->BookmarkAdded(mCachedParent, childContent);
 }  }
 -(IBAction)deleteBookmark: (id)aSender  -(IBAction)deleteBookmark: (id)aSender
 {  {
       if (!mBookmarks)
       int index = [mOutlineView selectedRow];
       if (index == -1)
       BookmarkItem* item = [mOutlineView itemAtRow: index];
       nsCOMPtr<nsIContent> content = [item contentNode];
       nsCOMPtr<nsIDOMElement> child(do_QueryInterface(content));
       nsCOMPtr<nsIDOMNode> parent;
       nsCOMPtr<nsIContent> parentContent(do_QueryInterface(parent));
       nsCOMPtr<nsIDOMNode> dummy;
       parent->RemoveChild(child, getter_AddRefs(dummy));
       mBookmarks->BookmarkRemoved(parentContent, content);
       int total = [mOutlineView numberOfRows];
       if (index == total)
       [mOutlineView selectRow: index byExtendingSelection: NO];
 }  }
 -(IBAction)openBookmark: (id)aSender  -(IBAction)openBookmark: (id)aSender
Line 144 Line 235
         if (!href.IsEmpty()) {          if (!href.IsEmpty()) {
             nsCAutoString cstr; cstr.AssignWithConversion(href);              nsCAutoString cstr; cstr.AssignWithConversion(href);
             NSString* url = [NSString stringWithCString: cstr.get()];              NSString* url = [NSString stringWithCString: cstr.get()];
            [[mBrowserView getBrowserView] loadURI:[NSURL URLWithString: url] flags:NSLoadFlagsNone];            [[[mBrowserWindowController getMyBrowserView] getBrowserView] loadURI:[NSURL URLWithString: url] flags:NSLoadFlagsNone];
             // Focus and activate our content area.
             [[[mBrowserWindowController getMyBrowserView] getBrowserView] setActive: YES];
         }          }
     }       } 
 }  }
   - (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
       return NO;
 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item  - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
 {  {
     if (!mBookmarks)      if (!mBookmarks)
Line 199 Line 297
 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item  - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
 {  {
    if (!item)    NSString                                    *columnName = [tableColumn identifier];
        return nil;    NSMutableAttributedString       *cellValue = [[NSMutableAttributedString alloc] init];
        NSFileWrapper                               *fileWrapper = [[NSFileWrapper alloc] initRegularFileWithContents:nil];
    NSString* columnName = [tableColumn identifier];    NSTextAttachment                    *textAttachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper];
          NSMutableAttributedString   *attachmentAttrString = nil;
     NSCell                                              *attachmentAttrStringCell;
     if ([columnName isEqualToString: @"name"]) {      if ([columnName isEqualToString: @"name"]) {
         nsIContent* content = [item contentNode];          nsIContent* content = [item contentNode];
         nsAutoString nameAttr;          nsAutoString nameAttr;
         content->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, nameAttr);          content->GetAttr(kNameSpaceID_None, BookmarksService::gNameAtom, nameAttr);
         nsCAutoString cStr; cStr.AssignWithConversion(nameAttr);          nsCAutoString cStr; cStr.AssignWithConversion(nameAttr);
        return [NSString stringWithCString: cStr.get()];        
         //Set cell's textual contents
         [cellValue replaceCharactersInRange:NSMakeRange(0, [cellValue length])
                                  withString:[NSString stringWithCString: cStr.get()]];
         //Create an attributed string to hold the empty attachment, then release the components.
         attachmentAttrString = [[NSMutableAttributedString attributedStringWithAttachment:textAttachment] retain];
         [textAttachment release];
         [fileWrapper release];
         //Get the cell of the text attachment.
         attachmentAttrStringCell = (NSCell *)[(NSTextAttachment *)[attachmentAttrString attribute:NSAttachmentAttributeName
                                                                                    effectiveRange:nil] attachmentCell];
         //Figure out which image to add, and set the cell's image.
         if ( [self outlineView:outlineView isItemExpandable:item] ) {
             [attachmentAttrStringCell setImage:[NSImage imageNamed:@"folder"]];
         } else {
             [attachmentAttrStringCell setImage:[NSImage imageNamed:@"smallbookmark"]];
         //Insert the image
         [cellValue replaceCharactersInRange:NSMakeRange(0, 0) withAttributedString:attachmentAttrString];
         //Tweak the baseline to vertically center the text.
         [cellValue addAttribute:NSBaselineOffsetAttributeName
                           value:[NSNumber numberWithFloat:-3.0]
                           range:NSMakeRange(0, 1)];
     }      }
        return cellValue;
    return nil; 
 }  }
 - (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item  - (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
Line 240 Line 365
 {  {
     mContentNode = aContentNode;      mContentNode = aContentNode;
 }  }
   - (id)copyWithZone:(NSZone *)aZone
       BookmarkItem* copy = [[[self class] allocWithZone: aZone] init];
       [copy setContentNode: mContentNode];
       return copy;
 @end  @end
 // Helper for stripping whitespace  // Helper for stripping whitespace
Line 270  StripWhitespaceNodes(nsIContent* aElemen Line 403  StripWhitespaceNodes(nsIContent* aElemen
 PRUint32 BookmarksService::gRefCnt = 0;  PRUint32 BookmarksService::gRefCnt = 0;
 nsIDocument* BookmarksService::gBookmarks = nsnull;  nsIDocument* BookmarksService::gBookmarks = nsnull;
 NSMutableDictionary* BookmarksService::gDictionary = nil;  NSMutableDictionary* BookmarksService::gDictionary = nil;
   MainController* BookmarksService::gMainController = nil;
   NSMenu* BookmarksService::gBookmarksMenu = nil;
   nsIDOMElement* BookmarksService::gToolbarRoot = nsnull;
 nsIAtom* BookmarksService::gFolderAtom = nsnull;  nsIAtom* BookmarksService::gFolderAtom = nsnull;
 nsIAtom* BookmarksService::gBookmarkAtom = nsnull;  nsIAtom* BookmarksService::gBookmarkAtom = nsnull;
 nsIAtom* BookmarksService::gHrefAtom = nsnull;  nsIAtom* BookmarksService::gHrefAtom = nsnull;
Line 278  nsVoidArray* BookmarksService::gInstance Line 414  nsVoidArray* BookmarksService::gInstance
 BookmarksService::BookmarksService(BookmarksDataSource* aDataSource)  BookmarksService::BookmarksService(BookmarksDataSource* aDataSource)
 {  {
    mDataSource = aDataSource;  mDataSource = aDataSource;
   mToolbar = nil;
 BookmarksService::BookmarksService(BookmarksToolbar* aToolbar)
   mDataSource = nil;
   mToolbar = aToolbar;
 }  }
 BookmarksService::~BookmarksService()  BookmarksService::~BookmarksService()
Line 318  BookmarksService::GetWrapperFor(nsIConte Line 461  BookmarksService::GetWrapperFor(nsIConte
     return item;      return item;
 }  }
   BookmarksService::LocateMenu(nsIContent* aContent)
     nsCOMPtr<nsIContent> parent;
     if (!parent)
       return BookmarksService::gBookmarksMenu;
     NSMenu* parentMenu = LocateMenu(parent);
     PRUint32 contentID;
     NSMenuItem* childMenu = [parentMenu itemWithTag: contentID];
     return [childMenu menu];
 void  void
BookmarksService::NotifyObservers(nsIContent* aContainer, PRBool aReloadChildren)BookmarksService::BookmarkAdded(nsIContent* aContainer, nsIContent* aChild)
 {  {
    if (!gInstances)  if (!gInstances || !gDictionary)
        return;    return;
    PRInt32 count = gInstances->Count();  PRInt32 count = gInstances->Count();
    for (PRInt32 i = 0; i < count; i++) {  for (PRInt32 i = 0; i < count; i++) {
        BookmarksService* instance = (BookmarksService*)gInstances->ElementAt(i);    BookmarksService* instance = (BookmarksService*)gInstances->ElementAt(i);
        instance->NotifyObserver(aContainer, aReloadChildren);
     if (instance->mDataSource) {
       // We're a tree view.
       nsCOMPtr<nsIContent> parent;
       BookmarkItem* item = nil;
       if (parent)
         // We're not the root.
         item = GetWrapperFor(aContainer);
       [(instance->mDataSource) reloadDataForItem: item reloadChildren: YES];
     else {
       // We're the menu.
       PRInt32 index = -1;
       aChild->IndexOf(aContainer, index);
       NSMenu* menu = LocateMenu(aContainer);
       AddMenuBookmark(menu, aContainer, aChild, index);
     }      }
 }  }
   BookmarksService::BookmarkChanged(nsIContent* aItem)
     if (!gInstances || !gDictionary)
     PRInt32 count = gInstances->Count();
     for (PRInt32 i = 0; i < count; i++) {
       BookmarksService* instance = (BookmarksService*)gInstances->ElementAt(i);
       if (instance->mDataSource) {
         BookmarkItem* item = GetWrapperFor(aItem);
         [(instance->mDataSource) reloadDataForItem: item reloadChildren: NO];
 void  void
BookmarksService::NotifyObserver(nsIContent* aContainer, PRBool aReloadChildren)BookmarksService::BookmarkRemoved(nsIContent* aContainer, nsIContent* aChild)
 {  {
    if (!gDictionary)  if (!gInstances)
        return;    return;
    printf("uh. appended!\n");  PRInt32 count = gInstances->Count();
      for (PRInt32 i = 0; i < count; i++) {
    nsCOMPtr<nsIContent> parent;    BookmarksService* instance = (BookmarksService*)gInstances->ElementAt(i);
        if (instance->mDataSource) {
    BookmarkItem* item = nil;      // We're a tree view.
    if (parent)      nsCOMPtr<nsIContent> parent;
       BookmarkItem* item = nil;
       if (parent)
         // We're not the root.          // We're not the root.
         item = GetWrapperFor(aContainer);          item = GetWrapperFor(aContainer);
    [mDataSource reloadDataForItem: item reloadChildren: aReloadChildren];      [(instance->mDataSource) reloadDataForItem: item reloadChildren: YES];
     else {
       // We're the menu.
       NSMenu* menu = LocateMenu(aContainer);
       PRUint32 contentID;
       NSMenuItem* childItem = [menu itemWithTag: contentID];
       [menu removeItem: childItem];
 }  }
 void  void
Line 361  BookmarksService::AddObserver() Line 576  BookmarksService::AddObserver()
         gNameAtom = NS_NewAtom("name");          gNameAtom = NS_NewAtom("name");
         gHrefAtom = NS_NewAtom("href");          gHrefAtom = NS_NewAtom("href");
         gInstances = new nsVoidArray();          gInstances = new nsVoidArray();
         nsCOMPtr<nsIFile> profileDir;          nsCOMPtr<nsIFile> profileDir;
         NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profileDir));          NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profileDir));
         profileDir->Append("bookmarks.xml");          profileDir->Append("bookmarks.xml");
        nsXPIDLCString bookmarksFileURL;        nsCAutoString bookmarksFileURL;
        NS_GetURLSpecFromFile(profileDir, getter_Copies(bookmarksFileURL));        NS_GetURLSpecFromFile(profileDir, bookmarksFileURL);
         nsCOMPtr<nsIURI> uri;          nsCOMPtr<nsIURI> uri;
         NS_NewURI(getter_AddRefs(uri), bookmarksFileURL.get());          NS_NewURI(getter_AddRefs(uri), bookmarksFileURL.get());
Line 402  BookmarksService::RemoveObserver() Line 617  BookmarksService::RemoveObserver()
     }      }
 }  }
       nsCOMPtr<nsIFile> bookmarksFile;
       NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(bookmarksFile));
       nsCOMPtr<nsIOutputStream> outputStream;
       NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), bookmarksFile);
       nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(gBookmarks));
       nsCOMPtr<nsIDOMSerializer> domSerializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID));
       domSerializer->SerializeToStream(domDoc, outputStream, nsnull);
   void BookmarksService::EnsureToolbarRoot()
     if (gToolbarRoot)
     nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(gBookmarks));
     nsCOMPtr<nsIDOMElement> rootElt;
     nsCOMPtr<nsIDOMNode> child;
     nsAutoString typeValue;
     while (child) {
       nsCOMPtr<nsIDOMElement> childElt(do_QueryInterface(child));
       if (childElt) {
         childElt->GetAttribute(NS_LITERAL_STRING("type"), typeValue);
         if (typeValue.Equals(NS_LITERAL_STRING("toolbar")))
           gToolbarRoot = childElt;
       nsCOMPtr<nsIDOMNode> temp;
       child = temp;
     if (!gToolbarRoot) {
       printf("Repairing personal toolbar.\n");
       nsCOMPtr<nsIDOMElement> elt;
       elt->SetAttribute(NS_LITERAL_STRING("name"), NS_LITERAL_STRING("Toolbar Bookmarks"));
       elt->SetAttribute(NS_LITERAL_STRING("type"), NS_LITERAL_STRING("toolbar"));
       nsCOMPtr<nsIDOMNode> dummy;
       rootElt->AppendChild(elt, getter_AddRefs(dummy));
       gToolbarRoot = elt;
   BookmarksService::ConstructBookmarksMenu(NSMenu* aMenu, nsIContent* aContent)
       nsCOMPtr<nsIContent> content = aContent;
       if (!content) {
           gBookmarksMenu = aMenu;
       // Now walk our children, and for folders also recur into them.
       PRInt32 childCount;
       for (PRInt32 i = 0; i < childCount; i++) {
         nsCOMPtr<nsIContent> child;
         content->ChildAt(i, *getter_AddRefs(child));
         AddMenuBookmark(aMenu, content, child, -1);
   BookmarksService::AddMenuBookmark(NSMenu* aMenu, nsIContent* aParent, nsIContent* aChild, PRInt32 aIndex)
     nsAutoString name;
     aChild->GetAttr(kNameSpaceID_None, gNameAtom, name);
     nsCAutoString nameCStr; nameCStr.AssignWithConversion(name);
     NSString* title = [NSString stringWithCString: nameCStr.get()];
     // Create a menu or menu item for the child.
     NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle: title action: NULL keyEquivalent: @""] autorelease];
     if (aIndex == -1)
       [aMenu addItem: menuItem];
       [aMenu insertItem: menuItem atIndex: aIndex];
     nsCOMPtr<nsIAtom> tagName;
     if (tagName == gFolderAtom) {
       NSMenu* menu = [[[NSMenu alloc] initWithTitle: title] autorelease];
       [aMenu setSubmenu: menu forItem: menuItem];
       [menu setAutoenablesItems: NO];
       ConstructBookmarksMenu(menu, aChild);
     else {
       [menuItem setTarget: gMainController];
       [menuItem setAction: @selector(openMenuBookmark:)];
     PRUint32 contentID;
     [menuItem setTag: contentID];
   BookmarksService::OpenMenuBookmark(BrowserWindowController* aController, id aMenuItem)
       // Get the corresponding bookmark item.
       BookmarkItem* item = [gDictionary objectForKey: [NSNumber numberWithInt: [aMenuItem tag]]];
       // Get the content node.
       nsIContent* content = [item contentNode];
       // Get the href attribute.  This is the URL we want to load.
       nsAutoString href;
       content->GetAttr(kNameSpaceID_None, gHrefAtom, href);
       nsCAutoString cref; cref.AssignWithConversion(href);
       if (cref.IsEmpty())
       NSString* url = [NSString stringWithCString: cref.get()];
       // Now load the URL in the window.
       [aController loadURL:[NSURL URLWithString: url]];
       // Focus and activate our content area.
       [[[aController getMyBrowserView] getBrowserView] setActive: YES];

Removed from v.1.5  
changed lines
  Added in v.1.22

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>