tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit cd8414274ddd56a475cafd889dedb22fbfab32d9
parent e386e1fe401d78ec67a09f16fcc7025a81657c14
Author: Martin Stransky <stransky@redhat.com>
Date:   Fri,  5 Dec 2025 12:21:44 +0000

Bug 1998188 Allow only one recursion of AppWindow::Center() r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D275039

Diffstat:
Mxpfe/appshell/AppWindow.cpp | 16++++++++++++----
Mxpfe/appshell/AppWindow.h | 3+++
2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/xpfe/appshell/AppWindow.cpp b/xpfe/appshell/AppWindow.cpp @@ -745,8 +745,8 @@ nsresult AppWindow::MoveResize(const Maybe<DesktopPoint>& aPosition, return NS_OK; } -NS_IMETHODIMP AppWindow::Center(nsIAppWindow* aRelative, bool aScreen, - bool aAlert) { +nsresult AppWindow::CenterImpl(nsIAppWindow* aRelative, bool aScreen, + bool aAlert, bool aAllowCenteringForSizeChange) { DesktopIntRect rect; bool screenCoordinates = false, windowCoordinates = false; nsresult result; @@ -814,12 +814,20 @@ NS_IMETHODIMP AppWindow::Center(nsIAppWindow* aRelative, bool aScreen, SetPositionDesktopPix(newPos.x, newPos.y); // If moving the window caused it to change size, re-do the centering. - if (GetSize() != ourDevSize) { - return Center(aRelative, aScreen, aAlert); + // Allow only one recursion here. + if (GetSize() != ourDevSize && aAllowCenteringForSizeChange) { + return CenterImpl(aRelative, aScreen, aAlert, + /* aAllowCenteringForSizeChange */ false); } return NS_OK; } +NS_IMETHODIMP AppWindow::Center(nsIAppWindow* aRelative, bool aScreen, + bool aAlert) { + return CenterImpl(aRelative, aScreen, aAlert, + /* aAllowCenteringForSizeChange */ true); +} + NS_IMETHODIMP AppWindow::GetParentWidget(nsIWidget** aParentWidget) { NS_ENSURE_ARG_POINTER(aParentWidget); NS_ENSURE_STATE(mWindow); diff --git a/xpfe/appshell/AppWindow.h b/xpfe/appshell/AppWindow.h @@ -376,6 +376,9 @@ class AppWindow final : public nsIBaseWindow, const Maybe<LayoutDeviceIntSize>& aSize, bool aRepaint); nsresult MoveResize(const Maybe<DesktopPoint>& aPosition, const Maybe<DesktopSize>& aSize, bool aRepaint); + nsresult CenterImpl(nsIAppWindow* aRelative, bool aScreen, bool aAlert, + bool aAllowCenteringForSizeChange); + nsCOMPtr<nsIXULStore> mLocalStore; bool mIsWidgetInFullscreen = false; };