From 8bf148471cfb0b7f93350589dcf262989e35509c Mon Sep 17 00:00:00 2001 From: ownedbywuigi Date: Wed, 1 Apr 2026 11:35:08 +0100 Subject: [PATCH] Add a "close all tabs to the left" button + fix compile error --- application/basilisk/base/content/browser.js | 6 +++ application/basilisk/base/content/browser.xul | 2 + .../basilisk/base/content/tabbrowser.xml | 38 ++++++++++++++++++- .../locales/en-US/chrome/browser/browser.dtd | 5 +++ .../webrequest/StreamFilterParent.cpp | 13 ++++--- 5 files changed, 57 insertions(+), 7 deletions(-) diff --git a/application/basilisk/base/content/browser.js b/application/basilisk/base/content/browser.js index 7d897b1569..6c917c4271 100644 --- a/application/basilisk/base/content/browser.js +++ b/application/basilisk/base/content/browser.js @@ -7441,6 +7441,12 @@ var TabContextMenu = { document.getElementById("context_pinTab").hidden = this.contextTab.pinned; document.getElementById("context_unpinTab").hidden = !this.contextTab.pinned; + // Disable "Close Tabs to the Left" if there are no tabs before it, + // and hide it when the user rightclicked on a pinned tab. + document.getElementById("context_closeTabsToTheStart").disabled = + gBrowser.getTabsToTheStartFrom(this.contextTab).length == 0; + document.getElementById("context_closeTabsToTheStart").hidden = this.contextTab.pinned; + // Disable "Close Tabs to the Right" if there are no tabs // following it and hide it when the user rightclicked on a pinned // tab. diff --git a/application/basilisk/base/content/browser.xul b/application/basilisk/base/content/browser.xul index cbe581df44..f4b802b245 100644 --- a/application/basilisk/base/content/browser.xul +++ b/application/basilisk/base/content/browser.xul @@ -112,6 +112,8 @@ label="&bookmarkAllTabs.label;" accesskey="&bookmarkAllTabs.accesskey;" command="Browser:BookmarkAllTabs"/> + - ({ ALL: 0, OTHER: 1, TO_END: 2 }); + ({ ALL: 0, OTHER: 1, TO_START: 2, TO_END: 3 }); null @@ -2310,6 +2310,12 @@ case this.closingTabsEnum.OTHER: tabsToClose = this.visibleTabs.length - 1 - gBrowser._numPinnedTabs; break; + case this.closingTabsEnum.TO_START: + if (!aTab) + throw new Error("Required argument missing: aTab"); + + tabsToClose = this.getTabsToTheStartFrom(aTab).length; + break; case this.closingTabsEnum.TO_END: if (!aTab) throw new Error("Required argument missing: aTab"); @@ -2366,6 +2372,36 @@ + + + + + + + + + + + + = 0; --i) { + this.removeTab(tabs[i], aParams); + } + } + ]]> + + + diff --git a/application/basilisk/locales/en-US/chrome/browser/browser.dtd b/application/basilisk/locales/en-US/chrome/browser/browser.dtd index b4063b5877..0d4f2c9503 100644 --- a/application/basilisk/locales/en-US/chrome/browser/browser.dtd +++ b/application/basilisk/locales/en-US/chrome/browser/browser.dtd @@ -23,6 +23,11 @@ + + + diff --git a/toolkit/components/webextensions/webrequest/StreamFilterParent.cpp b/toolkit/components/webextensions/webrequest/StreamFilterParent.cpp index d8abd7e823..ef0aa07a66 100644 --- a/toolkit/components/webextensions/webrequest/StreamFilterParent.cpp +++ b/toolkit/components/webextensions/webrequest/StreamFilterParent.cpp @@ -250,8 +250,9 @@ bool StreamFilterParent::RecvClose() { void StreamFilterParent::Destroy() { // Close the channel asynchronously so the actor is never destroyed before // this message is fully processed. - ActorThread()->Dispatch(NewRunnableMethod(this, - &StreamFilterParent::Close), + ActorThread()->Dispatch(NS_NewRunnableFunction([self = RefPtr(this)]() { + self->Close(); + }), NS_DISPATCH_NORMAL); } @@ -354,8 +355,8 @@ void StreamFilterParent::FinishDisconnect() { bool StreamFilterParent::RecvWrite(Data&& aData) { AssertIsActorThread(); - RunOnIOThread(NS_NewRunnableFunction([this, data = std::move(aData)]() mutable { - WriteMove(std::move(data)); + RunOnIOThread(NS_NewRunnableFunction([self = RefPtr(this), data = std::move(aData)]() mutable { + self->WriteMove(std::move(data)); })); return true; } @@ -612,8 +613,8 @@ StreamFilterParent::OnDataAvailable(nsIRequest* aRequest, return NS_ERROR_FAILURE; } else { ActorThread()->Dispatch( - NS_NewRunnableFunction([this, data = std::move(data)]() mutable { - DoSendData(std::move(data)); + NS_NewRunnableFunction([self = RefPtr(this), data = std::move(data)]() mutable { + self->DoSendData(std::move(data)); }), NS_DISPATCH_NORMAL); }