Bug 1388753 - unbreak bookmarks/history item clicks and tidy up code in browserPlacesViews.js, r=mikedeboer
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 10 Aug 2017 23:04:54 +0100
changeset 426053 94efd7ef04b2ecc73185d026b8e949e18a4e8221
parent 426052 f74094603063c92b710c0bae0bb5c092b915e92c
child 426054 64f5e3f40f0e7accb12cd90080e58eff0be46383
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1388753
milestone57.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 1388753 - unbreak bookmarks/history item clicks and tidy up code in browserPlacesViews.js, r=mikedeboer MozReview-Commit-ID: 1vjP6IeIiPz
browser/components/customizableui/PanelMultiView.jsm
browser/components/places/content/browserPlacesViews.js
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -333,17 +333,16 @@ this.PanelMultiView = class {
     } else {
       this._clickCapturer.removeEventListener("click", this);
     }
     this._panel.removeEventListener("mousemove", this);
     this._panel.removeEventListener("popupshowing", this);
     this._panel.removeEventListener("popupshown", this);
     this._panel.removeEventListener("popuphidden", this);
     this.window.removeEventListener("keydown", this);
-    this._dispatchViewEvent(this.node, "destructed");
     this.node = this._clickCapturer = this._viewContainer = this._mainViewContainer =
       this._subViews = this._viewStack = this.__dwu = this._panelViewCache = null;
   }
 
   /**
    * Remove any child subviews into the panelViewCache, to ensure
    * they remain usable even if this panelmultiview instance is removed
    * from the DOM.
@@ -671,18 +670,18 @@ this.PanelMultiView = class {
    * @param  {String}    eventName Name of the event to dispatch.
    * @param  {DOMNode}   [anchor]  Node where the panel is anchored to. Optional.
    * @param  {Object}    [detail]  Event detail object. Optional.
    * @return {Boolean} `true` if the event was canceled by an event handler, `false`
    *                   otherwise.
    */
   _dispatchViewEvent(viewNode, eventName, anchor, detail) {
     let cancel = false;
-    if (eventName != "PanelMultiViewHidden" && eventName != "destructed") {
-      // Don't need to do this for PanelMultiViewHidden or "destructed" events
+    if (eventName != "PanelMultiViewHidden") {
+      // Don't need to do this for PanelMultiViewHidden event
       CustomizableUI.ensureSubviewListeners(viewNode);
     }
 
     let evt = new this.window.CustomEvent(eventName, {
       detail,
       bubbles: true,
       cancelable: eventName == "ViewShowing"
     });
--- a/browser/components/places/content/browserPlacesViews.js
+++ b/browser/components/places/content/browserPlacesViews.js
@@ -2015,72 +2015,58 @@ this.PlacesPanelview = class extends Pla
     this._onPopupShowing({ originalTarget: this._rootElt });
     this._addEventListeners(window, ["unload"]);
     this._rootElt.setAttribute("context", "placesContext");
   }
 
   get events() {
     if (this._events)
       return this._events;
-    return this._events = ["command", "destructed", "dragend", "dragstart",
-      "ViewHiding", "ViewShowing", "ViewShown"];
+    return this._events = ["command", "dragend", "dragstart", "ViewHiding", "ViewShown"];
   }
 
   get panel() {
     return this.panelMultiView.parentNode;
   }
 
   get panelMultiView() {
     return this._viewElt.panelMultiView;
   }
 
   handleEvent(event) {
     switch (event.type) {
       case "command":
         this._onCommand(event);
         break;
-      case "destructed":
-        this._onDestructed(event);
-        break;
       case "dragend":
         this._onDragEnd(event);
         break;
       case "dragstart":
         this._onDragStart(event);
         break;
       case "unload":
         this.uninit(event);
         break;
       case "ViewHiding":
         this._onPopupHidden(event);
         break;
-      case "ViewShowing":
-        this._onPopupShowing(event);
-        break;
       case "ViewShown":
         this._onViewShown(event);
         break;
     }
   }
 
   _onCommand(event) {
     let button = event.originalTarget;
     if (!button._placesNode)
       return;
 
     PlacesUIUtils.openNodeWithEvent(button._placesNode, event);
   }
 
-  _onDestructed(event) {
-    // The panelmultiview is ephemeral, so let's keep an eye out when the root
-    // element is showing again.
-    this._removeEventListeners(event.target, this.events);
-    this._addEventListeners(this._viewElt, ["ViewShowing"]);
-  }
-
   _onDragEnd() {
     this._draggedElt = null;
   }
 
   _onDragStart(event) {
     let draggedElt = event.originalTarget;
     if (draggedElt.parentNode != this._rootElt || !draggedElt._placesNode)
       return;
@@ -2090,17 +2076,16 @@ this.PlacesPanelview = class extends Pla
     this._rootElt.focus();
 
     this._controller.setDataTransfer(event);
     event.stopPropagation();
   }
 
   uninit(event) {
     this._removeEventListeners(this.panelMultiView, this.events);
-    this._removeEventListeners(this._viewElt, ["ViewShowing"]);
     this._removeEventListeners(window, ["unload"]);
     super.uninit(event);
   }
 
   _createDOMNodeForPlacesNode(placesNode) {
     this._domNodes.delete(placesNode);
 
     let element;
@@ -2172,21 +2157,19 @@ this.PlacesPanelview = class extends Pla
       if (!PlacesUtils.nodeIsFolder(placesNode) ||
           this.controller.hasCachedLivemarkInfo(placesNode)) {
         placesNode.containerOpen = false;
       }
     }
   }
 
   _onPopupShowing(event) {
-    // If the event came from the root element, this is a sign that the panelmultiview
-    // was just instantiated (see `_onDestructed` above) or this is the first time
+    // If the event came from the root element, this is the first time
     // we ever get here.
-    if (event.originalTarget == this._viewElt) {
-      this._removeEventListeners(this._viewElt, ["ViewShowing"]);
+    if (event.originalTarget == this._rootElt) {
       // Start listening for events from all panels inside the panelmultiview.
       this._addEventListeners(this.panelMultiView, this.events);
     }
     super._onPopupShowing(event);
   }
 
   _onViewShown(event) {
     if (event.originalTarget != this._viewElt)