Bug 1473974 - Fix opening all tabs panel with cycle recent tabs r?dao
MozReview-Commit-ID: EGYJo8AAF2K
--- a/browser/base/content/browser-allTabsMenu.js
+++ b/browser/base/content/browser-allTabsMenu.js
@@ -13,21 +13,25 @@ var gTabsPanel = {
allTabsButton: "alltabs-button",
allTabsView: "allTabsMenu-allTabsView",
allTabsViewTabs: "allTabsMenu-allTabsViewTabs",
containerTabsView: "allTabsMenu-containerTabsView",
hiddenTabsButton: "allTabsMenu-hiddenTabsButton",
hiddenTabsView: "allTabsMenu-hiddenTabsView",
},
_initialized: false,
+ _initializedElements: false,
initElements() {
+ if (this._initializedElements) return;
+
for (let [name, id] of Object.entries(this.kElements)) {
this[name] = document.getElementById(id);
}
+ this._initializedElements = true;
},
init() {
if (this._initialized) return;
this.initElements();
let hiddenTabsMenuButton = this.allTabsView.querySelector(".hidden-tabs-button");
@@ -119,26 +123,36 @@ var gTabsPanel = {
this.hiddenTabsPopup = new TabsPanel({
view: this.hiddenTabsView,
filterFn: (tab) => tab.hidden,
});
this._initialized = true;
},
+ get canOpen() {
+ this.initElements();
+ return isElementVisible(this.allTabsButton);
+ },
+
showAllTabsPanel() {
this.init();
- PanelUI.showSubView(this.kElements.allTabsView, this.allTabsButton);
+ if (this.canOpen) {
+ PanelUI.showSubView(this.kElements.allTabsView, this.allTabsButton);
+ }
},
hideAllTabsPanel() {
this.init();
PanelMultiView.hidePopup(this.allTabsView.closest("panel"));
},
showHiddenTabsPanel() {
this.init();
+ if (!this.canOpen) {
+ return;
+ }
this.allTabsView.addEventListener("ViewShown", (e) => {
PanelUI.showSubView(this.kElements.hiddenTabsView, this.hiddenTabsButton);
}, {once: true});
this.showAllTabsPanel();
},
};
--- a/browser/base/content/browser-ctrlTab.js
+++ b/browser/base/content/browser-ctrlTab.js
@@ -289,17 +289,17 @@ var ctrlTab = {
updatePreviews: function ctrlTab_updatePreviews() {
for (let i = 0; i < this.previews.length; i++)
this.updatePreview(this.previews[i], this.tabList[i]);
var showAllLabel = gNavigatorBundle.getString("ctrlTab.listAllTabs.label");
this.showAllButton._label.setAttribute("value",
PluralForm.get(this.tabCount, showAllLabel).replace("#1", this.tabCount));
- this.showAllButton.hidden = !allTabs.canOpen;
+ this.showAllButton.hidden = !gTabsPanel.canOpen;
},
updatePreview: function ctrlTab_updatePreview(aPreview, aTab) {
if (aPreview == this.showAllButton)
return;
aPreview._tab = aTab;
@@ -565,17 +565,17 @@ var ctrlTab = {
this.onKeyPress(event);
break;
case "keyup":
if (event.keyCode == event.DOM_VK_CONTROL)
this.pick();
break;
case "popupshowing":
if (event.target.id == "menu_viewPopup")
- document.getElementById("menu_showAllTabs").hidden = !allTabs.canOpen;
+ document.getElementById("menu_showAllTabs").hidden = !gTabsPanel.canOpen;
break;
}
},
filterForThumbnailExpiration(aCallback) {
// Save a few more thumbnails than we actually display, so that when tabs
// are closed, the previews we add instead still get thumbnails.
const extraThumbnails = 3;
@@ -623,32 +623,8 @@ var ctrlTab = {
// Show All Tabs.
var key_showAllTabs = document.getElementById("key_showAllTabs");
if (enable)
key_showAllTabs.removeAttribute("disabled");
else
key_showAllTabs.setAttribute("disabled", "true");
}
};
-
-
-/**
- * All Tabs menu
- */
-var allTabs = {
- get toolbarButton() {
- return document.getElementById("alltabs-button");
- },
-
- get canOpen() {
- return isElementVisible(this.toolbarButton);
- },
-
- open: function allTabs_open() {
- if (this.canOpen) {
- // Without setTimeout, the menupopup won't stay open when invoking
- // "View > Show All Tabs" and the menu bar auto-hides.
- setTimeout(() => {
- this.toolbarButton.open = true;
- }, 0);
- }
- }
-};
--- a/browser/base/content/browser-sets.inc
+++ b/browser/base/content/browser-sets.inc
@@ -76,17 +76,17 @@
<command id="Browser:ReloadOrDuplicate" oncommand="BrowserReloadOrDuplicate(event)" disabled="true">
<observes element="Browser:Reload" attribute="disabled"/>
</command>
<command id="Browser:ReloadSkipCache" oncommand="BrowserReloadSkipCache()" disabled="true">
<observes element="Browser:Reload" attribute="disabled"/>
</command>
<command id="Browser:NextTab" oncommand="gBrowser.tabContainer.advanceSelectedTab(1, true);"/>
<command id="Browser:PrevTab" oncommand="gBrowser.tabContainer.advanceSelectedTab(-1, true);"/>
- <command id="Browser:ShowAllTabs" oncommand="allTabs.open();"/>
+ <command id="Browser:ShowAllTabs" oncommand="gTabsPanel.showAllTabsPanel();"/>
<command id="cmd_fullZoomReduce" oncommand="FullZoom.reduce()"/>
<command id="cmd_fullZoomEnlarge" oncommand="FullZoom.enlarge()"/>
<command id="cmd_fullZoomReset" oncommand="FullZoom.reset()"/>
<command id="cmd_fullZoomToggle" oncommand="ZoomManager.toggleZoom();"/>
<command id="cmd_gestureRotateLeft" oncommand="gGestureSupport.rotate(event.sourceEvent)"/>
<command id="cmd_gestureRotateRight" oncommand="gGestureSupport.rotate(event.sourceEvent)"/>
<command id="cmd_gestureRotateEnd" oncommand="gGestureSupport.rotateEnd()"/>
<command id="Browser:OpenLocation" oncommand="openLocation();"/>