michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsListItemFrame.h" michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsNameSpaceManager.h" michael@0: #include "nsGkAtoms.h" michael@0: #include "nsDisplayList.h" michael@0: #include "nsBoxLayout.h" michael@0: #include michael@0: michael@0: nsListItemFrame::nsListItemFrame(nsIPresShell* aPresShell, michael@0: nsStyleContext* aContext, michael@0: bool aIsRoot, michael@0: nsBoxLayout* aLayoutManager) michael@0: : nsGridRowLeafFrame(aPresShell, aContext, aIsRoot, aLayoutManager) michael@0: { michael@0: } michael@0: michael@0: nsListItemFrame::~nsListItemFrame() michael@0: { michael@0: } michael@0: michael@0: nsSize michael@0: nsListItemFrame::GetPrefSize(nsBoxLayoutState& aState) michael@0: { michael@0: nsSize size = nsBoxFrame::GetPrefSize(aState); michael@0: DISPLAY_PREF_SIZE(this, size); michael@0: michael@0: // guarantee that our preferred height doesn't exceed the standard michael@0: // listbox row height michael@0: size.height = std::max(mRect.height, size.height); michael@0: return size; michael@0: } michael@0: michael@0: void michael@0: nsListItemFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder, michael@0: const nsRect& aDirtyRect, michael@0: const nsDisplayListSet& aLists) michael@0: { michael@0: if (aBuilder->IsForEventDelivery()) { michael@0: if (!mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::allowevents, michael@0: nsGkAtoms::_true, eCaseMatters)) michael@0: return; michael@0: } michael@0: michael@0: nsGridRowLeafFrame::BuildDisplayListForChildren(aBuilder, aDirtyRect, aLists); michael@0: } michael@0: michael@0: // Creation Routine /////////////////////////////////////////////////////////////////////// michael@0: michael@0: already_AddRefed NS_NewGridRowLeafLayout(); michael@0: michael@0: nsIFrame* michael@0: NS_NewListItemFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) michael@0: { michael@0: nsCOMPtr layout = NS_NewGridRowLeafLayout(); michael@0: if (!layout) { michael@0: return nullptr; michael@0: } michael@0: michael@0: return new (aPresShell) nsListItemFrame(aPresShell, aContext, false, layout); michael@0: } michael@0: michael@0: NS_IMPL_FRAMEARENA_HELPERS(nsListItemFrame)