@@ -141,16 +141,29 @@ static nsIWidget::InputRegion ComputeInputRegion(const ComputedStyle& aStyle,
141141 .Truncated ()};
142142}
143143
144+ bool nsMenuPopupFrame::IsDragPopup () const {
145+ return !mInContentShell && mPopupType == PopupType::Panel &&
146+ mContent ->AsElement ()->AttrValueIs (kNameSpaceID_None , nsGkAtoms::type,
147+ nsGkAtoms::drag, eIgnoreCase);
148+ }
149+
144150bool nsMenuPopupFrame::ShouldHaveWidgetWhenHidden () const {
145- // Create a widget upfront for panels that never hide frames for their
146- // contents (like web extension popups). These, for now, need to create the
147- // widgets upfront, so that the frames inside the popup don't get "reparented"
148- // in the widget tree.
149- //
150- // TODO(emilio, bug 1976324): Try to somehow remove this special-case, web-ext
151- // panel needs it to compute the "natural" bounds of their contents before
152- // showing the popup, but that seems like it could be tweaked.
153- return mContent ->AsElement ()->HasAttr (nsGkAtoms::neverhidden);
151+ if (mContent ->AsElement ()->HasAttr (nsGkAtoms::neverhidden)) {
152+ // Create a widget upfront for panels that never hide frames for their
153+ // contents (like web extension popups). These, for now, need to create the
154+ // widgets upfront, so that the frames inside the popup don't get
155+ // "reparented" in the widget tree.
156+ //
157+ // TODO(emilio, bug 1976324): Try to somehow remove this special-case,
158+ // web-ext panel needs it to compute the "natural" bounds of their contents
159+ // before showing the popup, but that seems like it could be tweaked.
160+ return true ;
161+ }
162+ if (IsDragPopup ()) {
163+ // Create widgets upfront for the drag popup for now, see bug 1976623.
164+ return true ;
165+ }
166+ return false ;
154167}
155168
156169void nsMenuPopupFrame::Init (nsIContent* aContent, nsContainerFrame* aParent,
@@ -302,15 +315,7 @@ nsresult nsMenuPopupFrame::CreateWidgetForView(nsView* aView) {
302315 widgetData.mBorderStyle = widget::BorderStyle::Default;
303316 widgetData.mClipSiblings = true ;
304317 widgetData.mPopupHint = mPopupType ;
305-
306- if (!mInContentShell ) {
307- // A drag popup may be used for non-static translucent drag feedback
308- if (mPopupType == PopupType::Panel &&
309- mContent ->AsElement ()->AttrValueIs (kNameSpaceID_None , nsGkAtoms::type,
310- nsGkAtoms::drag, eIgnoreCase)) {
311- widgetData.mIsDragPopup = true ;
312- }
313- }
318+ widgetData.mIsDragPopup = IsDragPopup ();
314319
315320 const bool remote = HasRemoteContent ();
316321
0 commit comments