layout/xul/grid/nsGridLayout2.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:55ee429e354c
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef nsGridLayout2_h___
8 #define nsGridLayout2_h___
9
10 #include "mozilla/Attributes.h"
11 #include "nsStackLayout.h"
12 #include "nsIGridPart.h"
13 #include "nsCoord.h"
14 #include "nsGrid.h"
15
16 class nsIPresContext;
17 class nsGridRowGroupLayout;
18 class nsGridRowLayout;
19 class nsGridRow;
20 class nsBoxLayoutState;
21 class nsGridCell;
22
23 /**
24 * The nsBoxLayout implementation for a grid.
25 */
26 class nsGridLayout2 : public nsStackLayout,
27 public nsIGridPart
28 {
29 public:
30
31 friend nsresult NS_NewGridLayout2(nsIPresShell* aPresShell, nsBoxLayout** aNewLayout);
32
33 NS_DECL_ISUPPORTS_INHERITED
34
35 NS_IMETHOD Layout(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
36 virtual void IntrinsicWidthsDirty(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
37
38 virtual nsGridRowGroupLayout* CastToRowGroupLayout() MOZ_OVERRIDE { return nullptr; }
39 virtual nsGridLayout2* CastToGridLayout() MOZ_OVERRIDE { return this; }
40 virtual nsGrid* GetGrid(nsIFrame* aBox, int32_t* aIndex, nsGridRowLayout* aRequestor=nullptr) MOZ_OVERRIDE;
41 virtual nsIGridPart* GetParentGridPart(nsIFrame* aBox, nsIFrame** aParentBox) MOZ_OVERRIDE {
42 NS_NOTREACHED("Should not be called"); return nullptr;
43 }
44 virtual nsSize GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
45 virtual nsSize GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
46 virtual nsSize GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
47 virtual void CountRowsColumns(nsIFrame* aBox, int32_t& aRowCount, int32_t& aComputedColumnCount) MOZ_OVERRIDE { aRowCount++; }
48 virtual void DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState) MOZ_OVERRIDE { }
49 virtual int32_t BuildRows(nsIFrame* aBox, nsGridRow* aRows) MOZ_OVERRIDE;
50 virtual nsMargin GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal) MOZ_OVERRIDE;
51 virtual Type GetType() MOZ_OVERRIDE { return eGrid; }
52 virtual void ChildrenInserted(nsIFrame* aBox, nsBoxLayoutState& aState,
53 nsIFrame* aPrevBox,
54 const nsFrameList::Slice& aNewChildren) MOZ_OVERRIDE;
55 virtual void ChildrenAppended(nsIFrame* aBox, nsBoxLayoutState& aState,
56 const nsFrameList::Slice& aNewChildren) MOZ_OVERRIDE;
57 virtual void ChildrenRemoved(nsIFrame* aBox, nsBoxLayoutState& aState,
58 nsIFrame* aChildList) MOZ_OVERRIDE;
59 virtual void ChildrenSet(nsIFrame* aBox, nsBoxLayoutState& aState,
60 nsIFrame* aChildList) MOZ_OVERRIDE;
61
62 virtual nsIGridPart* AsGridPart() MOZ_OVERRIDE { return this; }
63
64 static void AddOffset(nsBoxLayoutState& aState, nsIFrame* aChild, nsSize& aSize);
65
66 protected:
67
68 nsGridLayout2(nsIPresShell* aShell);
69 nsGrid mGrid;
70
71 private:
72 void AddWidth(nsSize& aSize, nscoord aSize2, bool aIsHorizontal);
73
74
75 }; // class nsGridLayout2
76
77
78 #endif
79

mercurial