Bug 991965 - Inhibit item selection and update commands when the DownloadsBlockedSubview is open. r=paolo a=jcristau
authorGeorge Pîrlea <george@dranov.ro>
Sat, 21 Jan 2017 17:42:36 +0000
changeset 375752 c10934134a854d324262f48190982071b073c69c
parent 375751 d83312cd0c260a9ce0a177f14c3504bb462218de
child 375753 4aa072b1110c8c2f2ccdd387d270d5115f488853
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo, jcristau
bugs991965
milestone53.0a2
Bug 991965 - Inhibit item selection and update commands when the DownloadsBlockedSubview is open. r=paolo a=jcristau MozReview-Commit-ID: Akly0NenY8Z
browser/components/downloads/content/downloads.js
--- a/browser/components/downloads/content/downloads.js
+++ b/browser/components/downloads/content/downloads.js
@@ -723,16 +723,21 @@ const DownloadsView = {
   kItemCountLimit: 5,
 
   /**
    * Indicates whether there is an open contextMenu for a download item.
    */
   contextMenuOpen: false,
 
   /**
+   * Indicates whether there is a DownloadsBlockedSubview open.
+   */
+  subViewOpen: false,
+
+  /**
    * Indicates whether we are still loading downloads data asynchronously.
    */
   loading: false,
 
   /**
    * Ordered array of all Download objects.  We need to keep this array because
    * only a limited number of items are shown at once, and if an item that is
    * currently visible is removed from the list, we might need to take another
@@ -1027,24 +1032,24 @@ const DownloadsView = {
     DownloadsCommon.log("Context menu has hidden.");
     this.contextMenuOpen = false;
   },
 
   /**
    * Mouse listeners to handle selection on hover.
    */
   onDownloadMouseOver(aEvent) {
-    if (!this.contextMenuOpen &&
+    if (!(this.contextMenuOpen || this.subViewOpen) &&
         aEvent.target.parentNode == this.richListBox) {
       this.richListBox.selectedItem = aEvent.target;
     }
   },
 
   onDownloadMouseOut(aEvent) {
-    if (!this.contextMenuOpen &&
+    if (!(this.contextMenuOpen || this.subViewOpen) &&
         aEvent.target.parentNode == this.richListBox) {
       // If the destination element is outside of the richlistitem, clear the
       // selection.
       let element = aEvent.relatedTarget;
       while (element && element != aEvent.target) {
         element = element.parentNode;
       }
       if (!element) {
@@ -1666,16 +1671,18 @@ const DownloadsBlockedSubview = {
   toggle(element, title, details) {
     if (this.view.showingSubView) {
       this.hide();
       return;
     }
 
     this.element = element;
     element.setAttribute("showingsubview", "true");
+    DownloadsView.subViewOpen = true;
+    DownloadsViewController.updateCommands();
 
     let e = this.elements;
     let s = DownloadsCommon.strings;
     e.title.textContent = title;
     e.details1.textContent = details[0];
     e.details2.textContent = details[1];
     e.openButton.label = s.unblockButtonOpen;
     e.deleteButton.label = s.unblockButtonConfirmBlock;
@@ -1692,16 +1699,17 @@ const DownloadsBlockedSubview = {
       window.getComputedStyle(this.view).width;
   },
 
   handleEvent(event) {
     switch (event.type) {
       case "ViewHiding":
         this.subview.removeEventListener(event.type, this);
         this.element.removeAttribute("showingsubview");
+        DownloadsView.subViewOpen = false;
         delete this.element;
         break;
       default:
         DownloadsCommon.log("Unhandled DownloadsBlockedSubview event: " +
                             event.type);
         break;
     }
   },