Backed out changeset e0061be20d1e (bug 866304) for causing metro mochitest failure
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 06 Aug 2013 12:19:09 +0200
changeset 149523 195dd104d35a0e7e2e1333041bd9e59b2edd6175
parent 149522 20aa76d088a977869380736bd9d85ed013d243b6
child 149524 781d56acd8b3b731da269a87d2854d96bd19c1f1
push idunknown
push userunknown
push dateunknown
bugs866304
milestone26.0a1
backs oute0061be20d1e7266027f23f3bcda54f1977ae5ad
Backed out changeset e0061be20d1e (bug 866304) for causing metro mochitest failure
browser/metro/base/content/browser-ui.js
--- a/browser/metro/base/content/browser-ui.js
+++ b/browser/metro/base/content/browser-ui.js
@@ -226,16 +226,17 @@ var BrowserUI = {
    * Content visibility
    */
 
   get isContentShowing() {
     return Elements.contentShowing.getAttribute("disabled") != true;
   },
 
   showContent: function showContent(aURI) {
+    DialogUI.closeAllDialogs();
     StartUI.update(aURI);
     ContextUI.dismissTabs();
     ContextUI.dismissContextAppbar();
     FlyoutPanelsUI.hide();
     PanelUI.hide();
   },
 
   /*********************************
@@ -729,16 +730,23 @@ var BrowserUI = {
     }
 
     // Check open popups
     if (DialogUI._popup) {
       DialogUI._hidePopup();
       return;
     }
 
+    // Check open dialogs
+    let dialog = DialogUI.activeDialog;
+    if (dialog) {
+      dialog.close();
+      return;
+    }
+
     // Check open modal elements
     if (DialogUI.modals.length > 0) {
       return;
     }
 
     // Check open panel
     if (PanelUI.isVisible) {
       PanelUI.hide();
@@ -1303,16 +1311,17 @@ var PanelUI = {
   _fire: function _fire(aName, anElement) {
     let event = document.createEvent("Events");
     event.initEvent(aName, true, true);
     anElement.dispatchEvent(event);
   }
 };
 
 var DialogUI = {
+  _dialogs: [],
   _popup: null,
 
   init: function() {
     window.addEventListener("mousedown", this, true);
   },
 
   /*******************************************
    * Modal popups
@@ -1370,16 +1379,49 @@ var DialogUI = {
     parentNode.insertBefore(back, contentMenuContainer);
 
     dialog.arguments = aArguments;
     dialog.parent = aParent;
     return dialog;
   },
 
   /*******************************************
+   * Dialogs
+   */
+
+  get activeDialog() {
+    // Return the topmost dialog
+    if (this._dialogs.length)
+      return this._dialogs[this._dialogs.length - 1];
+    return null;
+  },
+
+  closeAllDialogs: function closeAllDialogs() {
+    while (this.activeDialog)
+      this.activeDialog.close();
+  },
+
+  pushDialog: function pushDialog(aDialog) {
+    // If we have a dialog push it on the stack and set the attr for CSS
+    if (aDialog) {
+      this._dialogs.push(aDialog);
+      Elements.contentShowing.setAttribute("disabled", "true");
+    }
+  },
+
+  popDialog: function popDialog() {
+    if (this._dialogs.length)
+      this._dialogs.pop();
+
+    // If no more dialogs are being displayed, remove the attr for CSS
+    if (!this._dialogs.length)
+      Elements.contentShowing.removeAttribute("disabled");
+  },
+
+  /*******************************************
    * Popups
    */
 
   pushPopup: function pushPopup(aPanel, aElements, aParent) {
     this._hidePopup();
     this._popup =  { "panel": aPanel,
                      "elements": (aElements instanceof Array) ? aElements : [aElements] };
     this._dispatchPopupChanged(true, aPanel);