Bumping manifests a=b2g-bump
[gecko.git] / layout / xul / nsBox.h
blobd8e523b0b1cbbb650b2f11729907921fd52aa82c
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 #ifndef nsBox_h___
7 #define nsBox_h___
9 #include "mozilla/Attributes.h"
10 #include "nsIFrame.h"
12 class nsITheme;
14 class nsBox : public nsIFrame {
16 public:
18 friend class nsIFrame;
20 static void Shutdown();
22 virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
23 virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
24 virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
25 virtual nscoord GetFlex(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
26 virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
28 virtual nsSize GetMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
30 virtual bool IsCollapsed() MOZ_OVERRIDE;
32 virtual void SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
33 bool aRemoveOverflowAreas = false) MOZ_OVERRIDE;
35 virtual nsresult GetBorder(nsMargin& aBorderAndPadding) MOZ_OVERRIDE;
36 virtual nsresult GetPadding(nsMargin& aBorderAndPadding) MOZ_OVERRIDE;
37 virtual nsresult GetMargin(nsMargin& aMargin) MOZ_OVERRIDE;
39 virtual Valignment GetVAlign() const MOZ_OVERRIDE { return vAlign_Top; }
40 virtual Halignment GetHAlign() const MOZ_OVERRIDE { return hAlign_Left; }
42 virtual nsresult RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild) MOZ_OVERRIDE;
44 #ifdef DEBUG_LAYOUT
45 NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIFrame** aBox);
46 virtual nsresult GetDebug(bool& aDebug) MOZ_OVERRIDE;
47 virtual nsresult SetDebug(nsBoxLayoutState& aState, bool aDebug) MOZ_OVERRIDE;
49 virtual nsresult DumpBox(FILE* out) MOZ_OVERRIDE;
50 void PropagateDebug(nsBoxLayoutState& aState);
51 #endif
53 nsBox();
54 virtual ~nsBox();
56 /**
57 * Returns true if this box clips its children, e.g., if this box is an sc
58 rollbox.
60 virtual bool DoesClipChildren();
61 virtual bool ComputesOwnOverflowArea() = 0;
63 nsresult SyncLayout(nsBoxLayoutState& aBoxLayoutState);
65 bool DoesNeedRecalc(const nsSize& aSize);
66 bool DoesNeedRecalc(nscoord aCoord);
67 void SizeNeedsRecalc(nsSize& aSize);
68 void CoordNeedsRecalc(nscoord& aCoord);
70 void AddBorderAndPadding(nsSize& aSize);
72 static void AddBorderAndPadding(nsIFrame* aBox, nsSize& aSize);
73 static void AddMargin(nsIFrame* aChild, nsSize& aSize);
74 static void AddMargin(nsSize& aSize, const nsMargin& aMargin);
76 static nsSize BoundsCheckMinMax(const nsSize& aMinSize, const nsSize& aMaxSize);
77 static nsSize BoundsCheck(const nsSize& aMinSize, const nsSize& aPrefSize, const nsSize& aMaxSize);
78 static nscoord BoundsCheck(nscoord aMinSize, nscoord aPrefSize, nscoord aMaxSize);
80 static nsIFrame* GetChildBox(const nsIFrame* aFrame);
81 static nsIFrame* GetNextBox(const nsIFrame* aFrame);
82 static nsIFrame* GetParentBox(const nsIFrame* aFrame);
84 protected:
86 #ifdef DEBUG_LAYOUT
87 virtual void AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult);
89 virtual void ListBox(nsAutoString& aResult);
90 #endif
92 virtual void GetLayoutFlags(uint32_t& aFlags);
94 nsresult BeginLayout(nsBoxLayoutState& aState);
95 NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
96 nsresult EndLayout(nsBoxLayoutState& aState);
98 #ifdef DEBUG_LAYOUT
99 virtual void GetBoxName(nsAutoString& aName);
100 void PropagateDebug(nsBoxLayoutState& aState);
101 #endif
103 static bool gGotTheme;
104 static nsITheme* gTheme;
106 enum eMouseThrough {
107 unset,
108 never,
109 always
112 private:
114 //nscoord mX;
115 //nscoord mY;
118 #ifdef DEBUG_LAYOUT
119 #define NS_BOX_ASSERTION(box,expr,str) \
120 if (!(expr)) { \
121 box->DumpBox(stdout); \
122 NS_DebugBreak(NSDebugAssertion, str, #expr, __FILE__, __LINE__); \
124 #else
125 #define NS_BOX_ASSERTION(box,expr,str) {}
126 #endif
128 #endif