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/. */
|
1999-03-27 04:35:55 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Eric D Vaughan
|
1999-05-10 01:46:24 +04: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 04:35:55 +03:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
1999-03-30 08:05:49 +04:00
|
|
|
#ifndef nsBoxFrame_h___
|
|
|
|
#define nsBoxFrame_h___
|
|
|
|
|
2012-09-14 20:10:08 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
1999-07-02 09:28:32 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2000-09-01 04:59:09 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2011-07-04 18:39:10 +04:00
|
|
|
#include "nsBoxLayout.h"
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
class nsBoxLayoutState;
|
1999-07-02 09:28:32 +04:00
|
|
|
|
2014-10-20 13:55:48 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
class DrawTarget;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2014-10-20 13:55:48 +04:00
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsRoot,
|
2011-07-11 18:05:10 +04:00
|
|
|
nsBoxLayout* aLayoutManager);
|
2009-01-19 21:31:33 +03:00
|
|
|
nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
2002-01-10 17:16:05 +03:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
class nsBoxFrame : public nsContainerFrame
|
1999-03-27 04:35:55 +03:00
|
|
|
{
|
2014-10-20 13:55:48 +04:00
|
|
|
protected:
|
2014-10-20 13:55:48 +04:00
|
|
|
typedef mozilla::gfx::DrawTarget DrawTarget;
|
|
|
|
|
1999-03-27 04:35:55 +03:00
|
|
|
public:
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2014-01-18 11:08:22 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsBoxFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
|
|
|
#endif
|
1999-03-27 04:35:55 +03:00
|
|
|
|
2005-10-27 01:46:39 +04:00
|
|
|
friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
|
2006-03-27 01:30:36 +04:00
|
|
|
nsStyleContext* aContext,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsRoot,
|
2011-07-11 18:05:10 +04:00
|
|
|
nsBoxLayout* aLayoutManager);
|
2009-01-19 21:31:33 +03:00
|
|
|
friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
2000-04-05 04:19:00 +04:00
|
|
|
|
1999-09-10 04:57:01 +04: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-10 01:02:40 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetLayoutManager(nsBoxLayout* aLayout) override { mLayoutManager = aLayout; }
|
|
|
|
virtual nsBoxLayout* GetLayoutManager() override { return mLayoutManager; }
|
2011-07-04 18:39:10 +04:00
|
|
|
|
2015-12-07 21:17:47 +03:00
|
|
|
virtual nsresult RelayoutChildAtOrdinal(nsIFrame* aChild) override;
|
1999-09-10 04:57:01 +04:00
|
|
|
|
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-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult SetDebug(nsBoxLayoutState& aBoxLayoutState, bool aDebug) override;
|
|
|
|
virtual nsresult GetDebug(bool& aDebug) override;
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual Valignment GetVAlign() const override { return mValign; }
|
|
|
|
virtual Halignment GetHAlign() const override { return mHalign; }
|
|
|
|
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState) override;
|
2000-04-25 11:10:48 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool ComputesOwnOverflowArea() override { return false; }
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// ----- child and sibling operations ---
|
|
|
|
|
|
|
|
// ----- public methods -------
|
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
virtual void Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aPrevInFlow) override;
|
1999-03-27 04:35:55 +03:00
|
|
|
|
1999-05-10 01:46:24 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2014-02-18 12:36:33 +04:00
|
|
|
nsIAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t aModType) override;
|
1999-03-27 04:35:55 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void MarkIntrinsicISizesDirty() override;
|
|
|
|
virtual nscoord GetMinISize(nsRenderingContext *aRenderingContext) override;
|
|
|
|
virtual nscoord GetPrefISize(nsRenderingContext *aRenderingContext) override;
|
2000-02-25 07:18:34 +03:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsReflowStatus& aStatus) override;
|
1999-03-27 04:35:55 +03:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void SetInitialChildList(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aChildList) override;
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void AppendFrames(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aFrameList) override;
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void InsertFrames(ChildListID aListID,
|
|
|
|
nsIFrame* aPrevFrame,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aFrameList) override;
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void RemoveFrame(ChildListID aListID,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame* aOldFrame) override;
|
1999-04-13 01:48:21 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsContainerFrame* GetContentInsertionFrame() override;
|
2007-10-26 03:30:49 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) override;
|
2006-04-18 03:58:17 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsIAtom* GetType() const override;
|
2007-02-24 21:33:33 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override
|
2007-02-24 21:33:33 +03:00
|
|
|
{
|
2008-07-14 02:41:18 +04: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 21:33:33 +03: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-14 02:41:18 +04:00
|
|
|
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock | eXULBox |
|
|
|
|
nsIFrame::eExcludesIgnorableWhitespace));
|
2007-02-24 21:33:33 +03:00
|
|
|
}
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override;
|
2001-09-15 04:45:54 +04:00
|
|
|
#endif
|
1999-07-14 21:32:56 +04:00
|
|
|
|
2014-05-13 04:47:53 +04:00
|
|
|
virtual void DidReflow(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState* aReflowState,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsDidReflowStatus aStatus) override;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool HonorPrintBackgroundSettings() override;
|
2007-10-12 22:37:51 +04:00
|
|
|
|
1999-08-27 10:06:39 +04:00
|
|
|
virtual ~nsBoxFrame();
|
2001-09-26 02:17:00 +04:00
|
|
|
|
2015-01-06 12:27:56 +03:00
|
|
|
explicit nsBoxFrame(nsStyleContext* aContext, bool aIsRoot = false, nsBoxLayout* aLayoutManager = nullptr);
|
2007-07-04 19:49:38 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
// virtual so nsStackFrame, nsButtonBoxFrame, nsSliderFrame and nsMenuFrame
|
|
|
|
// can override it
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
2000-09-01 04:59:09 +04:00
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsDisplayListSet& aLists) override;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_LAYOUT
|
2012-08-06 07:00:57 +04:00
|
|
|
virtual void SetDebugOnChildList(nsBoxLayoutState& aState, nsIFrame* aChild, bool aDebug);
|
|
|
|
nsresult DisplayDebugInfoFor(nsIFrame* aBox,
|
2006-01-26 05:29:17 +03:00
|
|
|
nsPoint& aPoint);
|
2004-09-28 22:37:50 +04:00
|
|
|
#endif
|
|
|
|
|
2012-08-06 07:00:57 +04:00
|
|
|
static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox, const nsRect& aRect);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2006-01-26 05:29:17 +03: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 15:12:27 +04:00
|
|
|
void WrapListsInRedirector(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aIn,
|
|
|
|
const nsDisplayListSet& aOut);
|
2005-02-11 16:18:40 +03:00
|
|
|
|
2009-01-09 03:11:30 +03:00
|
|
|
/**
|
|
|
|
* This defaults to true, but some box frames (nsListBoxBodyFrame for
|
|
|
|
* example) don't support ordinals in their children.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool SupportsOrdinalsInChildren();
|
2009-01-09 03:11:30 +03:00
|
|
|
|
1999-03-27 04:35:55 +03:00
|
|
|
protected:
|
2002-09-10 01:32:33 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void GetBoxName(nsAutoString& aName) override;
|
2011-04-08 05:04:40 +04:00
|
|
|
void PaintXULDebugBackground(nsRenderingContext& aRenderingContext,
|
2006-01-26 05:29:17 +03:00
|
|
|
nsPoint aPt);
|
2014-10-20 13:55:48 +04:00
|
|
|
void PaintXULDebugOverlay(DrawTarget& aRenderingContext,
|
2006-01-26 05:29:17 +03:00
|
|
|
nsPoint aPt);
|
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
|
|
|
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 11:02:06 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
|
2000-02-14 04:42:09 +03:00
|
|
|
|
2000-06-06 05:25:03 +04:00
|
|
|
nsSize mPrefSize;
|
|
|
|
nsSize mMinSize;
|
|
|
|
nsSize mMaxSize;
|
|
|
|
nscoord mFlex;
|
|
|
|
nscoord mAscent;
|
|
|
|
|
2011-07-11 18:05:10 +04:00
|
|
|
nsCOMPtr<nsBoxLayout> mLayoutManager;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2012-07-28 02:01:12 +04:00
|
|
|
// Get the point associated with this event. Returns true if a single valid
|
|
|
|
// point was found. Otherwise false.
|
2013-10-02 07:46:03 +04:00
|
|
|
bool GetEventPoint(mozilla::WidgetGUIEvent* aEvent, nsPoint& aPoint);
|
2012-07-28 02:01:12 +04: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-02 01:27:41 +03:00
|
|
|
bool GetEventPoint(mozilla::WidgetGUIEvent* aEvent,
|
|
|
|
mozilla::LayoutDeviceIntPoint& aPoint);
|
2012-07-28 02:01:12 +04:00
|
|
|
|
2002-02-21 16:39:39 +03:00
|
|
|
protected:
|
2013-03-20 05:47:48 +04:00
|
|
|
void RegUnregAccessKey(bool aDoReg);
|
2002-07-03 20:38:15 +04:00
|
|
|
|
2014-06-02 16:08:21 +04:00
|
|
|
void CheckBoxOrder();
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2002-02-21 16:39:39 +03:00
|
|
|
private:
|
2002-10-10 10:39:30 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult SetDebug(nsPresContext* aPresContext, bool aDebug);
|
|
|
|
bool GetInitialDebug(bool& aDebug);
|
2015-12-07 04:15:53 +03:00
|
|
|
void GetDebugPref();
|
2004-06-19 13:07:47 +04:00
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
void GetDebugBorder(nsMargin& aInset);
|
|
|
|
void GetDebugPadding(nsMargin& aInset);
|
|
|
|
void GetDebugMargin(nsMargin& aInset);
|
2004-06-19 13:07:47 +04:00
|
|
|
|
2012-08-06 07:00:57 +04:00
|
|
|
nsresult GetFrameSizeWithMargin(nsIFrame* aBox, nsSize& aSize);
|
2004-06-19 13:07:47 +04:00
|
|
|
|
2015-12-07 04:15:53 +03:00
|
|
|
void PixelMarginToTwips(nsMargin& aMarginPixels);
|
2002-10-10 10:39:30 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void GetValue(nsPresContext* aPresContext, const nsSize& a, const nsSize& b, char* value);
|
2012-08-22 19:56:38 +04:00
|
|
|
void GetValue(nsPresContext* aPresContext, int32_t a, int32_t b, char* value);
|
2014-10-20 13:55:48 +04: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 18:49:56 +03:00
|
|
|
#endif
|
2010-11-30 17:59:46 +03:00
|
|
|
virtual void UpdateMouseThrough();
|
2002-10-10 10:39:30 +04:00
|
|
|
|
|
|
|
void CacheAttributes();
|
|
|
|
|
|
|
|
// instance variables.
|
|
|
|
Halignment mHalign;
|
|
|
|
Valignment mValign;
|
|
|
|
|
2004-06-19 13:07:47 +04:00
|
|
|
#ifdef DEBUG_LAYOUT
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool gDebug;
|
2012-08-06 07:00:57 +04:00
|
|
|
static nsIFrame* mDebugChild;
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2002-10-10 10:39:30 +04:00
|
|
|
|
1999-03-27 04:35:55 +03:00
|
|
|
}; // class nsBoxFrame
|
|
|
|
|
1999-03-30 08:05:49 +04:00
|
|
|
#endif
|
|
|
|
|