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