Bug 396983, flush frames before opening a popup, r+sr=bz, a=dbaron

This commit is contained in:
enndeakin@sympatico.ca 2007-10-09 05:11:14 -07:00
Родитель 3bbaaa8fe9
Коммит 47431a8032
4 изменённых файлов: 57 добавлений и 6 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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<nsIPresShell> 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<nsMenuFrame *>
(GetFrameOfTypeForContent(aContent, nsGkAtoms::menuFrame));
(GetFrameOfTypeForContent(aContent, nsGkAtoms::menuFrame, PR_FALSE));
}
nsMenuPopupFrame*
nsXULPopupManager::GetPopupFrameForContent(nsIContent* aContent)
{
return static_cast<nsMenuPopupFrame *>
(GetFrameOfTypeForContent(aContent, nsGkAtoms::menuPopupFrame));
(GetFrameOfTypeForContent(aContent, nsGkAtoms::menuPopupFrame, PR_TRUE));
}
nsMenuChainItem*

Просмотреть файл

@ -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)))

Просмотреть файл

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
<window title="Hidden Popup Test"
onload="setTimeout(runTests, 0);"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<menupopup id="popup" hidden="true" onpopupshown="ok(true, 'popupshown'); this.hidePopup()"
onpopuphidden="SimpleTest.finish()">
<menuitem id="i1" label="One"/>
<menuitem id="i2" label="Two"/>
</menupopup>
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
function runTests()
{
var popup = $("popup");
popup.hidden = false;
popup.openPopup(null, "after_start");
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display">
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</window>