Bug 1392081 - Reset the Places toolbar view when the toolbar is collapsed. r=Gijs
☠☠ backed out by aabf377fc622 ☠ ☠
authorMarco Bonardo <mbonardo@mozilla.com>
Tue, 29 Aug 2017 23:26:24 +0200
changeset 428519 cf5b68506bef58600c4e8ec1654102fd36bf0c52
parent 428518 882a40327e5abbb2aff0af12860a639657ea266e
child 428520 5d320d8864e90aa9684462251fee5b60f055ea9b
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1392081
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 1392081 - Reset the Places toolbar view when the toolbar is collapsed. r=Gijs MozReview-Commit-ID: IFOxCnslZRX
browser/base/content/browser-places.js
browser/base/content/browser.js
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1157,34 +1157,52 @@ var PlacesToolbarHelper = {
     let viewElt = this._viewElt;
     if (!viewElt || viewElt._placesView)
       return;
 
     // CustomizableUI.addListener is idempotent, so we can safely
     // call this multiple times.
     CustomizableUI.addListener(this);
 
+    if (!this._isObservingToolbars) {
+      this._isObservingToolbars = true;
+      window.addEventListener("toolbarvisibilitychange", this);
+    }
+
     // If the bookmarks toolbar item is:
     // - not in a toolbar, or;
     // - the toolbar is collapsed, or;
     // - the toolbar is hidden some other way:
     // don't initialize.  Also, there is no need to initialize the toolbar if
     // customizing, because that will happen when the customization is done.
     let toolbar = this._getParentToolbar(viewElt);
     if (!toolbar || toolbar.collapsed || this._isCustomizing ||
-        getComputedStyle(toolbar, "").display == "none")
+        getComputedStyle(toolbar, "").display == "none") {
       return;
+    }
 
     new PlacesToolbar(this._place);
     if (forceToolbarOverflowCheck) {
       viewElt._placesView.updateOverflowStatus();
     }
   },
 
+  handleEvent(event) {
+    switch (event.type) {
+      case "toolbarvisibilitychange":
+        this._resetView();
+        break;
+    }
+  },
+
   uninit: function PTH_uninit() {
+    if (this._isObservingToolbars) {
+      delete this._isObservingToolbars;
+      window.removeEventListener("toolbarvisibilitychange", this);
+    }
     CustomizableUI.removeListener(this);
   },
 
   customizeStart: function PTH_customizeStart() {
     try {
       let viewElt = this._viewElt;
       if (viewElt && viewElt._placesView)
         viewElt._placesView.uninit();
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5525,17 +5525,16 @@ function setToolbarVisibility(toolbar, i
     detail: {
       visible: isVisible
     },
     bubbles: true
   };
   let event = new CustomEvent("toolbarvisibilitychange", eventParams);
   toolbar.dispatchEvent(event);
 
-  PlacesToolbarHelper.init();
   BookmarkingUI.onToolbarVisibilityChange();
 }
 
 function updateToggleControlLabel(control) {
   if (!control.hasAttribute("label-checked")) {
     return;
   }