layout/xul/nsBox.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsBox_h___
michael@0 7 #define nsBox_h___
michael@0 8
michael@0 9 #include "mozilla/Attributes.h"
michael@0 10 #include "nsIFrame.h"
michael@0 11
michael@0 12 class nsITheme;
michael@0 13
michael@0 14 class nsBox : public nsIFrame {
michael@0 15
michael@0 16 public:
michael@0 17
michael@0 18 friend class nsIFrame;
michael@0 19
michael@0 20 static void Shutdown();
michael@0 21
michael@0 22 virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 23 virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 24 virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 25 virtual nscoord GetFlex(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 26 virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 27
michael@0 28 virtual nsSize GetMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
michael@0 29
michael@0 30 virtual bool IsCollapsed() MOZ_OVERRIDE;
michael@0 31
michael@0 32 virtual void SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
michael@0 33 bool aRemoveOverflowAreas = false) MOZ_OVERRIDE;
michael@0 34
michael@0 35 virtual nsresult GetBorder(nsMargin& aBorderAndPadding) MOZ_OVERRIDE;
michael@0 36 virtual nsresult GetPadding(nsMargin& aBorderAndPadding) MOZ_OVERRIDE;
michael@0 37 virtual nsresult GetMargin(nsMargin& aMargin) MOZ_OVERRIDE;
michael@0 38
michael@0 39 virtual Valignment GetVAlign() const MOZ_OVERRIDE { return vAlign_Top; }
michael@0 40 virtual Halignment GetHAlign() const MOZ_OVERRIDE { return hAlign_Left; }
michael@0 41
michael@0 42 virtual nsresult RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild) MOZ_OVERRIDE;
michael@0 43
michael@0 44 #ifdef DEBUG_LAYOUT
michael@0 45 NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIFrame** aBox);
michael@0 46 virtual nsresult GetDebug(bool& aDebug) MOZ_OVERRIDE;
michael@0 47 virtual nsresult SetDebug(nsBoxLayoutState& aState, bool aDebug) MOZ_OVERRIDE;
michael@0 48
michael@0 49 virtual nsresult DumpBox(FILE* out) MOZ_OVERRIDE;
michael@0 50 NS_HIDDEN_(void) PropagateDebug(nsBoxLayoutState& aState);
michael@0 51 #endif
michael@0 52
michael@0 53 nsBox();
michael@0 54 virtual ~nsBox();
michael@0 55
michael@0 56 /**
michael@0 57 * Returns true if this box clips its children, e.g., if this box is an sc
michael@0 58 rollbox.
michael@0 59 */
michael@0 60 virtual bool DoesClipChildren();
michael@0 61 virtual bool ComputesOwnOverflowArea() = 0;
michael@0 62
michael@0 63 NS_HIDDEN_(nsresult) SyncLayout(nsBoxLayoutState& aBoxLayoutState);
michael@0 64
michael@0 65 bool DoesNeedRecalc(const nsSize& aSize);
michael@0 66 bool DoesNeedRecalc(nscoord aCoord);
michael@0 67 void SizeNeedsRecalc(nsSize& aSize);
michael@0 68 void CoordNeedsRecalc(nscoord& aCoord);
michael@0 69
michael@0 70 void AddBorderAndPadding(nsSize& aSize);
michael@0 71
michael@0 72 static void AddBorderAndPadding(nsIFrame* aBox, nsSize& aSize);
michael@0 73 static void AddMargin(nsIFrame* aChild, nsSize& aSize);
michael@0 74 static void AddMargin(nsSize& aSize, const nsMargin& aMargin);
michael@0 75
michael@0 76 static nsSize BoundsCheckMinMax(const nsSize& aMinSize, const nsSize& aMaxSize);
michael@0 77 static nsSize BoundsCheck(const nsSize& aMinSize, const nsSize& aPrefSize, const nsSize& aMaxSize);
michael@0 78 static nscoord BoundsCheck(nscoord aMinSize, nscoord aPrefSize, nscoord aMaxSize);
michael@0 79
michael@0 80 protected:
michael@0 81
michael@0 82 #ifdef DEBUG_LAYOUT
michael@0 83 virtual void AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult);
michael@0 84
michael@0 85 virtual void ListBox(nsAutoString& aResult);
michael@0 86 #endif
michael@0 87
michael@0 88 virtual void GetLayoutFlags(uint32_t& aFlags);
michael@0 89
michael@0 90 NS_HIDDEN_(nsresult) BeginLayout(nsBoxLayoutState& aState);
michael@0 91 NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
michael@0 92 NS_HIDDEN_(nsresult) EndLayout(nsBoxLayoutState& aState);
michael@0 93
michael@0 94 #ifdef DEBUG_LAYOUT
michael@0 95 virtual void GetBoxName(nsAutoString& aName);
michael@0 96 NS_HIDDEN_(void) PropagateDebug(nsBoxLayoutState& aState);
michael@0 97 #endif
michael@0 98
michael@0 99 static bool gGotTheme;
michael@0 100 static nsITheme* gTheme;
michael@0 101
michael@0 102 enum eMouseThrough {
michael@0 103 unset,
michael@0 104 never,
michael@0 105 always
michael@0 106 };
michael@0 107
michael@0 108 private:
michael@0 109
michael@0 110 //nscoord mX;
michael@0 111 //nscoord mY;
michael@0 112 };
michael@0 113
michael@0 114 #ifdef DEBUG_LAYOUT
michael@0 115 #define NS_BOX_ASSERTION(box,expr,str) \
michael@0 116 if (!(expr)) { \
michael@0 117 box->DumpBox(stdout); \
michael@0 118 NS_DebugBreak(NSDebugAssertion, str, #expr, __FILE__, __LINE__); \
michael@0 119 }
michael@0 120 #else
michael@0 121 #define NS_BOX_ASSERTION(box,expr,str) {}
michael@0 122 #endif
michael@0 123
michael@0 124 #endif
michael@0 125

mercurial