gecko-dev/layout/xul/nsBox.h

130 lines
3.9 KiB
C
Raw Normal View History

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2012-05-21 11:12:37 +00:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
2000-03-31 07:02:06 +00:00
#ifndef nsBox_h___
#define nsBox_h___
#include "mozilla/Attributes.h"
#include "nsIFrame.h"
2000-03-31 07:02:06 +00:00
class nsITheme;
class nsBox : public nsIFrame {
2000-03-31 07:02:06 +00:00
public:
friend class nsIFrame;
static void Shutdown();
virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
virtual nscoord GetFlex(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
virtual nsSize GetMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
virtual bool IsCollapsed() MOZ_OVERRIDE;
2000-03-31 07:02:06 +00:00
virtual void SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
bool aRemoveOverflowAreas = false) MOZ_OVERRIDE;
virtual nsresult GetBorder(nsMargin& aBorderAndPadding) MOZ_OVERRIDE;
virtual nsresult GetPadding(nsMargin& aBorderAndPadding) MOZ_OVERRIDE;
virtual nsresult GetMargin(nsMargin& aMargin) MOZ_OVERRIDE;
virtual Valignment GetVAlign() const MOZ_OVERRIDE { return vAlign_Top; }
virtual Halignment GetHAlign() const MOZ_OVERRIDE { return hAlign_Left; }
2000-03-31 07:02:06 +00:00
virtual nsresult RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild) MOZ_OVERRIDE;
#ifdef DEBUG_LAYOUT
NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIFrame** aBox);
virtual nsresult GetDebug(bool& aDebug) MOZ_OVERRIDE;
virtual nsresult SetDebug(nsBoxLayoutState& aState, bool aDebug) MOZ_OVERRIDE;
virtual nsresult DumpBox(FILE* out) MOZ_OVERRIDE;
void PropagateDebug(nsBoxLayoutState& aState);
#endif
nsBox();
virtual ~nsBox();
2000-03-31 07:02:06 +00:00
/**
* Returns true if this box clips its children, e.g., if this box is an sc
rollbox.
*/
virtual bool DoesClipChildren();
virtual bool ComputesOwnOverflowArea() = 0;
nsresult SyncLayout(nsBoxLayoutState& aBoxLayoutState);
2000-03-31 07:02:06 +00:00
bool DoesNeedRecalc(const nsSize& aSize);
bool DoesNeedRecalc(nscoord aCoord);
void SizeNeedsRecalc(nsSize& aSize);
void CoordNeedsRecalc(nscoord& aCoord);
2000-03-31 07:02:06 +00:00
void AddBorderAndPadding(nsSize& aSize);
2000-03-31 07:02:06 +00:00
static void AddBorderAndPadding(nsIFrame* aBox, nsSize& aSize);
static void AddMargin(nsIFrame* aChild, nsSize& aSize);
2000-03-31 07:02:06 +00:00
static void AddMargin(nsSize& aSize, const nsMargin& aMargin);
static nsSize BoundsCheckMinMax(const nsSize& aMinSize, const nsSize& aMaxSize);
static nsSize BoundsCheck(const nsSize& aMinSize, const nsSize& aPrefSize, const nsSize& aMaxSize);
static nscoord BoundsCheck(nscoord aMinSize, nscoord aPrefSize, nscoord aMaxSize);
2000-03-31 07:02:06 +00:00
static nsIFrame* GetChildBox(const nsIFrame* aFrame);
static nsIFrame* GetNextBox(const nsIFrame* aFrame);
static nsIFrame* GetParentBox(const nsIFrame* aFrame);
2000-03-31 07:02:06 +00:00
protected:
#ifdef DEBUG_LAYOUT
virtual void AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult);
virtual void ListBox(nsAutoString& aResult);
#endif
virtual void GetLayoutFlags(uint32_t& aFlags);
2000-03-31 07:02:06 +00:00
nsresult BeginLayout(nsBoxLayoutState& aState);
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
nsresult EndLayout(nsBoxLayoutState& aState);
#ifdef DEBUG_LAYOUT
virtual void GetBoxName(nsAutoString& aName);
void PropagateDebug(nsBoxLayoutState& aState);
#endif
static bool gGotTheme;
static nsITheme* gTheme;
2000-03-31 07:02:06 +00:00
enum eMouseThrough {
unset,
2000-03-31 07:02:06 +00:00
never,
always
};
private:
//nscoord mX;
//nscoord mY;
};
2002-09-09 21:36:49 +00:00
#ifdef DEBUG_LAYOUT
#define NS_BOX_ASSERTION(box,expr,str) \
if (!(expr)) { \
box->DumpBox(stdout); \
NS_DebugBreak(NSDebugAssertion, str, #expr, __FILE__, __LINE__); \
}
#else
#define NS_BOX_ASSERTION(box,expr,str) {}
#endif
2000-03-31 07:02:06 +00:00
#endif