2002-01-12 01:18:10 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2002-01-12 01:18:10 +00:00
|
|
|
|
|
|
|
#include "nsListItemFrame.h"
|
|
|
|
|
2014-08-06 05:19:27 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2002-03-29 02:46:01 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2014-02-27 23:04:46 +00:00
|
|
|
#include "nsNameSpaceManager.h"
|
2006-12-26 17:47:52 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2011-07-11 14:05:10 +00:00
|
|
|
#include "nsBoxLayout.h"
|
2014-08-06 05:19:27 +00:00
|
|
|
#include "nsIContent.h"
|
2002-03-29 02:46:01 +00:00
|
|
|
|
2015-01-06 09:27:56 +00:00
|
|
|
nsListItemFrame::nsListItemFrame(nsStyleContext* aContext,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsRoot,
|
2011-07-11 14:05:10 +00:00
|
|
|
nsBoxLayout* aLayoutManager)
|
2017-07-06 12:00:35 +00:00
|
|
|
: nsGridRowLeafFrame(aContext, aIsRoot, aLayoutManager, kClassID)
|
2002-01-12 01:18:10 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsListItemFrame::~nsListItemFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
nsSize
|
2016-04-21 04:28:31 +00:00
|
|
|
nsListItemFrame::GetXULPrefSize(nsBoxLayoutState& aState)
|
2002-01-12 01:18:10 +00:00
|
|
|
{
|
2017-07-06 12:00:35 +00:00
|
|
|
nsSize size = nsBoxFrame::GetXULPrefSize(aState);
|
2007-01-08 02:57:59 +00:00
|
|
|
DISPLAY_PREF_SIZE(this, size);
|
2002-01-12 01:18:10 +00:00
|
|
|
|
|
|
|
// guarantee that our preferred height doesn't exceed the standard
|
|
|
|
// listbox row height
|
2013-01-15 12:22:03 +00:00
|
|
|
size.height = std::max(mRect.height, size.height);
|
2007-01-08 02:57:59 +00:00
|
|
|
return size;
|
2002-01-12 01:18:10 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
nsListItemFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists)
|
2002-03-29 02:46:01 +00:00
|
|
|
{
|
2006-01-26 02:29:17 +00:00
|
|
|
if (aBuilder->IsForEventDelivery()) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (!mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::allowevents,
|
|
|
|
nsGkAtoms::_true, eCaseMatters))
|
2013-02-14 11:12:27 +00:00
|
|
|
return;
|
2002-03-29 02:46:01 +00:00
|
|
|
}
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2017-08-07 02:23:35 +00:00
|
|
|
nsGridRowLeafFrame::BuildDisplayListForChildren(aBuilder, aLists);
|
2002-03-29 02:46:01 +00:00
|
|
|
}
|
|
|
|
|
2002-01-12 01:18:10 +00:00
|
|
|
// Creation Routine ///////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-07-11 14:05:10 +00:00
|
|
|
already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout();
|
2009-01-19 18:31:33 +00:00
|
|
|
|
2005-10-26 21:46:39 +00:00
|
|
|
nsIFrame*
|
2009-01-19 18:31:33 +00:00
|
|
|
NS_NewListItemFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2002-01-12 01:18:10 +00:00
|
|
|
{
|
2011-07-11 14:05:10 +00:00
|
|
|
nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowLeafLayout();
|
2009-01-19 18:31:33 +00:00
|
|
|
if (!layout) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2009-01-19 18:31:33 +00:00
|
|
|
}
|
2017-07-06 12:00:35 +00:00
|
|
|
|
2015-01-06 09:27:56 +00:00
|
|
|
return new (aPresShell) nsListItemFrame(aContext, false, layout);
|
2009-09-12 16:49:24 +00:00
|
|
|
}
|
2002-01-12 01:18:10 +00:00
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsListItemFrame)
|