From 41ea1535c8d161a3540b9747be24a35f906a29b2 Mon Sep 17 00:00:00 2001 From: Mike de Boer Date: Fri, 6 Feb 2015 12:09:55 +0100 Subject: [PATCH] Bug 1091785: make sure the info panel anchors to the overflow chevron if needed. r=jaws --- browser/components/uitour/UITour.jsm | 33 ++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/browser/components/uitour/UITour.jsm b/browser/components/uitour/UITour.jsm index 9737ded28ea..74a5a91d2eb 100644 --- a/browser/components/uitour/UITour.jsm +++ b/browser/components/uitour/UITour.jsm @@ -1119,6 +1119,26 @@ this.UITour = { this.notify("Heartbeat:NotificationOffered", { flowId: aFlowId, timestamp: Date.now() }); }, + /** + * The node to which a highlight or notification(-popup) is anchored is sometimes + * obscured because it may be inside an overflow menu. This function should figure + * that out and offer the overflow chevron as an alternative. + * + * @param {Node} aAnchor The element that's supposed to be the anchor + * @type {Node} + */ + _correctAnchor: function(aAnchor) { + // If the target is in the overflow panel, just return the overflow button. + if (aAnchor.getAttribute("overflowedItem")) { + let doc = aAnchor.ownerDocument; + let placement = CustomizableUI.getPlacementOfWidget(aAnchor.id); + let areaNode = doc.getElementById(placement.area); + return areaNode.overflowable._chevron; + } + + return aAnchor; + }, + /** * @param aChromeWindow The chrome window that the highlight is in. Necessary since some targets * are in a sub-frame so the defaultView is not the same as the chrome @@ -1158,16 +1178,7 @@ this.UITour = { highlighter.parentElement.setAttribute("targetName", aTarget.targetName); highlighter.parentElement.hidden = false; - 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 highlightAnchor = this._correctAnchor(aTarget.node); let targetRect = highlightAnchor.getBoundingClientRect(); let highlightHeight = targetRect.height; let highlightWidth = targetRect.width; @@ -1366,7 +1377,7 @@ this.UITour = { this._setAppMenuStateForAnnotation(aChromeWindow, "info", this.targetIsInAppMenu(aAnchor), - showInfoPanel.bind(this, aAnchor.node)); + showInfoPanel.bind(this, this._correctAnchor(aAnchor.node))); }, hideInfo: function(aWindow) {