diff --git a/layout/xul/base/public/nsXULPopupManager.h b/layout/xul/base/public/nsXULPopupManager.h index 6d70045142f5..e87eee6e38d4 100644 --- a/layout/xul/base/public/nsXULPopupManager.h +++ b/layout/xul/base/public/nsXULPopupManager.h @@ -337,8 +337,11 @@ public: static nsXULPopupManager* GetInstance(); // get the frame for a content node aContent if the frame's type - // matches aFrameType. Otherwise, return null. - nsIFrame* GetFrameOfTypeForContent(nsIContent* aContent, nsIAtom* aFrameType); + // matches aFrameType. Otherwise, return null. If aShouldFlush is true, + // then the frames are flushed before retrieving the frame. + nsIFrame* GetFrameOfTypeForContent(nsIContent* aContent, + nsIAtom* aFrameType, + PRBool aShouldFlush); // given a menu frame, find the prevous or next menu frame. If aPopup is // true then navigate a menupopup, from one item on the menu to the previous diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index 373c6dedc17e..c8c472cfb840 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -212,12 +212,16 @@ nsXULPopupManager::GetSubmenuWidgetChain(nsISupportsArray **_retval) nsIFrame* nsXULPopupManager::GetFrameOfTypeForContent(nsIContent* aContent, - nsIAtom* aFrameType) + nsIAtom* aFrameType, + PRBool aShouldFlush) { nsIDocument *document = aContent->GetCurrentDoc(); if (document) { - nsIPresShell* presShell = document->GetPrimaryShell(); + nsCOMPtr presShell = document->GetPrimaryShell(); if (presShell) { + if (aShouldFlush) + presShell->FlushPendingNotifications(Flush_Frames); + nsIFrame* frame = presShell->GetPrimaryFrameFor(aContent); if (frame && frame->GetType() == aFrameType) return frame; @@ -230,15 +234,16 @@ nsXULPopupManager::GetFrameOfTypeForContent(nsIContent* aContent, nsMenuFrame* nsXULPopupManager::GetMenuFrameForContent(nsIContent* aContent) { + // as ShowMenu is called from frames, don't flush to be safe. return static_cast - (GetFrameOfTypeForContent(aContent, nsGkAtoms::menuFrame)); + (GetFrameOfTypeForContent(aContent, nsGkAtoms::menuFrame, PR_FALSE)); } nsMenuPopupFrame* nsXULPopupManager::GetPopupFrameForContent(nsIContent* aContent) { return static_cast - (GetFrameOfTypeForContent(aContent, nsGkAtoms::menuPopupFrame)); + (GetFrameOfTypeForContent(aContent, nsGkAtoms::menuPopupFrame, PR_TRUE)); } nsMenuChainItem* diff --git a/toolkit/content/tests/widgets/Makefile.in b/toolkit/content/tests/widgets/Makefile.in index 60a27a86de22..7ad628e93cdb 100644 --- a/toolkit/content/tests/widgets/Makefile.in +++ b/toolkit/content/tests/widgets/Makefile.in @@ -80,6 +80,7 @@ _TEST_FILES = test_bug360220.xul \ test_hiddenpaging.xul \ test_popup_tree.xul \ test_popup_keys.xul \ + test_popuphidden.xul \ $(NULL) ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) diff --git a/toolkit/content/tests/widgets/test_popuphidden.xul b/toolkit/content/tests/widgets/test_popuphidden.xul new file mode 100644 index 000000000000..c8cd72b285d9 --- /dev/null +++ b/toolkit/content/tests/widgets/test_popuphidden.xul @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + +

+

+ +
+
+ + +