Bumping manifests a=b2g-bump
[gecko.git] / layout / xul / nsListItemFrame.cpp
blob54a16e4a1e0b7521dd600f9d54f592af44af2972
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsListItemFrame.h"
8 #include <algorithm>
10 #include "nsCOMPtr.h"
11 #include "nsNameSpaceManager.h"
12 #include "nsGkAtoms.h"
13 #include "nsDisplayList.h"
14 #include "nsBoxLayout.h"
15 #include "nsIContent.h"
17 nsListItemFrame::nsListItemFrame(nsIPresShell* aPresShell,
18 nsStyleContext* aContext,
19 bool aIsRoot,
20 nsBoxLayout* aLayoutManager)
21 : nsGridRowLeafFrame(aPresShell, aContext, aIsRoot, aLayoutManager)
25 nsListItemFrame::~nsListItemFrame()
29 nsSize
30 nsListItemFrame::GetPrefSize(nsBoxLayoutState& aState)
32 nsSize size = nsBoxFrame::GetPrefSize(aState);
33 DISPLAY_PREF_SIZE(this, size);
35 // guarantee that our preferred height doesn't exceed the standard
36 // listbox row height
37 size.height = std::max(mRect.height, size.height);
38 return size;
41 void
42 nsListItemFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
43 const nsRect& aDirtyRect,
44 const nsDisplayListSet& aLists)
46 if (aBuilder->IsForEventDelivery()) {
47 if (!mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::allowevents,
48 nsGkAtoms::_true, eCaseMatters))
49 return;
52 nsGridRowLeafFrame::BuildDisplayListForChildren(aBuilder, aDirtyRect, aLists);
55 // Creation Routine ///////////////////////////////////////////////////////////////////////
57 already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout();
59 nsIFrame*
60 NS_NewListItemFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
62 nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowLeafLayout();
63 if (!layout) {
64 return nullptr;
67 return new (aPresShell) nsListItemFrame(aPresShell, aContext, false, layout);
70 NS_IMPL_FRAMEARENA_HELPERS(nsListItemFrame)