diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js index 19b886f5c3c..40159205ad8 100644 --- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -582,12 +582,12 @@ var BookmarksEventHandler = { var target = aEvent.originalTarget; var view = PlacesUtils.getViewForNode(target); - if (PlacesUtils.nodeIsFolder(view.selectedNode)) { + if (target.node && PlacesUtils.nodeIsFolder(target.node)) { // Don't open the root folder in tabs when the empty area on the toolbar // is middle-clicked or when a non-bookmark item except for Open in Tabs) // in a bookmarks menupopup is middle-clicked. - if (!view.controller.rootNodeIsSelected()) - view.controller.openSelectionInTabs(aEvent); + if (target.localName == "menu" || target.localName == "toolbarbutton") + PlacesUtils.openContainerNodeInTabs(target.node, aEvent); } else this.onCommand(aEvent); @@ -624,11 +624,8 @@ var BookmarksEventHandler = { */ onCommand: function BM_onCommand(aEvent) { var target = aEvent.originalTarget; - if (target.node) { - PlacesUtils.getViewForNode(target) - .controller - .openSelectedNodeWithEvent(aEvent); - } + if (target.node) + PlacesUtils.openNodeWithEvent(target.node, aEvent); }, /** diff --git a/browser/components/places/content/bookmarksPanel.xul b/browser/components/places/content/bookmarksPanel.xul index 4a1559049f7..8708d90b472 100644 --- a/browser/components/places/content/bookmarksPanel.xul +++ b/browser/components/places/content/bookmarksPanel.xul @@ -72,8 +72,8 @@ flex="1" hidecolumnpicker="true" context="placesContext" - onkeypress="if (event.keyCode == 13) this.controller.openSelectedNodeWithEvent(event);" - onclick="SidebarUtils.handleClick(this, event);" + onkeypress="SidebarUtils.handleTreeKeyPress(event);" + onclick="SidebarUtils.handleTreeClick(this, event);" onmousemove="SidebarUtils.handleTreeMouseMove(event);" onmouseout="SidebarUtils.clearURLFromStatusBar();"> diff --git a/browser/components/places/content/controller.js b/browser/components/places/content/controller.js index 5cb1127f40f..5bc9e953632 100755 --- a/browser/components/places/content/controller.js +++ b/browser/components/places/content/controller.js @@ -213,13 +213,13 @@ PlacesController.prototype = { this.selectAll(); break; case "placesCmd_open": - this.openSelectedNodeIn("current"); + PlacesUtils.openNodeIn(this._view.selectedNode, "current"); break; case "placesCmd_open:window": - this.openSelectedNodeIn("window"); + PlacesUtils.openNodeIn(this._view.selectedNode, "window"); break; case "placesCmd_open:tab": - this.openSelectedNodeIn("tab"); + PlacesUtils.openNodeIn(this._view.selectedNode, "tab"); break; case "placesCmd_new:folder": this.newItem("folder"); @@ -612,50 +612,6 @@ PlacesController.prototype = { this._view.selectAll(); }, - /** - * Loads the selected node's URL in the appropriate tab or window or as a web - * panel given the user's preference specified by modifier keys tracked by a - * DOM mouse/key event. - * @param aEvent - * The DOM mouse/key event with modifier keys set that track the - * user's preferred destination window or tab. - */ - openSelectedNodeWithEvent: function PC_openSelectedNodeWithEvent(aEvent) { - this.openSelectedNodeIn(whereToOpenLink(aEvent)); - }, - - /** - * Loads the selected node's URL in the appropriate tab or window or as a - * web panel. - * see also openUILinkIn - */ - openSelectedNodeIn: function PC_openSelectedNodeIn(aWhere) { - var node = this._view.selectedNode; - if (node && PlacesUtils.nodeIsURI(node) && - PlacesUtils.checkURLSecurity(node)) { - var isBookmark = PlacesUtils.nodeIsBookmark(node); - - if (isBookmark) - PlacesUtils.markPageAsFollowedBookmark(node.uri); - else - PlacesUtils.markPageAsTyped(node.uri); - - // Check whether the node is a bookmark which should be opened as - // a web panel - if (aWhere == "current" && isBookmark) { - if (PlacesUtils.annotations - .itemHasAnnotation(node.itemId, LOAD_IN_SIDEBAR_ANNO)) { - var w = getTopWin(); - if (w) { - w.openWebPanel(node.title, node.uri); - return; - } - } - } - openUILinkIn(node.uri, aWhere); - } - }, - /** * Opens the bookmark properties for the selected URI Node. */ diff --git a/browser/components/places/content/history-panel.xul b/browser/components/places/content/history-panel.xul index ec68e58571d..ef5fdd3ffdb 100644 --- a/browser/components/places/content/history-panel.xul +++ b/browser/components/places/content/history-panel.xul @@ -119,9 +119,9 @@ flex="1" type="places" context="placesContext" - onkeypress="if (event.keyCode == 13) this.controller.openSelectedNodeWithEvent(event);" hidecolumnpicker="true" - onclick="SidebarUtils.handleClick(this, event, true);" + onkeypress="SidebarUtils.handleTreeKeyPress(event);" + onclick="SidebarUtils.handleTreeClick(this, event);" onmousemove="SidebarUtils.handleTreeMouseMove(event);" onmouseout="SidebarUtils.clearURLFromStatusBar();"> diff --git a/browser/components/places/content/places.js b/browser/components/places/content/places.js index 1cf1281b1cb..83258ddf589 100755 --- a/browser/components/places/content/places.js +++ b/browser/components/places/content/places.js @@ -232,21 +232,19 @@ var PlacesOrganizer = { * The mouse event. */ onTreeClick: function PO_onTreeClick(aEvent) { - var currentView = aEvent.currentTarget; - var controller = currentView.controller; - if (aEvent.target.localName != "treechildren") return; + var currentView = aEvent.currentTarget; var selectedNode = currentView.selectedNode; if (selectedNode && aEvent.button == 1) { - if (PlacesUtils.nodeIsURI(currentView.selectedNode)) - controller.openSelectedNodeWithEvent(aEvent); + if (PlacesUtils.nodeIsURI(selectedNode)) + PlacesUtils.openNodeWithEvent(selectedNode, aEvent); else if (PlacesUtils.nodeIsContainer(selectedNode)) { // The command execution function will take care of seeing the // selection is a folder/container and loading its contents in // tabs for us. - controller.openLinksInTabs(); + PlacesUtils.openContainerNodeInTabs(selectedNode); } } }, @@ -259,7 +257,7 @@ var PlacesOrganizer = { }, openSelectedNode: function PU_openSelectedNode(aEvent) { - this._content.controller.openSelectedNodeWithEvent(aEvent); + PlacesUtils.openNodeWithEvent(this._content.selectedNode, aEvent); }, /** diff --git a/browser/components/places/content/sidebarUtils.js b/browser/components/places/content/sidebarUtils.js index 174610b160e..5a70f85a8a8 100644 --- a/browser/components/places/content/sidebarUtils.js +++ b/browser/components/places/content/sidebarUtils.js @@ -37,7 +37,7 @@ # ***** END LICENSE BLOCK ***** var SidebarUtils = { - handleClick: function SU_handleClick(aTree, aEvent, aGutterSelect) { + handleTreeClick: function SU_handleTreeClick(aTree, aEvent, aGutterSelect) { var tbo = aTree.treeBoxObject; var row = { }, col = { }, obj = { }; @@ -67,10 +67,15 @@ var SidebarUtils = { // do this *before* attempting to load the link since openURL uses // selection as an indication of which link to load. tbo.view.selection.select(row.value); - aTree.controller.openSelectedNodeWithEvent(aEvent); + PlacesUtils.openNodeWithEvent(aTree.selectedNode, aEvent); } }, - + + handleTreeKeyPress: function SU_handleTreeKeyPress(aEvent) { + if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN) + PlacesUtils.openNodeWithEvent(aEvent.target.selectedNode, aEvent); + }, + /** * The following function displays the URL of a node that is being * hovered over. diff --git a/browser/components/places/content/utils.js b/browser/components/places/content/utils.js index 386a5edccf2..aad466da7cb 100644 --- a/browser/components/places/content/utils.js +++ b/browser/components/places/content/utils.js @@ -1780,6 +1780,51 @@ var PlacesUtils = { this._openTabset(urlsToOpen, aEvent); }, + /** + * Loads the node's URL in the appropriate tab or window or as a web + * panel given the user's preference specified by modifier keys tracked by a + * DOM mouse/key event. + * @param aNode + * An uri result node. + * @param aEvent + * The DOM mouse/key event with modifier keys set that track the + * user's preferred destination window or tab. + */ + openNodeWithEvent: function PU_openNodeWithEvent(aNode, aEvent) { + this.openNodeIn(aNode, whereToOpenLink(aEvent)); + }, + + /** + * Loads the node's URL in the appropriate tab or window or as a + * web panel. + * see also openUILinkIn + */ + openNodeIn: function PU_openNodeIn(aNode, aWhere) { + if (aNode && PlacesUtils.nodeIsURI(aNode) && + PlacesUtils.checkURLSecurity(aNode)) { + var isBookmark = PlacesUtils.nodeIsBookmark(aNode); + + if (isBookmark) + PlacesUtils.markPageAsFollowedBookmark(aNode.uri); + else + PlacesUtils.markPageAsTyped(aNode.uri); + + // Check whether the node is a bookmark which should be opened as + // a web panel + if (aWhere == "current" && isBookmark) { + if (PlacesUtils.annotations + .itemHasAnnotation(aNode.itemId, LOAD_IN_SIDEBAR_ANNO)) { + var w = getTopWin(); + if (w) { + w.openWebPanel(aNode.title, aNode.uri); + return; + } + } + } + openUILinkIn(aNode.uri, aWhere); + } + }, + /** * Helper for the toolbar and menu views */