Bug 1382579 - Part 1: Update the BrowserPageActions API for the UITour's usage, r=Gijs draft
authorFischer.json <fischer.json@gmail.com>
Tue, 01 Aug 2017 12:09:25 +0800
changeset 641504 be1bd805a80de4c078782f962315cda969ba8856
parent 641444 bb8de16ce00cb57b587a14c210ecc7505f366328
child 641505 0d6e3633a550bdb73acb1d712b5fbff378eef7a3
child 641546 906947bc262e1718fe36eb8887ef7ff7497dd358
child 642382 bc774e747c84e9a26f73ab5c0bfaddade47b956d
push id72556
push userfliu@mozilla.com
push dateMon, 07 Aug 2017 07:39:01 +0000
reviewersGijs
bugs1382579
milestone57.0a1
Bug 1382579 - Part 1: Update the BrowserPageActions API for the UITour's usage, r=Gijs - adds `showPanel` so UITour could call it to open the page action panel - makes clicking page action button on the urlbar would toggle the panel. This is for the case, when UITour opens the page action panel to highlight a button it would set "noautohide" to let the panel persistently opened. But we still need a way to let user able to close the panel so made this change. The PanelUI is doing the same thing [1]. UITour wuold remove "noautohide" on the panelHidden event [2]. [1] https://dxr.mozilla.org/mozilla-central/rev/1b065ffd8a535a0ad4c39a912af18e948e6a42c1/browser/components/customizableui/content/panelUI.js#246 [2] https://dxr.mozilla.org/mozilla-central/rev/1b065ffd8a535a0ad4c39a912af18e948e6a42c1/browser/components/uitour/UITour.jsm#1483 MozReview-Commit-ID: FtJZZ0bfy61
browser/base/content/browser-pageActions.js
--- a/browser/base/content/browser-pageActions.js
+++ b/browser/base/content/browser-pageActions.js
@@ -506,16 +506,31 @@ var BrowserPageActions = {
 
     // If the temp panel is open and anchored to the main button, close it.
     let tempPanel = document.getElementById(this._tempPanelID);
     if (tempPanel && tempPanel.anchorNode.id == this.mainButtonNode.id) {
       tempPanel.hidePopup();
       return;
     }
 
+    if (this.panelNode.state == "open") {
+      this.panelNode.hidePopup();
+    } else if (this.panelNode.state == "closed") {
+      this.showPanel(event);
+    }
+  },
+
+  /**
+   * Show the page action panel
+   *
+   * @param  event (DOM event, optional)
+   *         The event that triggers showing the panel. (such as a mouse click,
+   *         if the user clicked something to open the panel)
+   */
+  showPanel(event = null) {
     for (let action of PageActions.actions) {
       let buttonNodeID = this._panelButtonNodeIDForActionID(action.id);
       let buttonNode = document.getElementById(buttonNodeID);
       action.onShowingInPanel(buttonNode);
     }
 
     this.panelNode.hidden = false;
     this.panelNode.openPopup(this.mainButtonNode, {