Bug 1934238 - Don't try to position anything from XUL if the widget is not in the normal sizemode. r=rkraesig

When the window is already properly maximized (which can happen with the
pre-skeleton UI), we shouldn't adjust the position of the window.

The reason this worked before my patch was because the skeleton UI
didn't have the right bounds, so the position didn't change.

But I don't think we should move the window at all in this case (I
believe the current patch in bug 1866583 part 4 maybe fix this too, but
it's better to be explicit).

Differential Revision: https://phabricator.services.mozilla.com/D230694
This commit is contained in:
Emilio Cobos Álvarez
2024-12-02 00:05:49 +00:00
parent 82fbc8fbe4
commit 0cf50782b7

View File

@@ -1151,14 +1151,17 @@ static Maybe<int32_t> ReadIntAttribute(const Element& aElement,
// to fit to the screen when staggering windows; if they're negative, // to fit to the screen when staggering windows; if they're negative,
// we use the window's current size instead. // we use the window's current size instead.
bool AppWindow::LoadPositionFromXUL(int32_t aSpecWidth, int32_t aSpecHeight) { bool AppWindow::LoadPositionFromXUL(int32_t aSpecWidth, int32_t aSpecHeight) {
bool gotPosition = false;
// if we're the hidden window, don't try to validate our size/position. We're // if we're the hidden window, don't try to validate our size/position. We're
// special. // special.
if (mIsHiddenWindow) { if (mIsHiddenWindow) {
return false; return false;
} }
// If we're not in the normal sizemode, don't move the window around.
if (mWindow->SizeMode() != nsSizeMode_Normal) {
return false;
}
RefPtr<dom::Element> root = GetWindowDOMElement(); RefPtr<dom::Element> root = GetWindowDOMElement();
NS_ENSURE_TRUE(root, false); NS_ENSURE_TRUE(root, false);
@@ -1184,6 +1187,7 @@ bool AppWindow::LoadPositionFromXUL(int32_t aSpecWidth, int32_t aSpecHeight) {
// Obtain the position information from the <xul:window> element. // Obtain the position information from the <xul:window> element.
DesktopIntPoint specPoint = curPoint; DesktopIntPoint specPoint = curPoint;
bool gotPosition = false;
// Also read lowercase screenx/y because the front-end sometimes sets these // Also read lowercase screenx/y because the front-end sometimes sets these
// via setAttribute on HTML documents like about:blank, and stuff gets // via setAttribute on HTML documents like about:blank, and stuff gets
@@ -1219,7 +1223,6 @@ bool AppWindow::LoadPositionFromXUL(int32_t aSpecWidth, int32_t aSpecHeight) {
if (specPoint != curPoint) { if (specPoint != curPoint) {
SetPositionDesktopPix(specPoint.x, specPoint.y); SetPositionDesktopPix(specPoint.x, specPoint.y);
} }
return gotPosition; return gotPosition;
} }