2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsBox_h___
|
|
|
|
#define nsBox_h___
|
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
|
|
|
|
class nsITheme;
|
|
|
|
|
2010-06-08 22:28:14 -07:00
|
|
|
#define NS_STATE_IS_ROOT NS_FRAME_STATE_BIT(24)
|
|
|
|
#define NS_STATE_SET_TO_DEBUG NS_FRAME_STATE_BIT(26)
|
|
|
|
#define NS_STATE_DEBUG_WAS_SET NS_FRAME_STATE_BIT(27)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
class nsBox : public nsIFrame {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
friend class nsIFrame;
|
|
|
|
|
|
|
|
static void Shutdown();
|
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
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;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual nsSize GetMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual bool IsCollapsed() MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
virtual void SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
|
2013-05-14 09:33:23 -07:00
|
|
|
bool aRemoveOverflowAreas = false) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
NS_IMETHOD GetBorder(nsMargin& aBorderAndPadding) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetPadding(nsMargin& aBorderAndPadding) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetMargin(nsMargin& aMargin) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
virtual Valignment GetVAlign() const MOZ_OVERRIDE { return vAlign_Top; }
|
|
|
|
virtual Halignment GetHAlign() const MOZ_OVERRIDE { return hAlign_Left; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG_LAYOUT
|
2012-08-05 20:00:57 -07:00
|
|
|
NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIFrame** aBox);
|
2013-05-14 09:33:23 -07:00
|
|
|
NS_IMETHOD GetDebug(bool& aDebug) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SetDebug(nsBoxLayoutState& aState, bool aDebug) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-14 09:33:23 -07:00
|
|
|
NS_IMETHOD DumpBox(FILE* out) MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_HIDDEN_(void) PropagateDebug(nsBoxLayoutState& aState);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsBox();
|
|
|
|
virtual ~nsBox();
|
|
|
|
|
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* Returns true if this box clips its children, e.g., if this box is an sc
|
2007-03-22 10:30:00 -07:00
|
|
|
rollbox.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool DoesClipChildren();
|
|
|
|
virtual bool ComputesOwnOverflowArea() = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_HIDDEN_(nsresult) SyncLayout(nsBoxLayoutState& aBoxLayoutState);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool DoesNeedRecalc(const nsSize& aSize);
|
|
|
|
bool DoesNeedRecalc(nscoord aCoord);
|
2007-03-22 10:30:00 -07:00
|
|
|
void SizeNeedsRecalc(nsSize& aSize);
|
|
|
|
void CoordNeedsRecalc(nscoord& aCoord);
|
|
|
|
|
|
|
|
void AddBorderAndPadding(nsSize& aSize);
|
|
|
|
|
2012-08-05 20:00:57 -07:00
|
|
|
static void AddBorderAndPadding(nsIFrame* aBox, nsSize& aSize);
|
|
|
|
static void AddMargin(nsIFrame* aChild, nsSize& aSize);
|
2007-03-22 10:30:00 -07:00
|
|
|
static void AddMargin(nsSize& aSize, const nsMargin& aMargin);
|
|
|
|
|
2008-01-04 21:49:44 -08:00
|
|
|
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);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
#ifdef DEBUG_LAYOUT
|
|
|
|
virtual void AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult);
|
|
|
|
|
|
|
|
virtual void ListBox(nsAutoString& aResult);
|
|
|
|
#endif
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void GetLayoutFlags(uint32_t& aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_HIDDEN_(nsresult) BeginLayout(nsBoxLayoutState& aState);
|
|
|
|
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
|
|
|
|
NS_HIDDEN_(nsresult) EndLayout(nsBoxLayoutState& aState);
|
|
|
|
|
|
|
|
#ifdef DEBUG_LAYOUT
|
|
|
|
virtual void GetBoxName(nsAutoString& aName);
|
|
|
|
NS_HIDDEN_(void) PropagateDebug(nsBoxLayoutState& aState);
|
|
|
|
#endif
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool gGotTheme;
|
2007-03-22 10:30:00 -07:00
|
|
|
static nsITheme* gTheme;
|
|
|
|
|
|
|
|
enum eMouseThrough {
|
|
|
|
unset,
|
|
|
|
never,
|
|
|
|
always
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
//nscoord mX;
|
|
|
|
//nscoord mY;
|
|
|
|
};
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|