B2G/gecko/toolkit/components/places/BookmarkHTMLUtils.jsm
/*
   * Handles "<a" tags by creating a new bookmark. The title of the bookmark
   * will be the text content, which will be stuffed in previousText for us
   * and which will be saved by handleLinkEnd
   */
Handles "<a" tags by creating a new bookmark. The title of the bookmark
will be the text content, which will be stuffed in previousText for us
and which will be saved by handleLinkEnd
Handles " <a " tags by creating a new bookmark . The title of the bookmark will be the text content which will be stuffed in previousText for us and which will be saved by handleLinkEnd
function handleLinkBegin(aElt) {
    let frame = this._curFrame;
    frame.previousFeed = null;
    frame.previousId = 0;
    frame.previousText = "";
    let href = this._safeTrim(aElt.getAttribute("href"));
    let feedUrl = this._safeTrim(aElt.getAttribute("feedurl"));
    let icon = this._safeTrim(aElt.getAttribute("icon"));
    let iconUri = this._safeTrim(aElt.getAttribute("icon_uri"));
    let lastCharset = this._safeTrim(aElt.getAttribute("last_charset"));
    let keyword = this._safeTrim(aElt.getAttribute("shortcuturl"));
    let postData = this._safeTrim(aElt.getAttribute("post_data"));
    let webPanel = this._safeTrim(aElt.getAttribute("web_panel"));
    let micsumGenURI = this._safeTrim(aElt.getAttribute("micsum_gen_uri"));
    let generatedTitle = this._safeTrim(aElt.getAttribute("generated_title"));
    let dateAdded = this._safeTrim(aElt.getAttribute("add_date"));
    let lastModified = this._safeTrim(aElt.getAttribute("last_modified"));
    if (feedUrl) {
      frame.previousFeed = NetUtil.newURI(feedUrl);
    }
    if (href) {
      try {
        frame.previousLink = NetUtil.newURI(href);
      } catch(e) {
        if (!frame.previousFeed) {
          frame.previousLink = null;
          return;
        }
      }
    } else {
      frame.previousLink = null;
      if (!frame.previousFeed) {
        return;
      }
    }
    if (lastModified) {
      frame.previousLastModifiedDate =
        this._convertImportedDateToInternalDate(lastModified);
    }
    if (frame.previousFeed) {
      return;
    }
    try {
      frame.previousId =
        PlacesUtils.bookmarks.insertBookmark(frame.containerId,
                                             frame.previousLink,
                                             PlacesUtils.bookmarks.DEFAULT_INDEX,
                                             "");
    } catch(e) {
      return;
    }
    if (dateAdded) {
      try {
        PlacesUtils.bookmarks.setItemDateAdded(frame.previousId,
          this._convertImportedDateToInternalDate(dateAdded));
      } catch(e) {
      }
    }
    if (icon || iconUri) {
      let iconUriObject;
      try {
        iconUriObject = NetUtil.newURI(iconUri);
      } catch(e) {
      }
      if (icon || iconUriObject) {
        try {
          this._setFaviconForURI(frame.previousLink, iconUriObject, icon);
        } catch(e) {
        }
      }
    }
    if (keyword) {
      try {
        PlacesUtils.bookmarks.setKeywordForBookmark(frame.previousId, keyword);
        if (postData) {
          PlacesUtils.annotations.setItemAnnotation(frame.previousId,
                                                    POST_DATA_ANNO,
                                                    postData,
                                                    0,
                                                    PlacesUtils.annotations.EXPIRE_NEVER);
        }
      } catch(e) {
      }
    }
    if (webPanel && webPanel.toLowerCase() == "true") {
      try {
        PlacesUtils.annotations.setItemAnnotation(frame.previousId,
                                                  LOAD_IN_SIDEBAR_ANNO,
                                                  1,
                                                  0,
                                                  PlacesUtils.annotations.EXPIRE_NEVER);
      } catch(e) {
      }
    }
    if (lastCharset) {
      try {
        PlacesUtils.history.setCharsetForURI(frame.previousLink, lastCharset);
      } catch(e) {
      }
    }
  }
function handleLinkBegin ( aElt ) { let frame = this . _curFrame ; frame . previousFeed = null ; frame . previousId = 0 ; frame . previousText = "" ; let href = this . _safeTrim ( aElt . getAttribute ( "href" ) ) ; let feedUrl = this . _safeTrim ( aElt . getAttribute ( "feedurl" ) ) ; let icon = this . _safeTrim ( aElt . getAttribute ( "icon" ) ) ; let iconUri = this . _safeTrim ( aElt . getAttribute ( "icon_uri" ) ) ; let lastCharset = this . _safeTrim ( aElt . getAttribute ( "last_charset" ) ) ; let keyword = this . _safeTrim ( aElt . getAttribute ( "shortcuturl" ) ) ; let postData = this . _safeTrim ( aElt . getAttribute ( "post_data" ) ) ; let webPanel = this . _safeTrim ( aElt . getAttribute ( "web_panel" ) ) ; let micsumGenURI = this . _safeTrim ( aElt . getAttribute ( "micsum_gen_uri" ) ) ; let generatedTitle = this . _safeTrim ( aElt . getAttribute ( "generated_title" ) ) ; let dateAdded = this . _safeTrim ( aElt . getAttribute ( "add_date" ) ) ; let lastModified = this . _safeTrim ( aElt . getAttribute ( "last_modified" ) ) ; if ( feedUrl ) { frame . previousFeed = NetUtil . newURI ( feedUrl ) ; } if ( href ) { try { frame . previousLink = NetUtil . newURI ( href ) ; } catch ( e ) { if ( ! frame . previousFeed ) { frame . previousLink = null ; return ; } } } else { frame . previousLink = null ; if ( ! frame . previousFeed ) { return ; } } if ( lastModified ) { frame . previousLastModifiedDate = this . _convertImportedDateToInternalDate ( lastModified ) ; } if ( frame . previousFeed ) { return ; } try { frame . previousId = PlacesUtils . bookmarks . insertBookmark ( frame . containerId , frame . previousLink , PlacesUtils . bookmarks . DEFAULT_INDEX , "" ) ; } catch ( e ) { return ; } if ( dateAdded ) { try { PlacesUtils . bookmarks . setItemDateAdded ( frame . previousId , this . _convertImportedDateToInternalDate ( dateAdded ) ) ; } catch ( e ) { } } if ( icon || iconUri ) { let iconUriObject ; try { iconUriObject = NetUtil . newURI ( iconUri ) ; } catch ( e ) { } if ( icon || iconUriObject ) { try { this . _setFaviconForURI ( frame . previousLink , iconUriObject , icon ) ; } catch ( e ) { } } } if ( keyword ) { try { PlacesUtils . bookmarks . setKeywordForBookmark ( frame . previousId , keyword ) ; if ( postData ) { PlacesUtils . annotations . setItemAnnotation ( frame . previousId , POST_DATA_ANNO , postData , 0 , PlacesUtils . annotations . EXPIRE_NEVER ) ; } } catch ( e ) { } } if ( webPanel && webPanel . toLowerCase ( ) == "true" ) { try { PlacesUtils . annotations . setItemAnnotation ( frame . previousId , LOAD_IN_SIDEBAR_ANNO , 1 , 0 , PlacesUtils . annotations . EXPIRE_NEVER ) ; } catch ( e ) { } } if ( lastCharset ) { try { PlacesUtils . history . setCharsetForURI ( frame . previousLink , lastCharset ) ; } catch ( e ) { } } }
Handles "<a" tags by creating a new bookmark.
Handles " <a " tags by creating a new bookmark .
// Make sure that the feed URIs from previous frames are emptied. // Make sure that the bookmark id from previous frames are emptied. // mPreviousText will hold link text, clear it. // Get the attributes we care about. // For feeds, get the feed URL.  If it is invalid, mPreviousFeed will be // NULL and we'll create it as a normal bookmark. // Ignore <a> tags that have no href. // Save the address if it's valid.  Note that we ignore errors if this is a // feed since href is optional for them. // The exception is for feeds, where the href is an optional component // indicating the source web site. // Save bookmark's last modified date. // If this is a live bookmark, we will handle it in HandleLinkEnd(), so we // can skip bookmark creation. // Create the bookmark.  The title is unknown for now, we will set it later. // Set the date added value, if we have it. // Save the favicon. // Save the keyword. // Set load-in-sidebar annotation for the bookmark. // Import last charset.