Bug 1428839 - Part 1 - Remove previous workaround for flickering at the end of the transition. r=Gijs draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Tue, 27 Feb 2018 15:17:29 +0000
changeset 761002 d5be0545ec353a1833ac9cf28cb17c05b8576b30
parent 761001 f9fc65374c1c1644f0743a920806b8546f3769fd
child 761003 dc8cd6476ef402ac52179a4895c1a81bd3d4173c
push id100802
push userpaolo.mozmail@amadzone.org
push dateWed, 28 Feb 2018 13:44:56 +0000
reviewersGijs
bugs1428839, 1374749
milestone60.0a1
Bug 1428839 - Part 1 - Remove previous workaround for flickering at the end of the transition. r=Gijs This was originally introduced in bug 1374749 but isn't needed anymore, and removing this allows making the _cleanupTransitionPhase method synchronous. MozReview-Commit-ID: 6v78QoPXZoU
browser/components/customizableui/PanelMultiView.jsm
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -119,17 +119,16 @@ XPCOMUtils.defineLazyGetter(this, "gBund
  * registered blockers does not return.
  */
 const BLOCKERS_TIMEOUT_MS = 10000;
 
 const TRANSITION_PHASES = Object.freeze({
   START: 1,
   PREPARE: 2,
   TRANSITION: 3,
-  END: 4
 });
 
 let gNodeToObjectMap = new WeakMap();
 let gWindowsWithUnloadHandler = new WeakSet();
 let gMultiLineElementsMap = new WeakMap();
 
 /**
  * Allows associating an object to a node lazily using a weak map.
@@ -686,17 +685,17 @@ var PanelMultiView = class extends this.
     }
 
     // The main view of a panel can be a subview in another one. Make sure to
     // reset all the properties that may be set on a subview.
     nextPanelView.mainview = true;
     nextPanelView.headerText = "";
     nextPanelView.minMaxWidth = 0;
 
-    await this._cleanupTransitionPhase();
+    this._cleanupTransitionPhase();
     nextPanelView.visible = true;
     nextPanelView.descriptionHeightWorkaround();
 
     return true;
   }
 
   /**
    * Opens the specified PanelView and dispatches the ViewShowing event, which
@@ -783,17 +782,17 @@ var PanelMultiView = class extends this.
    *                                     after the transition has finished.
    * @param {Boolean}   reverse          Whether we're navigation back to a
    *                                     previous view or forward to a next view.
    * @param {Element}   anchor           the anchor for which we're opening
    *                                     a new panelview, if any
    */
   async _transitionViews(previousViewNode, viewNode, reverse, anchor) {
     // Clean up any previous transition that may be active at this point.
-    await this._cleanupTransitionPhase();
+    this._cleanupTransitionPhase();
 
     // There's absolutely no need to show off our epic animation skillz when
     // the panel's not even open.
     if (this._panel.state != "open") {
       return;
     }
 
     const { window } = this;
@@ -931,42 +930,40 @@ var PanelMultiView = class extends this.
         if (ev.target != this._viewStack)
           return;
         this._viewContainer.removeEventListener("transitioncancel", details.cancelListener);
         delete details.cancelListener;
         resolve();
       });
     });
 
-    details.phase = TRANSITION_PHASES.END;
-
     // Apply the final visibility, unless the view was closed in the meantime.
     if (nextPanelView.node.panelMultiView == this.node) {
       prevPanelView.visible = false;
     }
 
     // This will complete the operation by removing any transition properties.
-    await this._cleanupTransitionPhase(details);
+    this._cleanupTransitionPhase(details);
 
     // Focus the correct element, unless the view was closed in the meantime.
     if (nextPanelView.node.panelMultiView == this.node) {
       nextPanelView.focusSelectedElement();
     }
   }
 
   /**
    * Attempt to clean up the attributes and properties set by `_transitionViews`
    * above. Which attributes and properties depends on the phase the transition
-   * was left from - normally that'd be `TRANSITION_PHASES.END`.
+   * was left from.
    *
    * @param {Object} details Dictionary object containing details of the transition
    *                         that should be cleaned up after. Defaults to the most
    *                         recent details.
    */
-  async _cleanupTransitionPhase(details = this._transitionDetails) {
+  _cleanupTransitionPhase(details = this._transitionDetails) {
     if (!details || !this.node)
       return;
 
     let {phase, previousViewNode, viewNode, reverse, resolve, listener, cancelListener, anchor} = details;
     if (details == this._transitionDetails)
       this._transitionDetails = null;
 
     // Do the things we _always_ need to do whenever the transition ends or is
@@ -1001,23 +998,16 @@ var PanelMultiView = class extends this.
       viewNode.style.removeProperty("width");
       if (listener)
         this._viewContainer.removeEventListener("transitionend", listener);
       if (cancelListener)
         this._viewContainer.removeEventListener("transitioncancel", cancelListener);
       if (resolve)
         resolve();
     }
-    if (phase >= TRANSITION_PHASES.END) {
-      // We force 'display: none' on the previous view node to make sure that it
-      // doesn't cause an annoying flicker whilst resetting the styles above.
-      previousViewNode.style.display = "none";
-      await this.window.promiseDocumentFlushed(() => {});
-      previousViewNode.style.removeProperty("display");
-    }
   }
 
   _calculateMaxHeight() {
     // While opening the panel, we have to limit the maximum height of any
     // view based on the space that will be available. We cannot just use
     // window.screen.availTop and availHeight because these may return an
     // incorrect value when the window spans multiple screens.
     let anchorBox = this._panel.anchorNode.boxObject;