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();
|
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
virtual nsSize GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) override;
|
2016-04-21 07:28:31 +03:00
|
|
|
virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override;
|
2016-04-21 07:28:31 +03:00
|
|
|
virtual nsSize GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) override;
|
2016-04-21 07:28:31 +03:00
|
|
|
virtual nscoord GetXULFlex() override;
|
2016-04-21 07:28:32 +03:00
|
|
|
virtual nscoord GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) override;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
virtual nsSize GetXULMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState) override;
|
2004-11-03 05:52:16 +03:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
virtual bool IsXULCollapsed() override;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
virtual void SetXULBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
|
|
|
|
bool aRemoveOverflowAreas = false) override;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2016-04-21 07:28:33 +03:00
|
|
|
virtual nsresult GetXULBorder(nsMargin& aBorderAndPadding) override;
|
2016-04-21 07:28:33 +03:00
|
|
|
virtual nsresult GetXULPadding(nsMargin& aBorderAndPadding) override;
|
2016-04-21 07:28:33 +03:00
|
|
|
virtual nsresult GetXULMargin(nsMargin& aMargin) override;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2016-04-21 07:28:33 +03:00
|
|
|
virtual Valignment GetXULVAlign() const override { return vAlign_Top; }
|
2016-04-21 07:28:33 +03:00
|
|
|
virtual Halignment GetXULHAlign() const override { return hAlign_Left; }
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
virtual nsresult XULRelayoutChildAtOrdinal(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);
|
2016-04-21 07:28:34 +03:00
|
|
|
virtual nsresult GetXULDebug(bool& aDebug) override;
|
2016-04-21 07:28:34 +03:00
|
|
|
virtual nsresult SetXULDebug(nsBoxLayoutState& aState, bool aDebug) override;
|
2004-06-19 13:07:47 +04:00
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
virtual nsresult XULDumpBox(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
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
static nsIFrame* GetChildXULBox(const nsIFrame* aFrame);
|
2016-04-21 07:28:32 +03:00
|
|
|
static nsIFrame* GetNextXULBox(const nsIFrame* aFrame);
|
2016-04-21 07:28:32 +03:00
|
|
|
static nsIFrame* GetParentXULBox(const nsIFrame* aFrame);
|
2014-05-25 02:20:41 +04:00
|
|
|
|
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)) { \
|
2016-04-21 07:28:34 +03:00
|
|
|
box->XULDumpBox(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
|
|
|
|
|