commit d61c4af6da7d209d9649a68819cbe36771c5e20a
parent 7f88f484011c8e6079cd740e1e61b44655c01799
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date: Wed, 17 Dec 2025 11:00:57 +0000
Bug 2006320 - Stop pretending menupopups can have titlebars. r=stransky
No platform supports a non-zero client offset for popups.
Differential Revision: https://phabricator.services.mozilla.com/D276658
Diffstat:
3 files changed, 3 insertions(+), 41 deletions(-)
diff --git a/layout/xul/nsMenuPopupFrame.cpp b/layout/xul/nsMenuPopupFrame.cpp
@@ -1752,17 +1752,6 @@ auto nsMenuPopupFrame::GetRects(const nsSize& aPrefSize) const -> Rects {
// determine the x and y position of the view by subtracting the desired
// screen position from the screen position of the root frame.
result.mViewPoint = result.mUsedRect.TopLeft() - rootScreenRect.TopLeft();
-
- // Offset the position by the width and height of the borders and titlebar.
- // Even though GetClientOffset should return (0, 0) when there is no titlebar
- // or borders, we skip these calculations anyway for non-panels to save time
- // since they will never have a titlebar.
- if (mPopupType == PopupType::Panel && widget) {
- result.mClientOffset = widget->GetClientOffset();
- result.mViewPoint +=
- LayoutDeviceIntPoint::ToAppUnits(result.mClientOffset, a2d);
- }
-
return result;
}
@@ -1813,7 +1802,6 @@ void nsMenuPopupFrame::PerformMove(const Rects& aRects) {
}
mAlignmentOffset = aRects.mAlignmentOffset;
- mLastClientOffset = aRects.mClientOffset;
mHFlip = aRects.mHFlip;
mVFlip = aRects.mVFlip;
mConstrainedByLayout = aRects.mConstrainedByLayout;
@@ -2277,7 +2265,6 @@ void nsMenuPopupFrame::DestroyWidgetIfNeeded() {
void nsMenuPopupFrame::MoveTo(const CSSPoint& aPos, bool aUpdateAttrs,
bool aByMoveToRect) {
- nsIWidget* widget = GetWidget();
nsPoint appUnitsPos = CSSPixel::ToAppUnits(aPos);
const bool rtl = IsDirectionRTL();
@@ -2298,8 +2285,7 @@ void nsMenuPopupFrame::MoveTo(const CSSPoint& aPos, bool aUpdateAttrs,
appUnitsPos.y -= margin.top;
}
- if (mScreenRect.TopLeft() == appUnitsPos &&
- (!widget || widget->GetClientOffset() == mLastClientOffset)) {
+ if (mScreenRect.TopLeft() == appUnitsPos) {
return;
}
@@ -2517,8 +2503,7 @@ void nsMenuPopupFrame::WindowMoved(nsIWidget* aWidget,
// Don't do anything if the popup is already at the specified location. This
// prevents recursive calls when a popup is positioned.
LayoutDeviceIntRect curDevBounds = CalcWidgetBounds();
- if (curDevBounds.TopLeft() == aPoint &&
- aWidget->GetClientOffset() == GetLastClientOffset()) {
+ if (curDevBounds.TopLeft() == aPoint) {
return;
}
diff --git a/layout/xul/nsMenuPopupFrame.h b/layout/xul/nsMenuPopupFrame.h
@@ -392,8 +392,6 @@ class nsMenuPopupFrame final : public nsBlockFrame, public nsIWidgetListener {
bool mHFlip = false;
bool mVFlip = false;
bool mConstrainedByLayout = false;
- // The client offset of our widget.
- mozilla::LayoutDeviceIntPoint mClientOffset;
nsPoint mViewPoint;
};
@@ -423,10 +421,6 @@ class nsMenuPopupFrame final : public nsBlockFrame, public nsIWidgetListener {
return mozilla::CSSRect::FromAppUnitsRounded(mScreenRect);
}
- mozilla::LayoutDeviceIntPoint GetLastClientOffset() const {
- return mLastClientOffset;
- }
-
mozilla::LayoutDeviceIntRect CalcWidgetBounds() const;
// Return the alignment of the popup
@@ -620,11 +614,6 @@ class nsMenuPopupFrame final : public nsBlockFrame, public nsIWidgetListener {
// mPosition)
nscoord mAlignmentOffset = 0;
- // The value of the client offset of our widget the last time we positioned
- // ourselves. We store this so that we can detect when it changes but the
- // position of our widget didn't change.
- mozilla::LayoutDeviceIntPoint mLastClientOffset;
-
// The focus sequence number of the last processed input event
uint64_t mAPZFocusSequenceNumber = 0;
diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp
@@ -2326,19 +2326,7 @@ void nsWindow::NativeMoveResizeWaylandPopup(bool aMove, bool aResize) {
mWaylandApplyPopupPositionBeforeShow = false;
}
- // We expect all Wayland popus have zero margin. If not, just position
- // it as is and throw an error message.
- if (!mClientMargin.IsAllZero()) {
- gfxCriticalNoteOnce << "Invalid non-zero margin for WaylandPopup!";
- if (aMove) {
- gtk_window_move(GTK_WINDOW(mShell), mLastMoveRequest.x,
- mLastMoveRequest.y);
- }
- if (aResize) {
- gtk_window_resize(GTK_WINDOW(mShell), mLastSizeRequest.width,
- mLastSizeRequest.height);
- }
- }
+ MOZ_ASSERT(mClientMargin.IsAllZero());
if (mWaitingForMoveToRectCallback) {
LOG(" waiting for move to rect, scheduling");