Bug 916256 - download animation should anchor on panel anchor when the downloads button is in a panel, r=mconley
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 07 Oct 2013 15:54:25 +0200
changeset 170397 aa03fbc1149f56b60a48f836908a7fb0a7673779
parent 170396 ffbb0944e1de21bedbcd39d507f3a98bd7cb871a
child 170398 13213dc602172391a81dcabffa4d2d385a4615a7
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs916256
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 916256 - download animation should anchor on panel anchor when the downloads button is in a panel, r=mconley
browser/components/customizableui/src/CustomizableUI.jsm
browser/components/downloads/content/indicator.js
--- a/browser/components/customizableui/src/CustomizableUI.jsm
+++ b/browser/components/customizableui/src/CustomizableUI.jsm
@@ -2174,17 +2174,26 @@ function WidgetSingleWrapper(aWidget, aN
   }
 
   this.__defineGetter__("disabled", function() aNode.disabled);
   this.__defineSetter__("disabled", function(aValue) {
     aNode.disabled = !!aValue;
   });
 
   this.__defineGetter__("anchor", function() {
-    let anchorId = aNode.getAttribute("customizableui-anchorid");
+    let anchorId;
+    // First check for an anchor for the area:
+    let placement = CustomizableUIInternal.getPlacementOfWidget(aWidgetId);
+    if (placement) {
+      anchorId = gAreas.get(placement.area).get("anchor");
+    }
+    if (!anchorId) {
+      anchorId = aNode.getAttribute("customizableui-anchorid");
+    }
+
     return anchorId ? aNode.ownerDocument.getElementById(anchorId)
                     : aNode;
   });
 
   this.__defineGetter__("overflowed", function() {
     return aNode.classList.contains("overflowedItem");
   });
 
@@ -2254,17 +2263,26 @@ function XULWidgetSingleWrapper(aWidgetI
 
   this.id = aWidgetId;
   this.type = "custom";
   this.provider = CustomizableUI.PROVIDER_XUL;
 
   this.node = aNode;
 
   this.__defineGetter__("anchor", function() {
-    let anchorId = aNode.getAttribute("customizableui-anchorid");
+    let anchorId;
+    // First check for an anchor for the area:
+    let placement = CustomizableUIInternal.getPlacementOfWidget(aWidgetId);
+    if (placement) {
+      anchorId = gAreas.get(placement.area).get("anchor");
+    }
+    if (!anchorId) {
+      anchorId = aNode.getAttribute("customizableui-anchorid");
+    }
+
     return anchorId ? aNode.ownerDocument.getElementById(anchorId)
                     : aNode;
   });
 
   this.__defineGetter__("overflowed", function() {
     return aNode.classList.contains("overflowedItem");
   });
 
--- a/browser/components/downloads/content/indicator.js
+++ b/browser/components/downloads/content/indicator.js
@@ -323,20 +323,30 @@ const DownloadsIndicatorView = {
       return;
     }
 
     // No need to show visual notification if the panel is visible.
     if (DownloadsPanel.isPanelShowing) {
       return;
     }
 
-    // If the anchor is not there or its container is hidden, don't show
-    // a notification
     let anchor = DownloadsButton._placeholder;
+    let widgetGroup = CustomizableUI.getWidget("downloads-button");
+    let widgetInWindow = widgetGroup.forWindow(window);
+    if (widgetInWindow.overflowed || widgetGroup.areaType == CustomizableUI.TYPE_MENU_PANEL) {
+      if (anchor && isElementVisible(anchor.parentNode)) {
+        // If the panel is open, don't do anything:
+        return;
+      }
+
+      // Otherwise, try to use the anchor of the panel:
+      anchor = widgetInWindow.anchor;
+    }
     if (!anchor || !isElementVisible(anchor.parentNode)) {
+      // Our container isn't visible, so can't show the animation:
       return;
     }
 
     if (this._notificationTimeout) {
       clearTimeout(this._notificationTimeout);
     }
 
     // The notification element is positioned to show in the same location as