2001-09-28 20:14:13 +00:00
|
|
|
/* -*- 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___
|
|
|
|
|
2013-05-14 16:33:23 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2004-09-28 18:37:50 +00:00
|
|
|
#include "nsIFrame.h"
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2001-12-17 22:51:39 +00:00
|
|
|
class nsITheme;
|
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
class nsBox : public nsIFrame {
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
friend class nsIFrame;
|
|
|
|
|
2002-12-11 02:33:33 +00:00
|
|
|
static void Shutdown();
|
|
|
|
|
2013-05-14 16:33:23 +00: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;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2013-05-14 16:33:23 +00:00
|
|
|
virtual nsSize GetMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
2004-11-03 02:52:16 +00:00
|
|
|
|
2013-05-14 16:33:23 +00:00
|
|
|
virtual bool IsCollapsed() MOZ_OVERRIDE;
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2007-02-22 18:05:14 +00:00
|
|
|
virtual void SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
|
2013-05-14 16:33:23 +00:00
|
|
|
bool aRemoveOverflowAreas = false) MOZ_OVERRIDE;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult GetBorder(nsMargin& aBorderAndPadding) MOZ_OVERRIDE;
|
|
|
|
virtual nsresult GetPadding(nsMargin& aBorderAndPadding) MOZ_OVERRIDE;
|
|
|
|
virtual nsresult GetMargin(nsMargin& aMargin) MOZ_OVERRIDE;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2013-05-14 16:33:23 +00:00
|
|
|
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
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild) MOZ_OVERRIDE;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2002-09-09 21:32:33 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2012-08-06 03:00:57 +00:00
|
|
|
NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIFrame** aBox);
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult GetDebug(bool& aDebug) MOZ_OVERRIDE;
|
|
|
|
virtual nsresult SetDebug(nsBoxLayoutState& aState, bool aDebug) MOZ_OVERRIDE;
|
2004-06-19 09:07:47 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult DumpBox(FILE* out) MOZ_OVERRIDE;
|
2014-06-02 12:08:21 +00:00
|
|
|
void PropagateDebug(nsBoxLayoutState& aState);
|
2002-09-09 21:32:33 +00:00
|
|
|
#endif
|
2000-04-25 07:10:48 +00:00
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
nsBox();
|
2001-12-17 22:51:39 +00:00
|
|
|
virtual ~nsBox();
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2004-07-16 16:56:21 +00:00
|
|
|
/**
|
2011-10-17 14:59:28 +00:00
|
|
|
* Returns true if this box clips its children, e.g., if this box is an sc
|
2004-09-28 18:37:50 +00:00
|
|
|
rollbox.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool DoesClipChildren();
|
|
|
|
virtual bool ComputesOwnOverflowArea() = 0;
|
2004-07-16 16:56:21 +00:00
|
|
|
|
2014-06-02 12:08:21 +00:00
|
|
|
nsresult SyncLayout(nsBoxLayoutState& aBoxLayoutState);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool DoesNeedRecalc(const nsSize& aSize);
|
|
|
|
bool DoesNeedRecalc(nscoord aCoord);
|
2004-09-28 18:37:50 +00:00
|
|
|
void SizeNeedsRecalc(nsSize& aSize);
|
|
|
|
void CoordNeedsRecalc(nscoord& aCoord);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
void AddBorderAndPadding(nsSize& aSize);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2012-08-06 03:00:57 +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);
|
|
|
|
|
2008-01-05 05:49:44 +00: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);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2014-05-24 22:20:41 +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:
|
2000-06-02 22:15:09 +00:00
|
|
|
|
2002-09-09 21:32:33 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-06-02 22:15:09 +00:00
|
|
|
virtual void AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult);
|
|
|
|
|
|
|
|
virtual void ListBox(nsAutoString& aResult);
|
2002-09-09 21:32:33 +00:00
|
|
|
#endif
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual void GetLayoutFlags(uint32_t& aFlags);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2014-06-02 12:08:21 +00:00
|
|
|
nsresult BeginLayout(nsBoxLayoutState& aState);
|
2000-07-07 22:24:06 +00:00
|
|
|
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
|
2014-06-02 12:08:21 +00:00
|
|
|
nsresult EndLayout(nsBoxLayoutState& aState);
|
2000-07-07 22:24:06 +00:00
|
|
|
|
2002-09-09 21:32:33 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2000-05-15 04:12:31 +00:00
|
|
|
virtual void GetBoxName(nsAutoString& aName);
|
2014-06-02 12:08:21 +00:00
|
|
|
void PropagateDebug(nsBoxLayoutState& aState);
|
2002-09-09 21:32:33 +00:00
|
|
|
#endif
|
2000-05-15 04:12:31 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool gGotTheme;
|
2001-12-17 22:51:39 +00:00
|
|
|
static nsITheme* gTheme;
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
enum eMouseThrough {
|
2000-04-18 00:17:00 +00:00
|
|
|
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
|
2000-06-02 22:15:09 +00:00
|
|
|
#define NS_BOX_ASSERTION(box,expr,str) \
|
|
|
|
if (!(expr)) { \
|
|
|
|
box->DumpBox(stdout); \
|
2006-02-10 15:00:36 +00:00
|
|
|
NS_DebugBreak(NSDebugAssertion, str, #expr, __FILE__, __LINE__); \
|
2000-09-10 19:14:24 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define NS_BOX_ASSERTION(box,expr,str) {}
|
|
|
|
#endif
|
2000-06-02 22:15:09 +00:00
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
#endif
|
|
|
|
|