gecko-dev/layout/xul/base/src/nsMenuFrame.cpp

1394 lines
40 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
1999-07-18 06:36:37 +00:00
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
1999-07-18 06:36:37 +00:00
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
1999-07-18 06:36:37 +00:00
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
1999-07-18 06:36:37 +00:00
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
1999-07-18 06:36:37 +00:00
*/
1999-07-20 08:19:47 +00:00
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLParts.h"
1999-07-18 06:36:37 +00:00
#include "nsMenuFrame.h"
1999-07-21 02:56:23 +00:00
#include "nsBoxFrame.h"
1999-07-18 06:36:37 +00:00
#include "nsIContent.h"
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsIPresContext.h"
#include "nsIPresShell.h"
1999-07-18 06:36:37 +00:00
#include "nsIStyleContext.h"
#include "nsIReflowCommand.h"
1999-07-18 06:36:37 +00:00
#include "nsCSSRendering.h"
#include "nsINameSpaceManager.h"
#include "nsLayoutAtoms.h"
#include "nsMenuPopupFrame.h"
1999-07-21 07:42:16 +00:00
#include "nsMenuBarFrame.h"
1999-07-26 02:26:26 +00:00
#include "nsIView.h"
#include "nsIWidget.h"
#include "nsIDocument.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMXULDocument.h"
#include "nsIDOMElement.h"
#include "nsISupportsArray.h"
#include "nsIDOMText.h"
1999-07-18 06:36:37 +00:00
#define NS_MENU_POPUP_LIST_INDEX (NS_AREA_FRAME_ABSOLUTE_LIST_INDEX + 1)
static PRInt32 gEatMouseMove = PR_FALSE;
1999-09-21 01:03:00 +00:00
nsMenuDismissalListener* nsMenuFrame::mDismissalListener = nsnull;
1999-07-18 06:36:37 +00:00
//
// NS_NewMenuFrame
//
// Wrapper for creating a new menu popup container
//
nsresult
NS_NewMenuFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRUint32 aFlags)
1999-07-18 06:36:37 +00:00
{
NS_PRECONDITION(aNewFrame, "null OUT ptr");
if (nsnull == aNewFrame) {
return NS_ERROR_NULL_POINTER;
}
nsMenuFrame* it = new (aPresShell) nsMenuFrame;
1999-07-18 06:36:37 +00:00
if ( !it )
return NS_ERROR_OUT_OF_MEMORY;
*aNewFrame = it;
if (aFlags)
it->SetIsMenu(PR_TRUE);
1999-07-18 06:36:37 +00:00
return NS_OK;
}
1999-07-21 07:42:16 +00:00
NS_IMETHODIMP_(nsrefcnt)
nsMenuFrame::AddRef(void)
{
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
1999-07-21 07:42:16 +00:00
nsMenuFrame::Release(void)
{
return NS_OK;
}
//
// QueryInterface
//
// Since we inherit from a base class with its own implementation of QI, we
// need to rely on that for the other interfaces supported, yet we still want
// to use the map macros. Currently, there is no macro to let you use the
// inherited version of QI, so we cheat. Hopefully this will change in the near
// future (pinkerton)
//
NS_INTERFACE_MAP_BEGIN(nsMenuFrame)
NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
NS_INTERFACE_MAP_ENTRY(nsIMenuFrame)
NS_INTERFACE_MAP_ENTRY(nsIAnonymousContentCreator)
foundInterface = 0;
nsresult status;
if ( !foundInterface )
status = nsBoxFrame::QueryInterface(aIID, NS_REINTERPRET_CAST(void**,&foundInterface)); \
else
{
NS_ADDREF(foundInterface);
status = NS_OK;
}
*aInstancePtr = foundInterface;
return status;
}
1999-07-18 06:36:37 +00:00
//
// nsMenuFrame cntr
//
nsMenuFrame::nsMenuFrame()
: mIsMenu(PR_FALSE),
mMenuOpen(PR_FALSE),
mHasAnonymousContent(PR_FALSE),
mChecked(PR_FALSE),
mType(eMenuType_Normal),
mMenuParent(nsnull),
mPresContext(nsnull),
mGroupName("")
1999-07-18 06:36:37 +00:00
{
} // cntr
1999-07-21 07:42:16 +00:00
NS_IMETHODIMP
nsMenuFrame::Init(nsIPresContext* aPresContext,
1999-07-21 07:42:16 +00:00
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
mPresContext = aPresContext; // Don't addref it. Our lifetime is shorter.
1999-07-21 07:42:16 +00:00
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
// Set our menu parent.
nsCOMPtr<nsIMenuParent> menuparent = do_QueryInterface(aParent);
mMenuParent = menuparent.get();
return rv;
}
// The following methods are all overridden to ensure that the menupopup frame
// is placed in the appropriate list.
NS_IMETHODIMP
nsMenuFrame::FirstChild(nsIAtom* aListName,
nsIFrame** aFirstChild) const
{
if (nsLayoutAtoms::popupList == aListName) {
*aFirstChild = mPopupFrames.FirstChild();
} else {
1999-07-21 02:56:23 +00:00
nsBoxFrame::FirstChild(aListName, aFirstChild);
}
return NS_OK;
}
NS_IMETHODIMP
nsMenuFrame::SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
nsresult rv = NS_OK;
if (nsLayoutAtoms::popupList == aListName) {
mPopupFrames.SetFrames(aChildList);
} else {
1999-07-20 08:19:47 +00:00
nsFrameList frames(aChildList);
// We may have a menupopup in here. Get it out, and move it into
1999-07-20 08:19:47 +00:00
// the popup frame list.
nsIFrame* frame = frames.FirstChild();
while (frame) {
nsCOMPtr<nsIContent> content;
frame->GetContent(getter_AddRefs(content));
nsCOMPtr<nsIAtom> tag;
content->GetTag(*getter_AddRefs(tag));
if (tag.get() == nsXULAtoms::menupopup) {
1999-07-20 08:19:47 +00:00
// Remove this frame from the list and place it in the other list.
frames.RemoveFrame(frame);
mPopupFrames.AppendFrame(this, frame);
nsIFrame* first = frames.FirstChild();
rv = nsBoxFrame::SetInitialChildList(aPresContext, aListName, first);
1999-07-20 08:19:47 +00:00
return rv;
}
frame->GetNextSibling(&frame);
}
// Didn't find it.
1999-07-21 02:56:23 +00:00
rv = nsBoxFrame::SetInitialChildList(aPresContext, aListName, aChildList);
}
return rv;
}
NS_IMETHODIMP
nsMenuFrame::GetAdditionalChildListName(PRInt32 aIndex,
nsIAtom** aListName) const
{
1999-07-21 02:56:23 +00:00
return nsBoxFrame::GetAdditionalChildListName(aIndex, aListName);
}
NS_IMETHODIMP
nsMenuFrame::Destroy(nsIPresContext* aPresContext)
{
// Cleanup frames in popup child list
mPopupFrames.DestroyFrames(aPresContext);
1999-07-22 02:24:52 +00:00
return nsBoxFrame::Destroy(aPresContext);
}
// Called to prevent events from going to anything inside the menu.
NS_IMETHODIMP
nsMenuFrame::GetFrameForPoint(nsIPresContext* aPresContext,
const nsPoint& aPoint,
nsIFrame** aFrame)
{
nsresult result = nsBoxFrame::GetFrameForPoint(aPresContext, aPoint, aFrame);
1999-10-15 07:54:43 +00:00
nsCOMPtr<nsIContent> content;
if (*aFrame) {
(*aFrame)->GetContent(getter_AddRefs(content));
if (content) {
// This allows selective overriding for subcontent.
nsAutoString value;
content->GetAttribute(kNameSpaceID_None, nsXULAtoms::allowevents, value);
if (value == "true")
return result;
}
}
*aFrame = this; // Capture all events so that we can perform selection
return NS_OK;
1999-07-20 08:19:47 +00:00
}
NS_IMETHODIMP
nsMenuFrame::HandleEvent(nsIPresContext* aPresContext,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
NS_ENSURE_ARG_POINTER(aEventStatus);
*aEventStatus = nsEventStatus_eConsumeDoDefault;
if (IsDisabled()) // Disabled menus process no events.
return NS_OK;
1999-07-20 09:50:48 +00:00
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
PRBool isMenuBar = PR_FALSE;
if (mMenuParent)
mMenuParent->IsMenuBar(isMenuBar);
// The menu item was selected. Bring up the menu.
// We have children.
if (mIsMenu)
ToggleMenuState();
if (isMenuBar && mIsMenu) {
if (!IsOpen()) {
// We closed up. The menu bar should always be
// deactivated when this happens.
mMenuParent->SetActive(PR_FALSE);
1999-07-23 08:36:39 +00:00
}
}
}
else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP && !IsMenu() &&
mMenuParent) {
// First, flip "checked" state if we're a checkbox menu, or
// an un-checked radio menu
if (mType == eMenuType_Checkbox ||
(mType == eMenuType_Radio && !mChecked)) {
nsAutoString checked;
if (mChecked)
checked = "false";
else
checked = "true";
mContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::checked, checked,
PR_TRUE);
/* the AttributeChanged code will update all the internal state */
}
// Execute the execute event handler.
Execute();
}
1999-07-21 07:42:16 +00:00
else if (aEvent->message == NS_MOUSE_EXIT) {
// Kill our timer if one is active.
if (mOpenTimer) {
mOpenTimer->Cancel();
mOpenTimer = nsnull;
}
1999-07-21 07:42:16 +00:00
// Deactivate the menu.
1999-07-23 08:36:39 +00:00
PRBool isActive = PR_FALSE;
PRBool isMenuBar = PR_FALSE;
if (mMenuParent) {
mMenuParent->IsMenuBar(isMenuBar);
PRBool cancel = PR_TRUE;
1999-07-23 08:36:39 +00:00
if (isMenuBar) {
mMenuParent->GetIsActive(isActive);
if (isActive) cancel = PR_FALSE;
1999-07-23 08:36:39 +00:00
}
if (cancel) {
if (IsMenu() && !isMenuBar && mMenuOpen) {
// Submenus don't get closed up.
}
else mMenuParent->SetCurrentMenuItem(nsnull);
}
1999-07-23 08:36:39 +00:00
}
1999-07-21 07:42:16 +00:00
}
1999-07-25 01:14:43 +00:00
else if (aEvent->message == NS_MOUSE_MOVE && mMenuParent) {
if (gEatMouseMove) {
gEatMouseMove = PR_FALSE;
return NS_OK;
}
// we checked for mMenuParent right above
PRBool isMenuBar = PR_FALSE;
1999-07-25 01:14:43 +00:00
mMenuParent->IsMenuBar(isMenuBar);
1999-08-02 07:26:24 +00:00
// Let the menu parent know we're the new item.
mMenuParent->SetCurrentMenuItem(this);
// If we're a menu (and not a menu item),
// kick off the timer.
1999-07-25 01:14:43 +00:00
if (!isMenuBar && IsMenu() && !mMenuOpen && !mOpenTimer) {
// We're a menu, we're built, we're closed, and no timer has been kicked off.
1999-08-02 07:26:24 +00:00
NS_NewTimer(getter_AddRefs(mOpenTimer));
mOpenTimer->Init(this, 250); // 250 ms delay
1999-07-25 01:14:43 +00:00
}
1999-07-21 07:42:16 +00:00
}
return NS_OK;
}
1999-09-21 01:03:00 +00:00
NS_IMETHODIMP
nsMenuFrame::ToggleMenuState()
1999-07-21 07:42:16 +00:00
{
if (mMenuOpen) {
1999-07-21 07:42:16 +00:00
OpenMenu(PR_FALSE);
}
else {
OpenMenu(PR_TRUE);
}
1999-09-21 01:03:00 +00:00
return NS_OK;
1999-07-21 07:42:16 +00:00
}
1999-09-21 01:03:00 +00:00
NS_IMETHODIMP
1999-07-21 07:42:16 +00:00
nsMenuFrame::SelectMenu(PRBool aActivateFlag)
{
if (aActivateFlag) {
// Highlight the menu.
mContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
}
else {
1999-07-21 07:42:16 +00:00
// Unhighlight the menu.
mContent->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
}
1999-09-21 01:03:00 +00:00
return NS_OK;
1999-07-21 07:42:16 +00:00
}
PRBool nsMenuFrame::IsGenerated()
1999-07-21 07:42:16 +00:00
{
nsCOMPtr<nsIContent> child;
GetMenuChildrenElement(getter_AddRefs(child));
// Generate the menu if it hasn't been generated already. This
// takes it from display: none to display: block and gives us
// a menu forevermore.
if (child) {
nsString genVal;
1999-09-10 08:47:12 +00:00
child->GetAttribute(kNameSpaceID_None, nsXULAtoms::menugenerated, genVal);
if (genVal == "")
return PR_FALSE;
}
return PR_TRUE;
}
1999-09-21 01:03:00 +00:00
NS_IMETHODIMP
nsMenuFrame::MarkAsGenerated()
{
1999-07-21 07:42:16 +00:00
nsCOMPtr<nsIContent> child;
GetMenuChildrenElement(getter_AddRefs(child));
// Generate the menu if it hasn't been generated already. This
// takes it from display: none to display: block and gives us
// a menu forevermore.
if (child) {
nsAutoString genVal;
1999-09-10 08:47:12 +00:00
child->GetAttribute(kNameSpaceID_None, nsXULAtoms::menugenerated, genVal);
if (genVal == "")
1999-09-10 08:47:12 +00:00
child->SetAttribute(kNameSpaceID_None, nsXULAtoms::menugenerated, "true", PR_TRUE);
}
1999-09-21 01:03:00 +00:00
return NS_OK;
}
1999-09-21 01:03:00 +00:00
NS_IMETHODIMP
nsMenuFrame::ActivateMenu(PRBool aActivateFlag)
{
// Activate the menu without opening it.
nsCOMPtr<nsIContent> child;
GetMenuChildrenElement(getter_AddRefs(child));
// We've got some children for real.
if (child) {
if (aActivateFlag)
child->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
else child->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
}
1999-09-21 01:03:00 +00:00
return NS_OK;
}
NS_IMETHODIMP
nsMenuFrame::AttributeChanged(nsIPresContext* aPresContext,
nsIContent* aChild,
PRInt32 aNameSpaceID,
nsIAtom* aAttribute,
PRInt32 aHint)
{
nsAutoString value;
if (aAttribute == nsXULAtoms::open) {
aChild->GetAttribute(kNameSpaceID_None, aAttribute, value);
if (value == "true")
OpenMenuInternal(PR_TRUE);
else
OpenMenuInternal(PR_FALSE);
} else if (aAttribute == nsHTMLAtoms::checked) {
if (mType != eMenuType_Normal)
UpdateMenuSpecialState();
} else if (aAttribute == nsHTMLAtoms::type) {
UpdateMenuType();
}
if (mHasAnonymousContent) {
if (aAttribute == nsXULAtoms::accesskey ||
aAttribute == nsHTMLAtoms::value) {
/* update accesskey or value on menu-left */
aChild->GetAttribute(kNameSpaceID_None, aAttribute, value);
mMenuText->SetAttribute(kNameSpaceID_None, aAttribute, value, PR_TRUE);
} else if (aAttribute == nsXULAtoms::acceltext) {
/* update content in accel-text */
aChild->GetAttribute(kNameSpaceID_None, aAttribute, value);
mAccelText->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value,
PR_TRUE);
}
/* we need to reflow, if these change */
if (aAttribute == nsHTMLAtoms::value ||
aAttribute == nsXULAtoms::acceltext ||
aAttribute == nsHTMLAtoms::type ||
aAttribute == nsHTMLAtoms::checked) {
nsCOMPtr<nsIPresShell> shell;
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIReflowCommand> reflowCmd;
rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), this,
nsIReflowCommand::StyleChanged);
if (NS_FAILED(rv))
return rv;
shell->AppendReflowCommand(reflowCmd);
}
}
return NS_OK;
}
1999-09-21 01:03:00 +00:00
NS_IMETHODIMP
nsMenuFrame::OpenMenu(PRBool aActivateFlag)
{
nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(mContent);
if (aActivateFlag) {
// Now that the menu is opened, we should have a menupopup child built.
// Mark it as generated, which ensures a frame gets built.
MarkAsGenerated();
domElement->SetAttribute("open", "true");
}
else domElement->RemoveAttribute("open");
1999-09-21 01:03:00 +00:00
return NS_OK;
}
void
nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
{
gEatMouseMove = PR_TRUE;
if (!mIsMenu)
return;
1999-07-21 07:42:16 +00:00
if (aActivateFlag) {
// Execute the oncreate handler
if (!OnCreate())
return;
// Set the focus back to our view's widget.
if (nsMenuFrame::mDismissalListener)
nsMenuFrame::mDismissalListener->EnableListener(PR_FALSE);
// XXX Only have this here because of RDF-generated content.
MarkAsGenerated();
nsIFrame* frame = mPopupFrames.FirstChild();
nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame;
if (menuPopup) {
// Tell the menu bar we're active.
if (mMenuParent)
mMenuParent->SetActive(PR_TRUE);
// Sync up the view.
nsCOMPtr<nsIContent> menuPopupContent;
menuPopup->GetContent(getter_AddRefs(menuPopupContent));
nsAutoString popupAnchor, popupAlign;
menuPopupContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::popupanchor, popupAnchor);
menuPopupContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::popupalign, popupAlign);
PRBool onMenuBar = PR_TRUE;
if (mMenuParent)
mMenuParent->IsMenuBar(onMenuBar);
if (onMenuBar) {
if (popupAnchor == "")
popupAnchor = "bottomleft";
if (popupAlign == "")
popupAlign = "topleft";
}
else {
if (popupAnchor == "")
popupAnchor = "topright";
if (popupAlign == "")
popupAlign = "topleft";
}
menuPopup->SyncViewWithFrame(mPresContext, popupAnchor, popupAlign, this, -1, -1);
}
ActivateMenu(PR_TRUE);
nsCOMPtr<nsIMenuParent> childPopup = do_QueryInterface(frame);
UpdateDismissalListener(childPopup);
mMenuOpen = PR_TRUE;
// Set the focus back to our view's widget.
if (nsMenuFrame::mDismissalListener)
nsMenuFrame::mDismissalListener->EnableListener(PR_TRUE);
}
1999-07-21 07:42:16 +00:00
else {
1999-07-24 22:02:23 +00:00
// Close the menu.
// Execute the ondestroy handler
if (!OnDestroy())
return;
// Set the focus back to our view's widget.
if (nsMenuFrame::mDismissalListener) {
nsMenuFrame::mDismissalListener->EnableListener(PR_FALSE);
nsMenuFrame::mDismissalListener->SetCurrentMenuParent(mMenuParent);
}
1999-09-21 01:03:00 +00:00
nsIFrame* frame = mPopupFrames.FirstChild();
nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame;
// Make sure we clear out our own items.
if (menuPopup)
menuPopup->SetCurrentMenuItem(nsnull);
ActivateMenu(PR_FALSE);
1999-07-21 07:42:16 +00:00
mMenuOpen = PR_FALSE;
/*
1999-07-26 02:26:26 +00:00
nsIView* view;
GetView(&view);
if (!view) {
nsPoint offset;
GetOffsetFromView(offset, &view);
}
nsCOMPtr<nsIWidget> widget;
view->GetWidget(*getter_AddRefs(widget));
widget->SetFocus();
*/
if (nsMenuFrame::mDismissalListener)
nsMenuFrame::mDismissalListener->EnableListener(PR_TRUE);
1999-07-21 07:42:16 +00:00
}
}
void
nsMenuFrame::GetMenuChildrenElement(nsIContent** aResult)
{
PRInt32 count;
mContent->ChildCount(count);
for (PRInt32 i = 0; i < count; i++) {
nsCOMPtr<nsIContent> child;
mContent->ChildAt(i, *getter_AddRefs(child));
nsCOMPtr<nsIAtom> tag;
child->GetTag(*getter_AddRefs(tag));
if (tag && tag.get() == nsXULAtoms::menupopup) {
*aResult = child.get();
NS_ADDREF(*aResult);
return;
}
}
}
NS_IMETHODIMP
nsMenuFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
1999-07-21 02:56:23 +00:00
nsresult rv = nsBoxFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
nsIFrame* frame = mPopupFrames.FirstChild();
if (!frame || (rv != NS_OK))
return rv;
// Constrain the child's width and height to aAvailableWidth and aAvailableHeight
nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, frame,
availSize);
kidReflowState.mComputedWidth = NS_UNCONSTRAINEDSIZE;
kidReflowState.mComputedHeight = NS_UNCONSTRAINEDSIZE;
// Reflow child
nscoord w = aDesiredSize.width;
nscoord h = aDesiredSize.height;
if (kidReflowState.reason == eReflowReason_Incremental)
kidReflowState.reason = eReflowReason_Resize;
nsRect rect;
frame->GetRect(rect);
rv = ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState,
rect.x, rect.y, NS_FRAME_NO_MOVE_VIEW, aStatus);
// Set the child's width and height to its desired size
// Note: don't position or size the view now, we'll do that in the
// DidReflow() function
frame->SizeTo(aPresContext, aDesiredSize.width, aDesiredSize.height);
frame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
// Don't let it affect our size.
aDesiredSize.width = w;
aDesiredSize.height = h;
return rv;
}
NS_IMETHODIMP
nsMenuFrame::DidReflow(nsIPresContext* aPresContext,
nsDidReflowStatus aStatus)
{
nsresult rv;
rv = nsBoxFrame::DidReflow(aPresContext, aStatus);
// Sync up the view.
nsIFrame* frame = mPopupFrames.FirstChild();
nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame;
if (mMenuOpen && menuPopup) {
nsCOMPtr<nsIContent> menuPopupContent;
menuPopup->GetContent(getter_AddRefs(menuPopupContent));
nsAutoString popupAnchor, popupAlign;
menuPopupContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::popupanchor, popupAnchor);
menuPopupContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::popupalign, popupAlign);
PRBool onMenuBar = PR_TRUE;
if (mMenuParent)
mMenuParent->IsMenuBar(onMenuBar);
if (onMenuBar) {
if (popupAnchor == "")
popupAnchor = "bottomleft";
if (popupAlign == "")
popupAlign = "topleft";
}
else {
if (popupAnchor == "")
popupAnchor = "topright";
if (popupAlign == "")
popupAlign = "topleft";
}
menuPopup->SyncViewWithFrame(aPresContext, popupAnchor, popupAlign, this, -1, -1);
}
return rv;
}
// Overridden Box method.
NS_IMETHODIMP
nsMenuFrame::Dirty(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame*& incrementalChild)
{
incrementalChild = nsnull;
nsresult rv = NS_OK;
// Dirty any children that need it.
nsIFrame* frame;
aReflowState.reflowCommand->GetNext(frame, PR_FALSE);
if (frame == nsnull) {
incrementalChild = this;
return rv;
}
// Now call our original box frame method
rv = nsBoxFrame::Dirty(aPresContext, aReflowState, incrementalChild);
if (rv != NS_OK || incrementalChild)
return rv;
nsIFrame* popup = mPopupFrames.FirstChild();
if (popup && (frame == popup)) {
// In order for the child box to know what it needs to reflow, we need
// to call its Dirty method...
nsIBox* ibox;
if (NS_SUCCEEDED(popup->QueryInterface(nsIBox::GetIID(), (void**)&ibox)) && ibox)
ibox->Dirty(aPresContext, aReflowState, incrementalChild);
else
incrementalChild = frame;
}
return rv;
}
1999-09-21 01:03:00 +00:00
NS_IMETHODIMP
nsMenuFrame::ShortcutNavigation(PRUint32 aLetter, PRBool& aHandledFlag)
{
nsIFrame* frame = mPopupFrames.FirstChild();
if (frame) {
nsMenuPopupFrame* popup = (nsMenuPopupFrame*)frame;
popup->ShortcutNavigation(aLetter, aHandledFlag);
}
1999-09-21 01:03:00 +00:00
return NS_OK;
}
1999-09-21 01:03:00 +00:00
NS_IMETHODIMP
nsMenuFrame::KeyboardNavigation(PRUint32 aDirection, PRBool& aHandledFlag)
{
nsIFrame* frame = mPopupFrames.FirstChild();
if (frame) {
nsMenuPopupFrame* popup = (nsMenuPopupFrame*)frame;
popup->KeyboardNavigation(aDirection, aHandledFlag);
}
1999-09-21 01:03:00 +00:00
return NS_OK;
}
1999-09-21 01:03:00 +00:00
NS_IMETHODIMP
1999-07-23 08:36:39 +00:00
nsMenuFrame::Escape(PRBool& aHandledFlag)
{
1999-07-23 08:36:39 +00:00
nsIFrame* frame = mPopupFrames.FirstChild();
if (frame) {
nsMenuPopupFrame* popup = (nsMenuPopupFrame*)frame;
popup->Escape(aHandledFlag);
}
1999-09-21 01:03:00 +00:00
return NS_OK;
}
1999-09-21 01:03:00 +00:00
NS_IMETHODIMP
1999-07-24 22:02:23 +00:00
nsMenuFrame::Enter()
{
if (!mMenuOpen) {
// The enter key press applies to us.
if (!IsMenu() && mMenuParent) {
// Execute our event handler
Execute();
1999-07-24 22:02:23 +00:00
}
else {
1999-07-24 22:02:23 +00:00
OpenMenu(PR_TRUE);
SelectFirstItem();
}
1999-09-21 01:03:00 +00:00
return NS_OK;
1999-07-24 22:02:23 +00:00
}
nsIFrame* frame = mPopupFrames.FirstChild();
if (frame) {
nsMenuPopupFrame* popup = (nsMenuPopupFrame*)frame;
popup->Enter();
}
1999-09-21 01:03:00 +00:00
return NS_OK;
1999-07-24 22:02:23 +00:00
}
1999-09-21 01:03:00 +00:00
NS_IMETHODIMP
nsMenuFrame::SelectFirstItem()
{
nsIFrame* frame = mPopupFrames.FirstChild();
if (frame) {
nsMenuPopupFrame* popup = (nsMenuPopupFrame*)frame;
1999-09-21 01:03:00 +00:00
nsIMenuFrame* result;
popup->GetNextMenuItem(nsnull, &result);
popup->SetCurrentMenuItem(result);
}
1999-09-21 01:03:00 +00:00
return NS_OK;
}
PRBool
nsMenuFrame::IsMenu()
{
nsCOMPtr<nsIAtom> tag;
mContent->GetTag(*getter_AddRefs(tag));
if (tag.get() == nsXULAtoms::menu)
return PR_TRUE;
return PR_FALSE;
1999-07-25 01:14:43 +00:00
}
void
nsMenuFrame::Notify(nsITimer* aTimer)
{
// Our timer has fired.
if (aTimer == mOpenTimer.get()) {
if (!mMenuOpen && mMenuParent) {
nsAutoString active = "";
mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, active);
if (active == "true") {
// We're still the active menu.
OpenMenu(PR_TRUE);
}
1999-07-25 01:14:43 +00:00
}
mOpenTimer->Cancel();
mOpenTimer = nsnull;
1999-07-25 01:14:43 +00:00
}
1999-07-25 01:14:43 +00:00
mOpenTimer = nsnull;
}
PRBool
nsMenuFrame::IsDisabled()
{
nsAutoString disabled;
mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::disabled, disabled);
if (disabled == "true")
return PR_TRUE;
return PR_FALSE;
}
void
nsMenuFrame::UpdateMenuType()
{
nsAutoString value;
mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, value);
if (value == "checkbox") {
mType = eMenuType_Checkbox;
} else if (value == "radio") {
mType = eMenuType_Radio;
} else {
if (mType != eMenuType_Normal)
mContent->UnsetAttribute(kNameSpaceID_None, nsHTMLAtoms::checked,
PR_TRUE);
mType = eMenuType_Normal;
}
UpdateMenuSpecialState();
}
/* update checked-ness for type="checkbox" and type="radio" */
void
nsMenuFrame::UpdateMenuSpecialState() {
nsAutoString value;
PRBool newChecked;
mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::checked,
value);
newChecked = (value == "true");
if (newChecked == mChecked) {
/* checked state didn't change */
if (mType != eMenuType_Radio)
return; // only Radio possibly cares about other kinds of change
mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::name, value);
if (value == mGroupName)
return; // no interesting change
mGroupName = value;
} else {
mChecked = newChecked;
if (mType != eMenuType_Radio || !mChecked)
/*
* Unchecking something requires no further changes, and only
* menuRadio has to do additional work when checked.
*/
return;
}
/*
* If we get this far, we're type=radio, and:
* - our name= changed, or
* - we went from checked="false" to checked="true"
*/
if (!mChecked)
/*
* If we're not checked, then it must have been a name change, and a name
* change on an unchecked item doesn't require any magic.
*/
return;
/*
* Behavioural note:
* If we're checked and renamed _into_ an existing radio group, we are
* made the new checked item, and we unselect the previous one.
*
* The only other reasonable behaviour would be to check for another selected
* item in that group. If found, unselect ourselves, otherwise we're the
* selected item. That, however, would be a lot more work, and I don't think
* it's better at all.
*/
/* walk siblings, looking for the other checked item with the same name */
nsIFrame *parent, *sib;
nsIMenuFrame *sibMenu;
nsMenuType sibType;
nsAutoString sibGroup;
PRBool sibChecked;
nsresult rv = GetParent(&parent);
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't get parent of radio menu frame\n");
if (NS_FAILED(rv)) return;
rv = parent->FirstChild(NULL, &sib);
NS_ASSERTION((NS_SUCCEEDED(rv) && sib),
"couldn't get first sib of radio menu frame\n");
if (NS_FAILED(rv) || !sib) return;
do {
if (NS_FAILED(sib->QueryInterface(NS_GET_IID(nsIMenuFrame),
(void **)&sibMenu)))
continue;
if (sibMenu != (nsIMenuFrame *)this && // correct way to check?
(sibMenu->GetMenuType(sibType), sibType == eMenuType_Radio) &&
(sibMenu->MenuIsChecked(sibChecked), sibChecked) &&
(sibMenu->GetRadioGroupName(sibGroup), sibGroup == mGroupName)) {
nsCOMPtr<nsIContent> content;
if (NS_FAILED(sib->GetContent(getter_AddRefs(content))))
continue; // break?
/* uncheck the old item */
content->UnsetAttribute(kNameSpaceID_None, nsHTMLAtoms::checked,
PR_TRUE);
/* XXX in DEBUG, check to make sure that there aren't two checked items */
return;
}
} while(NS_SUCCEEDED(sib->GetNextSibling(&sib)) && sib);
}
NS_IMETHODIMP
nsMenuFrame::CreateAnonymousContent(nsISupportsArray& aAnonymousChildren)
{
// Create anonymous children only if the menu has no children or
// only has a menuchildren as its child.
nsCOMPtr<nsIDOMNode> dummyResult;
PRInt32 childCount;
mContent->ChildCount(childCount);
mHasAnonymousContent = PR_TRUE;
for (PRInt32 i = 0; i < childCount; i++) {
// XXX Should optimize this to look for a display type of none.
// Not sure how to do this. For now screen out some known tags.
nsCOMPtr<nsIContent> childContent;
mContent->ChildAt(i, *getter_AddRefs(childContent));
nsCOMPtr<nsIAtom> tag;
childContent->GetTag(*getter_AddRefs(tag));
if (tag.get() != nsXULAtoms::menupopup &&
tag.get() != nsXULAtoms::templateAtom &&
tag.get() != nsXULAtoms::observes) {
mHasAnonymousContent = PR_FALSE;
break;
}
}
if (!mHasAnonymousContent)
return NS_OK;
nsCOMPtr<nsIDocument> idocument;
mContent->GetDocument(*getter_AddRefs(idocument));
nsCOMPtr<nsIDOMNSDocument> nsDocument(do_QueryInterface(idocument));
nsCOMPtr<nsIDOMDocument> document(do_QueryInterface(idocument));
nsAutoString xulNamespace("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
nsAutoString htmlNamespace("http://www.w3.org/TR/REC-html40");
nsCOMPtr<nsIAtom> classAtom = dont_AddRef(NS_NewAtom("class"));
nsCOMPtr<nsIDOMElement> node;
nsCOMPtr<nsIContent> content;
PRBool onMenuBar = PR_FALSE;
if (mMenuParent)
mMenuParent->IsMenuBar(onMenuBar);
/* Create .menu-left (.menubar-left) titledbutton for icon. */
nsDocument->CreateElementWithNameSpace("titledbutton", xulNamespace,
getter_AddRefs(node));
content = do_QueryInterface(node);
content->SetAttribute(kNameSpaceID_None, classAtom,
onMenuBar ? "menubar-left" : "menu-left" , PR_FALSE);
aAnonymousChildren.AppendElement(content);
/*
* Create the .menu-text titledbutton, and propagate crop, accesskey and
* value attributes. If we're a menubar, make the class menubar-text
* instead.
*/
nsDocument->CreateElementWithNameSpace("titledbutton", xulNamespace,
getter_AddRefs(node));
content = do_QueryInterface(node);
content->SetAttribute(kNameSpaceID_None, classAtom,
onMenuBar ? "menubar-text" : "menu-text", PR_FALSE);
nsAutoString accessKey, value, crop;
mMenuText = content;
mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value);
content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, value, PR_FALSE);
mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::accesskey, accessKey);
content->SetAttribute(kNameSpaceID_None, nsXULAtoms::accesskey, accessKey,
PR_FALSE);
mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::crop, crop);
1999-09-17 21:29:50 +00:00
if (crop == "")
crop = "right";
content->SetAttribute(kNameSpaceID_None, nsXULAtoms::crop, crop, PR_FALSE);
// XXX Causes menu items to disappear.
// content->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, "1", PR_FALSE);
// append now, after we've set all the attributes
aAnonymousChildren.AppendElement(content);
// Do the type="checkbox" magic
UpdateMenuType();
// Create a spring that serves as padding between the text and the
// accelerator.
if (!onMenuBar) {
nsDocument->CreateElementWithNameSpace("spring", xulNamespace, getter_AddRefs(node));
content = do_QueryInterface(node);
content->SetAttribute(kNameSpaceID_None, classAtom, "menu-spring",
PR_FALSE);
1999-12-05 20:17:10 +00:00
content->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, "100000",
PR_FALSE);
aAnonymousChildren.AppendElement(content);
// Build the accelerator out of the corresponding key node.
nsAutoString accelString;
BuildAcceleratorText(accelString);
if (accelString != "") {
// Create the accelerator (a titledbutton)
nsDocument->CreateElementWithNameSpace("titledbutton", xulNamespace,
getter_AddRefs(node));
content = do_QueryInterface(node);
mAccelText = content;
content->SetAttribute(kNameSpaceID_None, classAtom, "menu-accel",
PR_FALSE);
content->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, accelString,
PR_FALSE);
aAnonymousChildren.AppendElement(content);
}
// Create the "menu-right" object. It's a titledbutton.
// XXX Maybe we should make one for a .menubar-right class so that the option exists
nsDocument->CreateElementWithNameSpace("titledbutton", xulNamespace, getter_AddRefs(node));
content = do_QueryInterface(node);
content->SetAttribute(kNameSpaceID_None, classAtom, "menu-right", PR_FALSE);
aAnonymousChildren.AppendElement(content);
}
return NS_OK;
}
void
nsMenuFrame::SplitOnShortcut(nsString& aBeforeString, nsString& aAccessString, nsString& aAfterString)
{
nsString value;
nsString accessKey;
aBeforeString = value;
aAccessString = "";
aAfterString = "";
if (accessKey == "") // Nothing to do.
return;
// Find the index of the first occurrence of the accessKey
PRInt32 indx = value.Find(accessKey, PR_TRUE);
if (indx == -1) // Wasn't in there. Just return.
return;
// It was in the value string. Split based on the indx.
value.Left(aBeforeString, indx);
value.Mid(aAccessString, indx, 1);
value.Right(aAfterString, value.Length()-indx-1);
}
void
nsMenuFrame::BuildAcceleratorText(nsString& aAccelString)
{
nsString accelText;
mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::acceltext, accelText);
if (accelText != "") {
// Just use this.
aAccelString = accelText;
return;
}
// See if we have a key node and use that instead.
nsString keyValue;
mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::key, keyValue);
nsCOMPtr<nsIDocument> document;
mContent->GetDocument(*getter_AddRefs(document));
// Turn the document into a XUL document so we can use getElementById
nsCOMPtr<nsIDOMXULDocument> xulDocument = do_QueryInterface(document);
if (!xulDocument)
return;
nsCOMPtr<nsIDOMElement> keyElement;
xulDocument->GetElementById(keyValue, getter_AddRefs(keyElement));
if (!keyElement)
return;
nsAutoString keyAtom("key");
nsAutoString shiftAtom("shift");
nsAutoString altAtom("alt");
nsAutoString commandAtom("command");
nsAutoString controlAtom("control");
nsString shiftValue;
nsString altValue;
nsString commandValue;
nsString controlValue;
nsString keyChar = " ";
keyElement->GetAttribute(keyAtom, keyChar);
keyElement->GetAttribute(shiftAtom, shiftValue);
keyElement->GetAttribute(altAtom, altValue);
keyElement->GetAttribute(commandAtom, commandValue);
keyElement->GetAttribute(controlAtom, controlValue);
nsAutoString xulkey;
keyElement->GetAttribute(nsAutoString("xulkey"), xulkey);
if (xulkey == "true") {
// Set the default for the xul key modifier
#ifdef XP_MAC
commandValue = "true";
#elif XP_PC
controlValue = "true";
#else
altValue = "true";
#endif
}
PRBool prependPlus = PR_FALSE;
if(commandValue != "" && commandValue != "false") {
prependPlus = PR_TRUE;
aAccelString += "Ctrl"; // Hmmm. Kinda defeats the point of having an abstraction.
}
if(controlValue != "" && controlValue != "false") {
prependPlus = PR_TRUE;
aAccelString += "Ctrl";
}
if(shiftValue != "" && shiftValue != "false") {
if (prependPlus)
aAccelString += "+";
prependPlus = PR_TRUE;
aAccelString += "Shift";
}
if (altValue != "" && altValue != "false") {
if (prependPlus)
aAccelString += "+";
prependPlus = PR_TRUE;
aAccelString += "Alt";
}
keyChar.ToUpperCase();
if (keyChar != "") {
if (prependPlus)
aAccelString += "+";
prependPlus = PR_TRUE;
aAccelString += keyChar;
}
}
void
nsMenuFrame::Execute()
{
1999-10-01 04:43:45 +00:00
// Temporarily disable rollup events on this menu. This is
// to suppress this menu getting removed in the case where
// the oncommand handler opens a dialog, etc.
if ( nsMenuFrame::mDismissalListener ) {
nsMenuFrame::mDismissalListener->EnableListener(PR_FALSE);
}
1999-08-13 23:49:53 +00:00
// Get our own content node and hold on to it to keep it from going away.
nsCOMPtr<nsIContent> content = dont_QueryInterface(mContent);
1999-10-01 04:43:45 +00:00
// First hide all of the open menus.
if (mMenuParent)
mMenuParent->HideChain();
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_MENU_ACTION;
event.isShift = PR_FALSE;
event.isControl = PR_FALSE;
event.isAlt = PR_FALSE;
event.isMeta = PR_FALSE;
event.clickCount = 0;
event.widget = nsnull;
mContent->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
1999-08-13 23:49:53 +00:00
// XXX HACK. Just gracefully exit if the node has been removed, e.g., window.close()
// was executed.
nsCOMPtr<nsIDocument> doc;
content->GetDocument(*getter_AddRefs(doc));
// Now properly close them all up.
1999-08-13 23:49:53 +00:00
if (doc && mMenuParent)
mMenuParent->DismissChain();
1999-10-01 04:43:45 +00:00
// Re-enable rollup events on this menu.
if ( nsMenuFrame::mDismissalListener ) {
nsMenuFrame::mDismissalListener->EnableListener(PR_TRUE);
}
}
PRBool
nsMenuFrame::OnCreate()
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_MENU_CREATE;
event.isShift = PR_FALSE;
event.isControl = PR_FALSE;
event.isAlt = PR_FALSE;
event.isMeta = PR_FALSE;
event.clickCount = 0;
event.widget = nsnull;
nsCOMPtr<nsIContent> child;
GetMenuChildrenElement(getter_AddRefs(child));
nsresult rv;
if (child)
rv = child->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
else rv = mContent->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault )
return PR_FALSE;
return PR_TRUE;
}
PRBool
nsMenuFrame::OnDestroy()
{
nsEventStatus status = nsEventStatus_eIgnore;
nsMouseEvent event;
event.eventStructType = NS_EVENT;
event.message = NS_MENU_DESTROY;
event.isShift = PR_FALSE;
event.isControl = PR_FALSE;
event.isAlt = PR_FALSE;
event.isMeta = PR_FALSE;
event.clickCount = 0;
event.widget = nsnull;
nsCOMPtr<nsIContent> child;
GetMenuChildrenElement(getter_AddRefs(child));
nsresult rv;
if (child)
rv = child->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
else rv = mContent->HandleDOMEvent(mPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
if ( NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault )
return PR_FALSE;
return PR_TRUE;
}
NS_IMETHODIMP
nsMenuFrame::RemoveFrame(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aOldFrame)
{
1999-08-19 03:51:25 +00:00
nsresult rv;
if (mPopupFrames.ContainsFrame(aOldFrame)) {
// Go ahead and remove this frame.
mPopupFrames.DestroyFrame(aPresContext, aOldFrame);
1999-08-19 03:51:25 +00:00
rv = GenerateDirtyReflowCommand(aPresContext, aPresShell);
} else {
rv = nsBoxFrame::RemoveFrame(aPresContext, aPresShell, aListName, aOldFrame);
}
1999-08-19 03:51:25 +00:00
return rv;
}
NS_IMETHODIMP
nsMenuFrame::InsertFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
{
nsCOMPtr<nsIContent> frameChild;
aFrameList->GetContent(getter_AddRefs(frameChild));
nsCOMPtr<nsIAtom> tag;
1999-08-19 03:51:25 +00:00
nsresult rv;
frameChild->GetTag(*getter_AddRefs(tag));
if (tag && tag.get() == nsXULAtoms::menupopup) {
mPopupFrames.InsertFrames(nsnull, nsnull, aFrameList);
1999-08-19 03:51:25 +00:00
rv = GenerateDirtyReflowCommand(aPresContext, aPresShell);
} else {
rv = nsBoxFrame::InsertFrames(aPresContext, aPresShell, aListName, aPrevFrame, aFrameList);
}
1999-08-19 03:51:25 +00:00
return rv;
}
NS_IMETHODIMP
nsMenuFrame::AppendFrames(nsIPresContext* aPresContext,
nsIPresShell& aPresShell,
nsIAtom* aListName,
nsIFrame* aFrameList)
{
if (!aFrameList)
return NS_OK;
nsCOMPtr<nsIContent> frameChild;
aFrameList->GetContent(getter_AddRefs(frameChild));
nsCOMPtr<nsIAtom> tag;
1999-08-19 03:51:25 +00:00
nsresult rv;
frameChild->GetTag(*getter_AddRefs(tag));
if (tag && tag.get() == nsXULAtoms::menupopup) {
mPopupFrames.AppendFrames(nsnull, aFrameList);
1999-08-19 03:51:25 +00:00
rv = GenerateDirtyReflowCommand(aPresContext, aPresShell);
} else {
rv = nsBoxFrame::AppendFrames(aPresContext, aPresShell, aListName, aFrameList);
}
1999-08-19 03:51:25 +00:00
return rv;
}
1999-09-21 01:03:00 +00:00
void
nsMenuFrame::UpdateDismissalListener(nsIMenuParent* aMenuParent)
{
if (!nsMenuFrame::mDismissalListener) {
if (!aMenuParent)
return;
1999-09-21 01:03:00 +00:00
// Create the listener and attach it to the outermost window.
aMenuParent->CreateDismissalListener();
}
// Make sure the menu dismissal listener knows what the current
// innermost menu popup frame is.
nsMenuFrame::mDismissalListener->SetCurrentMenuParent(aMenuParent);
1999-09-21 01:03:00 +00:00
}