Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
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 NS_HIDDEN_(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.
59 */
60 virtual bool DoesClipChildren();
61 virtual bool ComputesOwnOverflowArea() = 0;
63 NS_HIDDEN_(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 protected:
82 #ifdef DEBUG_LAYOUT
83 virtual void AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult);
85 virtual void ListBox(nsAutoString& aResult);
86 #endif
88 virtual void GetLayoutFlags(uint32_t& aFlags);
90 NS_HIDDEN_(nsresult) BeginLayout(nsBoxLayoutState& aState);
91 NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
92 NS_HIDDEN_(nsresult) EndLayout(nsBoxLayoutState& aState);
94 #ifdef DEBUG_LAYOUT
95 virtual void GetBoxName(nsAutoString& aName);
96 NS_HIDDEN_(void) PropagateDebug(nsBoxLayoutState& aState);
97 #endif
99 static bool gGotTheme;
100 static nsITheme* gTheme;
102 enum eMouseThrough {
103 unset,
104 never,
105 always
106 };
108 private:
110 //nscoord mX;
111 //nscoord mY;
112 };
114 #ifdef DEBUG_LAYOUT
115 #define NS_BOX_ASSERTION(box,expr,str) \
116 if (!(expr)) { \
117 box->DumpBox(stdout); \
118 NS_DebugBreak(NSDebugAssertion, str, #expr, __FILE__, __LINE__); \
119 }
120 #else
121 #define NS_BOX_ASSERTION(box,expr,str) {}
122 #endif
124 #endif