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
|
|
|
|
2014-10-20 09:55:48 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
class DrawTarget;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2014-10-20 09:55:48 +00:00
|
|
|
protected:
|
2014-10-20 09:55:48 +00:00
|
|
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
|
|
|
|
1999-03-27 01:35:55 +00:00
|
|
|
public:
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2014-01-18 07:08:22 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsBoxFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
|
|
|
#endif
|
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
|
|
|
|
2013-05-14 16:33:23 +00:00
|
|
|
virtual void SetLayoutManager(nsBoxLayout* aLayout) MOZ_OVERRIDE { mLayoutManager = aLayout; }
|
|
|
|
virtual nsBoxLayout* GetLayoutManager() MOZ_OVERRIDE { return mLayoutManager; }
|
2011-07-04 14:39:10 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild) MOZ_OVERRIDE;
|
1999-09-10 00:57:01 +00:00
|
|
|
|
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-06-19 09:07:47 +00:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult SetDebug(nsBoxLayoutState& aBoxLayoutState, bool aDebug) MOZ_OVERRIDE;
|
|
|
|
virtual nsresult 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; }
|
2013-05-14 16:33:23 +00:00
|
|
|
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState) MOZ_OVERRIDE;
|
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 -------
|
|
|
|
|
2014-05-24 22:20:40 +00:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
|
1999-03-27 01:35:55 +00:00
|
|
|
|
1999-05-09 21:46:24 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 08:36:33 +00:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType) MOZ_OVERRIDE;
|
1999-03-27 01:35:55 +00:00
|
|
|
|
2014-07-24 17:03:26 +00:00
|
|
|
virtual void MarkIntrinsicISizesDirty() MOZ_OVERRIDE;
|
2014-07-24 17:03:25 +00:00
|
|
|
virtual nscoord GetMinISize(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetPrefISize(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE;
|
2000-02-25 04:18:34 +00:00
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
1999-03-27 01:35:55 +00:00
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
virtual void SetInitialChildList(ChildListID aListID,
|
|
|
|
nsFrameList& aChildList) MOZ_OVERRIDE;
|
|
|
|
virtual void AppendFrames(ChildListID aListID,
|
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
|
|
|
virtual void InsertFrames(ChildListID aListID,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsFrameList& aFrameList) MOZ_OVERRIDE;
|
|
|
|
virtual void RemoveFrame(ChildListID aListID,
|
|
|
|
nsIFrame* aOldFrame) MOZ_OVERRIDE;
|
1999-04-12 21:48:21 +00:00
|
|
|
|
2014-05-24 22:20:39 +00:00
|
|
|
virtual nsContainerFrame* GetContentInsertionFrame() MOZ_OVERRIDE;
|
2007-10-25 23:30:49 +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
|
|
|
|
2013-05-14 16:33:23 +00:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
|
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
|
|
|
}
|
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
2001-09-15 00:45:54 +00:00
|
|
|
#endif
|
1999-07-14 17:32:56 +00:00
|
|
|
|
2014-05-13 00:47:53 +00:00
|
|
|
virtual void DidReflow(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nsDidReflowStatus aStatus) MOZ_OVERRIDE;
|
2000-03-31 07:02:06 +00:00
|
|
|
|
2013-05-14 16:33:23 +00:00
|
|
|
virtual bool HonorPrintBackgroundSettings() MOZ_OVERRIDE;
|
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
|
|
|
|
2015-01-06 09:27:56 +00:00
|
|
|
explicit nsBoxFrame(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);
|
2014-10-20 09:55:48 +00:00
|
|
|
void PaintXULDebugOverlay(DrawTarget& 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.
|
2013-10-02 03:46:03 +00:00
|
|
|
bool GetEventPoint(mozilla::WidgetGUIEvent* aEvent, nsPoint& aPoint);
|
2012-07-27 22:01:12 +00:00
|
|
|
// Gets the event coordinates relative to the widget offset associated with
|
|
|
|
// this frame. Return true if a single valid point was found.
|
2015-02-01 22:27:41 +00:00
|
|
|
bool GetEventPoint(mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
mozilla::LayoutDeviceIntPoint& aPoint);
|
2012-07-27 22:01:12 +00:00
|
|
|
|
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
|
|
|
|
2014-06-02 12:08:21 +00:00
|
|
|
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);
|
2014-10-20 09:55:48 +00:00
|
|
|
void DrawSpacer(nsPresContext* aPresContext, DrawTarget& aDrawTarget, bool aHorizontal, int32_t flex, nscoord x, nscoord y, nscoord size, nscoord spacerSize);
|
|
|
|
void DrawLine(DrawTarget& aDrawTarget, bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2);
|
|
|
|
void FillRect(DrawTarget& aDrawTarget, 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
|
|
|
|
|