From 3831af027e2f48ca821bdb6bec91395e8818229f Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Tue, 3 Mar 2026 00:46:30 +0100 Subject: [PATCH] feat: Fixed wrong rendering when animating popover opens, b=no-bug, c=common --- .../firefox/native_macos_popovers.patch | 25 ++++++++----------- src/zen/common/styles/zen-panel-ui.css | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/external-patches/firefox/native_macos_popovers.patch b/src/external-patches/firefox/native_macos_popovers.patch index 687cf9106..d317b9764 100644 --- a/src/external-patches/firefox/native_macos_popovers.patch +++ b/src/external-patches/firefox/native_macos_popovers.patch @@ -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"), diff --git a/src/zen/common/styles/zen-panel-ui.css b/src/zen/common/styles/zen-panel-ui.css index 10788b3d0..e232d68ff 100644 --- a/src/zen/common/styles/zen-panel-ui.css +++ b/src/zen/common/styles/zen-panel-ui.css @@ -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),