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 : #ifndef nsBox_h___
7 : #define nsBox_h___
8 :
9 : #include "mozilla/Attributes.h"
10 : #include "nsIFrame.h"
11 :
12 : class nsITheme;
13 :
14 : class nsBox : public nsIFrame {
15 :
16 : public:
17 :
18 : friend class nsIFrame;
19 :
20 : static void Shutdown();
21 :
22 : virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
23 : virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
24 : virtual nsSize GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) override;
25 : virtual nscoord GetXULFlex() override;
26 : virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;
27 :
28 : virtual nsSize GetXULMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState) override;
29 :
30 : virtual bool IsXULCollapsed() override;
31 :
32 : virtual void SetXULBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
33 : bool aRemoveOverflowAreas = false) override;
34 :
35 : virtual nsresult GetXULBorder(nsMargin& aBorderAndPadding) override;
36 : virtual nsresult GetXULPadding(nsMargin& aBorderAndPadding) override;
37 : virtual nsresult GetXULMargin(nsMargin& aMargin) override;
38 :
39 0 : virtual Valignment GetXULVAlign() const override { return vAlign_Top; }
40 0 : virtual Halignment GetXULHAlign() const override { return hAlign_Left; }
41 :
42 : virtual nsresult XULRelayoutChildAtOrdinal(nsIFrame* aChild) override;
43 :
44 : #ifdef DEBUG_LAYOUT
45 : NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIFrame** aBox);
46 : virtual nsresult GetXULDebug(bool& aDebug) override;
47 : virtual nsresult SetXULDebug(nsBoxLayoutState& aState, bool aDebug) override;
48 :
49 : virtual nsresult XULDumpBox(FILE* out) override;
50 : void PropagateDebug(nsBoxLayoutState& aState);
51 : #endif
52 :
53 : nsBox(ClassID aID);
54 : virtual ~nsBox();
55 :
56 : /**
57 : * Returns true if this box clips its children, e.g., if this box is an sc
58 : rollbox.
59 : */
60 : virtual bool DoesClipChildren();
61 : virtual bool ComputesOwnOverflowArea() = 0;
62 :
63 : nsresult SyncLayout(nsBoxLayoutState& aBoxLayoutState);
64 :
65 : bool DoesNeedRecalc(const nsSize& aSize);
66 : bool DoesNeedRecalc(nscoord aCoord);
67 : void SizeNeedsRecalc(nsSize& aSize);
68 : void CoordNeedsRecalc(nscoord& aCoord);
69 :
70 : void AddBorderAndPadding(nsSize& aSize);
71 :
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);
75 :
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);
79 :
80 : static nsIFrame* GetChildXULBox(const nsIFrame* aFrame);
81 : static nsIFrame* GetNextXULBox(const nsIFrame* aFrame);
82 : static nsIFrame* GetParentXULBox(const nsIFrame* aFrame);
83 :
84 : protected:
85 :
86 : #ifdef DEBUG_LAYOUT
87 : virtual void AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult);
88 :
89 : virtual void ListBox(nsAutoString& aResult);
90 : #endif
91 :
92 : nsresult BeginXULLayout(nsBoxLayoutState& aState);
93 : NS_IMETHOD DoXULLayout(nsBoxLayoutState& aBoxLayoutState);
94 : nsresult EndXULLayout(nsBoxLayoutState& aState);
95 :
96 : #ifdef DEBUG_LAYOUT
97 : virtual void GetBoxName(nsAutoString& aName);
98 : void PropagateDebug(nsBoxLayoutState& aState);
99 : #endif
100 :
101 : static bool gGotTheme;
102 : static nsITheme* gTheme;
103 :
104 : enum eMouseThrough {
105 : unset,
106 : never,
107 : always
108 : };
109 :
110 : private:
111 :
112 : //nscoord mX;
113 : //nscoord mY;
114 : };
115 :
116 : #ifdef DEBUG_LAYOUT
117 : #define NS_BOX_ASSERTION(box,expr,str) \
118 : if (!(expr)) { \
119 : box->XULDumpBox(stdout); \
120 : NS_DebugBreak(NSDebugAssertion, str, #expr, __FILE__, __LINE__); \
121 : }
122 : #else
123 : #define NS_BOX_ASSERTION(box,expr,str) {}
124 : #endif
125 :
126 : #endif
127 :
|