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