Bug 387138: set livemark attribute on toolbar entries. r=mak a=dolske
authorRichard Newman <rnewman@mozilla.com>
Fri, 25 Feb 2011 19:06:00 -0800
changeset 63124 f20f6ca6be78703dad7c22df9f274c4ede9885d1
parent 63123 a0cd97a4231526c1042da16f009c7c786f2be993
child 63128 d708c2fa7fea7b3d5517c3d3122dcdd6b7687ef8
push id8
push userrnewman@mozilla.com
push dateSat, 26 Feb 2011 03:07:07 +0000
treeherderservices-central@f20f6ca6be78 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak, dolske
bugs387138
milestone2.0b13pre
Bug 387138: set livemark attribute on toolbar entries. r=mak a=dolske
browser/components/places/content/browserPlacesViews.js
--- a/browser/components/places/content/browserPlacesViews.js
+++ b/browser/components/places/content/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";
@@ -1139,16 +1138,42 @@ 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)