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/. */
9 #include "mozilla/Attributes.h"
14 class nsBox
: public nsIFrame
{
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
;
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
);
57 * Returns true if this box clips its children, e.g., if this box is an sc
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
);
87 virtual void AppendAttribute(const nsAutoString
& aAttribute
, const nsAutoString
& aValue
, nsAutoString
& aResult
);
89 virtual void ListBox(nsAutoString
& aResult
);
92 virtual void GetLayoutFlags(uint32_t& aFlags
);
94 nsresult
BeginLayout(nsBoxLayoutState
& aState
);
95 NS_IMETHOD
DoLayout(nsBoxLayoutState
& aBoxLayoutState
);
96 nsresult
EndLayout(nsBoxLayoutState
& aState
);
99 virtual void GetBoxName(nsAutoString
& aName
);
100 void PropagateDebug(nsBoxLayoutState
& aState
);
103 static bool gGotTheme
;
104 static nsITheme
* gTheme
;
119 #define NS_BOX_ASSERTION(box,expr,str) \
121 box->DumpBox(stdout); \
122 NS_DebugBreak(NSDebugAssertion, str, #expr, __FILE__, __LINE__); \
125 #define NS_BOX_ASSERTION(box,expr,str) {}