Commit d9d492ed authored by Jared Wein's avatar Jared Wein
Browse files

Bug 887515 - Restore multiple tab closings using Undo Close Tab(s) after a...

Bug 887515 - Restore multiple tab closings using Undo Close Tab(s) after a multiple-tab operation. r=fluent-reviewers,flod,Gijs

Differential Revision: https://phabricator.services.mozilla.com/D76087
parent 415dcacc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -7,9 +7,9 @@
    <vbox class="panel-subview-body">
      <toolbarbutton id="allTabsMenu-undoCloseTab"
                     class="subviewbutton subviewbutton-iconic"
                     data-l10n-id="all-tabs-menu-undo-close-tab"
                     data-l10n-id="all-tabs-menu-undo-close-tabs"
                     key="key_undoCloseTab"
                     command="History:UndoCloseTab"/>
                     observes="History:UndoCloseTab"/>
      <toolbarbutton id="allTabsMenu-searchTabs"
                     class="subviewbutton subviewbutton-iconic"
                     oncommand="gTabsPanel.searchTabs();"
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@
      oncommand="OpenBrowserWindow({fission: false});"
      hidden="true"/>
#endif
    <command id="History:UndoCloseTab" oncommand="undoCloseTab();"/>
    <command id="History:UndoCloseTab" oncommand="undoCloseTab();" data-l10n-args='{"tabCount": 1}'/>
    <command id="History:UndoCloseWindow" oncommand="undoCloseWindow();"/>

    <command id="wrCaptureCmd" oncommand="gGfxUtils.webrenderCapture();" disabled="true"/>
+14 −6
Original line number Diff line number Diff line
@@ -8039,19 +8039,27 @@ function AddKeywordForSearchField() {
 */
function undoCloseTab(aIndex) {
  // wallpaper patch to prevent an unnecessary blank tab (bug 343895)
  var blankTabToRemove = null;
  let blankTabToRemove = null;
  if (gBrowser.tabs.length == 1 && gBrowser.selectedTab.isEmpty) {
    blankTabToRemove = gBrowser.selectedTab;
  }

  var tab = null;
  if (SessionStore.getClosedTabCount(window) > (aIndex || 0)) {
    tab = SessionStore.undoCloseTab(window, aIndex || 0);
  let tab = null;
  // aIndex is undefined if the function is called without a specific tab to restore.
  let tabsToRemove =
    aIndex !== undefined
      ? [aIndex]
      : new Array(SessionStore.getLastClosedTabCount(window)).fill(0);
  for (let index of tabsToRemove) {
    if (SessionStore.getClosedTabCount(window) > index) {
      tab = SessionStore.undoCloseTab(window, index);

      if (blankTabToRemove) {
        gBrowser.removeTab(blankTabToRemove);
      }
    }
  }
  SessionStore.setLastClosedTabCount(window, 1);

  return tab;
}
+12 −6
Original line number Diff line number Diff line
@@ -185,12 +185,18 @@
                   onpopupshowing="gSync.populateSendTabToDevicesMenu(event.target, TabContextMenu.contextTab.linkedBrowser.currentURI.spec, TabContextMenu.contextTab.linkedBrowser.contentTitle, TabContextMenu.contextTab.multiselected);"/>
      </menu>
      <menuseparator/>
      <menu id="context_closeTabOptions"
            data-lazy-l10n-id="tab-context-close-multiple-tabs">
        <menupopup id="closeTabOptions">
          <menuitem id="context_closeTabsToTheEnd" data-lazy-l10n-id="close-tabs-to-the-end"
                    oncommand="gBrowser.removeTabsToTheEndFrom(TabContextMenu.contextTab, {animate: true});"/>
          <menuitem id="context_closeOtherTabs" data-lazy-l10n-id="close-other-tabs"
                    oncommand="gBrowser.removeAllTabsBut(TabContextMenu.contextTab);"/>
        </menupopup>
      </menu>
      <menuitem id="context_undoCloseTab"
                data-lazy-l10n-id="undo-close-tab"
                data-lazy-l10n-id="tab-context-undo-close-tabs"
                data-l10n-args='{"tabCount": 1}'
                observes="History:UndoCloseTab"/>
      <menuitem id="context_closeTab" data-lazy-l10n-id="close-tab"
                oncommand="gBrowser.removeTab(TabContextMenu.contextTab, { animate: true });"/>
@@ -443,7 +449,7 @@
                data-lazy-l10n-id="toolbar-context-menu-select-all-tabs"/>
      <menuitem id="toolbar-context-undoCloseTab"
                contexttype="tabbar"
                data-lazy-l10n-id="toolbar-context-menu-undo-close-tab"
                data-lazy-l10n-id="toolbar-context-menu-undo-close-tabs"
                observes="History:UndoCloseTab"/>
      <menuseparator/>
      <menuseparator id="viewToolbarsMenuSeparator"/>
+19 −0
Original line number Diff line number Diff line
@@ -2545,6 +2545,13 @@
        );
      }

      // Don't use document.l10n.setAttributes because the FTL file is loaded
      // lazily and we won't be able to resolve the string.
      document
        .getElementById("History:UndoCloseTab")
        .setAttribute("data-l10n-args", JSON.stringify({ tabCount: 1 }));
      SessionStore.setLastClosedTabCount(window, 1);

      // if we're adding tabs, we're past interrupt mode, ditch the owner
      if (this.selectedTab.owner) {
        this.selectedTab.owner = null;
@@ -3294,6 +3301,7 @@
        return;
      }

      let initialTabCount = tabs.length;
      this._clearMultiSelectionLocked = true;

      // Guarantee that _clearMultiSelectionLocked lock gets released.
@@ -3329,6 +3337,17 @@

      this._clearMultiSelectionLocked = false;
      this.avoidSingleSelectedTab();
      let closedTabsCount =
        initialTabCount - tabs.filter(t => !t.closing).length;
      // Don't use document.l10n.setAttributes because the FTL file is loaded
      // lazily and we won't be able to resolve the string.
      document
        .getElementById("History:UndoCloseTab")
        .setAttribute(
          "data-l10n-args",
          JSON.stringify({ tabCount: closedTabsCount })
        );
      SessionStore.setLastClosedTabCount(window, closedTabsCount);
    },

    removeCurrentTab(aParams) {
Loading