Bug 1446101 - Part 4: Remove old alltabs code, rename alltabs-popup to newtab-popup r?dao
MozReview-Commit-ID: 1U0Jg9bpEGV
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -246,19 +246,18 @@ panelview[mainview] > .panel-header {
/* Allow dropping a tab on buttons with associated drop actions. */
#TabsToolbar[movingtab] + #nav-bar > #nav-bar-customization-target > #personal-bookmarks,
#TabsToolbar[movingtab] + #nav-bar > #nav-bar-customization-target > #home-button,
#TabsToolbar[movingtab] + #nav-bar > #nav-bar-customization-target > #downloads-button,
#TabsToolbar[movingtab] + #nav-bar > #nav-bar-customization-target > #bookmarks-menu-button {
pointer-events: auto;
}
-.new-tab-popup,
-#alltabs-popup {
- -moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-alltabs-popup");
+.new-tab-popup {
+ -moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-newtab-popup");
}
toolbar[printpreview="true"] {
-moz-binding: url("chrome://global/content/printPreviewBindings.xml#printpreviewtoolbar");
}
toolbar[overflowable] > .customization-target {
overflow: hidden;
@@ -839,17 +838,16 @@ toolbarspring {
.bookmark-item > label {
/* ensure we use the direction of the bookmarks label instead of the
* browser locale */
unicode-bidi: plaintext;
}
/* Apply crisp rendering for favicons at exactly 2dppx resolution */
@media (resolution: 2dppx) {
- #alltabs-popup > .menuitem-iconic > .menu-iconic-left > .menu-iconic-icon,
.menuitem-with-favicon > .menu-iconic-left > .menu-iconic-icon {
image-rendering: -moz-crisp-edges;
}
.bookmark-item > .toolbarbutton-icon,
.bookmark-item > .menu-iconic-left > .menu-iconic-icon {
image-rendering: -moz-crisp-edges;
}
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -51,17 +51,16 @@ XPCOMUtils.defineLazyModuleGetters(this,
Sanitizer: "resource:///modules/Sanitizer.jsm",
SessionStore: "resource:///modules/sessionstore/SessionStore.jsm",
SchedulePressure: "resource:///modules/SchedulePressure.jsm",
ShortcutUtils: "resource://gre/modules/ShortcutUtils.jsm",
SimpleServiceDiscovery: "resource://gre/modules/SimpleServiceDiscovery.jsm",
SiteDataManager: "resource:///modules/SiteDataManager.jsm",
SitePermissions: "resource:///modules/SitePermissions.jsm",
TabCrashHandler: "resource:///modules/ContentCrashHandlers.jsm",
- TabsPopup: "resource:///modules/TabsList.jsm",
TelemetryStopwatch: "resource://gre/modules/TelemetryStopwatch.jsm",
Translation: "resource:///modules/translation/Translation.jsm",
UITour: "resource:///modules/UITour.jsm",
UpdateUtils: "resource://gre/modules/UpdateUtils.jsm",
Utils: "resource://gre/modules/sessionstore/Utils.jsm",
Weave: "resource://services-sync/main.js",
WebNavigationFrames: "resource://gre/modules/WebNavigationFrames.jsm",
fxAccounts: "resource://gre/modules/FxAccounts.jsm",
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2074,134 +2074,25 @@
if (event.originalTarget.getAttribute("anonid") == "tab-loading-burst") {
this.removeAttribute("bursting");
}
]]>
</handler>
</handlers>
</binding>
- <binding id="tabbrowser-alltabs-popup"
+ <binding id="tabbrowser-newtab-popup"
extends="chrome://global/content/bindings/popup.xml#popup">
- <implementation>
- <method name="_updateTabsVisibilityStatus">
- <body><![CDATA[
- var tabContainer = gBrowser.tabContainer;
- // We don't want menu item decoration unless there is overflow.
- if (tabContainer.getAttribute("overflow") != "true") {
- return;
- }
-
- let windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
- .getInterface(Ci.nsIDOMWindowUtils);
- let arrowScrollboxRect = windowUtils.getBoundsWithoutFlushing(tabContainer.arrowScrollbox);
- for (let menuitem of this.childNodes) {
- let curTab = menuitem.tab;
- if (!curTab) {
- // "Undo close tab", menuseparator, or entries put here by addons.
- continue;
- }
- let curTabRect = windowUtils.getBoundsWithoutFlushing(curTab);
- if (curTabRect.left >= arrowScrollboxRect.left &&
- curTabRect.right <= arrowScrollboxRect.right) {
- menuitem.setAttribute("tabIsVisible", "true");
- } else {
- menuitem.removeAttribute("tabIsVisible");
- }
- }
- ]]></body>
- </method>
-
- <method name="_initializeTabsPopups">
- <parameter name="event"/>
- <body><![CDATA[
- if (this._tabsPopups) {
- return;
- }
- // These TabsPopup objects will handle creating menuitem elements
- // for tabs in this popup. They have their own popupshowing and
- // popuphidden listeners to manage the items.
- //
- // Since gBrowser isn't initialized yet in the constructor these are
- // created on the first popupshowing event. The initial event is
- // proxied once the popups are created.
- this._tabsPopups = [
- new TabsPopup({
- className: "alltabs-item",
- filterFn: (tab) => !tab.pinned && !tab.hidden,
- popup: document.getElementById("alltabs-popup"),
- onPopulate: () => this._updateTabsVisibilityStatus(),
- }),
- new TabsPopup({
- filterFn: (tab) => tab.hidden && tab.soundPlaying,
- popup: document.getElementById("alltabs-popup"),
- insertBefore: document.getElementById("alltabs-popup-separator-3"),
- }),
- new TabsPopup({
- filterFn: (tab) => tab.hidden,
- popup: document.getElementById("alltabs_hiddenTabsMenu"),
- }),
- ];
- this._tabsPopups.forEach(popup => popup.handleEvent(event));
- ]]></body>
- </method>
- </implementation>
-
<handlers>
<handler event="popupshowing">
<![CDATA[
- if (event.target.getAttribute("id") == "alltabs_containersMenuTab") {
- createUserContextMenu(event, {useAccessKeys: false});
- return;
- } else if (event.target != this) {
- return;
- }
-
- let containersEnabled = Services.prefs.getBoolPref("privacy.userContext.enabled");
-
- if (event.target.getAttribute("anonid") == "newtab-popup" ||
- event.target.id == "newtab-popup") {
- createUserContextMenu(event, {
- useAccessKeys: false,
- showDefaultTab: Services.prefs.getIntPref("privacy.userContext.longPressBehavior") == 1
- });
- } else {
- document.getElementById("alltabs-popup-separator-1").hidden = !containersEnabled;
- let containersTab = document.getElementById("alltabs_containersTab");
-
- containersTab.hidden = !containersEnabled;
- if (PrivateBrowsingUtils.isWindowPrivate(window)) {
- containersTab.setAttribute("disabled", "true");
- }
-
- document.getElementById("alltabs_undoCloseTab").disabled =
- SessionStore.getClosedTabCount(window) == 0;
-
- let showHiddenTabs = gBrowser.visibleTabs.length < gBrowser.tabs.length;
- document.getElementById("alltabs_hiddenTabs").hidden = !showHiddenTabs;
- document.getElementById("alltabs-popup-separator-3").hidden = !showHiddenTabs;
-
- this._initializeTabsPopups(event);
- }
- ]]></handler>
-
- <handler event="DOMMenuItemActive">
- <![CDATA[
- var tab = event.target.tab;
- if (tab) {
- let overLink = tab.linkedBrowser.currentURI.displaySpec;
- if (overLink == "about:blank")
- overLink = "";
- XULBrowserWindow.setOverLink(overLink, null);
- }
- ]]></handler>
-
- <handler event="DOMMenuItemInactive">
- <![CDATA[
- XULBrowserWindow.setOverLink("", null);
+ createUserContextMenu(event, {
+ useAccessKeys: false,
+ showDefaultTab: Services.prefs.getIntPref("privacy.userContext.longPressBehavior") == 1
+ });
]]></handler>
</handlers>
</binding>
<binding id="tabbrowser-tabpanels"
extends="chrome://global/content/bindings/tabbox.xml#tabpanels">
<implementation>
<field name="_selectedIndex">0</field>
--- a/browser/modules/TabsList.jsm
+++ b/browser/modules/TabsList.jsm
@@ -2,17 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
ChromeUtils.defineModuleGetter(this, "PanelMultiView",
"resource:///modules/PanelMultiView.jsm");
-var EXPORTED_SYMBOLS = ["TabsPanel", "TabsPopup"];
+var EXPORTED_SYMBOLS = ["TabsPanel"];
const NSXUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
function setAttributes(element, attrs) {
for (let [name, value] of Object.entries(attrs)) {
if (value) {
element.setAttribute(name, value);
} else {
element.removeAttribute(name);
@@ -136,120 +136,16 @@ class TabsListBase {
}
_removeItem(item, tab) {
this.tabToElement.delete(tab);
item.remove();
}
}
-class TabsPopup extends TabsListBase {
- /*
- * Generate toolbarbuttons for tabs that meet some criteria.
- *
- * @param {object} opts Options for configuring this instance.
- * @param {function} opts.filterFn
- * A function to filter which tabs are used.
- * @param {object} opts.view
- * A panel view to listen to events on.
- * @param {object} opts.containerNode
- * An optional element to append elements to, if ommitted they
- * will be appended to opts.view.firstChild or before
- * opts.insertBefore.
- * @param {object} opts.insertBefore
- * An optional element to insert the results before, if
- * omitted they will be appended to opts.containerNode.
- * @param {function} opts.onPopulate
- * An optional function that will be called with the
- * popupshowing event that caused the menu to be populated.
- */
- constructor({className, filterFn, insertBefore, onPopulate, popup}) {
- super({className, filterFn, insertBefore, onPopulate, containerNode: popup});
- this.containerNode.addEventListener("popupshowing", this);
- }
-
- handleEvent(event) {
- switch (event.type) {
- case "popuphidden":
- if (event.target == this.containerNode) {
- this._cleanup();
- }
- break;
- case "popupshowing":
- if (event.target == this.containerNode) {
- this._populate(event);
- }
- break;
- default:
- super.handleEvent(event);
- break;
- }
- }
-
- _setupListeners() {
- super._setupListeners();
- this.containerNode.addEventListener("popuphidden", this);
- }
-
- _cleanupListeners() {
- super._cleanupListeners();
- this.containerNode.removeEventListener("popuphidden", this);
- }
-
- _createRow(tab) {
- let item = this.doc.createElementNS(NSXUL, "menuitem");
- item.setAttribute("class", "menuitem-iconic menuitem-with-favicon");
- this._setRowAttributes(item, tab);
- return item;
- }
-
- _setRowAttributes(item, tab) {
- item.setAttribute("label", tab.label);
- item.setAttribute("crop", "end");
-
- if (tab.hasAttribute("busy")) {
- item.setAttribute("busy", tab.getAttribute("busy"));
- item.removeAttribute("iconloadingprincipal");
- item.removeAttribute("image");
- } else {
- item.setAttribute("iconloadingprincipal", tab.getAttribute("iconloadingprincipal"));
- item.setAttribute("image", tab.getAttribute("image"));
- item.removeAttribute("busy");
- }
-
- if (tab.hasAttribute("pending"))
- item.setAttribute("pending", tab.getAttribute("pending"));
- else
- item.removeAttribute("pending");
-
- if (tab.selected)
- item.setAttribute("selected", "true");
- else
- item.removeAttribute("selected");
-
- let addEndImage = () => {
- let endImage = this.doc.createElement("image");
- endImage.setAttribute("class", "alltabs-endimage");
- let endImageContainer = this.doc.createElement("hbox");
- endImageContainer.setAttribute("align", "center");
- endImageContainer.setAttribute("pack", "center");
- endImageContainer.appendChild(endImage);
- item.appendChild(endImageContainer);
- return endImage;
- };
-
- if (item.firstChild)
- item.firstChild.remove();
- if (tab.hasAttribute("muted"))
- addEndImage().setAttribute("muted", "true");
- else if (tab.hasAttribute("soundplaying"))
- addEndImage().setAttribute("soundplaying", "true");
- }
-}
-
const TABS_PANEL_EVENTS = {
show: "ViewShowing",
hide: "PanelMultiViewHidden",
};
class TabsPanel extends TabsListBase {
constructor(opts) {
super({
--- a/browser/themes/shared/tabs.inc.css
+++ b/browser/themes/shared/tabs.inc.css
@@ -743,53 +743,16 @@
fill-opacity: var(--toolbarbutton-icon-fill-opacity);
/* "!important" is necessary to override the rule in toolbarbutton.css */
margin: -7px 0 0 !important;
margin-inline-end: -4px !important;
min-width: 12px;
min-height: 12px;
}
-.alltabs-item > .menu-iconic-left > .menu-iconic-icon {
- list-style-image: url("chrome://mozapps/skin/places/defaultFavicon.svg");
- -moz-context-properties: fill;
- fill: currentColor;
-}
-
-.alltabs-item[busy] > .menu-iconic-left > .menu-iconic-icon {
- list-style-image: url("chrome://global/skin/icons/loading.png");
-}
-
-@media (min-resolution: 1.1dppx) {
- .alltabs-item[busy] > .menu-iconic-left > .menu-iconic-icon {
- list-style-image: url("chrome://global/skin/icons/loading@2x.png");
- }
-}
-
-.alltabs-item[tabIsVisible] {
- /* box-shadow instead of background-color to work around native styling */
- box-shadow: inset -5px 0 ThreeDShadow;
-}
-
-.alltabs-endimage[soundplaying],
-.alltabs-endimage[muted],
-.alltabs-endimage[activemedia-blocked] {
- list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-playing.svg);
- -moz-context-properties: fill;
- fill: currentColor;
-}
-
-.alltabs-endimage[muted] {
- list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-muted.svg);
-}
-
-.alltabs-endimage[activemedia-blocked] {
- list-style-image: url(chrome://browser/skin/tabbrowser/tab-audio-blocked.svg);
-}
-
#appMenu-allTabsView {
--blue-40: #45a1ff;
max-width: 42em;
}
.all-tabs-item > .all-tabs-secondary-button {
padding: 0;
padding-inline-start: 6px;