feat: Fixed wrong rendering when animating popover opens, b=no-bug, c=common

This commit is contained in:
mr. m
2026-03-03 00:46:30 +01:00
parent ee5c1894eb
commit 3831af027e
2 changed files with 12 additions and 15 deletions

View File

@@ -118,7 +118,7 @@ diff --git a/toolkit/themes/shared/global-shared.css b/toolkit/themes/shared/glo
+/* stylelint-disable-next-line media-query-no-invalid */
+@media -moz-pref("widget.macos.native-popovers") and (-moz-platform: macos) {
+ panel:where([nativepopover="true"]) {
+ panel:not(:where([nonnativepopover="true"])) {
+ background-color: transparent;
+ --panel-background: transparent;
+ --panel-shadow: none;
@@ -281,22 +281,19 @@ diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
if (!mWindow) {
@@ -5227,10 +5282,65 @@
@@ -5227,10 +5282,63 @@
mWindow.contentView.needsDisplay = YES;
if (!nativeParentWindow || mPopupLevel != PopupLevel::Parent) {
[mWindow orderFront:nil];
}
NS_OBJC_END_TRY_IGNORE_BLOCK;
+ nsMenuPopupFrame* popupFrame = GetPopupFrame();
+ mozilla::ErrorResult rv;
+ if ([mWindow isKindOfClass:[PopupWindow class]] &&
+ [(PopupWindow*)mWindow usePopover] && popupFrame &&
+ popupFrame->ShouldFollowAnchor() &&
+ !popupFrame->PopupElement().GetBoolAttr(
+ nsGkAtoms::nonnativepopover)) {
+ if (nativeParentWindow) {
+ popupFrame->PopupElement().SetXULBoolAttr(nsGkAtoms::nativepopover,
+ true, rv);
+ NSRectEdge preferredEdge =
+ AlignmentPositionToNSRectEdge(popupFrame->GetAlignmentPosition());
+ nsRect anchorRectAppUnits = popupFrame->GetUntransformedAnchorRect();
@@ -339,15 +336,16 @@ diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm
+ return;
+ }
+ if (popupFrame) {
+ popupFrame->PopupElement().SetXULBoolAttr(nsGkAtoms::nativepopover,
+ false, rv);
+ mozilla::ErrorResult rv;
+ popupFrame->PopupElement().SetXULBoolAttr(nsGkAtoms::nonnativepopover,
+ true, rv);
+ }
// If our popup window is a non-native context menu, tell the OS (and
// other programs) that a menu has opened. This is how the OS knows to
// close other programs' context menus when ours open.
if ([mWindow isKindOfClass:[PopupWindow class]] &&
[(PopupWindow*)mWindow isContextMenu]) {
@@ -5301,10 +5411,15 @@
@@ -5301,10 +5409,15 @@
// of a window it hides the parent window.
if (mWindowType == WindowType::Popup && nativeParentWindow) {
[nativeParentWindow removeChildWindow:mWindow];
@@ -363,7 +361,7 @@ diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm
// other programs) that a menu has closed.
if ([mWindow isKindOfClass:[PopupWindow class]] &&
[(PopupWindow*)mWindow isContextMenu]) {
@@ -5351,10 +5466,17 @@
@@ -5351,10 +5464,17 @@
return false;
}
return nsIWidget::ShouldUseOffMainThreadCompositing();
@@ -381,7 +379,7 @@ diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm
return mWindow.isOpaque ? TransparencyMode::Opaque
: TransparencyMode::Transparent;
@@ -6313,10 +6435,20 @@
@@ -6313,10 +6433,20 @@
// We ignore aRepaint -- we have to call display:YES, otherwise the
// title bar doesn't immediately get repainted and is displayed in
// the wrong place, leading to a visual jump.
@@ -402,7 +400,7 @@ diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm
void nsCocoaWindow::Resize(const DesktopRect& aRect, bool aRepaint) {
DoResize(aRect.x, aRect.y, aRect.width, aRect.height, aRepaint, false);
@@ -8277,18 +8409,27 @@
@@ -8277,18 +8407,27 @@
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)deferCreation {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
@@ -430,7 +428,7 @@ diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm
// Return 0 in order to match what the system does for sheet windows and
// _NSPopoverWindows.
- (CGFloat)_backdropBleedAmount {
@@ -8342,10 +8483,120 @@
@@ -8342,10 +8481,120 @@
- (void)setIsContextMenu:(BOOL)flag {
mIsContextMenu = flag;
@@ -566,14 +564,13 @@ diff --git a/xpcom/ds/StaticAtoms.py b/xpcom/ds/StaticAtoms.py
Atom("highest", "highest"),
Atom("horizontal", "horizontal"),
Atom("hover", "hover"),
@@ -756,10 +757,12 @@
@@ -756,10 +757,11 @@
Atom("nohref", "nohref"),
Atom("noinitialselection", "noinitialselection"),
Atom("nomodule", "nomodule"),
Atom("nonce", "nonce"),
Atom("none", "none"),
+ Atom("nonnativepopover", "nonnativepopover"),
+ Atom("nativepopover", "nativepopover"),
Atom("noresize", "noresize"),
Atom("normal", "normal"),
Atom("normalizeSpace", "normalize-space"),

View File

@@ -30,7 +30,7 @@ panel[type="arrow"]:not(#feature-callout) {
}
@media (-moz-platform: macos) {
&:where(:not([nativepopover="true"])) {
&:where([nonnativepopover="true"]) {
appearance: auto !important;
-moz-default-appearance: menupopup;
/* We set the default background here, rather than on ::part(content),