layout/xul/nsListItemFrame.cpp

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:dcd1fce1d056
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/. */
5
6 #include "nsListItemFrame.h"
7
8 #include "nsCOMPtr.h"
9 #include "nsNameSpaceManager.h"
10 #include "nsGkAtoms.h"
11 #include "nsDisplayList.h"
12 #include "nsBoxLayout.h"
13 #include <algorithm>
14
15 nsListItemFrame::nsListItemFrame(nsIPresShell* aPresShell,
16 nsStyleContext* aContext,
17 bool aIsRoot,
18 nsBoxLayout* aLayoutManager)
19 : nsGridRowLeafFrame(aPresShell, aContext, aIsRoot, aLayoutManager)
20 {
21 }
22
23 nsListItemFrame::~nsListItemFrame()
24 {
25 }
26
27 nsSize
28 nsListItemFrame::GetPrefSize(nsBoxLayoutState& aState)
29 {
30 nsSize size = nsBoxFrame::GetPrefSize(aState);
31 DISPLAY_PREF_SIZE(this, size);
32
33 // guarantee that our preferred height doesn't exceed the standard
34 // listbox row height
35 size.height = std::max(mRect.height, size.height);
36 return size;
37 }
38
39 void
40 nsListItemFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
41 const nsRect& aDirtyRect,
42 const nsDisplayListSet& aLists)
43 {
44 if (aBuilder->IsForEventDelivery()) {
45 if (!mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::allowevents,
46 nsGkAtoms::_true, eCaseMatters))
47 return;
48 }
49
50 nsGridRowLeafFrame::BuildDisplayListForChildren(aBuilder, aDirtyRect, aLists);
51 }
52
53 // Creation Routine ///////////////////////////////////////////////////////////////////////
54
55 already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout();
56
57 nsIFrame*
58 NS_NewListItemFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
59 {
60 nsCOMPtr<nsBoxLayout> layout = NS_NewGridRowLeafLayout();
61 if (!layout) {
62 return nullptr;
63 }
64
65 return new (aPresShell) nsListItemFrame(aPresShell, aContext, false, layout);
66 }
67
68 NS_IMPL_FRAMEARENA_HELPERS(nsListItemFrame)

mercurial