2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2001-10-25 05:08:40 +04:00
|
|
|
// vim:cindent:ts=2:et:sw=2:
|
2001-09-29 00:14:13 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-09-15 04:19:49 +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-09-15 04:19:49 +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-09-15 04:19:49 +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 ***** */
|
1998-09-24 00:10:40 +04:00
|
|
|
|
2001-05-01 08:22:57 +04:00
|
|
|
#include "nsBlockReflowContext.h"
|
|
|
|
#include "nsBlockReflowState.h"
|
|
|
|
#include "nsBlockFrame.h"
|
|
|
|
#include "nsLineLayout.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsLayoutAtoms.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#include "nsBlockDebugFlags.h"
|
|
|
|
#endif
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1999-03-05 07:21:32 +03:00
|
|
|
nsBlockReflowState::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)
|
1999-04-03 22:59:01 +04:00
|
|
|
: mBlock(aFrame),
|
|
|
|
mPresContext(aPresContext),
|
1999-03-05 07:21:32 +03:00
|
|
|
mReflowState(aReflowState),
|
2001-05-22 03:03:46 +04:00
|
|
|
mLastFloaterY(0),
|
1999-04-03 22:59:01 +04:00
|
|
|
mNextRCFrame(nsnull),
|
2001-10-25 05:08:40 +04:00
|
|
|
mPrevBottomMargin(),
|
2000-04-17 18:40:46 +04:00
|
|
|
mLineNumber(0),
|
|
|
|
mFlags(0)
|
1998-11-15 00:01:26 +03:00
|
|
|
{
|
2000-01-18 18:36:36 +03:00
|
|
|
const nsMargin& borderPadding = BorderPadding();
|
|
|
|
|
2000-01-03 07:32:13 +03:00
|
|
|
if (aBlockMarginRoot) {
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(BRS_ISTOPMARGINROOT, PR_TRUE);
|
|
|
|
SetFlag(BRS_ISBOTTOMMARGINROOT, PR_TRUE);
|
2000-01-03 07:32:13 +03:00
|
|
|
}
|
2000-01-13 05:05:31 +03:00
|
|
|
if (0 != aReflowState.mComputedBorderPadding.top) {
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(BRS_ISTOPMARGINROOT, PR_TRUE);
|
2000-01-13 05:05:31 +03:00
|
|
|
}
|
|
|
|
if (0 != aReflowState.mComputedBorderPadding.bottom) {
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(BRS_ISBOTTOMMARGINROOT, PR_TRUE);
|
2000-01-13 05:05:31 +03:00
|
|
|
}
|
2000-04-17 18:40:46 +04:00
|
|
|
if (GetFlag(BRS_ISTOPMARGINROOT)) {
|
|
|
|
SetFlag(BRS_APPLYTOPMARGIN, PR_TRUE);
|
2000-01-03 07:32:13 +03:00
|
|
|
}
|
|
|
|
|
1999-07-20 07:41:03 +04:00
|
|
|
mSpaceManager = aReflowState.mSpaceManager;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
2001-10-26 09:06:07 +04:00
|
|
|
NS_ASSERTION(mSpaceManager,
|
|
|
|
"SpaceManager should be set in nsBlockReflowState" );
|
|
|
|
if (mSpaceManager) {
|
2000-01-18 18:36:36 +03:00
|
|
|
// Translate into our content area and then save the
|
|
|
|
// coordinate system origin for later.
|
|
|
|
mSpaceManager->Translate(borderPadding.left, borderPadding.top);
|
|
|
|
mSpaceManager->GetTranslation(mSpaceManagerX, mSpaceManagerY);
|
|
|
|
}
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
mReflowStatus = NS_FRAME_COMPLETE;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
mPresContext = aPresContext;
|
2001-10-25 05:08:40 +04:00
|
|
|
mBlock->GetNextInFlow(NS_REINTERPRET_CAST(nsIFrame**, &mNextInFlow));
|
1998-12-05 19:02:08 +03:00
|
|
|
mKidXMost = 0;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1999-03-05 07:21:32 +03:00
|
|
|
// Compute content area width (the content area is inside the border
|
|
|
|
// and padding)
|
1999-07-20 07:41:03 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedWidth) {
|
|
|
|
mContentArea.width = aReflowState.mComputedWidth;
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
|
|
|
else {
|
1999-03-05 07:21:32 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth) {
|
1998-12-05 19:02:08 +03:00
|
|
|
mContentArea.width = NS_UNCONSTRAINEDSIZE;
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(BRS_UNCONSTRAINEDWIDTH, PR_TRUE);
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
2000-01-03 07:32:13 +03:00
|
|
|
else if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedMaxWidth) {
|
|
|
|
// Choose a width based on the content (shrink wrap width) up
|
|
|
|
// to the maximum width
|
|
|
|
mContentArea.width = aReflowState.mComputedMaxWidth;
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(BRS_SHRINKWRAPWIDTH, PR_TRUE);
|
2000-01-03 07:32:13 +03:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
1999-03-05 07:21:32 +03:00
|
|
|
nscoord lr = borderPadding.left + borderPadding.right;
|
|
|
|
mContentArea.width = aReflowState.availableWidth - lr;
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
|
|
|
}
|
1999-10-15 03:10:03 +04:00
|
|
|
mHaveRightFloaters = PR_FALSE;
|
1998-12-30 20:50:00 +03:00
|
|
|
|
1999-03-05 07:21:32 +03:00
|
|
|
// Compute content area height. Unlike the width, if we have a
|
|
|
|
// specified style height we ignore it since extra content is
|
|
|
|
// managed by the "overflow" property. When we don't have a
|
|
|
|
// specified style height then we may end up limiting our height if
|
|
|
|
// the availableHeight is constrained (this situation occurs when we
|
|
|
|
// are paginated).
|
1999-03-23 07:28:20 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight) {
|
1999-04-03 22:59:01 +04:00
|
|
|
// We are in a paginated situation. The bottom edge is just inside
|
|
|
|
// the bottom border and padding. The content area height doesn't
|
|
|
|
// include either border or padding edge.
|
|
|
|
mBottomEdge = aReflowState.availableHeight - borderPadding.bottom;
|
|
|
|
mContentArea.height = mBottomEdge - borderPadding.top;
|
1999-03-23 07:28:20 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// When we are not in a paginated situation then we always use
|
|
|
|
// an constrained height.
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(BRS_UNCONSTRAINEDHEIGHT, PR_TRUE);
|
1999-04-03 22:59:01 +04:00
|
|
|
mContentArea.height = mBottomEdge = NS_UNCONSTRAINEDSIZE;
|
1999-03-05 07:21:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mY = borderPadding.top;
|
1999-04-03 22:59:01 +04:00
|
|
|
mBand.Init(mSpaceManager, mContentArea);
|
1998-12-05 19:02:08 +03:00
|
|
|
|
|
|
|
mPrevChild = nsnull;
|
2001-10-25 05:08:40 +04:00
|
|
|
mCurrentLine = aFrame->end_lines();
|
1999-03-05 07:21:32 +03:00
|
|
|
|
|
|
|
const nsStyleText* styleText;
|
|
|
|
mBlock->GetStyleData(eStyleStruct_Text,
|
|
|
|
(const nsStyleStruct*&) styleText);
|
|
|
|
switch (styleText->mWhiteSpace) {
|
|
|
|
case NS_STYLE_WHITESPACE_PRE:
|
|
|
|
case NS_STYLE_WHITESPACE_NOWRAP:
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(BRS_NOWRAP, PR_TRUE);
|
1999-03-05 07:21:32 +03:00
|
|
|
break;
|
|
|
|
default:
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(BRS_NOWRAP, PR_FALSE);
|
1999-03-05 07:21:32 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(BRS_COMPUTEMAXELEMENTSIZE, (nsnull != aMetrics.maxElementSize));
|
2000-05-14 08:56:25 +04:00
|
|
|
#ifdef NOISY_MAX_ELEMENT_SIZE
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("BRS: setting compute-MES to %d\n", (nsnull != aMetrics.maxElementSize));
|
2000-05-14 08:56:25 +04:00
|
|
|
#endif
|
1999-03-05 07:21:32 +03:00
|
|
|
mMaxElementSize.SizeTo(0, 0);
|
2000-04-17 18:40:46 +04:00
|
|
|
SetFlag(BRS_COMPUTEMAXWIDTH,
|
|
|
|
(NS_REFLOW_CALC_MAX_WIDTH == (aMetrics.mFlags & NS_REFLOW_CALC_MAX_WIDTH)));
|
1999-12-30 07:15:45 +03:00
|
|
|
mMaximumWidth = 0;
|
1999-03-05 07:21:32 +03:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
mMinLineHeight = nsHTMLReflowState::CalcLineHeight(mPresContext,
|
1999-09-10 00:53:32 +04:00
|
|
|
aReflowState.rendContext,
|
1999-08-28 01:45:37 +04:00
|
|
|
aReflowState.frame);
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
nsBlockReflowState::~nsBlockReflowState()
|
1998-09-24 00:10:40 +04:00
|
|
|
{
|
2001-11-03 08:18:39 +03:00
|
|
|
// Restore the coordinate system, unless the space manager is null,
|
|
|
|
// which means it was just destroyed.
|
|
|
|
if (mSpaceManager) {
|
|
|
|
const nsMargin& borderPadding = BorderPadding();
|
|
|
|
mSpaceManager->Translate(-borderPadding.left, -borderPadding.top);
|
|
|
|
}
|
1999-10-20 03:04:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsLineBox*
|
|
|
|
nsBlockReflowState::NewLineBox(nsIFrame* aFrame,
|
|
|
|
PRInt32 aCount,
|
|
|
|
PRBool aIsBlock)
|
|
|
|
{
|
2000-03-12 06:00:51 +03:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
mPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
|
|
|
|
return NS_NewLineBox(shell, aFrame, aCount, aIsBlock);
|
1999-10-20 03:04:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockReflowState::FreeLineBox(nsLineBox* aLine)
|
|
|
|
{
|
|
|
|
if (aLine) {
|
2000-03-12 06:00:51 +03:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
|
|
|
|
aLine->Destroy(presShell);
|
1999-10-20 03:04:19 +04:00
|
|
|
}
|
1998-09-24 00:10:40 +04:00
|
|
|
}
|
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
// Compute the amount of available space for reflowing a block frame
|
|
|
|
// at the current Y coordinate. This method assumes that
|
|
|
|
// GetAvailableSpace has already been called.
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
1999-08-28 01:45:37 +04:00
|
|
|
nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
|
|
|
|
nsSplittableType aSplitType,
|
|
|
|
const nsStyleDisplay* aDisplay,
|
1999-04-03 22:59:01 +04:00
|
|
|
nsRect& aResult)
|
1998-09-24 00:10:40 +04:00
|
|
|
{
|
2000-04-17 18:40:46 +04:00
|
|
|
#ifdef REALLY_NOISY_REFLOW
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("CBAS frame=%p has floater count %d\n", aFrame, mBand.GetFloaterCount());
|
2000-04-17 18:40:46 +04:00
|
|
|
mBand.List();
|
|
|
|
#endif
|
1999-09-16 23:56:36 +04:00
|
|
|
aResult.y = mY;
|
2000-04-17 18:40:46 +04:00
|
|
|
aResult.height = GetFlag(BRS_UNCONSTRAINEDHEIGHT)
|
1999-04-03 22:59:01 +04:00
|
|
|
? NS_UNCONSTRAINEDSIZE
|
|
|
|
: mBottomEdge - mY;
|
1998-09-24 00:10:40 +04:00
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
const nsMargin& borderPadding = BorderPadding();
|
1999-08-28 01:45:37 +04:00
|
|
|
|
2000-09-15 10:20:07 +04:00
|
|
|
/* bug 18445: treat elements mapped to display: block such as text controls
|
|
|
|
* just like normal blocks */
|
|
|
|
PRBool treatAsNotSplittable=PR_FALSE;
|
|
|
|
nsCOMPtr<nsIAtom>frameType;
|
|
|
|
aFrame->GetFrameType(getter_AddRefs(frameType));
|
2001-07-04 06:00:05 +04:00
|
|
|
if (frameType) {
|
|
|
|
// text controls are not splittable, so make a special case here
|
|
|
|
// XXXldb Why not just set the frame state bit?
|
2000-09-15 10:20:07 +04:00
|
|
|
if (nsLayoutAtoms::textInputFrame == frameType.get())
|
|
|
|
treatAsNotSplittable = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_FRAME_SPLITTABLE_NON_RECTANGULAR == aSplitType || // normal blocks
|
|
|
|
NS_FRAME_NOT_SPLITTABLE == aSplitType || // things like images mapped to display: block
|
|
|
|
PR_TRUE == treatAsNotSplittable) // text input controls mapped to display: block (special case)
|
2000-09-12 00:46:44 +04:00
|
|
|
{
|
1999-09-16 23:56:36 +04:00
|
|
|
if (mBand.GetFloaterCount()) {
|
|
|
|
// Use the float-edge property to determine how the child block
|
|
|
|
// will interact with the floater.
|
2001-02-07 12:57:26 +03:00
|
|
|
const nsStyleBorder* borderStyle;
|
|
|
|
aFrame->GetStyleData(eStyleStruct_Border,
|
|
|
|
(const nsStyleStruct*&) borderStyle);
|
|
|
|
switch (borderStyle->mFloatEdge) {
|
1999-09-16 23:56:36 +04:00
|
|
|
default:
|
2000-03-23 02:19:10 +03:00
|
|
|
case NS_STYLE_FLOAT_EDGE_CONTENT: // content and only content does runaround of floaters
|
1999-09-16 23:56:36 +04:00
|
|
|
// The child block will flow around the floater. Therefore
|
|
|
|
// give it all of the available space.
|
|
|
|
aResult.x = borderPadding.left;
|
2000-04-17 18:40:46 +04:00
|
|
|
aResult.width = GetFlag(BRS_UNCONSTRAINEDWIDTH)
|
1999-09-16 23:56:36 +04:00
|
|
|
? NS_UNCONSTRAINEDSIZE
|
|
|
|
: mContentArea.width;
|
2000-03-23 02:19:10 +03:00
|
|
|
break;
|
|
|
|
case NS_STYLE_FLOAT_EDGE_BORDER:
|
1999-09-16 23:56:36 +04:00
|
|
|
case NS_STYLE_FLOAT_EDGE_PADDING:
|
|
|
|
{
|
|
|
|
// The child block's border should be placed adjacent to,
|
|
|
|
// but not overlap the floater(s).
|
|
|
|
nsMargin m(0, 0, 0, 0);
|
2001-02-07 12:57:26 +03:00
|
|
|
const nsStyleMargin* styleMargin;
|
|
|
|
aFrame->GetStyleData(eStyleStruct_Margin,
|
|
|
|
(const nsStyleStruct*&) styleMargin);
|
|
|
|
styleMargin->GetMargin(m); // XXX percentage margins
|
|
|
|
if (NS_STYLE_FLOAT_EDGE_PADDING == borderStyle->mFloatEdge) {
|
1999-09-16 23:56:36 +04:00
|
|
|
// Add in border too
|
|
|
|
nsMargin b;
|
2001-02-07 12:57:26 +03:00
|
|
|
borderStyle->GetBorder(b);
|
1999-09-16 23:56:36 +04:00
|
|
|
m += b;
|
|
|
|
}
|
|
|
|
|
|
|
|
// determine left edge
|
|
|
|
if (mBand.GetLeftFloaterCount()) {
|
|
|
|
aResult.x = mAvailSpaceRect.x + borderPadding.left - m.left;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aResult.x = borderPadding.left;
|
|
|
|
}
|
|
|
|
|
|
|
|
// determine width
|
2000-04-17 18:40:46 +04:00
|
|
|
if (GetFlag(BRS_UNCONSTRAINEDWIDTH)) {
|
1999-09-16 23:56:36 +04:00
|
|
|
aResult.width = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (mBand.GetRightFloaterCount()) {
|
|
|
|
if (mBand.GetLeftFloaterCount()) {
|
|
|
|
aResult.width = mAvailSpaceRect.width + m.left + m.right;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aResult.width = mAvailSpaceRect.width + m.right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aResult.width = mAvailSpaceRect.width + m.left;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_FLOAT_EDGE_MARGIN:
|
|
|
|
{
|
|
|
|
// The child block's margins should be placed adjacent to,
|
|
|
|
// but not overlap the floater.
|
|
|
|
aResult.x = mAvailSpaceRect.x + borderPadding.left;
|
|
|
|
aResult.width = mAvailSpaceRect.width;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Since there are no floaters present the float-edge property
|
|
|
|
// doesn't matter therefore give the block element all of the
|
|
|
|
// available space since it will flow around the floater itself.
|
|
|
|
aResult.x = borderPadding.left;
|
2000-04-17 18:40:46 +04:00
|
|
|
aResult.width = GetFlag(BRS_UNCONSTRAINEDWIDTH)
|
1999-09-16 23:56:36 +04:00
|
|
|
? NS_UNCONSTRAINEDSIZE
|
|
|
|
: mContentArea.width;
|
|
|
|
}
|
1999-04-03 22:59:01 +04:00
|
|
|
}
|
|
|
|
else {
|
1999-09-16 23:56:36 +04:00
|
|
|
// The frame is clueless about the space manager and therefore we
|
|
|
|
// only give it free space. An example is a table frame - the
|
|
|
|
// tables do not flow around floaters.
|
|
|
|
aResult.x = mAvailSpaceRect.x + borderPadding.left;
|
|
|
|
aResult.width = mAvailSpaceRect.width;
|
1999-04-03 22:59:01 +04:00
|
|
|
}
|
2000-03-23 02:19:10 +03:00
|
|
|
#ifdef REALLY_NOISY_REFLOW
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" CBAS: result %d %d %d %d\n", aResult.x, aResult.y, aResult.width, aResult.height);
|
2000-03-23 02:19:10 +03:00
|
|
|
#endif
|
1999-04-03 22:59:01 +04:00
|
|
|
}
|
1998-09-24 00:10:40 +04:00
|
|
|
|
2001-05-01 08:22:57 +04:00
|
|
|
void
|
|
|
|
nsBlockReflowState::GetAvailableSpace(nscoord aY)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Verify that the caller setup the coordinate system properly
|
|
|
|
nscoord wx, wy;
|
|
|
|
mSpaceManager->GetTranslation(wx, wy);
|
|
|
|
NS_ASSERTION((wx == mSpaceManagerX) && (wy == mSpaceManagerY),
|
|
|
|
"bad coord system");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
mBand.GetAvailableSpace(aY - BorderPadding().top, mAvailSpaceRect);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
|
|
|
nsFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent);
|
|
|
|
printf("GetAvailableSpace: band=%d,%d,%d,%d count=%d\n",
|
|
|
|
mAvailSpaceRect.x, mAvailSpaceRect.y,
|
|
|
|
mAvailSpaceRect.width, mAvailSpaceRect.height,
|
|
|
|
mBand.GetTrapezoidCount());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
PRBool
|
|
|
|
nsBlockReflowState::ClearPastFloaters(PRUint8 aBreakType)
|
|
|
|
{
|
|
|
|
nscoord saveY, deltaY;
|
|
|
|
|
|
|
|
PRBool applyTopMargin = PR_FALSE;
|
|
|
|
switch (aBreakType) {
|
|
|
|
case NS_STYLE_CLEAR_LEFT:
|
|
|
|
case NS_STYLE_CLEAR_RIGHT:
|
|
|
|
case NS_STYLE_CLEAR_LEFT_AND_RIGHT:
|
|
|
|
// Apply the previous margin before clearing
|
2001-10-25 05:08:40 +04:00
|
|
|
saveY = mY + mPrevBottomMargin.get();
|
1999-04-03 22:59:01 +04:00
|
|
|
ClearFloaters(saveY, aBreakType);
|
1999-09-16 23:56:36 +04:00
|
|
|
#ifdef NOISY_FLOATER_CLEARING
|
|
|
|
nsFrame::ListTag(stdout, mBlock);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(": ClearPastFloaters: mPrevBottomMargin=%d saveY=%d oldY=%d newY=%d deltaY=%d\n",
|
1999-09-16 23:56:36 +04:00
|
|
|
mPrevBottomMargin, saveY, saveY - mPrevBottomMargin, mY,
|
|
|
|
mY - saveY);
|
|
|
|
#endif
|
1999-04-03 22:59:01 +04:00
|
|
|
|
|
|
|
// Determine how far we just moved. If we didn't move then there
|
|
|
|
// was nothing to clear to don't mess with the normal margin
|
|
|
|
// collapsing behavior. In either case we need to restore the Y
|
|
|
|
// coordinate to what it was before the clear.
|
|
|
|
deltaY = mY - saveY;
|
|
|
|
if (0 != deltaY) {
|
|
|
|
// Pretend that the distance we just moved is a previous
|
|
|
|
// blocks bottom margin. Note that GetAvailableSpace has been
|
|
|
|
// done so that the available space calculations will be done
|
|
|
|
// after clearing the appropriate floaters.
|
|
|
|
//
|
|
|
|
// What we are doing here is applying CSS2 section 9.5.2's
|
|
|
|
// rules for clearing - "The top margin of the generated box
|
|
|
|
// is increased enough that the top border edge is below the
|
|
|
|
// bottom outer edge of the floating boxes..."
|
|
|
|
//
|
|
|
|
// What this will do is cause the top-margin of the block
|
|
|
|
// frame we are about to reflow to be collapsed with that
|
|
|
|
// distance.
|
2001-07-04 06:00:05 +04:00
|
|
|
|
|
|
|
// XXXldb This doesn't handle collapsing with negative margins
|
|
|
|
// correctly, although it's arguable what "correct" is.
|
|
|
|
|
2001-10-25 05:08:40 +04:00
|
|
|
// XXX Are all the other margins included by this point?
|
|
|
|
mPrevBottomMargin.Zero();
|
|
|
|
mPrevBottomMargin.Include(deltaY);
|
1999-04-03 22:59:01 +04:00
|
|
|
mY = saveY;
|
|
|
|
|
|
|
|
// Force margin to be applied in this circumstance
|
|
|
|
applyTopMargin = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
2001-07-04 06:00:05 +04:00
|
|
|
// Put mY back to its original value since no clearing
|
1999-04-03 22:59:01 +04:00
|
|
|
// happened. That way the previous blocks bottom margin will
|
|
|
|
// be applied properly.
|
2001-10-25 05:08:40 +04:00
|
|
|
mY = saveY - mPrevBottomMargin.get();
|
1999-04-03 22:59:01 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return applyTopMargin;
|
|
|
|
}
|
|
|
|
|
2001-10-25 05:08:40 +04:00
|
|
|
/*
|
|
|
|
* Reconstruct the vertical margin before the line |aLine| in order to
|
|
|
|
* do an incremental reflow that begins with |aLine| without reflowing
|
|
|
|
* the line before it. |aLine| may point to the fencepost at the end of
|
|
|
|
* the line list, and it is used this way since we (for now, anyway)
|
|
|
|
* always need to recover margins at the end of a block.
|
|
|
|
*
|
|
|
|
* The reconstruction involves walking backward through the line list to
|
|
|
|
* find any collapsed margins preceding the line that would have been in
|
|
|
|
* the reflow state's |mPrevBottomMargin| when we reflowed that line in
|
|
|
|
* a full reflow (under the rule in CSS2 that all adjacent vertical
|
|
|
|
* margins of blocks collapse).
|
|
|
|
*/
|
1999-04-03 22:59:01 +04:00
|
|
|
void
|
2001-10-25 05:08:40 +04:00
|
|
|
nsBlockReflowState::ReconstructMarginAbove(nsLineList::iterator aLine)
|
1999-04-03 22:59:01 +04:00
|
|
|
{
|
2001-10-25 05:08:40 +04:00
|
|
|
mPrevBottomMargin.Zero();
|
|
|
|
nsBlockFrame *block = mBlock;
|
|
|
|
|
|
|
|
const nsStyleText* styleText = NS_STATIC_CAST(const nsStyleText*,
|
|
|
|
block->mStyleContext->GetStyleData(eStyleStruct_Text));
|
|
|
|
PRBool isPre =
|
|
|
|
((NS_STYLE_WHITESPACE_PRE == styleText->mWhiteSpace) ||
|
|
|
|
(NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == styleText->mWhiteSpace));
|
|
|
|
|
|
|
|
nsCompatibility mode;
|
|
|
|
mPresContext->GetCompatibilityMode(&mode);
|
|
|
|
PRBool isQuirkMode = mode == eCompatibility_NavQuirks;
|
|
|
|
|
|
|
|
nsLineList::iterator firstLine = block->begin_lines();
|
|
|
|
for (;;) {
|
|
|
|
--aLine;
|
|
|
|
if (aLine->IsBlock()) {
|
|
|
|
mPrevBottomMargin = aLine->GetCarriedOutBottomMargin();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
PRBool isEmpty;
|
|
|
|
aLine->IsEmpty(isQuirkMode, isPre, &isEmpty);
|
|
|
|
if (! isEmpty) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (aLine == firstLine) {
|
|
|
|
// If the top margin was carried out (and thus already applied),
|
|
|
|
// set it to zero. Either way, we're done.
|
|
|
|
if ((0 == mReflowState.mComputedBorderPadding.top) &&
|
|
|
|
!(block->mState & NS_BLOCK_MARGIN_ROOT)) {
|
|
|
|
mPrevBottomMargin.Zero();
|
|
|
|
}
|
|
|
|
break;
|
1999-04-03 22:59:01 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1999-04-03 22:59:01 +04:00
|
|
|
}
|
|
|
|
|
2002-01-06 21:14:00 +03:00
|
|
|
/**
|
|
|
|
* Restore information about floaters into the space manager for an
|
|
|
|
* incremental reflow, and simultaneously push the floaters by
|
|
|
|
* |aDeltaY|, which is the amount |aLine| was pushed relative to its
|
|
|
|
* parent. The recovery of state is one of the things that makes
|
|
|
|
* incremental reflow O(N^2) and this state should really be kept
|
|
|
|
* around, attached to the frame tree.
|
|
|
|
*/
|
2001-11-15 10:28:46 +03:00
|
|
|
void
|
|
|
|
nsBlockReflowState::RecoverFloaters(nsLineList::iterator aLine,
|
|
|
|
nscoord aDeltaY)
|
|
|
|
{
|
|
|
|
if (aLine->HasFloaters()) {
|
|
|
|
// Place the floaters into the space-manager again. Also slide
|
|
|
|
// them, just like the regular frames on the line.
|
|
|
|
nsFloaterCache* fc = aLine->GetFirstFloater();
|
|
|
|
while (fc) {
|
|
|
|
nsIFrame* floater = fc->mPlaceholder->GetOutOfFlowFrame();
|
2002-01-06 21:14:00 +03:00
|
|
|
if (aDeltaY != 0) {
|
|
|
|
fc->mRegion.y += aDeltaY;
|
|
|
|
fc->mCombinedArea.y += aDeltaY;
|
|
|
|
nsPoint p;
|
|
|
|
floater->GetOrigin(p);
|
|
|
|
floater->MoveTo(mPresContext, p.x, p.y + aDeltaY);
|
|
|
|
}
|
2001-11-15 10:28:46 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (nsBlockFrame::gNoisyReflow || nsBlockFrame::gNoisySpaceManager) {
|
|
|
|
nscoord tx, ty;
|
|
|
|
mSpaceManager->GetTranslation(tx, ty);
|
|
|
|
nsFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent);
|
2002-01-06 21:14:00 +03:00
|
|
|
printf("RecoverFloaters: txy=%d,%d (%d,%d) ",
|
2001-11-15 10:28:46 +03:00
|
|
|
tx, ty, mSpaceManagerX, mSpaceManagerY);
|
|
|
|
nsFrame::ListTag(stdout, floater);
|
2002-01-06 21:14:00 +03:00
|
|
|
printf(" aDeltaY=%d region={%d,%d,%d,%d}\n",
|
|
|
|
aDeltaY, fc->mRegion.x, fc->mRegion.y,
|
2001-11-15 10:28:46 +03:00
|
|
|
fc->mRegion.width, fc->mRegion.height);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
mSpaceManager->AddRectRegion(floater, fc->mRegion);
|
|
|
|
mLastFloaterY = fc->mRegion.y;
|
|
|
|
fc = fc->Next();
|
|
|
|
}
|
|
|
|
} else if (aLine->IsBlock()) {
|
|
|
|
nsBlockFrame *kid = nsnull;
|
|
|
|
aLine->mFirstChild->QueryInterface(kBlockFrameCID, (void**)&kid);
|
|
|
|
if (kid) {
|
2002-01-06 21:14:00 +03:00
|
|
|
nscoord kidx = kid->mRect.x, kidy = kid->mRect.y;
|
|
|
|
mSpaceManager->Translate(kidx, kidy);
|
2001-11-15 10:28:46 +03:00
|
|
|
for (nsBlockFrame::line_iterator line = kid->begin_lines(),
|
|
|
|
line_end = kid->end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line)
|
2002-01-06 21:14:00 +03:00
|
|
|
// Pass 0, not the real DeltaY, since these floaters aren't
|
|
|
|
// moving relative to their parent block, only relative to
|
|
|
|
// the space manager.
|
|
|
|
RecoverFloaters(line, 0);
|
|
|
|
mSpaceManager->Translate(-kidx, -kidy);
|
2001-11-15 10:28:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-03 08:18:39 +03:00
|
|
|
/**
|
|
|
|
* Everything done in this function is done O(N) times for each pass of
|
|
|
|
* reflow so it is O(N*M) where M is the number of incremental reflow
|
|
|
|
* passes. That's bad. Don't do stuff here.
|
|
|
|
*
|
|
|
|
* When this function is called, |aLine| has just been slid by |aDeltaY|
|
|
|
|
* and the purpose of RecoverStateFrom is to ensure that the
|
|
|
|
* nsBlockReflowState is in the same state that it would have been in
|
|
|
|
* had the line just been reflowed.
|
|
|
|
*
|
|
|
|
* Most of the state recovery that we have to do involves floaters.
|
|
|
|
*/
|
1999-04-03 22:59:01 +04:00
|
|
|
void
|
2001-10-25 05:08:40 +04:00
|
|
|
nsBlockReflowState::RecoverStateFrom(nsLineList::iterator aLine,
|
|
|
|
nscoord aDeltaY)
|
1999-04-03 22:59:01 +04:00
|
|
|
{
|
|
|
|
// Make the line being recovered the current line
|
|
|
|
mCurrentLine = aLine;
|
|
|
|
|
1999-12-30 07:15:45 +03:00
|
|
|
// Recover mKidXMost and mMaxElementSize
|
1999-04-03 22:59:01 +04:00
|
|
|
nscoord xmost = aLine->mBounds.XMost();
|
|
|
|
if (xmost > mKidXMost) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (CRAZY_WIDTH(xmost)) {
|
|
|
|
nsFrame::ListTag(stdout, mBlock);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(": WARNING: xmost:%d\n", xmost);
|
1999-04-03 22:59:01 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
#endif
|
2000-06-12 02:14:33 +04:00
|
|
|
#ifdef NOISY_KIDXMOST
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("%p RecoverState block %p aState.mKidXMost=%d\n", this, mBlock, xmost);
|
2000-06-12 02:14:33 +04:00
|
|
|
#endif
|
1999-04-03 22:59:01 +04:00
|
|
|
mKidXMost = xmost;
|
|
|
|
}
|
2000-04-17 18:40:46 +04:00
|
|
|
if (GetFlag(BRS_COMPUTEMAXELEMENTSIZE)) {
|
2000-05-14 08:56:25 +04:00
|
|
|
#ifdef NOISY_MAX_ELEMENT_SIZE
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("nsBlockReflowState::RecoverStateFrom block %p caching max width %d\n", mBlock, aLine->mMaxElementWidth);
|
2000-05-14 08:56:25 +04:00
|
|
|
#endif
|
1999-08-28 04:39:55 +04:00
|
|
|
UpdateMaxElementSize(nsSize(aLine->mMaxElementWidth, aLine->mBounds.height));
|
|
|
|
}
|
1999-04-03 22:59:01 +04:00
|
|
|
|
1999-12-30 07:15:45 +03:00
|
|
|
// If computing the maximum width, then update mMaximumWidth
|
2000-04-17 18:40:46 +04:00
|
|
|
if (GetFlag(BRS_COMPUTEMAXWIDTH)) {
|
2000-05-14 08:56:25 +04:00
|
|
|
#ifdef NOISY_MAXIMUM_WIDTH
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("nsBlockReflowState::RecoverStateFrom block %p caching max width %d\n", mBlock, aLine->mMaximumWidth);
|
2000-05-14 08:56:25 +04:00
|
|
|
#endif
|
1999-12-30 07:15:45 +03:00
|
|
|
UpdateMaximumWidth(aLine->mMaximumWidth);
|
|
|
|
}
|
|
|
|
|
1999-09-15 04:28:10 +04:00
|
|
|
// Place floaters for this line into the space manager
|
2001-11-15 10:28:46 +03:00
|
|
|
if (aLine->HasFloaters() || aLine->IsBlock()) {
|
1999-09-16 23:56:36 +04:00
|
|
|
// Undo border/padding translation since the nsFloaterCache's
|
|
|
|
// coordinates are relative to the frame not relative to the
|
|
|
|
// border/padding.
|
|
|
|
const nsMargin& bp = BorderPadding();
|
|
|
|
mSpaceManager->Translate(-bp.left, -bp.top);
|
|
|
|
|
2001-11-15 10:28:46 +03:00
|
|
|
RecoverFloaters(aLine, aDeltaY);
|
|
|
|
|
2000-03-23 02:19:10 +03:00
|
|
|
#ifdef DEBUG
|
2001-05-01 08:22:57 +04:00
|
|
|
if (nsBlockFrame::gNoisyReflow || nsBlockFrame::gNoisySpaceManager) {
|
2000-03-23 02:19:10 +03:00
|
|
|
mSpaceManager->List(stdout);
|
|
|
|
}
|
|
|
|
#endif
|
1999-09-16 23:56:36 +04:00
|
|
|
// And then put the translation back again
|
|
|
|
mSpaceManager->Translate(bp.left, bp.top);
|
1999-04-03 22:59:01 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-24 00:10:40 +04:00
|
|
|
|
2001-05-01 08:22:57 +04:00
|
|
|
PRBool
|
|
|
|
nsBlockReflowState::IsImpactedByFloater() const
|
|
|
|
{
|
|
|
|
#ifdef REALLY_NOISY_REFLOW
|
|
|
|
printf("nsBlockReflowState::IsImpactedByFloater %p returned %d\n",
|
|
|
|
this, mBand.GetFloaterCount());
|
|
|
|
#endif
|
2001-10-25 05:08:40 +04:00
|
|
|
return mBand.GetFloaterCount() > 0;
|
2001-05-01 08:22:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
1999-08-28 01:45:37 +04:00
|
|
|
nsBlockReflowState::InitFloater(nsLineLayout& aLineLayout,
|
|
|
|
nsPlaceholderFrame* aPlaceholder)
|
1998-09-23 06:25:26 +04:00
|
|
|
{
|
1998-12-15 07:20:54 +03:00
|
|
|
// Set the geometric parent of the floater
|
1999-04-23 18:34:48 +04:00
|
|
|
nsIFrame* floater = aPlaceholder->GetOutOfFlowFrame();
|
1999-01-14 08:16:23 +03:00
|
|
|
floater->SetParent(mBlock);
|
1998-10-10 02:58:25 +04:00
|
|
|
|
1998-12-15 07:20:54 +03:00
|
|
|
// Then add the floater to the current line and place it when
|
|
|
|
// appropriate
|
1999-08-28 01:45:37 +04:00
|
|
|
AddFloater(aLineLayout, aPlaceholder, PR_TRUE);
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// This is called by the line layout's AddFloater method when a
|
|
|
|
// place-holder frame is reflowed in a line. If the floater is a
|
|
|
|
// left-most child (it's x coordinate is at the line's left margin)
|
|
|
|
// then the floater is place immediately, otherwise the floater
|
|
|
|
// placement is deferred until the line has been reflowed.
|
2001-07-04 06:00:05 +04:00
|
|
|
|
|
|
|
// XXXldb This behavior doesn't quite fit with CSS1 and CSS2 --
|
|
|
|
// technically we're supposed let the current line flow around the
|
|
|
|
// float as well unless it won't fit next to what we already have.
|
|
|
|
// But nobody else implements it that way...
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
1999-08-28 01:45:37 +04:00
|
|
|
nsBlockReflowState::AddFloater(nsLineLayout& aLineLayout,
|
|
|
|
nsPlaceholderFrame* aPlaceholder,
|
1998-12-15 07:20:54 +03:00
|
|
|
PRBool aInitialReflow)
|
1998-12-05 19:02:08 +03:00
|
|
|
{
|
2001-10-25 05:08:40 +04:00
|
|
|
NS_PRECONDITION(mBlock->end_lines() != mCurrentLine, "null ptr");
|
1999-03-23 07:28:20 +03:00
|
|
|
|
1999-09-15 04:28:10 +04:00
|
|
|
// Allocate a nsFloaterCache for the floater
|
|
|
|
nsFloaterCache* fc = mFloaterCacheFreeList.Alloc();
|
|
|
|
fc->mPlaceholder = aPlaceholder;
|
|
|
|
fc->mIsCurrentLineFloater = aLineLayout.CanPlaceFloaterNow();
|
1998-09-23 06:25:26 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Now place the floater immediately if possible. Otherwise stash it
|
|
|
|
// away in mPendingFloaters and place it later.
|
1999-09-15 04:28:10 +04:00
|
|
|
if (fc->mIsCurrentLineFloater) {
|
|
|
|
// Record this floater in the current-line list
|
|
|
|
mCurrentLineFloaters.Append(fc);
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Because we are in the middle of reflowing a placeholder frame
|
|
|
|
// within a line (and possibly nested in an inline frame or two
|
|
|
|
// that's a child of our block) we need to restore the space
|
|
|
|
// manager's translation to the space that the block resides in
|
|
|
|
// before placing the floater.
|
|
|
|
nscoord ox, oy;
|
|
|
|
mSpaceManager->GetTranslation(ox, oy);
|
|
|
|
nscoord dx = ox - mSpaceManagerX;
|
|
|
|
nscoord dy = oy - mSpaceManagerY;
|
|
|
|
mSpaceManager->Translate(-dx, -dy);
|
1999-09-10 22:52:56 +04:00
|
|
|
|
1999-09-15 04:28:10 +04:00
|
|
|
// And then place it
|
1999-09-10 22:52:56 +04:00
|
|
|
PRBool isLeftFloater;
|
2001-05-22 03:03:46 +04:00
|
|
|
FlowAndPlaceFloater(fc, &isLeftFloater);
|
1998-10-03 01:50:53 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Pass on updated available space to the current inline reflow engine
|
|
|
|
GetAvailableSpace();
|
1999-08-28 01:45:37 +04:00
|
|
|
aLineLayout.UpdateBand(mAvailSpaceRect.x + BorderPadding().left, mY,
|
2000-04-17 18:40:46 +04:00
|
|
|
GetFlag(BRS_UNCONSTRAINEDWIDTH) ? NS_UNCONSTRAINEDSIZE : mAvailSpaceRect.width,
|
1999-08-28 01:45:37 +04:00
|
|
|
mAvailSpaceRect.height,
|
1999-10-29 18:34:53 +04:00
|
|
|
isLeftFloater,
|
|
|
|
aPlaceholder->GetOutOfFlowFrame());
|
1998-10-03 01:50:53 +04:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Restore coordinate system
|
|
|
|
mSpaceManager->Translate(dx, dy);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
else {
|
|
|
|
// This floater will be placed after the line is done (it is a
|
1999-09-15 04:28:10 +04:00
|
|
|
// below-current-line floater).
|
|
|
|
mBelowCurrentLineFloaters.Append(fc);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
2001-05-01 08:22:57 +04:00
|
|
|
void
|
|
|
|
nsBlockReflowState::UpdateMaxElementSize(const nsSize& aMaxElementSize)
|
|
|
|
{
|
|
|
|
#ifdef NOISY_MAX_ELEMENT_SIZE
|
|
|
|
nsSize oldSize = mMaxElementSize;
|
|
|
|
#endif
|
|
|
|
if (aMaxElementSize.width > mMaxElementSize.width) {
|
|
|
|
mMaxElementSize.width = aMaxElementSize.width;
|
|
|
|
}
|
|
|
|
if (aMaxElementSize.height > mMaxElementSize.height) {
|
|
|
|
mMaxElementSize.height = aMaxElementSize.height;
|
|
|
|
}
|
|
|
|
#ifdef NOISY_MAX_ELEMENT_SIZE
|
|
|
|
if ((mMaxElementSize.width != oldSize.width) ||
|
|
|
|
(mMaxElementSize.height != oldSize.height)) {
|
|
|
|
nsFrame::IndentBy(stdout, mBlock->GetDepth());
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == mReflowState.availableWidth) {
|
|
|
|
printf("PASS1 ");
|
|
|
|
}
|
|
|
|
nsFrame::ListTag(stdout, mBlock);
|
|
|
|
printf(": old max-element-size=%d,%d new=%d,%d\n",
|
|
|
|
oldSize.width, oldSize.height,
|
|
|
|
mMaxElementSize.width, mMaxElementSize.height);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockReflowState::UpdateMaximumWidth(nscoord aMaximumWidth)
|
|
|
|
{
|
|
|
|
if (aMaximumWidth > mMaximumWidth) {
|
|
|
|
#ifdef NOISY_MAXIMUM_WIDTH
|
|
|
|
printf("nsBlockReflowState::UpdateMaximumWidth block %p caching max width %d\n", mBlock, aMaximumWidth);
|
|
|
|
#endif
|
|
|
|
mMaximumWidth = aMaximumWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-31 08:10:27 +04:00
|
|
|
PRBool
|
|
|
|
nsBlockReflowState::CanPlaceFloater(const nsRect& aFloaterRect,
|
|
|
|
PRUint8 aFloats)
|
|
|
|
{
|
|
|
|
// If the current Y coordinate is not impacted by any floaters
|
|
|
|
// then by definition the floater fits.
|
|
|
|
PRBool result = PR_TRUE;
|
1999-04-03 22:59:01 +04:00
|
|
|
if (0 != mBand.GetFloaterCount()) {
|
2001-07-19 06:33:43 +04:00
|
|
|
// XXX We should allow overflow by up to half a pixel here (bug 21193).
|
1999-03-31 08:10:27 +04:00
|
|
|
if (mAvailSpaceRect.width < aFloaterRect.width) {
|
|
|
|
// The available width is too narrow (and its been impacted by a
|
|
|
|
// prior floater)
|
|
|
|
result = PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// At this point we know that there is enough horizontal space for
|
|
|
|
// the floater (somewhere). Lets see if there is enough vertical
|
|
|
|
// space.
|
|
|
|
if (mAvailSpaceRect.height < aFloaterRect.height) {
|
|
|
|
// The available height is too short. However, its possible that
|
|
|
|
// there is enough open space below which is not impacted by a
|
|
|
|
// floater.
|
|
|
|
//
|
|
|
|
// Compute the X coordinate for the floater based on its float
|
|
|
|
// type, assuming its placed on the current line. This is
|
|
|
|
// where the floater will be placed horizontally if it can go
|
|
|
|
// here.
|
1999-05-13 04:55:38 +04:00
|
|
|
nscoord xa;
|
1999-03-31 08:10:27 +04:00
|
|
|
if (NS_STYLE_FLOAT_LEFT == aFloats) {
|
1999-05-13 04:55:38 +04:00
|
|
|
xa = mAvailSpaceRect.x;
|
1999-03-31 08:10:27 +04:00
|
|
|
}
|
|
|
|
else {
|
1999-05-13 04:55:38 +04:00
|
|
|
xa = mAvailSpaceRect.XMost() - aFloaterRect.width;
|
1999-03-31 08:10:27 +04:00
|
|
|
|
|
|
|
// In case the floater is too big, don't go past the left edge
|
1999-05-13 04:55:38 +04:00
|
|
|
if (xa < mAvailSpaceRect.x) {
|
|
|
|
xa = mAvailSpaceRect.x;
|
1999-03-31 08:10:27 +04:00
|
|
|
}
|
|
|
|
}
|
1999-05-13 04:55:38 +04:00
|
|
|
nscoord xb = xa + aFloaterRect.width;
|
1999-03-31 08:10:27 +04:00
|
|
|
|
|
|
|
// Calculate the top and bottom y coordinates, again assuming
|
|
|
|
// that the floater is placed on the current line.
|
|
|
|
const nsMargin& borderPadding = BorderPadding();
|
1999-05-13 04:55:38 +04:00
|
|
|
nscoord ya = mY - borderPadding.top;
|
|
|
|
if (ya < 0) {
|
2001-07-04 06:00:05 +04:00
|
|
|
// CSS2 spec, 9.5.1 rule [4]: "A floating box's outer top may not
|
|
|
|
// be higher than the top of its containing block." (Since the
|
|
|
|
// containing block is the content edge of the block box, this
|
|
|
|
// means the margin edge of the floater can't be higher than the
|
|
|
|
// content edge of the block that contains it.)
|
1999-05-13 04:55:38 +04:00
|
|
|
ya = 0;
|
1999-03-31 08:10:27 +04:00
|
|
|
}
|
1999-05-13 04:55:38 +04:00
|
|
|
nscoord yb = ya + aFloaterRect.height;
|
1999-03-31 08:10:27 +04:00
|
|
|
|
|
|
|
nscoord saveY = mY;
|
|
|
|
for (;;) {
|
|
|
|
// Get the available space at the new Y coordinate
|
|
|
|
mY += mAvailSpaceRect.height;
|
|
|
|
GetAvailableSpace();
|
|
|
|
|
1999-04-03 22:59:01 +04:00
|
|
|
if (0 == mBand.GetFloaterCount()) {
|
1999-03-31 08:10:27 +04:00
|
|
|
// Winner. This band has no floaters on it, therefore
|
|
|
|
// there can be no overlap.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check and make sure the floater won't intersect any
|
|
|
|
// floaters on this band. The floaters starting and ending
|
|
|
|
// coordinates must be entirely in the available space.
|
1999-05-13 04:55:38 +04:00
|
|
|
if ((xa < mAvailSpaceRect.x) || (xb > mAvailSpaceRect.XMost())) {
|
1999-03-31 08:10:27 +04:00
|
|
|
// The floater can't go here.
|
|
|
|
result = PR_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if there is now enough height for the floater.
|
1999-05-13 04:55:38 +04:00
|
|
|
if (yb < mY + mAvailSpaceRect.height) {
|
1999-03-31 08:10:27 +04:00
|
|
|
// Winner. The bottom Y coordinate of the floater is in
|
|
|
|
// this band.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restore Y coordinate and available space information
|
|
|
|
// regardless of the outcome.
|
|
|
|
mY = saveY;
|
|
|
|
GetAvailableSpace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
2001-05-22 03:03:46 +04:00
|
|
|
nsBlockReflowState::FlowAndPlaceFloater(nsFloaterCache* aFloaterCache,
|
|
|
|
PRBool* aIsLeftFloater)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
1998-12-12 22:19:11 +03:00
|
|
|
// Save away the Y coordinate before placing the floater. We will
|
|
|
|
// restore mY at the end after placing the floater. This is
|
|
|
|
// necessary because any adjustments to mY during the floater
|
|
|
|
// placement are for the floater only, not for any non-floating
|
|
|
|
// content.
|
|
|
|
nscoord saveY = mY;
|
2001-05-22 03:03:46 +04:00
|
|
|
|
1999-09-15 04:28:10 +04:00
|
|
|
nsIFrame* floater = aFloaterCache->mPlaceholder->GetOutOfFlowFrame();
|
1998-09-15 04:19:49 +04:00
|
|
|
|
2001-05-22 03:03:46 +04:00
|
|
|
// Grab the floater's display information
|
1998-12-05 19:02:08 +03:00
|
|
|
const nsStyleDisplay* floaterDisplay;
|
|
|
|
floater->GetStyleData(eStyleStruct_Display,
|
|
|
|
(const nsStyleStruct*&)floaterDisplay);
|
|
|
|
|
2001-05-22 03:03:46 +04:00
|
|
|
// This will hold the floater's geometry when we've found a place
|
|
|
|
// for it to live.
|
1998-12-05 19:02:08 +03:00
|
|
|
nsRect region;
|
2001-05-22 03:03:46 +04:00
|
|
|
|
|
|
|
// Advance mY to mLastFloaterY (if it's not past it already) to
|
|
|
|
// enforce 9.5.1 rule [2]; i.e., make sure that a float isn't
|
|
|
|
// ``above'' another float that preceded it in the flow.
|
|
|
|
mY = NS_MAX(mLastFloaterY, mY);
|
|
|
|
|
2001-07-19 06:33:43 +04:00
|
|
|
// See if the floater should clear any preceeding floaters...
|
|
|
|
if (NS_STYLE_CLEAR_NONE != floaterDisplay->mBreakType) {
|
|
|
|
// XXXldb Does this handle vertical margins correctly?
|
|
|
|
ClearFloaters(mY, floaterDisplay->mBreakType);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Get the band of available space
|
|
|
|
GetAvailableSpace();
|
|
|
|
}
|
2001-05-22 03:03:46 +04:00
|
|
|
|
2001-07-19 06:33:43 +04:00
|
|
|
// Reflow the floater
|
|
|
|
mBlock->ReflowFloater(*this, aFloaterCache->mPlaceholder, aFloaterCache->mCombinedArea,
|
|
|
|
aFloaterCache->mMargins, aFloaterCache->mOffsets);
|
2001-05-22 03:03:46 +04:00
|
|
|
|
2001-07-19 06:33:43 +04:00
|
|
|
// Get the floaters bounding box and margin information
|
|
|
|
floater->GetRect(region);
|
2001-05-22 03:03:46 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2001-07-19 06:33:43 +04:00
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
|
|
|
nsFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent);
|
|
|
|
printf("flowed floater: ");
|
|
|
|
nsFrame::ListTag(stdout, floater);
|
|
|
|
printf(" (%d,%d,%d,%d)\n",
|
|
|
|
region.x, region.y, region.width, region.height);
|
|
|
|
}
|
2001-05-22 03:03:46 +04:00
|
|
|
#endif
|
|
|
|
|
2001-07-19 06:33:43 +04:00
|
|
|
// Adjust the floater size by its margin. That's the area that will
|
|
|
|
// impact the space manager.
|
|
|
|
region.width += aFloaterCache->mMargins.left + aFloaterCache->mMargins.right;
|
|
|
|
region.height += aFloaterCache->mMargins.top + aFloaterCache->mMargins.bottom;
|
|
|
|
|
|
|
|
// Find a place to place the floater. The CSS2 spec doesn't want
|
|
|
|
// floaters overlapping each other or sticking out of the containing
|
|
|
|
// block if possible (CSS2 spec section 9.5.1, see the rule list).
|
|
|
|
NS_ASSERTION((NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) ||
|
|
|
|
(NS_STYLE_FLOAT_RIGHT == floaterDisplay->mFloats),
|
|
|
|
"invalid float type");
|
|
|
|
|
2002-01-09 06:01:13 +03:00
|
|
|
// Can the floater fit here?
|
|
|
|
while (! CanPlaceFloater(region, floaterDisplay->mFloats)) {
|
|
|
|
// Nope. Advance to the next band.
|
|
|
|
mY += mAvailSpaceRect.height;
|
|
|
|
GetAvailableSpace();
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-11-15 00:01:26 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Assign an x and y coordinate to the floater. Note that the x,y
|
|
|
|
// coordinates are computed <b>relative to the translation in the
|
|
|
|
// spacemanager</b> which means that the impacted region will be
|
|
|
|
// <b>inside</b> the border/padding area.
|
1999-09-18 03:16:43 +04:00
|
|
|
PRBool okToAddRectRegion = PR_TRUE;
|
1999-10-15 03:10:03 +04:00
|
|
|
PRBool isLeftFloater;
|
1998-12-05 19:02:08 +03:00
|
|
|
if (NS_STYLE_FLOAT_LEFT == floaterDisplay->mFloats) {
|
1999-10-15 03:10:03 +04:00
|
|
|
isLeftFloater = PR_TRUE;
|
1998-12-09 00:43:15 +03:00
|
|
|
region.x = mAvailSpaceRect.x;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
else {
|
1999-10-15 03:10:03 +04:00
|
|
|
isLeftFloater = PR_FALSE;
|
2000-04-17 18:40:46 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != mAvailSpaceRect.XMost())
|
|
|
|
region.x = mAvailSpaceRect.XMost() - region.width;
|
|
|
|
else {
|
|
|
|
okToAddRectRegion = PR_FALSE;
|
|
|
|
region.x = mAvailSpaceRect.x;
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
1999-10-15 03:10:03 +04:00
|
|
|
*aIsLeftFloater = isLeftFloater;
|
1999-03-05 07:21:32 +03:00
|
|
|
const nsMargin& borderPadding = BorderPadding();
|
|
|
|
region.y = mY - borderPadding.top;
|
1998-12-05 19:02:08 +03:00
|
|
|
if (region.y < 0) {
|
2001-07-04 06:00:05 +04:00
|
|
|
// CSS2 spec, 9.5.1 rule [4]: "A floating box's outer top may not
|
|
|
|
// be higher than the top of its containing block." (Since the
|
|
|
|
// containing block is the content edge of the block box, this
|
|
|
|
// means the margin edge of the floater can't be higher than the
|
|
|
|
// content edge of the block that contains it.)
|
1998-12-05 19:02:08 +03:00
|
|
|
region.y = 0;
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Place the floater in the space manager
|
1999-09-18 03:16:43 +04:00
|
|
|
if (okToAddRectRegion) {
|
1999-10-29 18:34:53 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsresult rv =
|
|
|
|
#endif
|
2000-01-03 07:32:13 +03:00
|
|
|
mSpaceManager->AddRectRegion(floater, region);
|
1999-10-29 18:34:53 +04:00
|
|
|
NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv), "bad floater placement");
|
1999-09-18 03:16:43 +04:00
|
|
|
}
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1999-09-15 04:28:10 +04:00
|
|
|
// Save away the floaters region in the spacemanager, after making
|
|
|
|
// it relative to the containing block's frame instead of relative
|
|
|
|
// to the spacemanager translation (which is inset by the
|
|
|
|
// border+padding).
|
|
|
|
aFloaterCache->mRegion.x = region.x + borderPadding.left;
|
|
|
|
aFloaterCache->mRegion.y = region.y + borderPadding.top;
|
|
|
|
aFloaterCache->mRegion.width = region.width;
|
|
|
|
aFloaterCache->mRegion.height = region.height;
|
|
|
|
#ifdef NOISY_SPACEMANAGER
|
|
|
|
nscoord tx, ty;
|
|
|
|
mSpaceManager->GetTranslation(tx, ty);
|
|
|
|
nsFrame::ListTag(stdout, mBlock);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(": PlaceFloater: AddRectRegion: txy=%d,%d (%d,%d) {%d,%d,%d,%d}\n",
|
1999-09-15 04:28:10 +04:00
|
|
|
tx, ty, mSpaceManagerX, mSpaceManagerY,
|
1999-09-16 23:56:36 +04:00
|
|
|
aFloaterCache->mRegion.x, aFloaterCache->mRegion.y,
|
|
|
|
aFloaterCache->mRegion.width, aFloaterCache->mRegion.height);
|
1999-09-15 04:28:10 +04:00
|
|
|
#endif
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
// Set the origin of the floater frame, in frame coordinates. These
|
|
|
|
// coordinates are <b>not</b> relative to the spacemanager
|
|
|
|
// translation, therefore we have to factor in our border/padding.
|
1999-09-15 04:28:10 +04:00
|
|
|
nscoord x = borderPadding.left + aFloaterCache->mMargins.left + region.x;
|
|
|
|
nscoord y = borderPadding.top + aFloaterCache->mMargins.top + region.y;
|
1999-07-14 21:26:20 +04:00
|
|
|
|
|
|
|
// If floater is relatively positioned, factor that in as well
|
2001-07-04 06:00:05 +04:00
|
|
|
// XXXldb Should this be done after handling the combined area
|
|
|
|
// below?
|
2001-06-01 02:19:43 +04:00
|
|
|
if (NS_STYLE_POSITION_RELATIVE == floaterDisplay->mPosition) {
|
1999-09-15 04:28:10 +04:00
|
|
|
x += aFloaterCache->mOffsets.left;
|
|
|
|
y += aFloaterCache->mOffsets.top;
|
1999-07-14 21:26:20 +04:00
|
|
|
}
|
1999-11-30 08:09:08 +03:00
|
|
|
|
2001-09-21 04:53:29 +04:00
|
|
|
// Position the floater and make sure and views are properly
|
|
|
|
// positioned. We need to explicitly position its child views as
|
|
|
|
// well, since we're moving the floater after flowing it.
|
1999-10-26 08:44:41 +04:00
|
|
|
floater->MoveTo(mPresContext, x, y);
|
2001-09-06 00:27:19 +04:00
|
|
|
nsContainerFrame::PositionFrameView(mPresContext, floater);
|
2001-09-21 04:53:29 +04:00
|
|
|
nsContainerFrame::PositionChildViews(mPresContext, floater);
|
1999-10-15 03:10:03 +04:00
|
|
|
|
|
|
|
// Update the floater combined area state
|
|
|
|
nsRect combinedArea = aFloaterCache->mCombinedArea;
|
|
|
|
combinedArea.x += x;
|
|
|
|
combinedArea.y += y;
|
2000-04-17 18:40:46 +04:00
|
|
|
if (!isLeftFloater &&
|
|
|
|
(GetFlag(BRS_UNCONSTRAINEDWIDTH) || GetFlag(BRS_SHRINKWRAPWIDTH))) {
|
2000-01-03 07:32:13 +03:00
|
|
|
// When we are placing a right floater in an unconstrained situation or
|
|
|
|
// when shrink wrapping, we don't apply it to the floater combined area
|
|
|
|
// immediately. Otherwise we end up with an infinitely wide combined
|
|
|
|
// area. Instead, we save it away in mRightFloaterCombinedArea so that
|
|
|
|
// later on when we know the width of a line we can compute a better value.
|
1999-10-15 03:10:03 +04:00
|
|
|
if (!mHaveRightFloaters) {
|
|
|
|
mRightFloaterCombinedArea = combinedArea;
|
|
|
|
mHaveRightFloaters = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
2001-05-01 08:22:57 +04:00
|
|
|
nsBlockFrame::CombineRects(combinedArea, mRightFloaterCombinedArea);
|
1999-10-15 03:10:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2001-05-01 08:22:57 +04:00
|
|
|
nsBlockFrame::CombineRects(combinedArea, mFloaterCombinedArea);
|
1999-03-24 18:42:19 +03:00
|
|
|
}
|
1998-12-12 22:19:11 +03:00
|
|
|
|
2001-05-22 03:03:46 +04:00
|
|
|
// Remember the y-coordinate of the floater we've just placed
|
|
|
|
mLastFloaterY = mY;
|
|
|
|
|
1998-12-12 22:19:11 +03:00
|
|
|
// Now restore mY
|
|
|
|
mY = saveY;
|
|
|
|
|
1999-10-16 03:35:10 +04:00
|
|
|
#ifdef DEBUG
|
2001-05-01 08:22:57 +04:00
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
1998-12-05 19:02:08 +03:00
|
|
|
nsRect r;
|
|
|
|
floater->GetRect(r);
|
2001-05-01 08:22:57 +04:00
|
|
|
nsFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("placed floater: ");
|
2001-05-22 03:03:46 +04:00
|
|
|
nsFrame::ListTag(stdout, floater);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" %d,%d,%d,%d\n", r.x, r.y, r.width, r.height);
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-11-05 22:33:01 +03:00
|
|
|
#endif
|
1998-12-05 19:02:08 +03:00
|
|
|
}
|
1998-11-05 22:33:01 +03:00
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
/**
|
|
|
|
* Place below-current-line floaters.
|
|
|
|
*/
|
|
|
|
void
|
1999-09-15 04:28:10 +04:00
|
|
|
nsBlockReflowState::PlaceBelowCurrentLineFloaters(nsFloaterCacheList& aList)
|
1998-12-05 19:02:08 +03:00
|
|
|
{
|
1999-09-15 04:28:10 +04:00
|
|
|
nsFloaterCache* fc = aList.Head();
|
|
|
|
while (fc) {
|
|
|
|
if (!fc->mIsCurrentLineFloater) {
|
1999-10-29 18:34:53 +04:00
|
|
|
#ifdef DEBUG
|
2001-05-01 08:22:57 +04:00
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
|
|
|
nsFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("placing bcl floater: ");
|
1999-10-29 18:34:53 +04:00
|
|
|
nsFrame::ListTag(stdout, fc->mPlaceholder->GetOutOfFlowFrame());
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("\n");
|
1999-10-29 18:34:53 +04:00
|
|
|
}
|
|
|
|
#endif
|
1999-03-23 07:28:20 +03:00
|
|
|
|
1999-09-15 04:28:10 +04:00
|
|
|
// Place the floater
|
1999-04-01 05:37:36 +04:00
|
|
|
PRBool isLeftFloater;
|
2001-05-22 03:03:46 +04:00
|
|
|
FlowAndPlaceFloater(fc, &isLeftFloater);
|
1999-02-09 20:31:33 +03:00
|
|
|
}
|
1999-09-15 04:28:10 +04:00
|
|
|
fc = fc->Next();
|
1999-02-09 20:31:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 19:02:08 +03:00
|
|
|
void
|
|
|
|
nsBlockReflowState::ClearFloaters(nscoord aY, PRUint8 aBreakType)
|
1998-10-27 19:51:02 +03:00
|
|
|
{
|
1999-10-16 03:35:10 +04:00
|
|
|
#ifdef DEBUG
|
2001-05-01 08:22:57 +04:00
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
|
|
|
nsFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("clear floaters: in: mY=%d aY=%d(%d)\n",
|
1999-10-16 03:35:10 +04:00
|
|
|
mY, aY, aY - BorderPadding().top);
|
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
#endif
|
1998-10-27 19:51:02 +03:00
|
|
|
|
1999-09-16 23:56:36 +04:00
|
|
|
#ifdef NOISY_FLOATER_CLEARING
|
2001-05-01 08:22:57 +04:00
|
|
|
printf("nsBlockReflowState::ClearFloaters: aY=%d breakType=%d\n",
|
1999-09-16 23:56:36 +04:00
|
|
|
aY, aBreakType);
|
|
|
|
mSpaceManager->List(stdout);
|
|
|
|
#endif
|
1999-03-05 07:21:32 +03:00
|
|
|
const nsMargin& bp = BorderPadding();
|
1999-04-03 22:59:01 +04:00
|
|
|
nscoord newY = mBand.ClearFloaters(aY - bp.top, aBreakType);
|
1999-03-05 07:21:32 +03:00
|
|
|
mY = newY + bp.top;
|
1998-12-05 19:02:08 +03:00
|
|
|
GetAvailableSpace();
|
1998-09-23 06:25:26 +04:00
|
|
|
|
1999-10-16 03:35:10 +04:00
|
|
|
#ifdef DEBUG
|
2001-05-01 08:22:57 +04:00
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
|
|
|
nsFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("clear floaters: out: mY=%d(%d)\n", mY, mY - bp.top);
|
1999-10-16 03:35:10 +04:00
|
|
|
}
|
1998-12-05 19:02:08 +03:00
|
|
|
#endif
|
|
|
|
}
|
2001-05-01 08:22:57 +04:00
|
|
|
|