Bug 991965 - Inhibit mouse events if a DownloadsBlockedSubview is open draft
authorGeorge Pîrlea <george@dranov.ro>
Sat, 21 Jan 2017 17:42:36 +0000
changeset 464637 3c3d22b1647175da881ea92feaea9c4bc67e883b
parent 464635 6ffe8384c6fcc107f3ad35efa5fb861fdf02558e
child 542956 a0233846080a067cfd65192fa139cdc147091859
push id42393
push userbmo:george@dranov.ro
push dateSat, 21 Jan 2017 17:52:20 +0000
bugs991965
milestone53.0a1
Bug 991965 - Inhibit mouse events if a DownloadsBlockedSubview is open 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,17 @@ const DownloadsBlockedSubview = {
   toggle(element, title, details) {
     if (this.view.showingSubView) {
       this.hide();
       return;
     }
 
     this.element = element;
     element.setAttribute("showingsubview", "true");
+    DownloadsView.subViewOpen = true;
 
     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 +1698,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;
     }
   },