From 6689704402ee2627c6f03d44f929bf5421a506b1 Mon Sep 17 00:00:00 2001 From: Gabriele Best Date: Sat, 14 Nov 2009 13:44:17 +0100 Subject: [PATCH] Bug 476838 - Missing tooltip and statusbar text on "Open " in live bookmarks, r=mak --- browser/base/content/browser-places.js | 33 ++++++++++++++-------- browser/components/places/content/menu.xml | 9 +++++- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js index c9e46f7b83e..6bb04af9add 100644 --- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -889,12 +889,12 @@ var BookmarksEventHandler = { // Add "Open (Feed Name)" menuitem if it's a livemark with a siteURI target._endOptOpenSiteURI = document.createElement("menuitem"); target._endOptOpenSiteURI.className = "openlivemarksite-menuitem"; - target._endOptOpenSiteURI.setAttribute("siteURI", siteURIString); + target._endOptOpenSiteURI.setAttribute("targetURI", siteURIString); target._endOptOpenSiteURI.setAttribute("oncommand", - "openUILink(this.getAttribute('siteURI'), event);"); + "openUILink(this.getAttribute('targetURI'), event);"); // If a user middle-clicks this item we serve the oncommand event // We are using checkForMiddleClick because of Bug 246720 - // Note: stopPropagation is needed to avoid serving middle-click + // Note: stopPropagation is needed to avoid serving middle-click // with BT_onClick that would open all items in tabs target._endOptOpenSiteURI.setAttribute("onclick", "checkForMiddleClick(this, event); event.stopPropagation();"); @@ -922,6 +922,7 @@ var BookmarksEventHandler = { fillInBHTooltip: function(aDocument, aEvent) { var node; var cropped = false; + var targetURI; if (aDocument.tooltipNode.localName == "treechildren") { var tree = aDocument.tooltipNode.parentNode; @@ -933,18 +934,28 @@ var BookmarksEventHandler = { node = tree.view.nodeForTreeIndex(row.value); cropped = tbo.isCellCropped(row.value, column.value); } - else - node = aDocument.tooltipNode.node; + else { + // Check whether the tooltipNode is a Places node. + // In such a case use it, otherwise check for targetURI attribute. + var tooltipNode = aDocument.tooltipNode; + if (tooltipNode.node) + node = tooltipNode.node; + else { + // This is a static non-Places node. + targetURI = tooltipNode.getAttribute("targetURI"); + } + } - if (!node) + if (!node && !targetURI) return false; - var title = node.title; - var url; + // Show node.label as tooltip's title for non-Places nodes. + var title = node ? node.title : tooltipNode.label; - // Show URL only for URI-type nodes. - if (PlacesUtils.nodeIsURI(node)) - url = node.uri; + // Show URL only for Places URI-nodes or nodes with a targetURI attribute. + var url; + if (targetURI || PlacesUtils.nodeIsURI(node)) + url = targetURI || node.uri; // Show tooltip for containers only if their title is cropped. if (!cropped && !url) diff --git a/browser/components/places/content/menu.xml b/browser/components/places/content/menu.xml index 6342604c153..96d47393f8f 100644 --- a/browser/components/places/content/menu.xml +++ b/browser/components/places/content/menu.xml @@ -510,8 +510,15 @@ if (window.XULBrowserWindow) { var nodeItem = event.target.node; + + var linkURI; if (nodeItem && PlacesUtils.nodeIsURI(nodeItem)) - window.XULBrowserWindow.setOverLink(nodeItem.uri, null); + linkURI = nodeItem.uri; + else if (node.hasAttribute("targetURI")) + linkURI = node.getAttribute("targetURI"); + + if (linkURI) + window.XULBrowserWindow.setOverLink(linkURI, null); } ]]>