Skip to content

Commit f6f66fd

Browse files
committed
Bug 1976623 - Create drag popups eagerly for now. r=tnikkel,layout-reviewers
Trivially restores pre-regression behavior, for now. Differential Revision: https://phabricator.services.mozilla.com/D256769
1 parent d83df2e commit f6f66fd

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

layout/xul/nsMenuPopupFrame.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
144150
bool 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

156169
void 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

layout/xul/nsMenuPopupFrame.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ class nsMenuPopupFrame final : public nsBlockFrame {
202202

203203
bool HasRemoteContent() const;
204204

205+
// Whether this is a drag popup to show drag feedback.
206+
bool IsDragPopup() const;
207+
205208
// Whether we should have a widget even when we're not shown.
206209
bool ShouldHaveWidgetWhenHidden() const;
207210

0 commit comments

Comments
 (0)