tor-browser

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

commit debdf7f1910f89980aa91285f0c8669940ec931a
parent ec10c7ec7e6c28249852472f7aea8d1484303e8e
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Fri, 17 Oct 2025 00:23:58 +0000

Bug 1994762 - Don't offset by parent screen offset. r=mac-reviewers,spohl

This is another related issue that was probably introduced by bug 1924240, but
papered by the fact that we did have spurious resizes via nsView.

When creating popups, the coordinates are screen coordinates, there's no need
to offset by the parent.

nsView::CalcWidgetBounds has always done this:

  https://searchfox.org/firefox-main/rev/f8a53e9a2f08aafc12e8cc4c4d77c17f0ff0307c/view/nsView.cpp#202-204

But probably nsChildView had different requirements.

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

Diffstat:
Mwidget/cocoa/nsCocoaWindow.mm | 27++-------------------------
1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm @@ -4752,15 +4752,6 @@ DesktopToLayoutDeviceScale ParentBackingScaleFactor(nsIWidget* aParent) { return DesktopToLayoutDeviceScale(1.0); } -// Returns the screen rectangle for the given widget. -// Child widgets are positioned relative to this rectangle. -// Exactly one of the arguments must be non-null. -static DesktopRect GetWidgetScreenRectForChildren(nsIWidget* aWidget) { - mozilla::DesktopToLayoutDeviceScale scale = - aWidget->GetDesktopToDeviceScale(); - return aWidget->GetClientBounds() / scale; -} - // aRect here is specified in desktop pixels // // For child windows aRect.{x,y} are offsets from the origin of the parent @@ -4785,22 +4776,8 @@ nsresult nsCocoaWindow::Create(nsIWidget* aParent, const DesktopIntRect& aRect, mAlwaysOnTop = aInitData->mAlwaysOnTop; mIsAlert = aInitData->mIsAlert; - // If we have a parent widget, the new widget will be offset from the - // parent widget by aRect.{x,y}. Otherwise, we'll use aRect for the - // new widget coordinates. - DesktopIntPoint parentOrigin; - - // Do we have a parent widget? - if (aParent) { - DesktopRect parentDesktopRect = GetWidgetScreenRectForChildren(aParent); - parentOrigin = gfx::RoundedToInt(parentDesktopRect.TopLeft()); - } - - DesktopIntRect widgetRect = aRect + parentOrigin; - - nsresult rv = - CreateNativeWindow(nsCocoaUtils::GeckoRectToCocoaRect(widgetRect), - mBorderStyle, false, aInitData->mIsPrivate); + nsresult rv = CreateNativeWindow(nsCocoaUtils::GeckoRectToCocoaRect(aRect), + mBorderStyle, false, aInitData->mIsPrivate); NS_ENSURE_SUCCESS(rv, rv); mIsAnimationSuppressed = aInitData->mIsAnimationSuppressed;