2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-06-18 20:25:41 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1998-06-18 20:25:41 +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-06-18 20:25:41 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* 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):
|
2000-04-17 18:40:46 +04:00
|
|
|
* Steve Clark <buster@netscape.com>
|
|
|
|
* Robert O'Callahan <roc+moz@cs.cmu.edu>
|
2000-09-05 01:44:48 +04:00
|
|
|
* L. David Baron <dbaron@fas.harvard.edu>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either 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"),
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-03-23 07:28:20 +03:00
|
|
|
|
2001-05-01 08:22:57 +04:00
|
|
|
#ifndef nsBlockReflowState_h__
|
|
|
|
#define nsBlockReflowState_h__
|
|
|
|
|
|
|
|
#include "nsBlockBandData.h"
|
|
|
|
#include "nsLineBox.h"
|
2002-05-29 02:50:43 +04:00
|
|
|
#include "nsFrameList.h"
|
2001-05-01 08:22:57 +04:00
|
|
|
|
2001-08-01 05:27:50 +04:00
|
|
|
class nsBlockFrame;
|
|
|
|
|
1999-03-05 07:21:32 +03:00
|
|
|
class nsBlockReflowState {
|
1998-12-05 19:02:08 +03:00
|
|
|
public:
|
1999-03-05 07:21:32 +03:00
|
|
|
nsBlockReflowState(const nsHTMLReflowState& aReflowState,
|
1999-04-20 04:27:43 +04:00
|
|
|
nsIPresContext* aPresContext,
|
1999-03-05 07:21:32 +03:00
|
|
|
nsBlockFrame* aFrame,
|
2000-01-03 07:32:13 +03:00
|
|
|
const nsHTMLReflowMetrics& aMetrics,
|
|
|
|
PRBool aBlockMarginRoot);
|
1998-09-24 00:10:40 +04:00
|
|
|
|
|
|
|
~nsBlockReflowState();
|
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
/**
|
|
|
|
* Get the available reflow space for the current y coordinate. The
|
|
|
|
* available space is relative to our coordinate system (0,0) is our
|
|
|
|
* upper left corner.
|
|
|
|
*/
|
|
|
|
void GetAvailableSpace() {
|
2001-04-28 06:34:58 +04:00
|
|
|
GetAvailableSpace(mY);
|
1999-09-15 04:28:10 +04:00
|
|
|
}
|
|
|
|
|
2001-05-01 08:22:57 +04:00
|
|
|
void GetAvailableSpace(nscoord aY);
|
1998-09-24 00:10:40 +04:00
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
void InitFloater(nsLineLayout& aLineLayout,
|
|
|
|
nsPlaceholderFrame* aPlaceholderFrame,
|
|
|
|
nsReflowStatus& aReflowStatus);
|
1998-11-10 21:03:29 +03:00
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
void AddFloater(nsLineLayout& aLineLayout,
|
1999-08-28 01:45:37 +04:00
|
|
|
nsPlaceholderFrame* aPlaceholderFrame,
|
2002-05-29 02:50:43 +04:00
|
|
|
PRBool aInitialReflow,
|
|
|
|
nsReflowStatus& aReflowStatus);
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1999-03-31 08:10:27 +04:00
|
|
|
PRBool CanPlaceFloater(const nsRect& aFloaterRect, PRUint8 aFloats);
|
|
|
|
|
2001-05-22 03:03:46 +04:00
|
|
|
void FlowAndPlaceFloater(nsFloaterCache* aFloaterCache,
|
2002-05-29 02:50:43 +04:00
|
|
|
PRBool* aIsLeftFloater,
|
|
|
|
nsReflowStatus& aReflowStatus);
|
1998-09-24 00:10:40 +04:00
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
PRBool PlaceBelowCurrentLineFloaters(nsFloaterCacheList& aFloaters);
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void ClearFloaters(nscoord aY, PRUint8 aBreakType);
|
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
PRBool ClearPastFloaters(PRUint8 aBreakType);
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
PRBool IsAdjacentWithTop() const {
|
1999-03-05 07:21:32 +03:00
|
|
|
return mY == mReflowState.mComputedBorderPadding.top;
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
|
|
|
|
1999-03-05 07:21:32 +03:00
|
|
|
const nsMargin& BorderPadding() const {
|
|
|
|
return mReflowState.mComputedBorderPadding;
|
|
|
|
}
|
|
|
|
|
2000-06-12 02:14:33 +04:00
|
|
|
const nsMargin& Margin() const {
|
|
|
|
return mReflowState.mComputedMargin;
|
|
|
|
}
|
|
|
|
|
2001-05-01 08:22:57 +04:00
|
|
|
void UpdateMaxElementSize(const nsSize& aMaxElementSize);
|
1999-04-03 22:59:01 +04:00
|
|
|
|
2001-05-01 08:22:57 +04:00
|
|
|
void UpdateMaximumWidth(nscoord aMaximumWidth);
|
1999-12-30 07:15:45 +03:00
|
|
|
|
2001-10-25 05:08:40 +04:00
|
|
|
// Reconstruct the previous bottom margin that goes above |aLine|.
|
|
|
|
void ReconstructMarginAbove(nsLineList::iterator aLine);
|
1999-04-03 22:59:01 +04:00
|
|
|
|
1999-08-28 01:45:37 +04:00
|
|
|
void ComputeBlockAvailSpace(nsIFrame* aFrame,
|
|
|
|
nsSplittableType aSplitType,
|
|
|
|
const nsStyleDisplay* aDisplay,
|
|
|
|
nsRect& aResult);
|
1999-04-03 22:59:01 +04:00
|
|
|
|
2001-11-15 10:28:46 +03:00
|
|
|
protected:
|
|
|
|
void RecoverFloaters(nsLineList::iterator aLine, nscoord aDeltaY);
|
|
|
|
|
|
|
|
public:
|
|
|
|
void RecoverStateFrom(nsLineList::iterator aLine, nscoord aDeltaY);
|
1999-04-03 22:59:01 +04:00
|
|
|
|
1999-08-28 01:45:37 +04:00
|
|
|
void AdvanceToNextLine() {
|
|
|
|
mLineNumber++;
|
|
|
|
}
|
|
|
|
|
2001-05-01 08:22:57 +04:00
|
|
|
PRBool IsImpactedByFloater() const;
|
1999-10-15 03:10:03 +04:00
|
|
|
|
1999-10-20 03:04:19 +04:00
|
|
|
nsLineBox* NewLineBox(nsIFrame* aFrame, PRInt32 aCount, PRBool aIsBlock);
|
|
|
|
|
|
|
|
void FreeLineBox(nsLineBox* aLine);
|
|
|
|
|
1999-10-22 00:43:48 +04:00
|
|
|
void StoreMaxElementSize(nsIFrame* aFloater, const nsSize& aSize) {
|
|
|
|
mBand.StoreMaxElementSize(mPresContext, aFloater, aSize);
|
|
|
|
}
|
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
// This state is the "global" state computed once for the reflow of
|
|
|
|
// the block.
|
|
|
|
|
|
|
|
// The block frame that is using this object
|
|
|
|
nsBlockFrame* mBlock;
|
|
|
|
|
1999-04-20 04:27:43 +04:00
|
|
|
nsIPresContext* mPresContext;
|
1999-04-03 22:59:01 +04:00
|
|
|
|
1999-03-05 07:21:32 +03:00
|
|
|
const nsHTMLReflowState& mReflowState;
|
|
|
|
|
2001-10-26 09:06:07 +04:00
|
|
|
nsSpaceManager* mSpaceManager;
|
1999-04-03 22:59:01 +04:00
|
|
|
|
|
|
|
// The coordinates within the spacemanager where the block is being
|
|
|
|
// placed <b>after</b> taking into account the blocks border and
|
|
|
|
// padding. This, therefore, represents the inner "content area" (in
|
|
|
|
// spacemanager coordinates) where child frames will be placed,
|
|
|
|
// including child blocks and floaters.
|
1998-09-28 22:50:59 +04:00
|
|
|
nscoord mSpaceManagerX, mSpaceManagerY;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
// XXX get rid of this
|
1998-12-05 19:02:08 +03:00
|
|
|
nsReflowStatus mReflowStatus;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
nscoord mBottomEdge;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
// The content area to reflow child frames within. The x/y
|
|
|
|
// coordinates are known to be mBorderPadding.left and
|
|
|
|
// mBorderPadding.top. The width/height may be NS_UNCONSTRAINEDSIZE
|
|
|
|
// if the container reflowing this frame has given the frame an
|
|
|
|
// unconstrained area.
|
|
|
|
nsSize mContentArea;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
//----------------------------------------
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
// This state is "running" state updated by the reflow of each line
|
|
|
|
// in the block. This same state is "recovered" when a line is not
|
|
|
|
// dirty and is passed over during incremental reflow.
|
|
|
|
|
|
|
|
// The current line being reflowed
|
2001-10-25 05:08:40 +04:00
|
|
|
// If it is mBlock->end_lines(), then it is invalid.
|
|
|
|
nsLineList::iterator mCurrentLine;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
// The current Y coordinate in the block
|
|
|
|
nscoord mY;
|
|
|
|
|
|
|
|
// The available space within the current band.
|
1998-12-09 00:43:15 +03:00
|
|
|
nsRect mAvailSpaceRect;
|
1999-02-23 22:32:00 +03:00
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
// The maximum x-most of each line
|
|
|
|
nscoord mKidXMost;
|
1999-03-05 07:21:32 +03:00
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
// The combined area of all floaters placed so far
|
|
|
|
nsRect mFloaterCombinedArea;
|
1999-03-05 07:21:32 +03:00
|
|
|
|
2001-05-22 03:03:46 +04:00
|
|
|
// The y-coordinate of the last floater placed. We keep this around
|
|
|
|
// to enforce 9.5.1 rule [2]
|
|
|
|
nscoord mLastFloaterY;
|
|
|
|
|
1999-10-15 03:10:03 +04:00
|
|
|
// For unconstained-width reflow, we keep the right floaters
|
|
|
|
// combined area stored seperately.
|
|
|
|
PRBool mHaveRightFloaters;
|
|
|
|
nsRect mRightFloaterCombinedArea;
|
|
|
|
|
1999-09-15 04:28:10 +04:00
|
|
|
nsFloaterCacheFreeList mFloaterCacheFreeList;
|
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
// next-in-flows of incomplete floaters which get put into overflow lines
|
|
|
|
nsFrameList mOverflowFloaters;
|
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
// Previous child. This is used when pulling up a frame to update
|
|
|
|
// the sibling list.
|
|
|
|
nsIFrame* mPrevChild;
|
1999-03-05 07:21:32 +03:00
|
|
|
|
|
|
|
// The previous child frames collapsed bottom margin value.
|
2001-10-25 05:08:40 +04:00
|
|
|
nsCollapsingMargin mPrevBottomMargin;
|
1999-03-05 07:21:32 +03:00
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
// The current next-in-flow for the block. When lines are pulled
|
|
|
|
// from a next-in-flow, this is used to know which next-in-flow to
|
|
|
|
// pull from. When a next-in-flow is emptied of lines, we advance
|
|
|
|
// this to the next next-in-flow.
|
|
|
|
nsBlockFrame* mNextInFlow;
|
1999-03-05 07:21:32 +03:00
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
// The current band data for the current Y coordinate
|
|
|
|
nsBlockBandData mBand;
|
1999-03-05 07:21:32 +03:00
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
// Temporary line-reflow state. This state is used during the reflow
|
|
|
|
// of a given line, but doesn't have meaning before or after.
|
1999-09-15 04:28:10 +04:00
|
|
|
|
|
|
|
// The list of floaters that are "current-line" floaters. These are
|
|
|
|
// added to the line after the line has been reflowed, to keep the
|
|
|
|
// list fiddling from being N^2.
|
|
|
|
nsFloaterCacheFreeList mCurrentLineFloaters;
|
|
|
|
|
|
|
|
// The list of floaters which are "below current-line"
|
|
|
|
// floaters. These are reflowed/placed after the line is reflowed
|
|
|
|
// and placed. Again, this is done to keep the list fiddling from
|
|
|
|
// being N^2.
|
|
|
|
nsFloaterCacheFreeList mBelowCurrentLineFloaters;
|
1999-04-03 22:59:01 +04:00
|
|
|
|
|
|
|
nsSize mMaxElementSize;
|
1999-12-30 07:15:45 +03:00
|
|
|
nscoord mMaximumWidth;
|
1999-08-28 01:45:37 +04:00
|
|
|
|
|
|
|
nscoord mMinLineHeight;
|
|
|
|
|
|
|
|
PRInt32 mLineNumber;
|
2000-04-17 18:40:46 +04:00
|
|
|
|
|
|
|
// block reflow state flags
|
|
|
|
#define BRS_UNCONSTRAINEDWIDTH 0x00000001
|
|
|
|
#define BRS_UNCONSTRAINEDHEIGHT 0x00000002
|
|
|
|
#define BRS_SHRINKWRAPWIDTH 0x00000004
|
|
|
|
#define BRS_NEEDRESIZEREFLOW 0x00000008
|
2002-04-11 05:13:41 +04:00
|
|
|
#define BRS_NOWRAP 0x00000010
|
|
|
|
#define BRS_ISTOPMARGINROOT 0x00000020 // Is this frame a root for top/bottom margin collapsing?
|
|
|
|
#define BRS_ISBOTTOMMARGINROOT 0x00000040
|
|
|
|
#define BRS_APPLYTOPMARGIN 0x00000080 // See ShouldApplyTopMargin
|
|
|
|
#define BRS_COMPUTEMAXELEMENTSIZE 0x00000100
|
|
|
|
#define BRS_COMPUTEMAXWIDTH 0x00000200
|
|
|
|
#define BRS_DAMAGECONSTRAINED 0x00000400 // is the target of an incremental reflow command inside a text control
|
2002-03-12 18:48:52 +03:00
|
|
|
#define BRS_LASTFLAG BRS_DAMAGECONSTRAINED
|
2000-04-17 18:40:46 +04:00
|
|
|
|
|
|
|
PRInt16 mFlags;
|
2002-07-17 05:48:56 +04:00
|
|
|
|
|
|
|
PRUint8 mFloaterBreakType;
|
2000-04-17 18:40:46 +04:00
|
|
|
|
|
|
|
void SetFlag(PRUint32 aFlag, PRBool aValue)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aFlag<=BRS_LASTFLAG, "bad flag");
|
|
|
|
NS_ASSERTION(aValue==PR_FALSE || aValue==PR_TRUE, "bad value");
|
|
|
|
if (aValue) { // set flag
|
|
|
|
mFlags |= aFlag;
|
|
|
|
}
|
|
|
|
else { // unset flag
|
|
|
|
mFlags &= ~aFlag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool GetFlag(PRUint32 aFlag) const
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aFlag<=BRS_LASTFLAG, "bad flag");
|
|
|
|
PRBool result = (mFlags & aFlag);
|
|
|
|
if (result) return PR_TRUE;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
1998-09-24 00:10:40 +04:00
|
|
|
};
|
2001-05-01 08:22:57 +04:00
|
|
|
|
|
|
|
#endif // nsBlockReflowState_h__
|