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 {
|
2019-04-16 10:24:49 +03:00
|
|
|
class PresShell;
|
2014-10-20 13:55:48 +04:00
|
|
|
namespace gfx {
|
|
|
|
class DrawTarget;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
2014-10-20 13:55:48 +04:00
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
nsIFrame* NS_NewBoxFrame(mozilla::PresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
mozilla::ComputedStyle* aStyle, bool aIsRoot,
|
2011-07-11 18:05:10 +04:00
|
|
|
nsBoxLayout* aLayoutManager);
|
2019-04-16 10:24:49 +03:00
|
|
|
nsIFrame* NS_NewBoxFrame(mozilla::PresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
mozilla::ComputedStyle* aStyle);
|
2002-01-10 17:16:05 +03:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
class nsBoxFrame : public nsContainerFrame {
|
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
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
friend nsIFrame* NS_NewBoxFrame(mozilla::PresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aStyle, bool aIsRoot,
|
2011-07-11 18:05:10 +04:00
|
|
|
nsBoxLayout* aLayoutManager);
|
2019-04-16 10:24:49 +03:00
|
|
|
friend nsIFrame* NS_NewBoxFrame(mozilla::PresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aStyle);
|
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;
|
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;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID, 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, 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,
|
2019-07-18 02:34:45 +03:00
|
|
|
const nsLineList::iterator* aPrevFrameLine,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsFrameList& aFrameList) override;
|
2014-05-28 23:36:58 +04:00
|
|
|
virtual void RemoveFrame(ChildListID aListID, 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
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
virtual void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) 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 {
|
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
|
2019-06-05 02:41:20 +03:00
|
|
|
// NS_UNCONSTRAINEDSIZE wide.)
|
2007-02-24 21:33:33 +03:00
|
|
|
return nsContainerFrame::IsFrameOfType(
|
2008-07-14 02:41:18 +04:00
|
|
|
aFlags & ~(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,
|
2017-12-14 18:21:49 +03:00
|
|
|
const ReflowInput* aReflowInput) 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
|
|
|
|
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
|
|
|
|
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:
|
2019-02-05 19:45:54 +03:00
|
|
|
explicit nsBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
|
|
|
|
: nsBoxFrame(aStyle, aPresContext, kClassID, false, nullptr) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
1999-03-27 04:35:55 +03:00
|
|
|
protected:
|
2019-02-05 19:45:54 +03:00
|
|
|
nsBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID,
|
|
|
|
bool aIsRoot = false, nsBoxLayout* aLayoutManager = nullptr);
|
2017-05-26 13:11:11 +03:00
|
|
|
virtual ~nsBoxFrame();
|
2017-04-30 18:30:08 +03: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:
|
2010-11-30 17:59:46 +03:00
|
|
|
virtual void UpdateMouseThrough();
|
2002-10-10 10:39:30 +04:00
|
|
|
|
2010-11-30 17:59:46 +03:00
|
|
|
void CacheAttributes();
|
2002-10-10 10:39:30 +04:00
|
|
|
|
|
|
|
// instance variables.
|
|
|
|
Halignment mHalign;
|
|
|
|
Valignment mValign;
|
|
|
|
|
1999-03-27 04:35:55 +03:00
|
|
|
}; // class nsBoxFrame
|
|
|
|
|
1999-03-30 08:05:49 +04:00
|
|
|
#endif
|