1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/xul/nsBox.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,125 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsBox_h___ 1.10 +#define nsBox_h___ 1.11 + 1.12 +#include "mozilla/Attributes.h" 1.13 +#include "nsIFrame.h" 1.14 + 1.15 +class nsITheme; 1.16 + 1.17 +class nsBox : public nsIFrame { 1.18 + 1.19 +public: 1.20 + 1.21 + friend class nsIFrame; 1.22 + 1.23 + static void Shutdown(); 1.24 + 1.25 + virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.26 + virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.27 + virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.28 + virtual nscoord GetFlex(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.29 + virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.30 + 1.31 + virtual nsSize GetMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE; 1.32 + 1.33 + virtual bool IsCollapsed() MOZ_OVERRIDE; 1.34 + 1.35 + virtual void SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect, 1.36 + bool aRemoveOverflowAreas = false) MOZ_OVERRIDE; 1.37 + 1.38 + virtual nsresult GetBorder(nsMargin& aBorderAndPadding) MOZ_OVERRIDE; 1.39 + virtual nsresult GetPadding(nsMargin& aBorderAndPadding) MOZ_OVERRIDE; 1.40 + virtual nsresult GetMargin(nsMargin& aMargin) MOZ_OVERRIDE; 1.41 + 1.42 + virtual Valignment GetVAlign() const MOZ_OVERRIDE { return vAlign_Top; } 1.43 + virtual Halignment GetHAlign() const MOZ_OVERRIDE { return hAlign_Left; } 1.44 + 1.45 + virtual nsresult RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild) MOZ_OVERRIDE; 1.46 + 1.47 +#ifdef DEBUG_LAYOUT 1.48 + NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIFrame** aBox); 1.49 + virtual nsresult GetDebug(bool& aDebug) MOZ_OVERRIDE; 1.50 + virtual nsresult SetDebug(nsBoxLayoutState& aState, bool aDebug) MOZ_OVERRIDE; 1.51 + 1.52 + virtual nsresult DumpBox(FILE* out) MOZ_OVERRIDE; 1.53 + NS_HIDDEN_(void) PropagateDebug(nsBoxLayoutState& aState); 1.54 +#endif 1.55 + 1.56 + nsBox(); 1.57 + virtual ~nsBox(); 1.58 + 1.59 + /** 1.60 + * Returns true if this box clips its children, e.g., if this box is an sc 1.61 +rollbox. 1.62 + */ 1.63 + virtual bool DoesClipChildren(); 1.64 + virtual bool ComputesOwnOverflowArea() = 0; 1.65 + 1.66 + NS_HIDDEN_(nsresult) SyncLayout(nsBoxLayoutState& aBoxLayoutState); 1.67 + 1.68 + bool DoesNeedRecalc(const nsSize& aSize); 1.69 + bool DoesNeedRecalc(nscoord aCoord); 1.70 + void SizeNeedsRecalc(nsSize& aSize); 1.71 + void CoordNeedsRecalc(nscoord& aCoord); 1.72 + 1.73 + void AddBorderAndPadding(nsSize& aSize); 1.74 + 1.75 + static void AddBorderAndPadding(nsIFrame* aBox, nsSize& aSize); 1.76 + static void AddMargin(nsIFrame* aChild, nsSize& aSize); 1.77 + static void AddMargin(nsSize& aSize, const nsMargin& aMargin); 1.78 + 1.79 + static nsSize BoundsCheckMinMax(const nsSize& aMinSize, const nsSize& aMaxSize); 1.80 + static nsSize BoundsCheck(const nsSize& aMinSize, const nsSize& aPrefSize, const nsSize& aMaxSize); 1.81 + static nscoord BoundsCheck(nscoord aMinSize, nscoord aPrefSize, nscoord aMaxSize); 1.82 + 1.83 +protected: 1.84 + 1.85 +#ifdef DEBUG_LAYOUT 1.86 + virtual void AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult); 1.87 + 1.88 + virtual void ListBox(nsAutoString& aResult); 1.89 +#endif 1.90 + 1.91 + virtual void GetLayoutFlags(uint32_t& aFlags); 1.92 + 1.93 + NS_HIDDEN_(nsresult) BeginLayout(nsBoxLayoutState& aState); 1.94 + NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState); 1.95 + NS_HIDDEN_(nsresult) EndLayout(nsBoxLayoutState& aState); 1.96 + 1.97 +#ifdef DEBUG_LAYOUT 1.98 + virtual void GetBoxName(nsAutoString& aName); 1.99 + NS_HIDDEN_(void) PropagateDebug(nsBoxLayoutState& aState); 1.100 +#endif 1.101 + 1.102 + static bool gGotTheme; 1.103 + static nsITheme* gTheme; 1.104 + 1.105 + enum eMouseThrough { 1.106 + unset, 1.107 + never, 1.108 + always 1.109 + }; 1.110 + 1.111 +private: 1.112 + 1.113 + //nscoord mX; 1.114 + //nscoord mY; 1.115 +}; 1.116 + 1.117 +#ifdef DEBUG_LAYOUT 1.118 +#define NS_BOX_ASSERTION(box,expr,str) \ 1.119 + if (!(expr)) { \ 1.120 + box->DumpBox(stdout); \ 1.121 + NS_DebugBreak(NSDebugAssertion, str, #expr, __FILE__, __LINE__); \ 1.122 + } 1.123 +#else 1.124 +#define NS_BOX_ASSERTION(box,expr,str) {} 1.125 +#endif 1.126 + 1.127 +#endif 1.128 +