diff --git a/layout/xul/nsMenuPopupFrame.cpp b/layout/xul/nsMenuPopupFrame.cpp index 034cd031f034..06e0d22141fb 100644 --- a/layout/xul/nsMenuPopupFrame.cpp +++ b/layout/xul/nsMenuPopupFrame.cpp @@ -58,7 +58,6 @@ using namespace mozilla; using mozilla::dom::Event; -using mozilla::dom::Document; using mozilla::dom::KeyboardEvent; int8_t nsMenuPopupFrame::sDefaultLevelIsTop = -1; @@ -392,6 +391,15 @@ void nsXULPopupShownEvent::CancelListener() { NS_IMPL_ISUPPORTS_INHERITED(nsXULPopupShownEvent, Runnable, nsIDOMEventListener); +void nsMenuPopupFrame::SetInitialChildList(ChildListID aListID, + nsFrameList& aChildList) { + // unless the list is empty, indicate that children have been generated. + if (aListID == kPrincipalList && aChildList.NotEmpty()) { + mGeneratedChildren = true; + } + nsBoxFrame::SetInitialChildList(aListID, aChildList); +} + bool nsMenuPopupFrame::IsLeafDynamic() const { if (mGeneratedChildren) return false; diff --git a/layout/xul/nsMenuPopupFrame.h b/layout/xul/nsMenuPopupFrame.h index 42746476428f..dd288e7f8c33 100644 --- a/layout/xul/nsMenuPopupFrame.h +++ b/layout/xul/nsMenuPopupFrame.h @@ -247,6 +247,9 @@ class nsMenuPopupFrame final : public nsBoxFrame, nsresult CreateWidgetForView(nsView* aView); uint8_t GetShadowStyle(); + virtual void SetInitialChildList(ChildListID aListID, + nsFrameList& aChildList) override; + virtual bool IsLeafDynamic() const override; virtual void UpdateWidgetProperties() override; diff --git a/layout/xul/nsXULPopupManager.cpp b/layout/xul/nsXULPopupManager.cpp index 9e70f6d1f42f..56506fcfb80d 100644 --- a/layout/xul/nsXULPopupManager.cpp +++ b/layout/xul/nsXULPopupManager.cpp @@ -1284,11 +1284,8 @@ void nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup, nsPopupType popupType = popupFrame->PopupType(); // generate the child frames if they have not already been generated - const bool generateFrames = popupFrame->IsLeaf(); - MOZ_ASSERT_IF(generateFrames, !popupFrame->HasGeneratedChildren()); - popupFrame->SetGeneratedChildren(); - if (generateFrames) { - MOZ_ASSERT(popupFrame->PrincipalChildList().IsEmpty()); + if (!popupFrame->HasGeneratedChildren()) { + popupFrame->SetGeneratedChildren(); presShell->FrameConstructor()->GenerateChildFrames(popupFrame); }