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