2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-08-06 22:16:27 +04:00
|
|
|
|
|
|
|
#include "nsPopupSetFrame.h"
|
2007-10-06 17:53:05 +04:00
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsCOMPtr.h"
|
1999-08-06 22:16:27 +04:00
|
|
|
#include "nsIContent.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsBoxLayoutState.h"
|
2000-05-15 08:12:31 +04:00
|
|
|
#include "nsIScrollableFrame.h"
|
2002-08-19 22:29:29 +04:00
|
|
|
#include "nsIRootBox.h"
|
2010-02-09 19:05:19 +03:00
|
|
|
#include "nsMenuPopupFrame.h"
|
1999-08-06 22:16:27 +04:00
|
|
|
|
2005-10-27 01:46:39 +04:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewPopupSetFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-08-06 22:16:27 +04:00
|
|
|
{
|
2015-01-06 12:27:56 +03:00
|
|
|
return new (aPresShell) nsPopupSetFrame(aContext);
|
1999-08-06 22:16:27 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsPopupSetFrame)
|
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2014-05-25 02:20:40 +04:00
|
|
|
nsPopupSetFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1999-08-06 22:16:27 +04:00
|
|
|
{
|
2013-03-20 05:47:48 +04:00
|
|
|
nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
|
2002-08-19 22:29:29 +04:00
|
|
|
|
2008-12-17 03:30:31 +03:00
|
|
|
// Normally the root box is our grandparent, but in case of wrapping
|
|
|
|
// it can be our great-grandparent.
|
|
|
|
nsIRootBox *rootBox = nsIRootBox::GetRootBox(PresContext()->GetPresShell());
|
|
|
|
if (rootBox) {
|
2002-08-19 22:29:29 +04:00
|
|
|
rootBox->SetPopupSetFrame(this);
|
|
|
|
}
|
1999-08-06 22:16:27 +04:00
|
|
|
}
|
|
|
|
|
2007-10-06 17:53:05 +04:00
|
|
|
nsIAtom*
|
|
|
|
nsPopupSetFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::popupSetFrame;
|
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsPopupSetFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2006-08-30 02:20:41 +04:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
if (aListID == kPopupList) {
|
2010-02-09 19:05:19 +03:00
|
|
|
AddPopupFrameList(aFrameList);
|
2014-05-28 23:36:58 +04:00
|
|
|
return;
|
2006-08-30 02:20:41 +04:00
|
|
|
}
|
2014-05-28 23:36:58 +04:00
|
|
|
nsBoxFrame::AppendFrames(aListID, aFrameList);
|
2006-08-30 02:20:41 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsPopupSetFrame::RemoveFrame(ChildListID aListID,
|
2006-08-30 02:20:41 +04:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
if (aListID == kPopupList) {
|
2010-02-09 19:05:19 +03:00
|
|
|
RemovePopupFrame(aOldFrame);
|
2014-05-28 23:36:58 +04:00
|
|
|
return;
|
2006-08-30 02:20:41 +04:00
|
|
|
}
|
2014-05-28 23:36:58 +04:00
|
|
|
nsBoxFrame::RemoveFrame(aListID, aOldFrame);
|
2006-08-30 02:20:41 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsPopupSetFrame::InsertFrames(ChildListID aListID,
|
2006-08-30 02:20:41 +04:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2006-08-30 02:20:41 +04:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
if (aListID == kPopupList) {
|
2010-02-09 19:05:19 +03:00
|
|
|
AddPopupFrameList(aFrameList);
|
2014-05-28 23:36:58 +04:00
|
|
|
return;
|
2007-03-02 15:03:02 +03:00
|
|
|
}
|
2014-05-28 23:36:58 +04:00
|
|
|
nsBoxFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
|
2006-08-30 02:20:41 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsPopupSetFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
2006-08-30 02:20:41 +04:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
if (aListID == kPopupList) {
|
2013-11-04 20:22:20 +04:00
|
|
|
NS_ASSERTION(mPopupList.IsEmpty(),
|
|
|
|
"SetInitialChildList on non-empty child list");
|
2010-02-09 19:05:19 +03:00
|
|
|
AddPopupFrameList(aChildList);
|
2014-05-28 23:36:58 +04:00
|
|
|
return;
|
2007-03-02 15:03:02 +03:00
|
|
|
}
|
2014-05-28 23:36:58 +04:00
|
|
|
nsBoxFrame::SetInitialChildList(aListID, aChildList);
|
2006-08-30 02:20:41 +04:00
|
|
|
}
|
|
|
|
|
2013-11-04 20:22:20 +04:00
|
|
|
const nsFrameList&
|
|
|
|
nsPopupSetFrame::GetChildList(ChildListID aListID) const
|
|
|
|
{
|
|
|
|
if (kPopupList == aListID) {
|
|
|
|
return mPopupList;
|
|
|
|
}
|
|
|
|
return nsBoxFrame::GetChildList(aListID);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsPopupSetFrame::GetChildLists(nsTArray<ChildList>* aLists) const
|
|
|
|
{
|
|
|
|
nsBoxFrame::GetChildLists(aLists);
|
|
|
|
mPopupList.AppendIfNonempty(aLists, kPopupList);
|
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsPopupSetFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
1999-08-06 22:16:27 +04:00
|
|
|
{
|
2010-02-09 19:05:19 +03:00
|
|
|
mPopupList.DestroyFramesFrom(aDestructRoot);
|
2000-08-03 04:22:36 +04:00
|
|
|
|
2008-12-17 03:30:31 +03:00
|
|
|
// Normally the root box is our grandparent, but in case of wrapping
|
|
|
|
// it can be our great-grandparent.
|
|
|
|
nsIRootBox *rootBox = nsIRootBox::GetRootBox(PresContext()->GetPresShell());
|
|
|
|
if (rootBox) {
|
2012-07-30 18:20:58 +04:00
|
|
|
rootBox->SetPopupSetFrame(nullptr);
|
2002-08-19 22:29:29 +04:00
|
|
|
}
|
|
|
|
|
2009-12-24 08:21:15 +03:00
|
|
|
nsBoxFrame::DestroyFrom(aDestructRoot);
|
1999-08-06 22:16:27 +04:00
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_IMETHODIMP
|
2016-04-21 07:28:35 +03:00
|
|
|
nsPopupSetFrame::DoXULLayout(nsBoxLayoutState& aState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
|
|
|
// lay us out
|
2016-04-21 07:28:35 +03:00
|
|
|
nsresult rv = nsBoxFrame::DoXULLayout(aState);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2001-08-18 05:04:47 +04:00
|
|
|
// lay out all of our currently open popups.
|
2010-02-09 19:05:19 +03:00
|
|
|
for (nsFrameList::Enumerator e(mPopupList); !e.AtEnd(); e.Next()) {
|
|
|
|
nsMenuPopupFrame* popupChild = static_cast<nsMenuPopupFrame*>(e.get());
|
2014-01-28 20:28:45 +04:00
|
|
|
popupChild->LayoutPopup(aState, nullptr, nullptr, false);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2010-02-09 19:05:19 +03:00
|
|
|
void
|
2001-09-22 04:32:23 +04:00
|
|
|
nsPopupSetFrame::RemovePopupFrame(nsIFrame* aPopup)
|
|
|
|
{
|
2010-02-09 19:05:19 +03:00
|
|
|
NS_PRECONDITION((aPopup->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
|
|
|
|
aPopup->GetType() == nsGkAtoms::menuPopupFrame,
|
|
|
|
"removing wrong type of frame in popupset's ::popupList");
|
2001-09-22 04:32:23 +04:00
|
|
|
|
2010-02-09 19:05:19 +03:00
|
|
|
mPopupList.DestroyFrame(aPopup);
|
2001-09-22 04:32:23 +04:00
|
|
|
}
|
|
|
|
|
2010-02-09 19:05:19 +03:00
|
|
|
void
|
2009-07-28 16:53:20 +04:00
|
|
|
nsPopupSetFrame::AddPopupFrameList(nsFrameList& aPopupFrameList)
|
2007-03-02 15:03:02 +03:00
|
|
|
{
|
2010-02-09 19:05:19 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
for (nsFrameList::Enumerator e(aPopupFrameList); !e.AtEnd(); e.Next()) {
|
|
|
|
NS_ASSERTION((e.get()->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
|
|
|
|
e.get()->GetType() == nsGkAtoms::menuPopupFrame,
|
|
|
|
"adding wrong type of frame in popupset's ::popupList");
|
2007-03-02 15:03:02 +03:00
|
|
|
}
|
2010-02-09 19:05:19 +03:00
|
|
|
#endif
|
2012-07-30 18:20:58 +04:00
|
|
|
mPopupList.InsertFrames(nullptr, nullptr, aPopupFrameList);
|
2000-08-17 13:15:51 +04:00
|
|
|
}
|