Bug 1162750 - Reader View tour tool tip cannot be dismissed by clicking outside the door hanger. r?MattN,past draft
authorJared Wein <jwein@mozilla.com>
Thu, 18 Feb 2016 18:41:32 -0500
changeset 332006 872fb614191094a90ea84780a9720395b5e156f7
parent 331943 6226f2e8a41b637c428862cf6931462bf59938ff
child 514518 507c584e0b865fe2dd94c7644e2a9093de7d0eeb
push id11135
push userjwein@mozilla.com
push dateThu, 18 Feb 2016 23:41:50 +0000
reviewersMattN, past
bugs1162750
milestone47.0a1
Bug 1162750 - Reader View tour tool tip cannot be dismissed by clicking outside the door hanger. r?MattN,past MozReview-Commit-ID: 6ymh8F3KTMq
browser/base/content/browser-trackingprotection.js
browser/components/uitour/UITour.jsm
browser/modules/ReaderParent.jsm
--- a/browser/base/content/browser-trackingprotection.js
+++ b/browser/base/content/browser-trackingprotection.js
@@ -229,11 +229,12 @@ var TrackingProtection = {
 
     let panelTarget = yield UITour.getTarget(window, "trackingProtection");
     UITour.initForBrowser(gBrowser.selectedBrowser, window);
     UITour.showInfo(window, panelTarget,
                     gNavigatorBundle.getString("trackingProtection.intro.title"),
                     gNavigatorBundle.getFormattedString("trackingProtection.intro.description2",
                                                         [brandShortName]),
                     undefined, buttons,
-                    { closeButtonCallback: () => this.dontShowIntroPanelAgain() });
+                    { closeButtonCallback: () => this.dontShowIntroPanelAgain(),
+                      autohide: true });
   }),
 };
--- a/browser/components/uitour/UITour.jsm
+++ b/browser/components/uitour/UITour.jsm
@@ -1487,16 +1487,17 @@ this.UITour = {
    * @param {Node}     aAnchor
    * @param {String}   [aTitle=""]
    * @param {String}   [aDescription=""]
    * @param {String}   [aIconURL=""]
    * @param {Object[]} [aButtons=[]]
    * @param {Object}   [aOptions={}]
    * @param {String}   [aOptions.closeButtonCallback]
    * @param {String}   [aOptions.targetCallback]
+   * @param {Boolean}  [aOptions.autohide]
    */
   showInfo(aChromeWindow, aAnchor, aTitle = "", aDescription = "",
            aIconURL = "", aButtons = [], aOptions = {}) {
     function showInfoPanel(aAnchorEl) {
       aAnchorEl.focus();
 
       let document = aChromeWindow.document;
       let tooltip = document.getElementById("UITourTooltip");
@@ -1562,24 +1563,34 @@ this.UITour = {
           type: event.type,
         };
         aOptions.targetCallback(details);
       };
       if (aOptions.targetCallback && aAnchor.addTargetListener) {
         aAnchor.addTargetListener(document, targetCallback);
       }
 
+      if (aOptions.autohide) {
+        tooltip.removeAttribute("noautohide");
+      }
+
       tooltip.addEventListener("popuphiding", function tooltipHiding(event) {
         tooltip.removeEventListener("popuphiding", tooltipHiding);
         tooltipClose.removeEventListener("command", closeButtonCallback);
         if (aOptions.targetCallback && aAnchor.removeTargetListener) {
           aAnchor.removeTargetListener(document, targetCallback);
         }
       });
 
+      tooltip.addEventListener("popuphidden", function tooltipHidden(event) {
+        tooltip.removeEventListener("popuphidden", tooltipHidden);
+        // noautohide attribute may have been removed by options.autohide
+        tooltip.setAttribute("noautohide", "true");
+      });
+
       tooltip.setAttribute("targetName", aAnchor.targetName);
       tooltip.hidden = false;
       let alignment = "bottomcenter topright";
       if (aAnchor.infoPanelPosition) {
         alignment = aAnchor.infoPanelPosition;
       }
 
       let { infoPanelOffsetX: xOffset, infoPanelOffsetY: yOffset } = aAnchor;
--- a/browser/modules/ReaderParent.jsm
+++ b/browser/modules/ReaderParent.jsm
@@ -187,17 +187,17 @@ var ReaderParent = {
       if (win.devicePixelRatio > 1) {
         icon += "reader-tour@2x.png";
       } else {
         icon += "reader-tour.png";
       }
       UITour.showInfo(win, target,
                       browserBundle.GetStringFromName("readingList.promo.firstUse.readerView.title"),
                       browserBundle.GetStringFromName("readingList.promo.firstUse.readerView.body"),
-                      icon);
+                      icon, undefined, {autohide: true});
     });
   },
 
   /**
    * Gets an article for a given URL. This method will download and parse a document.
    *
    * @param url The article URL.
    * @param browser The browser where the article is currently loaded.