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/. */
|
1999-03-27 01:35:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Eric D Vaughan
|
1999-05-09 21:46:24 +00:00
|
|
|
nsBoxFrame is a frame that can lay its children out either vertically or horizontally.
|
|
|
|
It lays them out according to a min max or preferred size.
|
1999-03-27 01:35:55 +00:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
1999-03-30 04:05:49 +00:00
|
|
|
#ifndef nsBoxFrame_h___
|
|
|
|
#define nsBoxFrame_h___
|
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
1999-07-02 05:28:32 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2000-09-01 00:59:09 +00:00
|
|
|
#include "nsContainerFrame.h"
|
2011-07-04 14:39:10 +00:00
|
|
|
#include "nsBoxLayout.h"
|
|
|
|
|
2000-03-31 07:02:06 +00:00
|
|
|
class nsBoxLayoutState;
|
1999-07-02 05:28:32 +00:00
|
|
|
|
2000-03-02 03:01:30 +00:00
|
|
|
// flags from box
|
2010-06-09 05:28:14 +00:00
|
|
|
#define NS_STATE_BOX_CHILD_RESERVED NS_FRAME_STATE_BIT(20)
|
|
|
|
#define NS_STATE_STACK_NOT_POSITIONED NS_FRAME_STATE_BIT(21)
|
|
|
|
//#define NS_STATE_IS_HORIZONTAL NS_FRAME_STATE_BIT(22) moved to nsIFrame.h
|
|
|
|
#define NS_STATE_AUTO_STRETCH NS_FRAME_STATE_BIT(23)
|
|
|
|
//#define NS_STATE_IS_ROOT NS_FRAME_STATE_BIT(24) moved to nsBox.h
|
|
|
|
#define NS_STATE_CURRENTLY_IN_DEBUG NS_FRAME_STATE_BIT(25)
|
|
|
|
//#define NS_STATE_SET_TO_DEBUG NS_FRAME_STATE_BIT(26) moved to nsBox.h
|
|
|
|
//#define NS_STATE_DEBUG_WAS_SET NS_FRAME_STATE_BIT(27) moved to nsBox.h
|
2012-03-08 01:57:37 +00:00
|
|
|
#define NS_STATE_MENU_HAS_POPUP_LIST NS_FRAME_STATE_BIT(28) /* used on nsMenuFrame */
|
2010-06-09 05:28:14 +00:00
|
|
|
#define NS_STATE_BOX_WRAPS_KIDS_IN_BLOCK NS_FRAME_STATE_BIT(29)
|
|
|
|
#define NS_STATE_EQUAL_SIZE NS_FRAME_STATE_BIT(30)
|
|
|
|
//#define NS_STATE_IS_DIRECTION_NORMAL NS_FRAME_STATE_BIT(31) moved to nsIFrame.h
|
2010-11-30 14:59:46 +00:00
|
|
|
#define NS_FRAME_MOUSE_THROUGH_ALWAYS NS_FRAME_STATE_BIT(60)
|
|
|
|
#define NS_FRAME_MOUSE_THROUGH_NEVER NS_FRAME_STATE_BIT(61)
|
2000-03-02 03:01:30 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsRoot,
|
2011-07-11 14:05:10 +00:00
|
|
|
nsBoxLayout* aLayoutManager);
|
2009-01-19 18:31:33 +00:00
|
|
|
nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
2002-01-10 14:16:05 +00:00
|
|
|
|
2004-09-28 18:37:50 +00:00
|
|
|
class nsBoxFrame : public nsContainerFrame
|
1999-03-27 01:35:55 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
1999-03-27 01:35:55 +00:00
|
|
|
|
2005-10-26 21:46:39 +00:00
|
|
|
friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
|
2006-03-26 21:30:36 +00:00
|
|
|
nsStyleContext* aContext,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aIsRoot,
|
2011-07-11 14:05:10 +00:00
|
|
|
nsBoxLayout* aLayoutManager);
|
2009-01-19 18:31:33 +00:00
|
|
|
friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
2000-04-05 00:19:00 +00:00
|
|
|
|
1999-09-10 00:57:01 +00:00
|
|
|
// gets the rect inside our border and debug border. If you wish to paint inside a box
|
|
|
|
// call this method to get the rect so you don't draw on the debug border or outer border.
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-09 22:02:40 +00:00
|
|
|
|
2011-07-11 14:05:10 +00:00
|
|
|
virtual void SetLayoutManager(nsBoxLayout* aLayout) { mLayoutManager = aLayout; }
|
|
|
|
virtual nsBoxLayout* GetLayoutManager() { return mLayoutManager; }
|
2011-07-04 14:39:10 +00:00
|
|
|
|
2012-08-06 03:00:57 +00:00
|
|
|
NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild);
|
1999-09-10 00:57:01 +00:00
|
|
|
|
2007-01-08 02:57:59 +00:00
|
|
|
virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
|
|
|
|
virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState);
|
|
|
|
virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState);
|
2007-01-31 16:02:42 +00:00
|
|
|
virtual nscoord GetFlex(nsBoxLayoutState& aBoxLayoutState);
|
|
|
|
virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState);
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD SetDebug(nsBoxLayoutState& aBoxLayoutState, bool aDebug);
|
2012-09-14 16:10:08 +00:00
|
|
|
NS_IMETHOD GetDebug(bool& aDebug) MOZ_OVERRIDE;
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual Valignment GetVAlign() const MOZ_OVERRIDE { return mValign; }
|
|
|
|
virtual Halignment GetHAlign() const MOZ_OVERRIDE { return mHalign; }
|
2000-07-07 22:24:06 +00:00
|
|
|
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
|
2000-04-25 07:10:48 +00:00
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual bool ComputesOwnOverflowArea() MOZ_OVERRIDE { return false; }
|
2000-03-31 07:02:06 +00:00
|
|
|
|
|
|
|
// ----- child and sibling operations ---
|
|
|
|
|
|
|
|
// ----- public methods -------
|
|
|
|
|
2013-03-20 01:47:48 +00:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* asPrevInFlow) MOZ_OVERRIDE;
|
1999-03-27 01:35:55 +00:00
|
|
|
|
1999-05-09 21:46:24 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD AttributeChanged(int32_t aNameSpaceID,
|
2002-10-10 06:39:30 +00:00
|
|
|
nsIAtom* aAttribute,
|
2012-09-14 16:10:08 +00:00
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
1999-03-27 01:35:55 +00:00
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual void MarkIntrinsicWidthsDirty() MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
2000-02-25 04:18:34 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
1999-03-27 01:35:55 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2012-09-14 16:10:08 +00:00
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
1999-03-27 01:35:55 +00:00
|
|
|
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD AppendFrames(ChildListID aListID,
|
2012-09-14 16:10:08 +00:00
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
1999-04-12 21:48:21 +00:00
|
|
|
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD InsertFrames(ChildListID aListID,
|
1999-04-12 21:48:21 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2012-09-14 16:10:08 +00:00
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
1999-04-12 21:48:21 +00:00
|
|
|
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD RemoveFrame(ChildListID aListID,
|
2012-09-14 16:10:08 +00:00
|
|
|
nsIFrame* aOldFrame) MOZ_OVERRIDE;
|
1999-04-12 21:48:21 +00:00
|
|
|
|
2007-10-25 23:30:49 +00:00
|
|
|
virtual nsIFrame* GetContentInsertionFrame();
|
|
|
|
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_IMETHOD SetInitialChildList(ChildListID aListID,
|
2012-09-14 16:10:08 +00:00
|
|
|
nsFrameList& aChildList) MOZ_OVERRIDE;
|
1999-12-02 01:07:27 +00:00
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
|
2006-04-17 23:58:17 +00:00
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual nsIAtom* GetType() const MOZ_OVERRIDE;
|
2007-02-24 18:33:33 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const
|
2007-02-24 18:33:33 +00:00
|
|
|
{
|
2008-07-13 22:41:18 +00:00
|
|
|
// record that children that are ignorable whitespace should be excluded
|
|
|
|
// (When content was loaded via the XUL content sink, it's already
|
|
|
|
// been excluded, but we need this for when the XUL namespace is used
|
|
|
|
// in other MIME types or when the XUL CSS display types are used with
|
|
|
|
// non-XUL elements.)
|
|
|
|
|
2007-02-24 18:33:33 +00:00
|
|
|
// This is bogus, but it's what we've always done.
|
|
|
|
// (Given that we're replaced, we need to say we're a replaced element
|
|
|
|
// that contains a block so nsHTMLReflowState doesn't tell us to be
|
|
|
|
// NS_INTRINSICSIZE wide.)
|
|
|
|
return nsContainerFrame::IsFrameOfType(aFlags &
|
2008-07-13 22:41:18 +00:00
|
|
|
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock | eXULBox |
|
|
|
|
nsIFrame::eExcludesIgnorableWhitespace));
|
2007-02-24 18:33:33 +00:00
|
|
|
}
|
|
|
|
|
2001-09-15 00:45:54 +00:00
|
|
|
#ifdef DEBUG
|
2012-09-14 16:10:08 +00:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
2001-09-15 00:45:54 +00:00
|
|
|
#endif
|
1999-07-14 17:32:56 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_IMETHOD DidReflow(nsPresContext* aPresContext,
|
2001-12-07 14:51:12 +00:00
|
|
|
const nsHTMLReflowState* aReflowState,
|
2012-09-14 16:10:08 +00:00
|
|
|
nsDidReflowStatus aStatus) MOZ_OVERRIDE;
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool HonorPrintBackgroundSettings();
|
2007-10-12 18:37:51 +00:00
|
|
|
|
1999-08-27 06:06:39 +00:00
|
|
|
virtual ~nsBoxFrame();
|
2001-09-25 22:17:00 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
nsBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, bool aIsRoot = false, nsBoxLayout* aLayoutManager = nullptr);
|
2007-07-04 15:49:38 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// virtual so nsStackFrame, nsButtonBoxFrame, nsSliderFrame and nsMenuFrame
|
|
|
|
// can override it
|
2013-02-14 11:12:27 +00:00
|
|
|
virtual void BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
2000-09-01 00:59:09 +00:00
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_LAYOUT
|
2012-08-06 03:00:57 +00:00
|
|
|
virtual void SetDebugOnChildList(nsBoxLayoutState& aState, nsIFrame* aChild, bool aDebug);
|
|
|
|
nsresult DisplayDebugInfoFor(nsIFrame* aBox,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsPoint& aPoint);
|
2004-09-28 18:37:50 +00:00
|
|
|
#endif
|
|
|
|
|
2012-08-06 03:00:57 +00:00
|
|
|
static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox, const nsRect& aRect);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
/**
|
|
|
|
* Utility method to redirect events on descendants to this frame.
|
|
|
|
* Supports 'allowevents' attribute on descendant elements to allow those
|
|
|
|
* elements and their descendants to receive events.
|
|
|
|
*/
|
2013-02-14 11:12:27 +00:00
|
|
|
void WrapListsInRedirector(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aIn,
|
|
|
|
const nsDisplayListSet& aOut);
|
2005-02-11 13:18:40 +00:00
|
|
|
|
2009-01-09 00:11:30 +00:00
|
|
|
/**
|
|
|
|
* This defaults to true, but some box frames (nsListBoxBodyFrame for
|
|
|
|
* example) don't support ordinals in their children.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
virtual bool SupportsOrdinalsInChildren();
|
2009-01-09 00:11:30 +00:00
|
|
|
|
1999-03-27 01:35:55 +00:00
|
|
|
protected:
|
2002-09-09 21:32:33 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual void GetBoxName(nsAutoString& aName) MOZ_OVERRIDE;
|
2011-04-08 01:04:40 +00:00
|
|
|
void PaintXULDebugBackground(nsRenderingContext& aRenderingContext,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsPoint aPt);
|
2011-04-08 01:04:40 +00:00
|
|
|
void PaintXULDebugOverlay(nsRenderingContext& aRenderingContext,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsPoint aPt);
|
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
|
|
|
virtual bool GetInitialEqualSize(bool& aEqualSize);
|
|
|
|
virtual void GetInitialOrientation(bool& aIsHorizontal);
|
|
|
|
virtual void GetInitialDirection(bool& aIsNormal);
|
|
|
|
virtual bool GetInitialHAlignment(Halignment& aHalign);
|
|
|
|
virtual bool GetInitialVAlignment(Valignment& aValign);
|
|
|
|
virtual bool GetInitialAutoStretch(bool& aStretch);
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
2000-02-14 01:42:09 +00:00
|
|
|
|
2000-06-06 01:25:03 +00:00
|
|
|
nsSize mPrefSize;
|
|
|
|
nsSize mMinSize;
|
|
|
|
nsSize mMaxSize;
|
|
|
|
nscoord mFlex;
|
|
|
|
nscoord mAscent;
|
|
|
|
|
2011-07-11 14:05:10 +00:00
|
|
|
nsCOMPtr<nsBoxLayout> mLayoutManager;
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2012-07-27 22:01:12 +00:00
|
|
|
// Get the point associated with this event. Returns true if a single valid
|
|
|
|
// point was found. Otherwise false.
|
|
|
|
bool GetEventPoint(nsGUIEvent *aEvent, nsPoint &aPoint);
|
|
|
|
// Gets the event coordinates relative to the widget offset associated with
|
|
|
|
// this frame. Return true if a single valid point was found.
|
|
|
|
bool GetEventPoint(nsGUIEvent *aEvent, nsIntPoint &aPoint);
|
|
|
|
|
2002-02-21 13:39:39 +00:00
|
|
|
protected:
|
2013-03-20 01:47:48 +00:00
|
|
|
void RegUnregAccessKey(bool aDoReg);
|
2002-07-03 16:38:15 +00:00
|
|
|
|
2012-11-30 23:25:32 +00:00
|
|
|
NS_HIDDEN_(void) CheckBoxOrder();
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2002-02-21 13:39:39 +00:00
|
|
|
private:
|
2002-10-10 06:39:30 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult SetDebug(nsPresContext* aPresContext, bool aDebug);
|
|
|
|
bool GetInitialDebug(bool& aDebug);
|
2004-07-31 23:15:21 +00:00
|
|
|
void GetDebugPref(nsPresContext* aPresContext);
|
2004-06-19 09:07:47 +00:00
|
|
|
|
2002-10-10 06:39:30 +00:00
|
|
|
void GetDebugBorder(nsMargin& aInset);
|
|
|
|
void GetDebugPadding(nsMargin& aInset);
|
|
|
|
void GetDebugMargin(nsMargin& aInset);
|
2004-06-19 09:07:47 +00:00
|
|
|
|
2012-08-06 03:00:57 +00:00
|
|
|
nsresult GetFrameSizeWithMargin(nsIFrame* aBox, nsSize& aSize);
|
2004-06-19 09:07:47 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void PixelMarginToTwips(nsPresContext* aPresContext, nsMargin& aMarginPixels);
|
2002-10-10 06:39:30 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void GetValue(nsPresContext* aPresContext, const nsSize& a, const nsSize& b, char* value);
|
2012-08-22 15:56:38 +00:00
|
|
|
void GetValue(nsPresContext* aPresContext, int32_t a, int32_t b, char* value);
|
|
|
|
void DrawSpacer(nsPresContext* aPresContext, nsRenderingContext& aRenderingContext, bool aHorizontal, int32_t flex, nscoord x, nscoord y, nscoord size, nscoord spacerSize);
|
2011-09-29 06:19:26 +00:00
|
|
|
void DrawLine(nsRenderingContext& aRenderingContext, bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2);
|
|
|
|
void FillRect(nsRenderingContext& aRenderingContext, bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height);
|
2006-02-13 15:49:56 +00:00
|
|
|
#endif
|
2010-11-30 14:59:46 +00:00
|
|
|
virtual void UpdateMouseThrough();
|
2002-10-10 06:39:30 +00:00
|
|
|
|
|
|
|
void CacheAttributes();
|
|
|
|
|
|
|
|
// instance variables.
|
|
|
|
Halignment mHalign;
|
|
|
|
Valignment mValign;
|
|
|
|
|
2004-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool gDebug;
|
2012-08-06 03:00:57 +00:00
|
|
|
static nsIFrame* mDebugChild;
|
2004-06-19 09:07:47 +00:00
|
|
|
#endif
|
2002-10-10 06:39:30 +00:00
|
|
|
|
1999-03-27 01:35:55 +00:00
|
|
|
}; // class nsBoxFrame
|
|
|
|
|
1999-03-30 04:05:49 +00:00
|
|
|
#endif
|
|
|
|
|