Bug 1517943 - Associate bookmarksEventHandler onClick and onCommand with a places view. r=IanN
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Sun, 06 Jan 2019 23:21:44 +0100
changeset 33277 477951a3314a
parent 33276 3bad8af89b0e
child 33278 ab47677bc7ad
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN
bugs1517943, 562998
Bug 1517943 - Associate bookmarksEventHandler onClick and onCommand with a places view. r=IanN Port remaining part of Bug 562998 [Selecting commands from a bookmarks context menu while the window isn't active does nothing].
suite/browser/browser-places.js
suite/browser/navigator.xul
suite/browser/navigatorOverlay.xul
--- a/suite/browser/browser-places.js
+++ b/suite/browser/browser-places.js
@@ -526,42 +526,44 @@ var PlacesCommandHook = {
     }
   },
 };
 
 /**
  * Functions for handling events in the Bookmarks Toolbar and menu.
  */
 var BookmarksEventHandler = {
-  /**
-   * Handler for click event for an item in the bookmarks toolbar or menu.
-   * Menus and submenus from the folder buttons bubble up to this handler.
-   * Left-click is handled in the onCommand function.
-   * When items are middle-clicked (or clicked with modifier), open in tabs.
-   * If the click came through a menu, close the menu.
-   * @param aEvent
-   *        DOMEvent for the click
-   */
 
   onMouseUp(aEvent) {
     // Handles left-click with modifier if not browser.bookmarks.openInTabClosesMenu.
     if (aEvent.button != 0 || PlacesUIUtils.openInTabClosesMenu)
       return;
     let target = aEvent.originalTarget;
     if (target.tagName != "menuitem")
       return;
     let modifKey = AppConstants.platform === "macosx" ? aEvent.metaKey
                                                       : aEvent.ctrlKey;
     // Don't keep menu open for 'Open all in Tabs'.
     if (modifKey && !target.classList.contains("openintabs-menuitem")) {
       target.setAttribute("closemenu", "none");
     }
   },
 
-  onClick: function BEH_onClick(aEvent) {
+  /**
+   * Handler for click event for an item in the bookmarks toolbar or menu.
+   * Menus and submenus from the folder buttons bubble up to this handler.
+   * Left-click is handled in the onCommand function.
+   * When items are middle-clicked (or clicked with modifier), open in tabs.
+   * If the click came through a menu, close the menu.
+   * @param aEvent
+   *        DOMEvent for the click
+   * @param aView
+   *        The places view which aEvent should be associated with.
+   */
+  onClick: function BEH_onClick(aEvent, aView) {
     // Only handle middle-click or left-click with modifiers.
     if (aEvent.button == 2 || (aEvent.button == 0 && !aEvent.shiftKey &&
                                !aEvent.ctrlKey && !aEvent.metaKey))
       return;
 
     var target = aEvent.originalTarget;
     // If this event bubbled up from a menu or menuitem,
     // close the menus if browser.bookmarks.openInTabClosesMenu.
@@ -581,17 +583,17 @@ var BookmarksEventHandler = {
       }, 500);
     }
 
     if (target._placesNode && PlacesUtils.nodeIsContainer(target._placesNode)) {
       // 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 (target.localName == "menu" || target.localName == "toolbarbutton")
-        PlacesUIUtils.openContainerNodeInTabs(target._placesNode, aEvent);
+        PlacesUIUtils.openContainerNodeInTabs(target._placesNode, aEvent, aView);
     }
     else if (aEvent.button == 1) {
       // left-clicks with modifier are already served by onCommand
       this.onCommand(aEvent);
     }
   },
 
   /**
--- a/suite/browser/navigator.xul
+++ b/suite/browser/navigator.xul
@@ -424,17 +424,17 @@
                      ondragover="PlacesMenuDNDHandler.onDragOver(event);"
                      ondragexit="PlacesMenuDNDHandler.onDragExit(event);"
                      ondrop="PlacesMenuDNDHandler.onDrop(event);">
         <menupopup id="BMB_bookmarksPopup"
                    placespopup="true"
                    context="placesContext"
                    openInTabs="children"
                    oncommand="BookmarksEventHandler.onCommand(event);"
-                   onclick="BookmarksEventHandler.onClick(event);"
+                   onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);"
                    onpopupshowing="BookmarksMenu.onPopupShowing(event, 'BMB_');
                                    BookmarksEventHandler.onPopupShowing(event);"
                    tooltip="bhTooltip" popupsinherittooltip="true">
           <menuitem command="Browser:AddBookmark"/>
           <menuitem command="Browser:AddBookmarkAs"/>
           <menuitem command="Browser:BookmarkAllTabs"/>
           <menuitem command="Browser:ManageBookmark"/>
           <menuseparator/>
@@ -468,17 +468,17 @@
         </menupopup>
       </toolbarbutton>
 
       <toolbaritem flex="1" id="personal-bookmarks" title="&bookmarksToolbarItem.label;"
                    removable="true">
         <hbox flex="1"
               id="PlacesToolbar"
               context="placesContext"
-              onclick="BookmarksEventHandler.onClick(event);"
+              onclick="BookmarksEventHandler.onClick(event, this._placesView);"
               oncommand="BookmarksEventHandler.onCommand(event);"
               tooltip="bhTooltip"
               popupsinherittooltip="true">
           <toolbarbutton class="bookmark-item bookmarks-toolbar-customize"
                          mousethrough="never"
                          label="&bookmarksToolbarItem.label;"/>
           <hbox flex="1">
             <hbox align="center">
--- a/suite/browser/navigatorOverlay.xul
+++ b/suite/browser/navigatorOverlay.xul
@@ -462,17 +462,17 @@
           ondragenter="PlacesMenuDNDHandler.onDragEnter(event);"
           ondragover="PlacesMenuDNDHandler.onDragOver(event);"
           ondrop="PlacesMenuDNDHandler.onDrop(event);">
       <menupopup id="bookmarksMenuPopup"
                  placespopup="true"
                  context="placesContext"
                  openInTabs="children"
                  oncommand="BookmarksEventHandler.onCommand(event);"
-                 onclick="BookmarksEventHandler.onClick(event);"
+                 onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);"
                  onpopupshowing="BookmarksMenu.onPopupShowing(event, '');
                                  BookmarksEventHandler.onPopupShowing(event);"
                  tooltip="bhTooltip" popupsinherittooltip="true">
         <menuitem id="menu_bookmarkThisPage"
                   command="Browser:AddBookmark"
                   key="addBookmarkKb"/>
         <menuitem id="menu_bookmarkThisPageAs"
                   command="Browser:AddBookmarkAs"