diff --git a/mozilla/browser/base/content/browser-places.js b/mozilla/browser/base/content/browser-places.js index ce57e8585a8..4039f510c1c 100644 --- a/mozilla/browser/base/content/browser-places.js +++ b/mozilla/browser/base/content/browser-places.js @@ -290,20 +290,28 @@ var BookmarksEventHandler = { if (target.localName == "menupopup" && target.id != "bookmarksMenuPopup" && target.getAttribute("anonid") != "chevronPopup") { - // Show "Open All in Tabs" menuitem if there are at least - // two menuitems with places result nodes, and "Open (Feed Name)" - // if it's a livemark with a siteURI. + // Add the "Open All in Tabs" menuitem if there are + // at least two menuitems with places result nodes. + // Add the "Open (Feed Name)" menuitem if it's a livemark with a siteURI. var numNodes = 0; var hasMultipleEntries = false; var hasFeedHomePage = false; var currentChild = target.firstChild; - while (currentChild && numNodes < 2) { - if (currentChild.node && currentChild.localName == "menuitem") + while (currentChild) { + if (currentChild.localName == "menuitem" && currentChild.node) numNodes++; + + // If the menuitem already exists, do nothing. + if (currentChild.getAttribute("openInTabs") == "true") + return; + if (currentChild.hasAttribute("siteURI")) + return; + currentChild = currentChild.nextSibling; } if (numNodes > 1) hasMultipleEntries = true; + var button = target.parentNode; if (button.getAttribute("livemark") == "true" && button.hasAttribute("siteURI")) diff --git a/mozilla/browser/components/places/content/menu.xml b/mozilla/browser/components/places/content/menu.xml index c8e157c3edd..86a21106fe0 100755 --- a/mozilla/browser/components/places/content/menu.xml +++ b/mozilla/browser/components/places/content/menu.xml @@ -62,8 +62,11 @@ ]]> @@ -88,11 +91,10 @@ @@ -180,7 +182,105 @@ //LOG("KIDS = " + this.childNodes.length); ]]> - + + + null + + + + + + + + + + + + +#ifdef XP_MACOSX + false +#endif + 0) { for (var i = 0; i < cc; ++i) { var child = this._resultNode.getChild(i); - var element = null; - if (PlacesUtils.nodeIsURI(child) || noSubmenus) { - element = document.createElementNS(XULNS, "menuitem"); - element.setAttribute("label", child.title); - element.setAttribute("url", child.uri); - element.setAttribute("statustext", child.uri); - element.className = "menuitem-iconic bookmark-item"; - } - else if (PlacesUtils.nodeIsSeparator(child)) { - element = document.createElementNS(XULNS, "menuseparator"); - } - else if (PlacesUtils.nodeIsContainer(child)) { - element = document.createElementNS(XULNS, "menu"); - element.setAttribute("type", "menu"); - element.setAttribute("container", "true"); - element.setAttribute("label", child.title); - - if (PlacesUtils.nodeIsLivemarkContainer(child)) { - element.setAttribute("livemark", "true"); - var folder = child.itemId; - var siteURI = PlacesUtils.livemarks.getSiteURI(folder); - if (siteURI) { - element.setAttribute("siteURI", siteURI.spec); - } - } - - var popup = document.createElementNS(XULNS, "menupopup"); - popup.setAttribute("type", "places"); - element.appendChild(popup); -#ifndef XP_MACOSX - // No context menus on menus on Mac - // The context menu is set here instead of in the xbl constructor - // because it doesn't get initialized properly if set in the constructor. - popup.setAttribute("context", "placesContext"); -#endif - popup._result = this._result; - popup._resultNode = child; - element.className = "menu-iconic bookmark-item"; -#ifdef XP_MACOSX - // If this is a child of the bookmarks menubar, we have to manually attach - // its xbl binding, because it's not a dom node and the style rules don't - // get applied correctly. - if (needsBindingAttachment) { - const MENU_URI = "chrome://browser/content/places/menu.xml#places-menupopup"; - document.addBinding(popup, MENU_URI); - } -#endif - } - // else if (nodeIsQuery) ... add menu to build kids - if (element) { - element.node = child; - - // Add the new element to the menu. If there is static content at - // the end of the menu, add the element before that. Otherwise, - // just add to the end. - if (this._endMarker != -1) - this.insertBefore(element, this.childNodes[this._endMarker++]); - else - this.appendChild(element); - } - if (child.icon) - element.setAttribute("image", child.icon.spec); + this.insertNewItem(child, null); } - } else { + } + else { // This menu is empty. If there is no static content, add // an element to show it is empty. if (this._startMarker == -1 && this._endMarker == -1) { var label = PlacesUtils.getString("bookmarksMenuEmptyFolder"); - var element = null; - element = document.createElementNS(XULNS, "menuitem"); + const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; + var element = document.createElementNS(XULNS, "menuitem"); element.setAttribute("label", label); element.setAttribute("disabled", true); this.appendChild(element); } } - - // Reset the container to the same state it was in before the function was called. - this._resultNode.containerOpen = wasOpen; ]]> - + + + + @@ -316,7 +482,7 @@ this.hidePopup(); ]]> - + - + - + - + - + - + - + - + - + - + @@ -695,7 +860,7 @@ return true; ]]> - + @@ -710,8 +875,8 @@ ]]> - - + + - if (event.target == this) { - if (PlacesUtils.nodeIsContainer(this._resultNode)) { - this._resultNode.QueryInterface(Ci.nsINavHistoryContainerResultNode); - this._resultNode.containerOpen = false; - } - // The autoopened attribute is set for folders which have been - // automatically opened when dragged over. Turn off this attribute - // when the folder closes because it is no longer applicable. - this.removeAttribute("autoopened"); - } + if (event.target != this) + return; + + // UI performance: keep the resultnode open so we don't rebuild its + // contents whenever the popup is reopened. + + // The autoopened attribute is set for folders which have been + // automatically opened when dragged over. Turn off this attribute + // when the folder closes because it is no longer applicable. + this.removeAttribute("autoopened"); + @@ -274,6 +272,9 @@ button.appendChild(popup); popup._result = this._result; popup._resultNode = child; + popup._containerNodesMap = this._containerNodesMap; + this._containerNodesMap.push({ resultNode: child, + domNode: popup }); } button.setAttribute("label", title); @@ -289,24 +290,24 @@ - @@ -370,7 +371,6 @@ options.value); this._result.viewer = this._viewer; this._result.root.containerOpen = true; - this._rebuild(); } catch(ex) { // Invalid query, or had no results. @@ -379,42 +379,42 @@ return val; ]]> - + - + - + - + - + - + - + - + - + PlacesUtils.GENERIC_VIEW_DROP_TYPES - + + + [] +