Bug 1112525 - UITour: Change the loop-selectedRoomButtons target to anchor from the chatbox's browser so info panels behave when the buttons disappear. r=dolske a=gavin
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Mon, 22 Dec 2014 14:24:35 -0500
changeset 234359 90ef4a7c49866f648ebeba41ca1a2b49f7b0ce58
parent 234358 324cec4998f2ce2df234e26202390399384058b8
child 234360 91050fafc8b62822d1b18a2bc25c5d371d9d70dd
push id4278
push usermozilla@noorenberghe.ca
push dateWed, 24 Dec 2014 05:56:20 +0000
treeherdermozilla-beta@90ef4a7c4986 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske, gavin
bugs1112525
milestone35.0
Bug 1112525 - UITour: Change the loop-selectedRoomButtons target to anchor from the chatbox's browser so info panels behave when the buttons disappear. r=dolske a=gavin The copy/email buttons can disappear when the feedback form appears or when someone else joins a room.
browser/modules/UITour.jsm
--- a/browser/modules/UITour.jsm
+++ b/browser/modules/UITour.jsm
@@ -140,37 +140,46 @@ this.UITour = {
         let loopBrowser = aDocument.querySelector("#loop-notification-panel > #loop");
         if (!loopBrowser) {
           return null;
         }
         return loopBrowser.contentDocument.querySelector(".room-list");
       },
     }],
     ["loop-selectedRoomButtons", {
-      infoPanelPosition: "leftcenter bottomright",
+      infoPanelOffsetY: -20,
+      infoPanelPosition: "start_after",
       query: (aDocument) => {
         let chatbox = aDocument.querySelector("chatbox[src^='about\:loopconversation'][selected]");
-        if (!chatbox || !chatbox.contentDocument) {
+
+        // Check that the real target actually exists
+        if (!chatbox || !chatbox.contentDocument ||
+            !chatbox.contentDocument.querySelector(".call-action-group")) {
           return null;
         }
-        return chatbox.contentDocument.querySelector(".call-action-group");
+
+        // But anchor on the <browser> in the chatbox so the panel doesn't jump to undefined
+        // positions when the copy/email buttons disappear e.g. when the feedback form opens or
+        // somebody else joins the room.
+        return chatbox.content;
       },
     }],
     ["loop-signInUpLink", {
       query: (aDocument) => {
         let loopBrowser = aDocument.querySelector("#loop-notification-panel > #loop");        if (!loopBrowser) {
           return null;
         }
         return loopBrowser.contentDocument.querySelector(".signin-link");
       },
     }],
 
     ["privateWindow",  {query: "#privatebrowsing-button"}],
     ["quit",        {query: "#PanelUI-quit"}],
     ["search",      {
+      infoPanelOffsetX: 18,
       infoPanelPosition: "after_start",
       query: "#searchbar",
       widgetName: "search-container",
     }],
     ["searchProvider", {
       query: (aDocument) => {
         let searchbar = aDocument.getElementById("searchbar");
         if (searchbar.hasAttribute("oneoffui")) {
@@ -954,16 +963,18 @@ this.UITour = {
           node = null;
         }
       } else {
         node = aWindow.document.querySelector(targetQuery);
       }
 
       deferred.resolve({
         addTargetListener: targetObject.addTargetListener,
+        infoPanelOffsetX: targetObject.infoPanelOffsetX,
+        infoPanelOffsetY: targetObject.infoPanelOffsetY,
         infoPanelPosition: targetObject.infoPanelPosition,
         node: node,
         removeTargetListener: targetObject.removeTargetListener,
         targetName: aTargetName,
         widgetName: targetObject.widgetName,
         allowAdd: targetObject.allowAdd,
       });
     }).catch(log.error);
@@ -1293,22 +1304,20 @@ this.UITour = {
 
       tooltip.setAttribute("targetName", aAnchor.targetName);
       tooltip.hidden = false;
       let alignment = "bottomcenter topright";
       if (aAnchor.infoPanelPosition) {
         alignment = aAnchor.infoPanelPosition;
       }
 
-      let xOffset = 0, yOffset = 0;
-      if (aAnchor.targetName == "search") {
-        xOffset = 18;
-      }
+      let { infoPanelOffsetX: xOffset, infoPanelOffsetY: yOffset } = aAnchor;
+
       this._addAnnotationPanelMutationObserver(tooltip);
-      tooltip.openPopup(aAnchorEl, alignment, xOffset, yOffset);
+      tooltip.openPopup(aAnchorEl, alignment, xOffset || 0, yOffset || 0);
       if (tooltip.state == "closed") {
         document.defaultView.addEventListener("endmodalstate", function endModalStateHandler() {
           document.defaultView.removeEventListener("endmodalstate", endModalStateHandler);
           tooltip.openPopup(aAnchorEl, alignment);
         }, false);
       }
     }