2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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.
|
2017-07-06 15:00:35 +03:00
|
|
|
|
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:
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsBoxFrame)
|
2014-01-18 11:08:22 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_DECL_QUERYFRAME
|
|
|
|
#endif
|
1999-03-27 04:35:55 +03:00
|
|
|
|
2017-07-06 15:00:35 +03: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
|
|
|
|
2016-04-21 07:28:33 +03:00
|
|
|
virtual void SetXULLayoutManager(nsBoxLayout* aLayout) override { mLayoutManager = aLayout; }
|
2016-04-21 07:28:33 +03:00
|
|
|
virtual nsBoxLayout* GetXULLayoutManager() override { return mLayoutManager; }
|
2011-07-04 18:39:10 +04:00
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
virtual nsresult XULRelayoutChildAtOrdinal(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
|
2016-04-21 07:28:34 +03:00
|
|
|
virtual nsresult SetXULDebug(nsBoxLayoutState& aBoxLayoutState, bool aDebug) override;
|
2016-04-21 07:28:34 +03:00
|
|
|
virtual nsresult GetXULDebug(bool& aDebug) override;
|
2004-06-19 13:07:47 +04:00
|
|
|
#endif
|
2016-04-21 07:28:33 +03:00
|
|
|
virtual Valignment GetXULVAlign() const override { return mValign; }
|
2016-04-21 07:28:33 +03:00
|
|
|
virtual Halignment GetXULHAlign() const override { return mHalign; }
|
2016-04-21 07:28:35 +03:00
|
|
|
NS_IMETHOD DoXULLayout(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 -------
|
2017-07-06 15:00:35 +03:00
|
|
|
|
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
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* 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;
|
2017-06-09 22:14:53 +03:00
|
|
|
virtual nscoord GetMinISize(gfxContext *aRenderingContext) override;
|
|
|
|
virtual nscoord GetPrefISize(gfxContext *aRenderingContext) override;
|
2000-02-25 07:18:34 +03:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
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 bool IsFrameOfType(uint32_t aFlags) const override
|
2007-02-24 21:33:33 +03:00
|
|
|
{
|
2017-07-06 15:00:35 +03:00
|
|
|
// record that children that are ignorable whitespace should be excluded
|
2008-07-14 02:41:18 +04:00
|
|
|
// (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
|
2016-07-21 13:36:35 +03:00
|
|
|
// that contains a block so ReflowInput doesn't tell us to be
|
2007-02-24 21:33:33 +03:00
|
|
|
// 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,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput* aReflowInput,
|
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
|
|
|
|
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 nsDisplayListSet& aLists);
|
2000-09-01 04:59:09 +04:00
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsDisplayListSet& aLists) override;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
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);
|
2017-07-06 15:00:35 +03:00
|
|
|
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
|
|
|
|
2017-08-09 23:43:47 +03:00
|
|
|
/**
|
|
|
|
* Return our wrapper block, if any.
|
|
|
|
*/
|
|
|
|
void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override;
|
|
|
|
|
2017-05-26 13:11:11 +03:00
|
|
|
private:
|
|
|
|
explicit nsBoxFrame(nsStyleContext* aContext)
|
|
|
|
: nsBoxFrame(aContext, kClassID, false, nullptr) {}
|
1999-03-27 04:35:55 +03:00
|
|
|
protected:
|
2017-05-26 13:11:11 +03:00
|
|
|
nsBoxFrame(nsStyleContext* aContext, ClassID aID, bool aIsRoot = false,
|
2017-04-30 18:30:08 +03:00
|
|
|
nsBoxLayout* aLayoutManager = nullptr);
|
2017-05-26 13:11:11 +03:00
|
|
|
virtual ~nsBoxFrame();
|
2017-04-30 18:30:08 +03:00
|
|
|
|
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;
|
2017-06-09 22:14:53 +03:00
|
|
|
void PaintXULDebugBackground(gfxContext& 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
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
virtual bool GetInitialEqualSize(bool& aEqualSize);
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual void GetInitialOrientation(bool& aIsHorizontal);
|
|
|
|
virtual void GetInitialDirection(bool& aIsNormal);
|
2017-07-06 15:00:35 +03:00
|
|
|
virtual bool GetInitialHAlignment(Halignment& aHalign);
|
|
|
|
virtual bool GetInitialVAlignment(Valignment& aValign);
|
|
|
|
virtual bool GetInitialAutoStretch(bool& aStretch);
|
|
|
|
|
2017-11-07 03:20:33 +03:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) 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
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
private:
|
2002-10-10 10:39:30 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_LAYOUT
|
2016-04-21 07:28:34 +03:00
|
|
|
nsresult SetXULDebug(nsPresContext* aPresContext, bool aDebug);
|
2011-09-29 10:19:26 +04:00
|
|
|
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
|
|
|
|
|