Bug 1441284 - Part 2 - Remove the "_currentSubView" property. r=Gijs draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Mon, 26 Feb 2018 18:43:43 +0000
changeset 760397 f120014c32b5cf65904952b4fba88a101f43d467
parent 760396 dc2be742b352759cff16697c02ad2ce12fd4f7a4
child 760398 8d2496beb7cc2269bb88724ce1e2fcc1565782a7
push id100626
push userpaolo.mozmail@amadzone.org
push dateTue, 27 Feb 2018 14:19:41 +0000
reviewersGijs
bugs1441284
milestone60.0a1
Bug 1441284 - Part 2 - Remove the "_currentSubView" property. r=Gijs MozReview-Commit-ID: Aua3V8hOT39
browser/components/customizableui/PanelMultiView.jsm
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -375,22 +375,16 @@ var PanelMultiView = class extends this.
 
   get _screenManager() {
     if (this.__screenManager)
       return this.__screenManager;
     return this.__screenManager = Cc["@mozilla.org/gfx/screenmanager;1"]
                                     .getService(Ci.nsIScreenManager);
   }
 
-  get _currentSubView() {
-    // Peek the top of the stack, but fall back to the main view if the list of
-    // opened views is currently empty.
-    let panelView = this.openViews[this.openViews.length - 1];
-    return (panelView && panelView.node) || this._mainView;
-  }
   get showingSubView() {
     return this.openViews.length > 1;
   }
 
   constructor(node) {
     super(node);
     this._openPopupPromise = Promise.resolve(false);
     this._openPopupCancelCallback = () => {};
@@ -1103,18 +1097,21 @@ var PanelMultiView = class extends this.
   handleEvent(aEvent) {
     if (aEvent.type.startsWith("popup") && aEvent.target != this._panel) {
       // Shouldn't act on e.g. context menus being shown from within the panel.
       return;
     }
     switch (aEvent.type) {
       case "keydown":
         if (!this._transitioning) {
-          PanelView.forNode(this._currentSubView)
-                   .keyNavigation(aEvent, this._dir);
+          // Since we start listening for the "keydown" event when the popup is
+          // already showing and stop listening when the panel is hidden, we
+          // always have at least one view open.
+          let currentView = this.openViews[this.openViews.length - 1];
+          currentView.keyNavigation(aEvent, this._dir);
         }
         break;
       case "mousemove":
         this.openViews.forEach(panelView => panelView.clearNavigation());
         break;
       case "popupshowing": {
         this._viewContainer.setAttribute("panelopen", "true");
         if (!this.node.hasAttribute("disablekeynav")) {