Bug 636974 - Port Livemark fixes from bug 387138 and bug 636828. r=Neil
authorJens Hatlak <jh@junetz.de>
Mon, 28 Feb 2011 19:28:10 +0100
changeset 7229 80d134cb484ffbebad28f3090e2005c05b7cfe40
parent 7228 c2a8fe26bf324a67166a51bcecfd814f294a18e6
child 7230 cfef66aa339240115eb48d259e72645fb86dd3e2
push idunknown
push userunknown
push dateunknown
reviewersNeil
bugs636974, 387138, 636828
Bug 636974 - Port Livemark fixes from bug 387138 and bug 636828. r=Neil
suite/common/bookmarks/browser-places.js
suite/common/places/browserPlacesViews.js
--- a/suite/common/bookmarks/browser-places.js
+++ b/suite/common/bookmarks/browser-places.js
@@ -789,17 +789,17 @@ var PlacesStarButton = {
     if (aEvent.button == 0 && !this._ignoreClicks)
       PlacesCommandHook.bookmarkCurrentPage(this._itemIds.length > 0);
   },
 
   // nsINavBookmarkObserver
   onItemAdded:
   function PSB_onItemAdded(aItemId, aFolder, aIndex, aItemType, aURI)
   {
-    if (aURI.equals(this._uri)) {
+    if (aURI && aURI.equals(this._uri)) {
       // If a new bookmark has been added to the tracked uri, register it.
       if (this._itemIds.indexOf(aItemId) == -1) {
         this._itemIds.push(aItemId);
         this._updateStateInternal();
       }
     }
   },
 
--- a/suite/common/places/browserPlacesViews.js
+++ b/suite/common/places/browserPlacesViews.js
@@ -438,17 +438,17 @@ PlacesViewBase.prototype = {
 
     // Here we need the <menu>.
     if (elt.localName == "menupopup")
       elt = elt.parentNode;
 
     elt.setAttribute("scheme", PlacesUIUtils.guessUrlSchemeForUI(aURIString));
   },
 
-  nodeIconChanged: function PT_nodeIconChanged(aPlacesNode) {
+  nodeIconChanged: function PVB_nodeIconChanged(aPlacesNode) {
     let elt = aPlacesNode._DOMElement;
     if (!elt)
       throw "aPlacesNode must have _DOMElement set";
 
     // There's no UI representation for the root node, thus there's nothing to
     // be done when the icon changes.
     if (elt == this._rootElt)
       return;
@@ -461,34 +461,33 @@ PlacesViewBase.prototype = {
     if (!icon)
       elt.removeAttribute("image");
     else if (icon != elt.getAttribute("image"))
       elt.setAttribute("image", icon);
   },
 
   nodeAnnotationChanged:
   function PVB_nodeAnnotationChanged(aPlacesNode, aAnno) {
-    // Ensure the changed annotation is a livemark one.
-    if (/^livemark\//.test(aAnno) &&
-        PlacesUtils.nodeIsLivemarkContainer(aPlacesNode)) {
+    // All livemarks have a feedURI, so use it as our indicator.
+    if (aAnno == "livemark/feedURI") {
       let elt = aPlacesNode._DOMElement;
       if (!elt)
         throw "aPlacesNode must have _DOMElement set";
 
       let menu = elt.parentNode;
       if (!menu.hasAttribute("livemark"))
         menu.setAttribute("livemark", "true");
 
       // Add or remove the livemark status menuitem.
       this._ensureLivemarkStatusMenuItem(elt);
     }
   },
 
   nodeTitleChanged:
-  function PM_nodeTitleChanged(aPlacesNode, aNewTitle) {
+  function PVB_nodeTitleChanged(aPlacesNode, aNewTitle) {
     let elt = aPlacesNode._DOMElement;
     if (!elt)
       throw "aPlacesNode must have _DOMElement set";
 
     // There's no UI representation for the root node, thus there's
     // nothing to be done when the title changes.
     if (elt == this._rootElt)
       return;
@@ -534,17 +533,17 @@ PlacesViewBase.prototype = {
         this._showEmptyMenuItem(parentElt);
 
       if (parentElt._endMarker != -1)
         parentElt._endMarker--;
     }
   },
 
   nodeReplaced:
-  function PBV_nodeReplaced(aParentPlacesNode, aOldPlacesNode, aNewPlacesNode, aIndex) {
+  function PVB_nodeReplaced(aParentPlacesNode, aOldPlacesNode, aNewPlacesNode, aIndex) {
     let parentElt = aParentPlacesNode._DOMElement;
     if (!parentElt)
       throw "aParentPlacesNode node must have _DOMElement set";
 
     if (parentElt._built) {
       let elt = aOldPlacesNode._DOMElement;
       if (!elt)
         throw "aOldPlacesNode must have _DOMElement set";
@@ -1137,16 +1136,40 @@ PlacesToolbar.prototype = {
       }
       this.updateChevron();
       return;
     }
 
     PlacesViewBase.prototype.nodeMoved.apply(this, arguments);
   },
 
+  nodeAnnotationChanged:
+  function PT_nodeAnnotationChanged(aPlacesNode, aAnno) {
+    let elt = aPlacesNode._DOMElement;
+    if (!elt)
+      throw "aPlacesNode must have _DOMElement set";
+
+    if (elt == this._rootElt)
+      return;
+
+    // We're notified for the menupopup, not the containing toolbarbutton.
+    if (elt.localName == "menupopup")
+      elt = elt.parentNode;
+
+    if (elt.parentNode == this._rootElt) {
+      // Node is on the toolbar.
+      // All livemarks have a feedURI, so use it as our indicator.
+      if (aAnno == "livemark/feedURI")
+        elt.setAttribute("livemark", true);
+      return;
+    }
+
+    PlacesViewBase.prototype.nodeAnnotationChanged.apply(this, arguments);
+  },
+
   nodeTitleChanged: function PT_nodeTitleChanged(aPlacesNode, aNewTitle) {
     let elt = aPlacesNode._DOMElement;
     if (!elt)
       throw "aPlacesNode must have _DOMElement set";
 
     // There's no UI representation for the root node, thus there's
     // nothing to be done when the title changes.
     if (elt == this._rootElt)