User talk:Wjjohnst

XBL/SVG Text Effects

I wrote up some xbl bindings for drop shadow text that I thought were kinda fun, and thought I'd post 'em here so they didn't disappear from my life forever. Essentially they just take some text in tags, replace it with an empty span and then absolutely position an svg element with the appropriate filter over the top. For instance, glowing text can be done with:

<?xml version="1.0"?>

<bindings xmlns="http://www.mozilla.org/xbl"
          xmlns:xbl="http://www.mozilla.org/xbl"
          xmlns:html="http://www.w3.org/1999/xhtml"
          xmlns:svg="http://www.w3.org/2000/svg">

<binding id="glow">
  <content>
    <html:span anonid="spanBase" style="display: inline-block;"/>
    <svg:svg anonid="svgbase" width="95" height="30" version="1.1" style="position: absolute;">
      <svg:defs>
        <svg:filter id="Glow" x="-10%" y="-10%" width="150%" height="150%">
          <svg:feGaussianBlur in="SourceAlpha" result="blurredAlpha" xbl:inherits="stdDeviation=glowradius"/>
          <svg:feFlood result="flooded" xbl:inherits="flood-color=glowcolor,flood-opacity=glowopacity"/>
          <svg:feComposite operator="atop" in="flooded" in2="blurredAlpha" result="coloredShadow"/>
          <svg:feComposite in="SourceGraphic" in2="coloredShadow" operator="over"/>
        </svg:filter>
      </svg:defs>
      <svg:g filter="url(texteffects.xml#Glow)" >
        <svg:text anonid="svgtext" xbl:inherits="style,fill=glowcolor" x="0" y="0">
        </svg:text>
      </svg:g>
    </svg:svg>
  </content>
  <implementation>
    <constructor><![CDATA[
      var text = document.getAnonymousElementByAttribute(this, 'anonid', 'svgtext');
      text.setAttribute('y', '1em');
      var width = text.getComputedTextLength();
     
      var span = document.getAnonymousElementByAttribute(this, 'anonid', 'spanBase');
      
      span.style.width = width + 'px';
      var x = span.offsetLeft;
      
      var svg = document.getAnonymousElementByAttribute(this, 'anonid', 'svgbase');
    
      svg.style.left = x + 'px';
    ]]></constructor>
  </implementation>
</binding>
</bindings>

and shadow effects with the filter changed to:

<svg:filter id="dS" x="-10%" y="-10%" width="150%" height="150%">
  <svg:feGaussianBlur in="SourceAlpha" xbl:inherits="stdDeviation=shadowradius" result="shadow" />
  <svg:feOffset in="shadow" xbl:inherits="dx=offsetX,dy=offsetY" result="movedShadow" />
  <svg:feComposite in="SourceGraphic" in2="movedShadow" operator="over"/>
</svg:filter>

In the end you can take some markup like:

<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:svg="http://www.w3.org/2000/svg">
  <head>
    <style>
      .glow {       -moz-binding: url(texteffects.xml#glow); 		 }
      .dropshadow { -moz-binding: url(texteffects.xml#dropShadow); }
    </style>
  </head>
  <body>
    <div style="font-family: serif;">
      Here is some <span glowopacity="0.1" glowcolor="green" glowradius="1" class="glow">glowing</span> text.
    </div>
    <div style="font-family: serif;">
      This is some <span glowopacity="0" glowcolor="green" glowradius="0" class="glow">NOT glowing</span> text.
    </div>
    <hr/>
    <div style="font-family: serif; font-size: 32pt;">
      Here is some <span shadowradius="1" offsetX="3" offsetY="3" class="dropshadow">shadow</span> text.
    </div>
    <div style="font-family: serif; font-size: 32pt;">
      Here is some <span shadowradius="0" offsetX="0" offsetY="0" class="dropshadow">non-shadow</span> text.
    </div>
  </body>
</html>

and get output like:

Image:Wj-textEffects.png

There's some sort of small offset problem there where the text baselines don't match, and this screws up with text that breaks over a line, or that is scaled, or if the browser window is too small. Basically its got lots of problems, but its kinda neat. Only tested (and probably only works) in FF3.

Utils.js

Utils.js in places has a lot of useful little functions and definitions. I'm always wondering what I'm missing from there, so here's an attempt to go through and dissect it. Probably will move this to a better page when its more cleaned up:

utils.js is located in chrome://browser/content/places/utils.js. It includes utility functions used by a lot of the bookmarking, tagging, and annotation services that are built into Firefox. By default its only included in browser.xul though, and other common areas for bookmarking (the bookmarks/history sidebar or the places organizer) require you to add it. Its not an interface, and as such it will never be frozen, but it provides some easy to use functions that can save you from reinventing the wheel and cluttering up your own classes/functions when you need it.

Global Objects

There are a few global objects and constants defined in utils.js. These are:

Methods

  • Log(str) - Dumps a string to the console for debugging purposes.

QI_node

QI_node(aNode, aIID) Runs a query interface on a bookmark node to expose the interface available to that type. If the interface isn't available to that node, null is returned.

  • aNode - The bookmark
  • aIID - The return type interface wanted.

There are several predefined versions of this for common calls. These just take in the node, as the interface is already defined:

  • asVisit(aNode)
  • asFullVisit(aNode)
  • asContainer(aNode)
  • asQuery(aNode)

Annotations

A few annotation names are defined here.

  • LOAD_IN_SIDEBAR_ANNO - This defines the annotation that is associated with bookmarks or items that should load in the sidebar automatically.
  • DESCRIPTION_ANNO - This defines the annotation that stores description information about a bookmark.
  • POST_DATA_ANNO - I need to clarify here, but I think this is the name of the annotation that stores information for keyword searches from a bookmark.
  • LMANNO_FEEDURI - Need to clarify here too, but I think for each livemark, there is an bookmark which contains an annotation storing the associated feed uri.
  • LMANNO_SITEURI - Need to clarify here, but I think for each livemark, there is an bookmark which contains an annotation storing the associated site uri.
  • ORGANIZER_QUERY_ANNO - This annotation is used by the places organizer to decide what nodes should be shown in the left pane.

PlacesUtils

This is a gigantic object full of usefulness if you need to do any bookmark work from within browser.xul. As such, it gets its own special section.

PlacesUtils

Method overview

nsIURI createFixedURI(string aSpec);
string getFormattedString(string key, string params);
string getString(string key);
boolean nodeIsFolder(nsINavHistoryResultNode aNode);
boolean nodeIsBookmark(nsINavHistoryResultNode aNode);
boolean nodeIsSeparator(nsINavHistoryResultNode aNode);
boolean nodeIsVisit(nsINavHistoryResultNode aNode);
boolean nodeIsURI(nsINavHistoryResultNode aNode);
boolean nodeIsQuery(nsINavHistoryResultNode aNode);
boolean nodeIsReadOnly(nsINavHistoryResultNode aNode);
boolean nodeIsHost(nsINavHistoryResultNode aNode);
boolean nodeIsContainer(nsINavHistoryResultNode aNode);
boolean nodeIsDynamicContainer(nsINavHistoryResultNode aNode);
boolean nodeIsLivemarkContainer(nsINavHistoryResultNode aNode);
boolean nodeIsLivemarkItem(nsINavHistoryResultNode aNode);
boolean isReadonlyFolder(nsINavHistoryResultNode aNode);
int getIndexOfNode(nsINavHistoryResultNode aNode);
string wrapNode(nsINavHistoryResultNode aNode, string aType, nsIURI aOverrideURI);
array unwrapNodes(string blob, string aType);
nsITransaction makeTransaction(string data, string type, nsINavHistoryResultNode container, int index, boolean copy);
nsINavHistoryResult getFolderContents(int aFolderId, boolean aExcludeItems, boolean aExpandQueries);
boolean showAddBookmarkUI(nsIURI aURI, string aTitle, string aDescription, int aDefaultInsertionPoint, boolean aShowPicker, boolean aLoadInSidebar, string aKeyword, string aPostData);
boolean showMinimalAddBookmarkUI(nsIURI aURI, string aTitle, string aDescription, int aDefaultInsertionPoint, boolean aShowPicker, boolean aLoadInSidebar, string aKeyword, string aPostData);
boolean showAddLivemarkUI(nsIURI aFeedURI, nsIURI aSiteURI, string aTitle, string aDescription, int aDefaultInsertionPoint, boolean aShowPicker);
boolean showMinimalAddLivemarkUI(nsIURI aFeedURI, nsIURI aSiteURI, string aTitle, string aDescription, int aDefaultInsertionPoint, boolean aShowPicker);
boolean showMinimalAddMultiBookmarkUI(array nsIURI aURIList);
boolean showBookmarkProperties(int aId);
boolean showFolderProperties(int aId);
boolean showAddFolderUI(string aTitle, int aDefaultInsertionPoint, boolean aShowPicker);
array object getAnnotationsForURI(nsIURI aURI);
array object getAnnotationsForItem(int aItemId);
void setAnnotationsForURI(nsIURI aURI, object aAnnos);
void setAnnotationsForURI(int aItemId, object aAnnos);
getViewForNode(nsIDOMNode aNode);
void markPageAsTyped(string aURL);
void markPageAsFollowedBookmark(string aURL);
boolean checkURLSecurity(nsINavHistoryResultNode aURINode);
string getQueryStringForFolder(int aFolderId);
string getDescriptionFromDocument(nsIDOMDocument doc);
string setPostDataForBookmark(int aBoomarkId, string aPostData);
string getPostDataForBookmark(int aBoomarkId);
array string getURLAndPostDataForKeyword(string aKeyword);
string getItemDescription(int aItemId);
nsINavHistoryResultNode getMostRecentBookmarkForURI(nsIURI aURI);
nsINavHistoryResultNode getMostRecentFolderForFeedURI(nsIURI aURI);
nsINavHistoryResultNode getURLsForContainerNode(nsINavHistoryResultNode aNode);
void openContainerNodeInTabs(nsINavHistoryResultNode aNode, nsIDOMEvent aEvent);
void openURINodesInTabs(array nsINavHistoryResultNode aNodes, nsIDOMEvent aEvent);
void createMenuItemForNode(nsINavHistoryResultNode aNode, aContainersMap);

Constants

Mimetypes

  • TYPE_X_MOZ_PLACE_CONTAINER
  • TYPE_X_MOZ_PLACE_SEPARATOR: "text/x-moz-place-separator",
  • TYPE_X_MOZ_PLACE: "text/x-moz-place",
  • TYPE_X_MOZ_URL: "text/x-moz-url",
  • TYPE_HTML: "text/html",
  • TYPE_UNICODE: "text/unicode",

Services

Theres easy access to some of the common services used in bookmarks or history navigation here. For instance, normally in order to get access to the bookmarks service, you have to run something like:

 Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
   .getService(Components.interfaces.nsINavBookmarksService);

With places utils all you need to write is:

 PlacesUtils.bookmarks

This should save on the number of references to the service that are needed, and can help clean up interfaces that are already fairly cluttered. There are currently 11 services defined in here.

<tt>bookmarks</tt>
nsINavBookmarksService
<tt>history</tt>
nsINavHistoryService
<tt>globalHistory</tt>
nsIBrowserHistory
<tt>livemarks</tt>
nsILivemarkService
<tt>annotations</tt>
nsIAnnotationService
<tt>favicons</tt>
nsIFaviconService
<tt>microsummaries</tt>
nsIMicrosummaryService
<tt>tagging</tt>
nsITaggingService
<tt>RDF</tt>
nsIRDFService
<tt>ptm</tt>
nsIPlacesTransactionsService
<tt>clipboard</tt>
nsIClipboard
<tt>URIFixup</tt>
nsIURIFixup

Special Places

These are essentially references to the id's of special folders within places. They can save you time calling the service and searching for a particular folder on your own.

<tt>placesRootId</tt>
<tt>bookmarksMenuFolderId</tt>
<tt>toolbarFolderId</tt>
<tt>tagsFolderId</tt>
<tt>unfiledBookmarksFolderId</tt>

Other

Other attributes stored in PlacesUtils.

<tt>localStore</tt>
Local store provides access to the local-store rdf data source, which stores persisted information about the browser.
<tt>uriTypes</tt>
<tt>containerTypes</tt>
<tt>leftPaneQueries</tt>
<tt>leftPaneFolderId</tt>
<tt>allBookmarksFolderId</tt>
<tt>placesFlavors</tt>
<tt>GENERIC_VIEW_DROP_TYPES</tt>

Methods

createFixedURI

 nsIURI createFixedURI(string aSpec)

Takes in a spec and returns a valid uri based on it using the nsIURIFixup service.

Parameters
<tt>aSpec</tt>
a url string that needs fixup
Return type

Returns a correct nsIURI.

getFormattedString()

 string getFormattedString(string key,
                           array string params)
Parameters
<tt>key</tt>
The string name to get from the string bundle
<tt>params</tt>
Strings to substitute into the bundle at designated points

See XUL:stringbundle for more information.

Return type

Returns a string from the default places stringbundle.

getString()

 string getString(string key)
Parameters
<tt>key</tt>
The name of the string to get.
Return type

Returns a string from the default places stringbundle.

nodeIs()

There are a ton of nodeIs(something) functions in here to check properties of a bookmark node. The all take in the same argument and return a boolean true or false, so I'm just going to list them all in one lump:

<tt>boolean nodeIsFolder(aNode)</tt>
Determines whether or not a ResultNode is a Bookmark folder or not.
<tt>boolean nodeIsBookmark(aNode)</tt>
Determines whether or not a ResultNode represents a bookmarked URI.
<tt>boolean nodeIsSeparator(aNode)</tt>
Determines whether or not a ResultNode is a Bookmark separator.
<tt>boolean nodeIsVisit(aNode)</tt>
Determines whether or not a ResultNode is a visit item or not
<tt>boolean nodeIsURI(aNode)</tt>
Determines whether or not a ResultNode is a URL item or not
<tt>boolean nodeIsQuery(aNode)</tt>
Determines whether or not a ResultNode is a Query item or not
<tt>boolean nodeIsReadOnly(aNode)</tt>
Determines if a node is read only (children cannot be inserted, sometimes they cannot be removed depending on the circumstance)
<tt>boolean nodeIsHost(aNode)</tt>
Determines whether or not a ResultNode is a host folder or not
<tt>boolean nodeIsContainer(aNode)</tt>
Determines whether or not a ResultNode is a container item or not
<tt>boolean nodeIsDynamicContainer(aNode)</tt>
Determines whether or not a result-node is a dynamic-container item. The dynamic container result node type is for dynamically created containers (e.g. for the file browser service where you get your folders in bookmark menus).
<tt>boolean nodeIsLivemarkContainer(aNode)</tt>
Determines whether a result node is a remote container registered by the livemark service.
<tt>boolean nodeIsLivemarkItem(aNode)</tt>
Determines whether a result node is a live-bookmark item
Parameters
<tt>aNode</tt>
The node to check.
Return type

Returns a boolean.

isReadonlyFolder()

Determines whether or not a node is a readonly folder.

 boolean isReadonlyFolder(aNode)
Parameters
<tt>aNode</tt>
The node to check.
Return type

Return true if the node is a folder, false otherwise.

getIndexOfNode()

Gets the index of a node within its parent container

 int getIndexOfNode(aNode)
Parameters
<tt>aNode</tt>
The node to look up
Return type

Returns the index of the node within its parent container, or -1 if the node was not found or the node specified has no parent.

wrapNode()

String-wraps a result node according to the rules of the specified content type.

 string wrapNode(aNode,
                 string aType,
                 nsIURI aOverrideURI)
Parameters
<tt>aNode</tt>
The Result node to wrap (serialize)
<tt>aType</tt>
The content type to serialize as
<tt>aOverrideURI</tt>
[optional] Used instead of the node's URI if provided. This is useful for wrapping a container as TYPE_X_MOZ_URL, TYPE_HTML or TYPE_UNICODE.
Return type

Returns A string serialization of the node

unwrapNodes()

Unwraps data from the Clipboard or the current Drag Session.

 array object unwrapNodes(blob,
                          type)
Parameters
<tt>blob</tt>
A blob (string) of data, in some format we potentially know how to parse.
<tt>type</tt>
The content type of the blob.
Return type

Returns an array of objects representing each item contained by the source.

makeTransaction()

Constructs a Transaction for the drop or paste of a blob of data into a container.

 makeTransaction(data,
                 type,
                 container,
                 index,
                 copy)
Parameters
<tt>data</tt>
The unwrapped data blob of dropped or pasted data.
<tt>type</tt>
The content type of the data
<tt>container</tt>
The container the data was dropped or pasted into
<tt>index</tt>
The index within the container the item was dropped or pasted at
<tt>copy</tt>
The drag action was copy, so don't move folders or links.
Return type

Returns an object implementing nsITransaction that can perform the move/insert.

getFolderContents()

 getFolderContents(aFolderId,
                   aExcludeItems,
                   aExpandQueries)

Generates a nsINavHistoryResult for the contents of a folder.

Parameters
<tt>folderId</tt>
The folder to open
<tt>[optional] excludeItems</tt>
True to hide all items (individual bookmarks). This is used on the left places pane so you just get a folder hierarchy.
<tt>[optional] expandQueries</tt>
True to make query items expand as new containers. For managing,you want this to be false, for menus and such, you want this to be true.
Return type

Returns a nsINavHistoryResult containing the contents of the folder. The result.root is guaranteed to be open.

Bookmark Dialog

Methods to show the bookmarkProperties dialog in its various modes.

The showMinimalAdd methods open the dialog by its alternative URI. Thus they persist the dialog dimensions separately from the showAdd methods. Note these variants also do not return the dialog "performed" state since they may not open the dialog modally.

showAddBookmarkUI()

Shows the "Add Bookmark" dialog.

 showAddBookmarkUI(aURI,
                   aTitle,
                   aDescription,
                   aDefaultInsertionPoint,
                   aShowPicker,
                   aLoadInSidebar,
                   aKeyword,
                   aPostData)
Parameters
<tt>[optional] aURI</tt>
An nsIURI object for which the "add bookmark" dialog is to be shown.
<tt>[optional] aTitle</tt>
The default title for the new bookmark.
<tt>[optional] aDescription</tt>
The default description for the new bookmark
<tt>[optional] aDefaultInsertionPoint</tt>
The default insertion point for the new item. If set, the folder picker would be hidden unless aShowPicker is set to true, in which case the dialog only uses the folder identifier from the insertion point as the initially selected item in the folder picker.
<tt>[optional] aShowPicker</tt>
see above
<tt>[optional] aLoadInSidebar</tt>
If true, the dialog will default to load the new item in the sidebar (as a web panel).
<tt>[optional] aKeyword</tt>
The default keyword for the new bookmark. The keyword field will be shown in the dialog if this is used.
<tt>[optional] aPostData</tt>
POST data for POST-style keywords.
Return type

Returns true if any transaction has been performed.

Note: The location, description and "load in sidebar" fields are visible only if there is no initial URI (aURI is null).
Note: When aDefaultInsertionPoint is not set, the dialog defaults to the bookmarks root folder.

showMinimalAddBookmarkUI()

 showMinimalAddBookmarkUI(aURI,
                        aTitle,
                        aDescription,
                        aDefaultInsertionPoint,
                        aShowPicker,
                        aLoadInSidebar,
                        aKeyword,
                        aPostData)

This opens the dialog with only the name and folder pickers visible by default. You can still pass in the various paramaters as the default properties for the new bookmark. The keyword field will be visible only if the aKeyword parameter was used.

See showAddBookmarkUI for a description of the params.

showAddLivemarkUI()

Shows the "Add Live Bookmark" dialog.

 boolean showAddLivemarkUI(aFeedURI,
                           aSiteURI,
                           aTitle,
                           aDescription,
                           aDefaultInsertionPoint,
                           aShowPicker)
Parameters
<tt>[optional] aFeedURI</tt>
The feed URI for which the dialog is to be shown (nsIURI).
<tt>[optional] aSiteURI</tt>
The site URI for the new live-bookmark (nsIURI).
<tt>[optional] aDefaultInsertionPoint</tt>
The default insertion point for the new item. If set, the folder picker would be hidden unless aShowPicker is set to true, in which case the dialog only uses the folder identifier from the insertion point as the initially selected item in the folder picker.
<tt>[optional] aShowPicker</tt>
see above
Return type

Return true if any transaction has been performed.

Note: The feedURI and description fields are visible only if there is no initial feed URI (aFeedURI is null).
Note: When aDefaultInsertionPoint is not set, the dialog defaults to the bookmarks root folder.

showMinimalAddLivemarkUI()

This opens the dialog with only the name and folder pickers visible by default. You can still pass in the various paramaters as the default propertiesfor the new live-bookmark.

 boolean showMinimalAddLivemarkUI(aFeedURI,
                                  aSiteURI,
                                  aTitle,
                                  aDescription,
                                  aDefaultInsertionPoint,
                                  aShowPicker)

See showAddLivemarkUI for a description of the params.

showMinimalAddMultiBookmarkUI()

Show an "Add Bookmarks" dialog to allow the adding of a folder full of bookmarks corresponding to the objects in the uriList. This will be called most often as the result of a "Bookmark All Tabs..." command.

 showAddMultiBookmarkUI(aURIList)
Parameters
<tt>aURIList</tt>
List of nsIURI objects representing the locations to be bookmarked.
Return type

Return true if any transaction has been performed.

showBookmarkProperties()

Opens the bookmark properties panel for a given bookmark identifier.

 showBookmarkProperties(aId)
Parameters
<tt>aId</tt>
bookmark identifier for which the properties are to be shown
Return type

Return true if any transaction has been performed.

showFolderProperties()

Opens the folder properties panel for a given folder ID.

 showFolderProperties(aId)
Parameters
<tt>aId</tt>
an integer representing the ID of the folder to edit
Return type

Return true if any transaction has been performed.

showAddFolderUI()

Shows the "New Folder" dialog.

 showAddFolderUI(aTitle,
                 aDefaultInsertionPoint, 
                 aShowPicker)
Parameters
<tt>[optional] aTitle</tt>
The default title for the new bookmark.
<tt>[optional] aDefaultInsertionPoint</tt>
The default insertion point for the new item. If set, the folder picker would be hidden unless aShowPicker is set to true, in which case the dialog only uses the folder identifier from the insertion point as the initially selected item in the folder picker.
<tt>[optional] aShowPicker</tt>
see above
Return type

Return true if any transaction has been performed.

Annotations

These are functions that simplify annotating pages. Information like keywords, descriptions, and POST data is already stored as annotations by Firefox, but you can create additional ones. Using the functions can save you some implementation work. For example, given a uri, the traditional code to get all its annotations would be:

 var annotationService = Components.classes["@mozilla.org/browser/annotation-service;1"]
   .getService(Components.interfaces.nsIAnnotationService);
 try {
   var names = annotationService.getPageAnnotationNames(uri);
 } catch(e) {
   // no annotations
 }
 var annotations = new Array();
 for(var i in names) {
   try {
     annotations.push(annotationService.getPageAnnotation(uri, names[i]));
   } catch(e) {
     // this shouldn't happen
   }
 }

The code using placesUtils collapses a bit to:

 var annotations = PlacesUtils.getAnnotationsForUri(uri);

saving you a bit of clumsy code and leaving Mozilla to make sure everything is written correctly. It also gives you more information that my hastily written (and probably incorrect) example up above. The annotation objects returned or send from/to all these functions all are arrays of objects which have the properties:

<tt>name</tt>
the annotation name
<tt>flags</tt>
annotation flags
<tt>expires</tt>
annotation expiration
<tt>mimeType</tt>
mimetype of the annotation, usually only used for binary annotations
<tt>type</tt>
the type used for non-binary annotations
<tt>value</tt>
the value of the annotation

getAnnotationsForURI()

Fetch all annotations for a URI, including all properties of each annotation which would be required to recreate it.

 array object getAnnotationsForURI(aURI)
Parameters
<tt>aURI</tt>
The URI for which annotations are to be retrieved.

Return array of objects, each containing the following properties: name, flags, expires, mimeType, type, value

getAnnotationsForItem()

Fetch all annotations for an item, including all properties of each annotation which would be required to recreate it.

 array object getAnnotationsForItem(aItemId)
Parameters
<tt>aItemId</tt>
The identifier of the itme for which annotations are to be retrieved.
Return type

Return Array of objects, each containing the following properties: name, flags, expires, mimeType, type, value

setAnnotationsForURI()

Annotate a URI with a batch of annotations.

 setAnnotationsForURI(nsIURI aURI,
                      array object aAnnos)
Parameters
<tt>aURI</tt>
The URI for which annotations are to be set.
<tt>aAnnotations</tt>
Array of objects, each containing the following properties: name, flags, expires, type, mimeType (only used for binary annotations) value.

setAnnotationsForItem()

Annotate an item with a batch of annotations.

 setAnnotationsForItem(int aItemId,
                       array object aAnnos)
Parameters
<tt>aItemId</tt>
The identifier of the item for which annotations are to be set
<tt>aAnnotations</tt>
Array of objects, each containing the following properties: name, flags, expires, type, mimeType (only used for binary annotations) value.

Other

Other functions that I'm not sure how to file.

getViewForNode()

Returns the closet ancestor places view for the given DOM node

 getViewForNode(aNode)
Parameters
<tt>aNode</tt>
a DOM node
Return type

Return the closet ancestor places view if exists, null otherwsie.

markPageAsTyped()

By calling this before we visit a URL, we will use TRANSITION_TYPED as the transition for the visit to that URL (if we don't have a referrer). This is used when visiting pages from the history menu, history sidebar, url bar, url autocomplete results, and history searches from the places organizer. If we don't call this, we'll treat those visits as TRANSITION_LINK.

 markPageAsTyped(string aURL)

markPageAsFollowedBookmark()

By calling this before we visit a URL, we will use TRANSITION_BOOKMARK as the transition for the visit to that URL (if we don't have a referrer). This is used when visiting pages from the bookmarks menu, personal toolbar, and bookmarks from within the places organizer. If we don't call this, we'll treat those visits as TRANSITION_LINK.

 markPageAsFollowedBookmark(string aURL)

checkURLSecurity()

Allows opening of javascript/data URI only if the given node is bookmarked (see bug 224521).

 checkURLSecurity(aURINode)
Parameters
<tt>aURINode</tt>
a URI node
Return type

Return true if it's safe to open the node in the browser, false otherwise.

getQueryStringForFolder()

Helper for getting a serialized Places query for a particular folder.

 getQueryStringForFolder(int aFolderId)
Parameters
<tt>aFolderId</tt>
The folder id to get a query for.
Return type

Return string serialized place URI

getDescriptionFromDocument()

Get the description associated with a document, as specified in a <META> element.

 getDescriptionFromDocument(doc)
Parameters
<tt>doc</tt>
A DOM Document to get a description for
Return type

Returns a description string if a META element was discovered with a "description" or "httpequiv" attribute, empty string otherwise.

setPostDataForBookmark()

Set the POST data associated with a bookmark, if any. Used by POST keywords.

 setPostDataForBookmark(int aBookmarkId,
                        string aPostData)
<tt>aBookmarkId</tt>
Return type

Returns string of POST data

getPostDataForBookmark()

Get the POST data associated with a bookmark, if any.

 getPostDataForBookmark(int aBookmarkId)
Parameters
<tt>aBookmarkId</tt>
Return type

Returns string of POST data if set for aBookmarkId. null otherwise.

getURLAndPostDataForKeyword()

Get the URI (and any associated POST data) for a given keyword.

 getURLAndPostDataForKeyword(aKeyword)
Parameters
<tt>aKeyword</tt>
keyword
Return type

Returns an array containing a string URL and a string of POST data

getItemDescription()

Retrieve the description of an item

 getItemDescription(aItemId)
Parameters
<tt>aItemId</tt>
item identifier
Return type

Returns the description of the given item, or an empty string if it is not set.

getMostRecentBookmarkForURI()

Get the most recently added/modified bookmark for a URL, excluding items under tag or livemark containers. -1 is returned if no item is found.

 getMostRecentBookmarkForURI(aURI)

getMostRecentFolderForFeedURI()

 getMostRecentFolderForFeedURI(aURI)

getURLsForContainerNode()

 getURLsForContainerNode(aNode)

openContainerNodeInTabs()

 openContainerInTabs(aNode,
                     aEvent)

openURINodesInTabs()

 openURINodesInTabs(aNodes,
                    aEvent)

createMenuItemForNode()

Helper for the toolbar and menu views.

 createMenuItemForNode(aNode,
                       aContainersMap)

Document Tags and Contributors

Last updated by: Wjjohnst,