2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-10-01 01:01:11 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-10-01 01:01:11 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-10-01 01:01:11 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-29 22:29:03 +04:00
|
|
|
|
|
|
|
/* base class #1 for rendering objects that have child lists */
|
|
|
|
|
1998-10-01 01:01:11 +04:00
|
|
|
#ifndef nsContainerFrame_h___
|
|
|
|
#define nsContainerFrame_h___
|
|
|
|
|
|
|
|
#include "nsSplittableFrame.h"
|
1999-01-16 01:53:39 +03:00
|
|
|
#include "nsFrameList.h"
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
#include "nsLayoutUtils.h"
|
1998-10-01 01:01:11 +04:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
// Option flags for ReflowChild() and FinishReflowChild()
|
|
|
|
// member functions
|
|
|
|
#define NS_FRAME_NO_MOVE_VIEW 0x0001
|
|
|
|
#define NS_FRAME_NO_MOVE_FRAME (0x0002 | NS_FRAME_NO_MOVE_VIEW)
|
|
|
|
#define NS_FRAME_NO_SIZE_VIEW 0x0004
|
2001-09-06 00:27:19 +04:00
|
|
|
#define NS_FRAME_NO_VISIBILITY 0x0008
|
1999-11-19 18:33:29 +03:00
|
|
|
|
1998-10-01 01:01:11 +04:00
|
|
|
/**
|
|
|
|
* Implementation of a container frame.
|
|
|
|
*/
|
|
|
|
class nsContainerFrame : public nsSplittableFrame
|
|
|
|
{
|
|
|
|
public:
|
1999-01-16 01:53:39 +03:00
|
|
|
// nsIFrame overrides
|
2006-12-25 21:53:52 +03:00
|
|
|
NS_IMETHOD Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow);
|
|
|
|
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList);
|
|
|
|
NS_IMETHOD AppendFrames(nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList);
|
|
|
|
NS_IMETHOD InsertFrames(nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList);
|
|
|
|
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame);
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
|
|
|
|
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
|
2006-04-10 04:16:29 +04:00
|
|
|
virtual void Destroy();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
virtual void ChildIsDirty(nsIFrame* aChild);
|
2000-01-12 11:28:24 +03:00
|
|
|
|
2005-08-17 02:52:48 +04:00
|
|
|
virtual PRBool IsLeaf() const;
|
2006-12-15 12:32:24 +03:00
|
|
|
virtual PRBool PeekOffsetNoAmount(PRBool aForward, PRInt32* aOffset);
|
|
|
|
virtual PRBool PeekOffsetCharacter(PRBool aForward, PRInt32* aOffset);
|
2005-08-17 02:52:48 +04:00
|
|
|
|
1999-09-01 05:02:16 +04:00
|
|
|
#ifdef DEBUG
|
2005-09-07 01:34:50 +04:00
|
|
|
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
2000-01-12 11:28:24 +03:00
|
|
|
#endif
|
1998-10-01 01:01:11 +04:00
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
// nsContainerFrame methods
|
2004-08-01 03:15:21 +04:00
|
|
|
virtual void DeleteNextInFlowChild(nsPresContext* aPresContext,
|
2002-10-09 00:35:26 +04:00
|
|
|
nsIFrame* aNextInFlow);
|
1998-10-01 01:01:11 +04:00
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
static PRInt32 LengthOf(nsIFrame* aFrameList) {
|
|
|
|
nsFrameList tmp(aFrameList);
|
|
|
|
return tmp.GetLength();
|
|
|
|
}
|
1998-10-01 01:01:11 +04:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
// Positions the frame's view based on the frame's origin
|
2004-12-27 18:05:18 +03:00
|
|
|
static void PositionFrameView(nsIFrame* aKidFrame);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
// Set the view's size and position after its frame has been reflowed.
|
1999-11-19 18:33:29 +03:00
|
|
|
//
|
|
|
|
// Flags:
|
|
|
|
// NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
|
|
|
|
// don't want to automatically sync the frame and view
|
1999-11-30 07:48:34 +03:00
|
|
|
// NS_FRAME_NO_SIZE_VIEW - don't size the view
|
2004-08-01 03:15:21 +04:00
|
|
|
static void SyncFrameViewAfterReflow(nsPresContext* aPresContext,
|
1999-11-19 18:33:29 +03:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIView* aView,
|
1999-11-30 07:48:34 +03:00
|
|
|
const nsRect* aCombinedArea,
|
1999-11-19 18:33:29 +03:00
|
|
|
PRUint32 aFlags = 0);
|
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
// Sets the view's attributes from the frame style.
|
|
|
|
// - opacity
|
|
|
|
// - visibility
|
|
|
|
// - content transparency
|
|
|
|
// - clip
|
|
|
|
// Call this when one of these styles changes or when the view has just
|
|
|
|
// been created.
|
|
|
|
// @param aStyleContext can be null, in which case the frame's style context is used
|
2004-08-01 03:15:21 +04:00
|
|
|
static void SyncFrameViewProperties(nsPresContext* aPresContext,
|
2002-09-30 15:56:37 +04:00
|
|
|
nsIFrame* aFrame,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aStyleContext,
|
2002-09-30 15:56:37 +04:00
|
|
|
nsIView* aView,
|
|
|
|
PRUint32 aFlags = 0);
|
|
|
|
|
|
|
|
// Returns PR_TRUE if the frame requires a view
|
2003-10-17 06:38:37 +04:00
|
|
|
static PRBool FrameNeedsView(nsIFrame* aFrame);
|
2002-09-30 15:56:37 +04:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// Used by both nsInlineFrame and nsFirstLetterFrame.
|
|
|
|
void DoInlineIntrinsicWidth(nsIRenderingContext *aRenderingContext,
|
|
|
|
InlineIntrinsicWidthData *aData,
|
|
|
|
nsLayoutUtils::IntrinsicWidthType aType);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the CSS block concept of computing 'auto' widths, which most
|
|
|
|
* classes derived from nsContainerFrame want.
|
|
|
|
*/
|
|
|
|
virtual nsSize ComputeAutoSize(nsIRenderingContext *aRenderingContext,
|
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder,
|
|
|
|
nsSize aPadding, PRBool aShrinkWrap);
|
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
/**
|
|
|
|
* Invokes the WillReflow() function, positions the frame and its view (if
|
|
|
|
* requested), and then calls Reflow(). If the reflow succeeds and the child
|
2002-10-09 00:35:26 +04:00
|
|
|
* frame is complete, deletes any next-in-flows using DeleteNextInFlowChild()
|
1999-11-19 18:33:29 +03:00
|
|
|
*
|
|
|
|
* Flags:
|
|
|
|
* NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
|
|
|
|
* don't want to automatically sync the frame and view
|
|
|
|
* NS_FRAME_NO_MOVE_VIEW - don't move the frame. aX and aY are ignored in this
|
|
|
|
* case. Also implies NS_FRAME_NO_MOVE_VIEW
|
|
|
|
*/
|
|
|
|
nsresult ReflowChild(nsIFrame* aKidFrame,
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* aPresContext,
|
1999-11-19 18:33:29 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
PRUint32 aFlags,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The second half of frame reflow. Does the following:
|
|
|
|
* - sets the frame's bounds
|
|
|
|
* - sizes and positions (if requested) the frame's view. If the frame's final
|
|
|
|
* position differs from the current position and the frame itself does not
|
|
|
|
* have a view, then any child frames with views are positioned so they stay
|
|
|
|
* in sync
|
|
|
|
* - sets the view's visibility, opacity, content transparency, and clip
|
|
|
|
* - invoked the DidReflow() function
|
|
|
|
*
|
|
|
|
* Flags:
|
|
|
|
* NS_FRAME_NO_MOVE_FRAME - don't move the frame. aX and aY are ignored in this
|
|
|
|
* case. Also implies NS_FRAME_NO_MOVE_VIEW
|
|
|
|
* NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
|
|
|
|
* don't want to automatically sync the frame and view
|
|
|
|
* NS_FRAME_NO_SIZE_VIEW - don't size the frame's view
|
|
|
|
*/
|
2001-12-07 17:51:12 +03:00
|
|
|
static nsresult FinishReflowChild(nsIFrame* aKidFrame,
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* aPresContext,
|
2001-12-07 17:51:12 +03:00
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
PRUint32 aFlags);
|
2001-03-12 07:19:10 +03:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2004-12-27 18:05:18 +03:00
|
|
|
static void PositionChildViews(nsIFrame* aFrame);
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds display lists for the children. The background
|
|
|
|
* of each child is placed in the Content() list (suitable for inline
|
|
|
|
* children and other elements that behave like inlines,
|
|
|
|
* but not for in-flow block children of blocks). DOES NOT
|
|
|
|
* paint the background/borders/outline of this frame. This should
|
|
|
|
* probably be avoided and eventually removed. It's currently here
|
|
|
|
* to emulate what nsContainerFrame::Paint did.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
1998-10-01 01:01:11 +04:00
|
|
|
protected:
|
2006-03-27 01:30:36 +04:00
|
|
|
nsContainerFrame(nsStyleContext* aContext) : nsSplittableFrame(aContext) {}
|
1999-01-16 01:53:39 +03:00
|
|
|
~nsContainerFrame();
|
1998-10-01 01:01:11 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* Builds a display list for non-block children that behave like
|
|
|
|
* inlines. This puts the background of each child into the
|
|
|
|
* Content() list (suitable for inline children but not for
|
|
|
|
* in-flow block children of blocks).
|
|
|
|
* @param aForcePseudoStack forces each child into a pseudo-stacking-context
|
|
|
|
* so its background and all other display items (except for positioned
|
|
|
|
* display items) go into the Content() list.
|
|
|
|
*/
|
|
|
|
nsresult BuildDisplayListForNonBlockChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists,
|
|
|
|
PRUint32 aFlags = 0);
|
1998-10-31 01:11:06 +03:00
|
|
|
|
1999-10-21 09:11:43 +04:00
|
|
|
/**
|
|
|
|
* Get the frames on the overflow list
|
|
|
|
*/
|
2004-08-01 03:15:21 +04:00
|
|
|
nsIFrame* GetOverflowFrames(nsPresContext* aPresContext,
|
2000-01-22 04:16:50 +03:00
|
|
|
PRBool aRemoveProperty) const;
|
1999-10-21 09:11:43 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the overflow list
|
|
|
|
*/
|
2004-08-01 03:15:21 +04:00
|
|
|
nsresult SetOverflowFrames(nsPresContext* aPresContext,
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* aOverflowFrames);
|
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
/**
|
|
|
|
* Moves any frames on both the prev-in-flow's overflow list and the
|
|
|
|
* receiver's overflow to the receiver's child list.
|
|
|
|
*
|
|
|
|
* Resets the overlist pointers to nsnull, and updates the receiver's child
|
|
|
|
* count and content mapping.
|
|
|
|
*
|
|
|
|
* @return PR_TRUE if any frames were moved and PR_FALSE otherwise
|
|
|
|
*/
|
2004-08-01 03:15:21 +04:00
|
|
|
PRBool MoveOverflowToChildList(nsPresContext* aPresContext);
|
1998-10-01 01:01:11 +04:00
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
/**
|
|
|
|
* Push aFromChild and its next siblings to the next-in-flow. Change
|
|
|
|
* the geometric parent of each frame that's pushed. If there is no
|
|
|
|
* next-in-flow the frames are placed on the overflow list (and the
|
|
|
|
* geometric parent is left unchanged).
|
|
|
|
*
|
|
|
|
* Updates the next-in-flow's child count. Does <b>not</b> update the
|
|
|
|
* pusher's child count.
|
|
|
|
*
|
|
|
|
* @param aFromChild the first child frame to push. It is disconnected from
|
|
|
|
* aPrevSibling
|
|
|
|
* @param aPrevSibling aFromChild's previous sibling. Must not be null.
|
|
|
|
* It's an error to push a parent's first child frame
|
|
|
|
*/
|
2004-08-01 03:15:21 +04:00
|
|
|
void PushChildren(nsPresContext* aPresContext,
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* aFromChild,
|
|
|
|
nsIFrame* aPrevSibling);
|
1998-10-01 01:01:11 +04:00
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
/**
|
|
|
|
* A helper for frames corresponding to generated content, which is used to
|
|
|
|
* remove the generated content from the tree when the :before or :after
|
|
|
|
* frame is destroyed.
|
|
|
|
*/
|
|
|
|
static void CleanupGeneratedContentIn(nsIContent* aRealContent,
|
|
|
|
nsIFrame* aRoot);
|
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
nsFrameList mFrames;
|
1998-10-01 01:01:11 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsContainerFrame_h___ */
|