Bug 1085330 - UITour: Highlight positioning breaks when icon target moves into "more tools" overflow panel. r=Unfocused, a=dolske
authorJustin Dolske <dolske@mozilla.com>
Tue, 28 Oct 2014 14:31:08 -0700
changeset 225841 74d96225a2a8
parent 225840 776f967418e1
child 225843 cc85ed51d280
push id4035
push usergijskruitbosch@gmail.com
push date2014-10-28 22:24 +0000
treeherdermozilla-beta@74d96225a2a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersUnfocused, dolske
bugs1085330
milestone34.0
Bug 1085330 - UITour: Highlight positioning breaks when icon target moves into "more tools" overflow panel. r=Unfocused, a=dolske
browser/modules/UITour.jsm
--- a/browser/modules/UITour.jsm
+++ b/browser/modules/UITour.jsm
@@ -860,17 +860,27 @@ this.UITour = {
       }
       // Toggle the effect attribute to "none" and flush layout before setting it so the effect plays.
       highlighter.setAttribute("active", "none");
       aTarget.node.ownerDocument.defaultView.getComputedStyle(highlighter).animationName;
       highlighter.setAttribute("active", effect);
       highlighter.parentElement.setAttribute("targetName", aTarget.targetName);
       highlighter.parentElement.hidden = false;
 
-      let targetRect = aTarget.node.getBoundingClientRect();
+      let highlightAnchor;
+      // If the target is in the overflow panel, just highlight the overflow button.
+      if (aTarget.node.getAttribute("overflowedItem")) {
+        let doc = aTarget.node.ownerDocument;
+        let placement = CustomizableUI.getPlacementOfWidget(aTarget.widgetName || aTarget.node.id);
+        let areaNode = doc.getElementById(placement.area);
+        highlightAnchor = areaNode.overflowable._chevron;
+      } else {
+        highlightAnchor = aTarget.node;
+      }
+      let targetRect = highlightAnchor.getBoundingClientRect();
       let highlightHeight = targetRect.height;
       let highlightWidth = targetRect.width;
       let minDimension = Math.min(highlightHeight, highlightWidth);
       let maxDimension = Math.max(highlightHeight, highlightWidth);
 
       // If the dimensions are within 200% of each other (to include the bookmarks button),
       // make the highlight a circle with the largest dimension as the diameter.
       if (maxDimension / minDimension <= 3.0) {
@@ -896,17 +906,17 @@ this.UITour = {
       let highlightStyle = highlightWindow.getComputedStyle(highlighter);
       let highlightHeightWithMin = Math.max(highlightHeight, parseFloat(highlightStyle.minHeight));
       let highlightWidthWithMin = Math.max(highlightWidth, parseFloat(highlightStyle.minWidth));
       let offsetX = paddingTopPx
                       - (Math.max(0, highlightWidthWithMin - targetRect.width) / 2);
       let offsetY = paddingLeftPx
                       - (Math.max(0, highlightHeightWithMin - targetRect.height) / 2);
       this._addAnnotationPanelMutationObserver(highlighter.parentElement);
-      highlighter.parentElement.openPopup(aTarget.node, "overlap", offsetX, offsetY);
+      highlighter.parentElement.openPopup(highlightAnchor, "overlap", offsetX, offsetY);
     }
 
     // Prevent showing a panel at an undefined position.
     if (!this.isElementVisible(aTarget.node))
       return;
 
     this._setAppMenuStateForAnnotation(aTarget.node.ownerDocument.defaultView, "highlight",
                                        this.targetIsInAppMenu(aTarget),