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