1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#include "nsTableRowFrame.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIContentDelegate.h"
|
|
|
|
#include "nsTableFrame.h"
|
1998-06-05 06:36:25 +04:00
|
|
|
#include "nsTableColFrame.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsTableCellFrame.h"
|
|
|
|
#include "nsCellLayoutData.h"
|
1998-06-05 06:36:25 +04:00
|
|
|
#include "nsColLayoutData.h"
|
1998-04-15 01:49:29 +04:00
|
|
|
#include "nsIView.h"
|
1998-06-03 04:43:53 +04:00
|
|
|
#include "nsIPtr.h"
|
1998-06-23 09:43:27 +04:00
|
|
|
#include "nsIReflowCommand.h"
|
1998-06-03 04:43:53 +04:00
|
|
|
|
|
|
|
NS_DEF_PTR(nsIStyleContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
const nsIID kTableRowFrameCID = NS_TABLEROWFRAME_CID;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
static PRBool gsDebug1 = PR_FALSE;
|
|
|
|
static PRBool gsDebug2 = PR_FALSE;
|
|
|
|
//#define NOISY
|
|
|
|
//#define NOISY_FLOW
|
|
|
|
#else
|
|
|
|
static const PRBool gsDebug1 = PR_FALSE;
|
|
|
|
static const PRBool gsDebug2 = PR_FALSE;
|
|
|
|
#endif
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
/* ----------- RowReflowState ---------- */
|
|
|
|
|
|
|
|
struct RowReflowState {
|
1998-05-30 00:36:05 +04:00
|
|
|
// Our reflow state
|
|
|
|
const nsReflowState& reflowState;
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
// The body's available size (computed from the body's parent)
|
|
|
|
nsSize availSize;
|
|
|
|
|
|
|
|
// Flags for whether the max size is unconstrained
|
|
|
|
PRBool unconstrainedWidth;
|
|
|
|
PRBool unconstrainedHeight;
|
|
|
|
|
|
|
|
// Running x-offset
|
|
|
|
nscoord x;
|
|
|
|
|
|
|
|
// Height of tallest cell (excluding cells with rowspan>1)
|
|
|
|
nscoord maxCellHeight;
|
1998-05-22 03:43:18 +04:00
|
|
|
nscoord maxCellVertSpace; // the maximum MAX(cellheight+top+bottom)
|
|
|
|
nscoord maxCellHorzSpace; // the maximum MAX(cellheight+top+bottom)
|
1998-04-23 21:29:07 +04:00
|
|
|
|
|
|
|
nsTableFrame *tableFrame;
|
|
|
|
|
|
|
|
|
1998-05-30 00:36:05 +04:00
|
|
|
RowReflowState( nsIPresContext* aPresContext,
|
|
|
|
const nsReflowState& aReflowState)
|
|
|
|
: reflowState(aReflowState)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
1998-05-30 00:36:05 +04:00
|
|
|
availSize.width = reflowState.maxSize.width;
|
|
|
|
availSize.height = reflowState.maxSize.height;
|
1998-04-23 21:29:07 +04:00
|
|
|
x=0;
|
1998-05-30 00:36:05 +04:00
|
|
|
unconstrainedWidth = PRBool(reflowState.maxSize.width == NS_UNCONSTRAINEDSIZE);
|
|
|
|
unconstrainedHeight = PRBool(reflowState.maxSize.height == NS_UNCONSTRAINEDSIZE);
|
1998-04-23 21:29:07 +04:00
|
|
|
maxCellHeight=0;
|
1998-05-22 03:43:18 +04:00
|
|
|
maxCellVertSpace=0;
|
|
|
|
maxCellHorzSpace=0;
|
1998-04-23 21:29:07 +04:00
|
|
|
tableFrame = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
~RowReflowState() {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------- nsTableRowpFrame ---------- */
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
nsTableRowFrame::nsTableRowFrame(nsIContent* aContent,
|
1998-04-23 21:29:07 +04:00
|
|
|
nsIFrame* aParentFrame)
|
1998-05-06 03:56:50 +04:00
|
|
|
: nsContainerFrame(aContent, aParentFrame),
|
1998-05-22 03:43:18 +04:00
|
|
|
mTallestCell(0),
|
|
|
|
mCellMaxTopMargin(0),
|
1998-06-24 23:13:19 +04:00
|
|
|
mCellMaxBottomMargin(0),
|
|
|
|
mMinRowSpan(1)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableRowFrame::~nsTableRowFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableRowFrame::ResetMaxChildHeight()
|
|
|
|
{
|
|
|
|
mTallestCell=0;
|
1998-05-22 03:43:18 +04:00
|
|
|
mCellMaxTopMargin=0;
|
|
|
|
mCellMaxBottomMargin=0;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
void nsTableRowFrame::SetMaxChildHeight(nscoord aChildHeight, nscoord aTopMargin, nscoord aBottomMargin)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
if (mTallestCell<aChildHeight)
|
|
|
|
mTallestCell = aChildHeight;
|
1998-05-22 03:43:18 +04:00
|
|
|
|
|
|
|
if (mCellMaxTopMargin<aTopMargin)
|
|
|
|
mCellMaxTopMargin = aTopMargin;
|
|
|
|
|
|
|
|
if (mCellMaxBottomMargin<aBottomMargin)
|
|
|
|
mCellMaxBottomMargin = aBottomMargin;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsTableRowFrame::Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
// for debug...
|
1998-04-30 04:27:59 +04:00
|
|
|
/*
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsIFrame::GetShowFrameBorders()) {
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0,0,128));
|
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
1998-04-30 04:27:59 +04:00
|
|
|
*/
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect);
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// aDirtyRect is in our coordinate system
|
|
|
|
// child rect's are also in our coordinate system
|
|
|
|
/** overloaded method from nsContainerFrame. The difference is that
|
|
|
|
* we don't want to clip our children, so a cell can do a rowspan
|
|
|
|
*/
|
|
|
|
void nsTableRowFrame::PaintChildren(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect)
|
|
|
|
{
|
|
|
|
nsIFrame* kid = mFirstChild;
|
|
|
|
while (nsnull != kid) {
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIView *pView;
|
|
|
|
|
|
|
|
kid->GetView(pView);
|
1998-04-15 01:49:29 +04:00
|
|
|
if (nsnull == pView) {
|
|
|
|
nsRect kidRect;
|
|
|
|
kid->GetRect(kidRect);
|
1998-06-14 04:45:21 +04:00
|
|
|
nsRect damageArea;
|
|
|
|
PRBool overlap = damageArea.IntersectRect(aDirtyRect, kidRect);
|
|
|
|
if (overlap) {
|
|
|
|
// Translate damage area into kid's coordinate system
|
|
|
|
nsRect kidDamageArea(damageArea.x - kidRect.x,
|
|
|
|
damageArea.y - kidRect.y,
|
|
|
|
damageArea.width, damageArea.height);
|
|
|
|
aRenderingContext.PushState();
|
|
|
|
aRenderingContext.Translate(kidRect.x, kidRect.y);
|
|
|
|
kid->Paint(aPresContext, aRenderingContext, kidDamageArea);
|
|
|
|
if (nsIFrame::GetShowFrameBorders()) {
|
|
|
|
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
|
|
|
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
|
|
|
|
}
|
|
|
|
aRenderingContext.PopState();
|
1998-04-15 01:49:29 +04:00
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
} else {
|
1998-04-15 01:49:29 +04:00
|
|
|
NS_RELEASE(pView);
|
1998-04-17 05:41:24 +04:00
|
|
|
}
|
|
|
|
kid->GetNextSibling(kid);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
void nsTableRowFrame::SetRowIndex (int aRowIndex)
|
|
|
|
{
|
|
|
|
mRowIndex = aRowIndex;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
/** returns the height of the tallest child in this row (ignoring any cell with rowspans) */
|
|
|
|
nscoord nsTableRowFrame::GetTallestChild() const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
return mTallestCell;
|
|
|
|
}
|
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
nscoord nsTableRowFrame::GetChildMaxTopMargin() const
|
|
|
|
{
|
|
|
|
return mCellMaxTopMargin;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord nsTableRowFrame::GetChildMaxBottomMargin() const
|
|
|
|
{
|
|
|
|
return mCellMaxBottomMargin;
|
|
|
|
}
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
PRInt32 nsTableRowFrame::GetMaxColumns() const
|
|
|
|
{
|
|
|
|
int sum = 0;
|
1998-06-26 04:48:44 +04:00
|
|
|
nsTableCellFrame *cell=(nsTableCellFrame *)mFirstChild;
|
1998-06-17 20:38:24 +04:00
|
|
|
while (nsnull!=cell) {
|
|
|
|
sum += cell->GetColSpan();
|
|
|
|
cell->GetNextSibling((nsIFrame *&)cell);
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
|
1998-06-24 23:13:19 +04:00
|
|
|
/* GetMinRowSpan is needed for deviant cases where every cell in a row has a rowspan > 1.
|
|
|
|
* It sets mMinRowSpan, which is used in FixMinCellHeight and PlaceChild
|
|
|
|
*/
|
|
|
|
void nsTableRowFrame::GetMinRowSpan()
|
|
|
|
{
|
|
|
|
PRInt32 minRowSpan=-1;
|
|
|
|
nsIFrame *frame=mFirstChild;
|
|
|
|
while (nsnull!=frame)
|
|
|
|
{
|
|
|
|
PRInt32 rowSpan = ((nsTableCellFrame *)frame)->GetRowSpan();
|
|
|
|
if (-1==minRowSpan)
|
|
|
|
minRowSpan = rowSpan;
|
|
|
|
else if (minRowSpan>rowSpan)
|
|
|
|
minRowSpan = rowSpan;
|
|
|
|
frame->GetNextSibling(frame);
|
|
|
|
}
|
|
|
|
mMinRowSpan = minRowSpan;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableRowFrame::FixMinCellHeight()
|
|
|
|
{
|
|
|
|
nsIFrame *frame=mFirstChild;
|
|
|
|
while (nsnull!=frame)
|
|
|
|
{
|
|
|
|
PRInt32 rowSpan = ((nsTableCellFrame *)frame)->GetRowSpan();
|
|
|
|
if (mMinRowSpan==rowSpan)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
frame->GetRect(rect);
|
|
|
|
if (rect.height > mTallestCell)
|
|
|
|
mTallestCell = rect.height;
|
|
|
|
}
|
|
|
|
frame->GetNextSibling(frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
// Position and size aKidFrame and update our reflow state. The origin of
|
|
|
|
// aKidRect is relative to the upper-left origin of our frame, and includes
|
|
|
|
// any left/top margin.
|
|
|
|
void nsTableRowFrame::PlaceChild(nsIPresContext* aPresContext,
|
|
|
|
RowReflowState& aState,
|
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
const nsRect& aKidRect,
|
|
|
|
nsSize* aMaxElementSize,
|
|
|
|
nsSize& aKidMaxElementSize)
|
|
|
|
{
|
|
|
|
if (PR_TRUE==gsDebug1)
|
|
|
|
printf ("row: placing cell at %d, %d, %d, %d\n",
|
|
|
|
aKidRect.x, aKidRect.y, aKidRect.width, aKidRect.height);
|
|
|
|
|
|
|
|
// Place and size the child
|
|
|
|
aKidFrame->SetRect(aKidRect);
|
|
|
|
|
1998-06-03 04:43:53 +04:00
|
|
|
// update the running total for the row width
|
|
|
|
aState.x += aKidRect.width;
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
// Update the maximum element size
|
|
|
|
PRInt32 rowSpan = ((nsTableCellFrame*)aKidFrame)->GetRowSpan();
|
1998-05-22 03:43:18 +04:00
|
|
|
if (nsnull != aMaxElementSize)
|
|
|
|
{
|
1998-04-23 21:29:07 +04:00
|
|
|
aMaxElementSize->width += aKidMaxElementSize.width;
|
1998-06-24 23:13:19 +04:00
|
|
|
if ((mMinRowSpan==rowSpan) && (aKidMaxElementSize.height>aMaxElementSize->height))
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
|
|
|
aMaxElementSize->height = aKidMaxElementSize.height;
|
|
|
|
}
|
|
|
|
}
|
1998-06-24 23:13:19 +04:00
|
|
|
if ((mMinRowSpan==rowSpan) && (aState.maxCellHeight<aKidRect.height))
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
|
|
|
aState.maxCellHeight = aKidRect.height;
|
|
|
|
}
|
1998-06-24 23:13:19 +04:00
|
|
|
if ((mMinRowSpan==rowSpan))
|
1998-05-22 03:43:18 +04:00
|
|
|
{
|
|
|
|
nsMargin margin(0,0,0,0);
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
if (aState.tableFrame->GetCellMarginData((nsTableCellFrame *)aKidFrame, margin) == NS_OK)
|
1998-05-22 03:43:18 +04:00
|
|
|
{
|
|
|
|
nscoord height = aKidRect.height + margin.top + margin.bottom;
|
|
|
|
|
|
|
|
if (height > aState.maxCellVertSpace)
|
|
|
|
aState.maxCellVertSpace = height;
|
|
|
|
}
|
|
|
|
}
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reflow the frames we've already created
|
|
|
|
*
|
|
|
|
* @param aPresContext presentation context to use
|
|
|
|
* @param aState current inline state
|
|
|
|
* @return true if we successfully reflowed all the mapped children and false
|
|
|
|
* otherwise, e.g. we pushed children to the next in flow
|
|
|
|
*/
|
|
|
|
PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
|
|
|
RowReflowState& aState,
|
|
|
|
nsSize* aMaxElementSize)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
#ifdef NS_DEBUG
|
1998-04-23 21:29:07 +04:00
|
|
|
VerifyLastIsComplete();
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif
|
1998-04-23 21:29:07 +04:00
|
|
|
#ifdef NOISY
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": reflow mapped (childCount=%d) [%d,%d,%c]\n",
|
|
|
|
mChildCount,
|
|
|
|
mFirstContentOffset, mLastContentOffset,
|
|
|
|
(mLastContentIsComplete ? 'T' : 'F'));
|
|
|
|
#ifdef NOISY_FLOW
|
|
|
|
{
|
|
|
|
nsTableRowFrame* flow = (nsTableRowFrame*) mNextInFlow;
|
|
|
|
while (flow != 0) {
|
|
|
|
printf(" %p: [%d,%d,%c]\n",
|
|
|
|
flow, flow->mFirstContentOffset, flow->mLastContentOffset,
|
|
|
|
(flow->mLastContentIsComplete ? 'T' : 'F'));
|
|
|
|
flow = (nsTableRowFrame*) flow->mNextInFlow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
NS_PRECONDITION(nsnull != mFirstChild, "no children");
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
PRInt32 childCount = 0;
|
|
|
|
nsIFrame* prevKidFrame = nsnull;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
// Remember our original mLastContentIsComplete so that if we end up
|
|
|
|
// having to push children, we have the correct value to hand to
|
|
|
|
// PushChildren.
|
|
|
|
PRBool lastContentIsComplete = mLastContentIsComplete;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
nsSize kidMaxElementSize;
|
|
|
|
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
|
|
|
PRBool result = PR_TRUE;
|
|
|
|
nscoord maxCellTopMargin = 0;
|
|
|
|
nscoord maxCellBottomMargin = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) {
|
|
|
|
nsSize kidAvailSize(aState.availSize);
|
|
|
|
if (0>=kidAvailSize.height)
|
|
|
|
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-25 21:31:49 +04:00
|
|
|
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
1998-06-03 04:43:53 +04:00
|
|
|
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
1998-05-22 03:43:18 +04:00
|
|
|
nsReflowStatus status;
|
|
|
|
|
|
|
|
nsMargin kidMargin(0,0,0,0);
|
1998-06-17 20:38:24 +04:00
|
|
|
aState.tableFrame->GetCellMarginData((nsTableCellFrame *)kidFrame,kidMargin);
|
1998-05-22 03:43:18 +04:00
|
|
|
if (kidMargin.top > maxCellTopMargin)
|
|
|
|
maxCellTopMargin = kidMargin.top;
|
|
|
|
if (kidMargin.bottom > maxCellBottomMargin)
|
|
|
|
maxCellBottomMargin = kidMargin.bottom;
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
// Figure out the amount of available size for the child (subtract
|
|
|
|
// off the top margin we are going to apply to it)
|
1998-05-22 03:43:18 +04:00
|
|
|
if (PR_FALSE == aState.unconstrainedHeight)
|
|
|
|
{
|
|
|
|
kidAvailSize.height -= kidMargin.top + kidMargin.bottom;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
// Subtract off for left and right margin
|
|
|
|
if (PR_FALSE == aState.unconstrainedWidth) {
|
1998-05-13 02:28:01 +04:00
|
|
|
kidAvailSize.width -= kidMargin.left + kidMargin.right;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
|
1998-06-24 22:09:47 +04:00
|
|
|
// Compute the x-origin for the child, taking into account straddlers (cells from prior
|
|
|
|
// rows with rowspans > 1)
|
|
|
|
nscoord x = kidMargin.left;
|
|
|
|
PRInt32 cellColIndex = ((nsTableCellFrame *)kidFrame)->GetColIndex();
|
|
|
|
for (PRInt32 colIndex=0; colIndex<cellColIndex; colIndex++)
|
|
|
|
{
|
|
|
|
x += aState.tableFrame->GetColumnWidth(colIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reflow the child
|
|
|
|
kidFrame->WillReflow(*aPresContext);
|
|
|
|
kidFrame->MoveTo(x, kidMargin.top);
|
|
|
|
|
1998-06-29 07:09:14 +04:00
|
|
|
// at this point, we know the column widths.
|
|
|
|
// so we get the avail width from the known column widths
|
|
|
|
nsCellLayoutData *cellData = aState.tableFrame->GetCellLayoutData((nsTableCellFrame *)kidFrame);
|
|
|
|
PRInt32 cellStartingCol = ((nsTableCellFrame *)kidFrame)->GetColIndex();
|
|
|
|
PRInt32 cellColSpan = ((nsTableCellFrame *)kidFrame)->GetColSpan();
|
|
|
|
nscoord availWidth = 0;
|
|
|
|
for (PRInt32 numColSpan=0; numColSpan<cellColSpan; numColSpan++)
|
|
|
|
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
|
|
|
|
|
|
|
|
kidAvailSize.width = availWidth;
|
|
|
|
nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
|
|
|
|
eReflowReason_Resize);
|
|
|
|
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
|
|
|
|
|
1998-06-03 04:43:53 +04:00
|
|
|
if (gsDebug1)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
1998-06-03 04:43:53 +04:00
|
|
|
if (nsnull!=pKidMaxElementSize)
|
|
|
|
printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
|
|
|
|
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
|
|
|
desiredSize.width, desiredSize.height,
|
|
|
|
pKidMaxElementSize->width, pKidMaxElementSize->height);
|
|
|
|
else
|
|
|
|
printf("reflow of cell returned result = %s with desired=%d,%d, min = nsnull\n",
|
|
|
|
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
|
|
|
desiredSize.width, desiredSize.height);
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
// Did the child fit?
|
|
|
|
if ((kidFrame != mFirstChild) &&
|
|
|
|
((kidAvailSize.height <= 0) ||
|
|
|
|
(desiredSize.height > kidAvailSize.height)))
|
|
|
|
{
|
|
|
|
// The child's height is too big to fit at all in our remaining space,
|
|
|
|
// and it's not our first child.
|
|
|
|
|
|
|
|
// Since we are giving the next-in-flow our last child, we
|
|
|
|
// give it our original mLastContentIsComplete, too (in case we
|
|
|
|
// are pushing into an empty next-in-flow)
|
|
|
|
PushChildren(kidFrame, prevKidFrame, lastContentIsComplete);
|
|
|
|
SetLastContentOffset(prevKidFrame);
|
|
|
|
|
|
|
|
// Our mLastContentIsComplete was already set by the last kid we
|
|
|
|
// reflowed reflow's status
|
|
|
|
result = PR_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-06-03 04:43:53 +04:00
|
|
|
// Place the child after taking into account it's margin and attributes
|
|
|
|
nscoord specifiedHeight = 0;
|
|
|
|
nscoord cellHeight = desiredSize.height;
|
|
|
|
nsIStyleContextPtr kidSC;
|
|
|
|
kidFrame->GetStyleContext(aPresContext, kidSC.AssignRef());
|
1998-06-05 10:09:09 +04:00
|
|
|
const nsStylePosition* kidPosition = (const nsStylePosition*)
|
|
|
|
kidSC->GetStyleData(eStyleStruct_Position);
|
1998-06-03 04:43:53 +04:00
|
|
|
switch (kidPosition->mHeight.GetUnit()) {
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
specifiedHeight = kidPosition->mHeight.GetCoordValue();
|
|
|
|
break;
|
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
case eStyleUnit_Inherit:
|
|
|
|
// XXX for now, do nothing
|
1998-06-03 04:43:53 +04:00
|
|
|
default:
|
|
|
|
case eStyleUnit_Auto:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (specifiedHeight>cellHeight)
|
|
|
|
cellHeight = specifiedHeight;
|
1998-06-24 03:23:21 +04:00
|
|
|
|
|
|
|
nscoord cellWidth = desiredSize.width;
|
|
|
|
// begin special Nav4 compatibility code
|
|
|
|
if (0==cellWidth)
|
|
|
|
{
|
|
|
|
cellWidth = aState.tableFrame->GetColumnWidth(cellColIndex);
|
|
|
|
}
|
|
|
|
// end special Nav4 compatibility code
|
|
|
|
|
1998-06-24 22:09:47 +04:00
|
|
|
// Adjust the running x-offset
|
|
|
|
aState.x = x;
|
|
|
|
|
|
|
|
// Place the child
|
|
|
|
nsRect kidRect (x, kidMargin.top, cellWidth, cellHeight);
|
1998-06-24 03:23:21 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize,
|
|
|
|
kidMaxElementSize);
|
|
|
|
childCount++;
|
|
|
|
|
|
|
|
// Remember where we just were in case we end up pushing children
|
|
|
|
prevKidFrame = kidFrame;
|
|
|
|
|
|
|
|
// Update mLastContentIsComplete now that this kid fits
|
1998-05-12 08:17:56 +04:00
|
|
|
mLastContentIsComplete = NS_FRAME_IS_COMPLETE(status);
|
1998-04-23 21:29:07 +04:00
|
|
|
|
|
|
|
/* Rows should not create continuing frames for cells
|
|
|
|
* unless they absolutely have to!
|
|
|
|
* check to see if this is absolutely necessary (with new params from troy)
|
|
|
|
* otherwise PushChildren and bail.
|
|
|
|
*/
|
|
|
|
// Special handling for incomplete children
|
1998-05-12 08:17:56 +04:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(status)) {
|
1998-04-23 21:29:07 +04:00
|
|
|
// XXX It's good to assume that we might still have room
|
|
|
|
// even if the child didn't complete (floaters will want this)
|
|
|
|
nsIFrame* kidNextInFlow;
|
|
|
|
|
|
|
|
kidFrame->GetNextInFlow(kidNextInFlow);
|
|
|
|
PRBool lastContentIsComplete = mLastContentIsComplete;
|
|
|
|
if (nsnull == kidNextInFlow) {
|
|
|
|
// No the child isn't complete, and it doesn't have a next in flow so
|
|
|
|
// create a continuing frame. This hooks the child into the flow.
|
|
|
|
nsIFrame* continuingFrame;
|
1998-05-07 04:08:20 +04:00
|
|
|
nsIStyleContext* kidSC;
|
|
|
|
kidFrame->GetStyleContext(aPresContext, kidSC);
|
|
|
|
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
|
|
|
|
continuingFrame);
|
|
|
|
NS_RELEASE(kidSC);
|
1998-04-23 21:29:07 +04:00
|
|
|
|
|
|
|
// Insert the frame. We'll reflow it next pass through the loop
|
|
|
|
nsIFrame* nextSib;
|
|
|
|
|
|
|
|
kidFrame->GetNextSibling(nextSib);
|
|
|
|
continuingFrame->SetNextSibling(nextSib);
|
|
|
|
kidFrame->SetNextSibling(continuingFrame);
|
|
|
|
if (nsnull == nextSib) {
|
|
|
|
// Assume that the continuation frame we just created is
|
|
|
|
// complete, for now. It will get reflowed by our
|
|
|
|
// next-in-flow (we are going to push it now)
|
|
|
|
lastContentIsComplete = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// We've used up all of our available space so push the remaining
|
|
|
|
// children to the next-in-flow
|
|
|
|
nsIFrame* nextSibling;
|
|
|
|
|
|
|
|
kidFrame->GetNextSibling(nextSibling);
|
|
|
|
if (nsnull != nextSibling) {
|
|
|
|
PushChildren(nextSibling, kidFrame, lastContentIsComplete);
|
|
|
|
SetLastContentOffset(prevKidFrame);
|
|
|
|
}
|
|
|
|
result = PR_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add back in the left and right margins, because one row does not
|
|
|
|
// impact another row's width
|
|
|
|
if (PR_FALSE == aState.unconstrainedWidth) {
|
1998-05-13 02:28:01 +04:00
|
|
|
kidAvailSize.width += kidMargin.left + kidMargin.right;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the next child
|
|
|
|
kidFrame->GetNextSibling(kidFrame);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
SetMaxChildHeight(aState.maxCellHeight,maxCellTopMargin, maxCellBottomMargin); // remember height of tallest child who doesn't have a row span
|
1998-04-23 21:29:07 +04:00
|
|
|
|
|
|
|
// Update the child count
|
|
|
|
mChildCount = childCount;
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
NS_POSTCONDITION(LengthOf(mFirstChild) == mChildCount, "bad child count");
|
|
|
|
|
|
|
|
nsIFrame* lastChild;
|
|
|
|
PRInt32 lastIndexInParent;
|
|
|
|
|
|
|
|
LastChild(lastChild);
|
1998-05-06 03:56:50 +04:00
|
|
|
lastChild->GetContentIndex(lastIndexInParent);
|
1998-04-23 21:29:07 +04:00
|
|
|
NS_POSTCONDITION(lastIndexInParent == mLastContentOffset, "bad last content offset");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
VerifyLastIsComplete();
|
|
|
|
#endif
|
|
|
|
#ifdef NOISY
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": reflow mapped %sok (childCount=%d) [%d,%d,%c]\n",
|
|
|
|
(result ? "" : "NOT "),
|
|
|
|
mChildCount,
|
|
|
|
mFirstContentOffset, mLastContentOffset,
|
|
|
|
(mLastContentIsComplete ? 'T' : 'F'));
|
|
|
|
#ifdef NOISY_FLOW
|
|
|
|
{
|
|
|
|
nsTableRowFrame* flow = (nsTableRowFrame*) mNextInFlow;
|
|
|
|
while (flow != 0) {
|
|
|
|
printf(" %p: [%d,%d,%c]\n",
|
|
|
|
flow, flow->mFirstContentOffset, flow->mLastContentOffset,
|
|
|
|
(flow->mLastContentIsComplete ? 'T' : 'F'));
|
|
|
|
flow = (nsTableRowFrame*) flow->mNextInFlow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try and pull-up frames from our next-in-flow
|
|
|
|
*
|
|
|
|
* @param aPresContext presentation context to use
|
|
|
|
* @param aState current inline state
|
|
|
|
* @return true if we successfully pulled-up all the children and false
|
|
|
|
* otherwise, e.g. child didn't fit
|
|
|
|
*/
|
|
|
|
PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext,
|
|
|
|
RowReflowState& aState,
|
|
|
|
nsSize* aMaxElementSize)
|
|
|
|
{
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
VerifyLastIsComplete();
|
|
|
|
#endif
|
|
|
|
#ifdef NOISY
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": pullup (childCount=%d) [%d,%d,%c]\n",
|
|
|
|
mChildCount,
|
|
|
|
mFirstContentOffset, mLastContentOffset,
|
|
|
|
(mLastContentIsComplete ? 'T' : 'F'));
|
|
|
|
#ifdef NOISY_FLOW
|
|
|
|
{
|
|
|
|
nsTableRowFrame* flow = (nsTableRowFrame*) mNextInFlow;
|
|
|
|
while (flow != 0) {
|
|
|
|
printf(" %p: [%d,%d,%c]\n",
|
|
|
|
flow, flow->mFirstContentOffset, flow->mLastContentOffset,
|
|
|
|
(flow->mLastContentIsComplete ? 'T' : 'F'));
|
|
|
|
flow = (nsTableRowFrame*) flow->mNextInFlow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
nsTableRowFrame* nextInFlow = (nsTableRowFrame*)mNextInFlow;
|
|
|
|
nsSize kidMaxElementSize;
|
|
|
|
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
|
|
|
nsSize kidAvailSize(aState.availSize);
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
PRInt32 kidIndex = NextChildOffset();
|
|
|
|
#endif
|
|
|
|
nsIFrame* prevKidFrame;
|
|
|
|
|
|
|
|
LastChild(prevKidFrame);
|
|
|
|
|
|
|
|
// This will hold the prevKidFrame's mLastContentIsComplete
|
|
|
|
// status. If we have to push the frame that follows prevKidFrame
|
|
|
|
// then this will become our mLastContentIsComplete state. Since
|
|
|
|
// prevKidFrame is initially our last frame, it's completion status
|
|
|
|
// is our mLastContentIsComplete value.
|
|
|
|
PRBool prevLastContentIsComplete = mLastContentIsComplete;
|
|
|
|
|
|
|
|
PRBool result = PR_TRUE;
|
|
|
|
|
|
|
|
while (nsnull != nextInFlow) {
|
1998-05-25 21:31:49 +04:00
|
|
|
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
1998-06-03 04:43:53 +04:00
|
|
|
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
1998-05-12 08:17:56 +04:00
|
|
|
nsReflowStatus status;
|
1998-04-23 21:29:07 +04:00
|
|
|
|
|
|
|
// Get the next child
|
|
|
|
nsIFrame* kidFrame = nextInFlow->mFirstChild;
|
|
|
|
|
|
|
|
// Any more child frames?
|
|
|
|
if (nsnull == kidFrame) {
|
|
|
|
// No. Any frames on its overflow list?
|
|
|
|
if (nsnull != nextInFlow->mOverflowList) {
|
|
|
|
// Move the overflow list to become the child list
|
|
|
|
// NS_ABORT();
|
|
|
|
nextInFlow->AppendChildren(nextInFlow->mOverflowList);
|
|
|
|
nextInFlow->mOverflowList = nsnull;
|
|
|
|
kidFrame = nextInFlow->mFirstChild;
|
|
|
|
} else {
|
|
|
|
// We've pulled up all the children, so move to the next-in-flow.
|
|
|
|
nextInFlow->GetNextInFlow((nsIFrame*&)nextInFlow);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if the child fits in the available space. If it fits or
|
|
|
|
// it's splittable then reflow it. The reason we can't just move
|
|
|
|
// it is that we still need ascent/descent information
|
1998-06-03 04:43:53 +04:00
|
|
|
nsSize kidFrameSize(0,0);
|
1998-05-22 08:54:11 +04:00
|
|
|
nsSplittableType kidIsSplittable;
|
1998-04-23 21:29:07 +04:00
|
|
|
|
|
|
|
kidFrame->GetSize(kidFrameSize);
|
|
|
|
kidFrame->IsSplittable(kidIsSplittable);
|
|
|
|
|
|
|
|
if ((kidFrameSize.height > aState.availSize.height) &&
|
1998-05-22 08:54:11 +04:00
|
|
|
NS_FRAME_IS_NOT_SPLITTABLE(kidIsSplittable)) {
|
1998-04-23 21:29:07 +04:00
|
|
|
result = PR_FALSE;
|
|
|
|
mLastContentIsComplete = prevLastContentIsComplete;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we're in a constrained situation, so get the avail width from the known column widths
|
1998-06-17 20:38:24 +04:00
|
|
|
nsCellLayoutData *cellData = aState.tableFrame->GetCellLayoutData((nsTableCellFrame *)kidFrame);
|
|
|
|
PRInt32 cellStartingCol = ((nsTableCellFrame *)kidFrame)->GetColIndex();
|
|
|
|
PRInt32 cellColSpan = ((nsTableCellFrame *)kidFrame)->GetColSpan();
|
1998-04-23 21:29:07 +04:00
|
|
|
nscoord availWidth = 0;
|
|
|
|
for (PRInt32 numColSpan=0; numColSpan<cellColSpan; numColSpan++)
|
|
|
|
availWidth += aState.tableFrame->GetColumnWidth(cellStartingCol+numColSpan);
|
|
|
|
NS_ASSERTION(0<availWidth, "illegal width for this column");
|
|
|
|
kidAvailSize.width = availWidth;
|
1998-05-30 00:36:05 +04:00
|
|
|
nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
|
|
|
|
eReflowReason_Resize);
|
1998-05-28 22:37:56 +04:00
|
|
|
kidFrame->WillReflow(*aPresContext);
|
1998-05-25 21:31:49 +04:00
|
|
|
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
|
1998-04-23 21:29:07 +04:00
|
|
|
if (nsnull!=pKidMaxElementSize)
|
|
|
|
{
|
|
|
|
if (gsDebug1)
|
|
|
|
{
|
|
|
|
if (nsnull!=pKidMaxElementSize)
|
|
|
|
printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
|
1998-05-12 08:17:56 +04:00
|
|
|
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
1998-04-23 21:29:07 +04:00
|
|
|
desiredSize.width, desiredSize.height,
|
|
|
|
pKidMaxElementSize->width, pKidMaxElementSize->height);
|
|
|
|
else
|
|
|
|
printf("reflow of cell returned result = %s with desired=%d,%d, min = nsnull\n",
|
1998-05-12 08:17:56 +04:00
|
|
|
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
1998-04-23 21:29:07 +04:00
|
|
|
desiredSize.width, desiredSize.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Did the child fit?
|
|
|
|
if ((desiredSize.height > aState.availSize.height) && (nsnull != mFirstChild)) {
|
|
|
|
// The child is too tall to fit in the available space, and it's
|
|
|
|
// not our first child
|
|
|
|
result = PR_FALSE;
|
|
|
|
mLastContentIsComplete = prevLastContentIsComplete;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Adjust the running x-offset, taking into account intruders (cells from prior rows with rowspans > 1)
|
|
|
|
aState.x = 0;
|
|
|
|
PRInt32 cellColIndex = ((nsTableCellFrame *)kidFrame)->GetColIndex();
|
|
|
|
for (PRInt32 colIndex=0; colIndex<cellColIndex; colIndex++)
|
|
|
|
aState.x += aState.tableFrame->GetColumnWidth(colIndex);
|
|
|
|
// Place the child
|
|
|
|
nsRect kidRect (aState.x, 0, desiredSize.width, desiredSize.height);
|
|
|
|
PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize);
|
|
|
|
|
|
|
|
// Remove the frame from its current parent
|
|
|
|
kidFrame->GetNextSibling(nextInFlow->mFirstChild);
|
|
|
|
nextInFlow->mChildCount--;
|
|
|
|
// Update the next-in-flows first content offset
|
|
|
|
if (nsnull != nextInFlow->mFirstChild) {
|
|
|
|
nextInFlow->SetFirstContentOffset(nextInFlow->mFirstChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Link the frame into our list of children
|
|
|
|
kidFrame->SetGeometricParent(this);
|
|
|
|
nsIFrame* kidContentParent;
|
|
|
|
|
|
|
|
kidFrame->GetContentParent(kidContentParent);
|
|
|
|
if (nextInFlow == kidContentParent) {
|
|
|
|
kidFrame->SetContentParent(this);
|
|
|
|
}
|
|
|
|
if (nsnull == prevKidFrame) {
|
|
|
|
mFirstChild = kidFrame;
|
|
|
|
SetFirstContentOffset(kidFrame);
|
|
|
|
} else {
|
|
|
|
prevKidFrame->SetNextSibling(kidFrame);
|
|
|
|
}
|
|
|
|
kidFrame->SetNextSibling(nsnull);
|
|
|
|
mChildCount++;
|
|
|
|
|
|
|
|
// Remember where we just were in case we end up pushing children
|
|
|
|
prevKidFrame = kidFrame;
|
|
|
|
prevLastContentIsComplete = mLastContentIsComplete;
|
|
|
|
|
|
|
|
// Is the child we just pulled up complete?
|
1998-05-12 08:17:56 +04:00
|
|
|
mLastContentIsComplete = NS_FRAME_IS_COMPLETE(status);
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(status)) {
|
1998-04-23 21:29:07 +04:00
|
|
|
// No the child isn't complete
|
|
|
|
nsIFrame* kidNextInFlow;
|
|
|
|
|
|
|
|
kidFrame->GetNextInFlow(kidNextInFlow);
|
|
|
|
if (nsnull == kidNextInFlow) {
|
|
|
|
// The child doesn't have a next-in-flow so create a
|
|
|
|
// continuing frame. The creation appends it to the flow and
|
|
|
|
// prepares it for reflow.
|
|
|
|
nsIFrame* continuingFrame;
|
1998-05-07 04:08:20 +04:00
|
|
|
nsIStyleContext* kidSC;
|
|
|
|
kidFrame->GetStyleContext(aPresContext, kidSC);
|
|
|
|
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
|
|
|
|
continuingFrame);
|
|
|
|
NS_RELEASE(kidSC);
|
1998-04-23 21:29:07 +04:00
|
|
|
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
|
|
|
|
|
|
|
|
// Add the continuing frame to our sibling list and then push
|
|
|
|
// it to the next-in-flow. This ensures the next-in-flow's
|
|
|
|
// content offsets and child count are set properly. Note that
|
|
|
|
// we can safely assume that the continuation is complete so
|
|
|
|
// we pass PR_TRUE into PushChidren in case our next-in-flow
|
|
|
|
// was just drained and now needs to know it's
|
|
|
|
// mLastContentIsComplete state.
|
|
|
|
kidFrame->SetNextSibling(continuingFrame);
|
|
|
|
|
|
|
|
PushChildren(continuingFrame, kidFrame, PR_TRUE);
|
|
|
|
|
|
|
|
// After we push the continuation frame we don't need to fuss
|
|
|
|
// with mLastContentIsComplete beause the continuation frame
|
|
|
|
// is no longer on *our* list.
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the child isn't complete then it means that we've used up
|
|
|
|
// all of our available space.
|
|
|
|
result = PR_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update our last content offset
|
|
|
|
if (nsnull != prevKidFrame) {
|
|
|
|
NS_ASSERTION(IsLastChild(prevKidFrame), "bad last child");
|
|
|
|
SetLastContentOffset(prevKidFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
// We need to make sure the first content offset is correct for any empty
|
|
|
|
// next-in-flow frames (frames where we pulled up all the child frames)
|
|
|
|
nextInFlow = (nsTableRowFrame*)mNextInFlow;
|
|
|
|
if ((nsnull != nextInFlow) && (nsnull == nextInFlow->mFirstChild)) {
|
|
|
|
// We have at least one empty frame. Did we succesfully pull up all the
|
|
|
|
// child frames?
|
|
|
|
if (PR_FALSE == result) {
|
|
|
|
// No, so we need to adjust the first content offset of all the empty
|
|
|
|
// frames
|
|
|
|
AdjustOffsetOfEmptyNextInFlows();
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
} else {
|
|
|
|
// Yes, we successfully pulled up all the child frames which means all
|
|
|
|
// the next-in-flows must be empty. Do a sanity check
|
|
|
|
while (nsnull != nextInFlow) {
|
|
|
|
NS_ASSERTION(nsnull == nextInFlow->mFirstChild, "non-empty next-in-flow");
|
|
|
|
nextInFlow->GetNextInFlow((nsIFrame*&)nextInFlow);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
VerifyLastIsComplete();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NOISY
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": pullup %sok (childCount=%d) [%d,%d,%c]\n",
|
|
|
|
(result ? "" : "NOT "),
|
|
|
|
mChildCount,
|
|
|
|
mFirstContentOffset, mLastContentOffset,
|
|
|
|
(mLastContentIsComplete ? 'T' : 'F'));
|
|
|
|
#ifdef NOISY_FLOW
|
|
|
|
{
|
|
|
|
nsTableRowFrame* flow = (nsTableRowFrame*) mNextInFlow;
|
|
|
|
while (flow != 0) {
|
|
|
|
printf(" %p: [%d,%d,%c]\n",
|
|
|
|
flow, flow->mFirstContentOffset, flow->mLastContentOffset,
|
|
|
|
(flow->mLastContentIsComplete ? 'T' : 'F'));
|
|
|
|
flow = (nsTableRowFrame*) flow->mNextInFlow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create new frames for content we haven't yet mapped
|
|
|
|
*
|
|
|
|
* @param aPresContext presentation context to use
|
|
|
|
* @param aState current inline state
|
1998-05-12 08:17:56 +04:00
|
|
|
* @return NS_FRAME_COMPLETE if all content has been mapped and NS_FRAME_NOT_COMPLETE
|
1998-04-23 21:29:07 +04:00
|
|
|
* if we should be continued
|
|
|
|
*/
|
1998-05-12 08:17:56 +04:00
|
|
|
nsReflowStatus
|
1998-04-23 21:29:07 +04:00
|
|
|
nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext,
|
|
|
|
RowReflowState& aState,
|
|
|
|
nsSize* aMaxElementSize)
|
|
|
|
{
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
VerifyLastIsComplete();
|
|
|
|
#endif
|
|
|
|
nsIFrame* kidPrevInFlow = nsnull;
|
1998-05-14 04:49:46 +04:00
|
|
|
nsReflowStatus result = NS_FRAME_NOT_COMPLETE;
|
1998-04-23 21:29:07 +04:00
|
|
|
|
|
|
|
// If we have no children and we have a prev-in-flow then we need to pick
|
|
|
|
// up where it left off. If we have children, e.g. we're being resized, then
|
|
|
|
// our content offset should already be set correctly...
|
|
|
|
if ((nsnull == mFirstChild) && (nsnull != mPrevInFlow)) {
|
|
|
|
nsTableRowFrame* prev = (nsTableRowFrame*)mPrevInFlow;
|
|
|
|
NS_ASSERTION(prev->mLastContentOffset >= prev->mFirstContentOffset, "bad prevInFlow");
|
|
|
|
|
|
|
|
mFirstContentOffset = prev->NextChildOffset();
|
|
|
|
if (!prev->mLastContentIsComplete) {
|
|
|
|
// Our prev-in-flow's last child is not complete
|
|
|
|
prev->LastChild(kidPrevInFlow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mLastContentIsComplete = PR_TRUE;
|
|
|
|
|
|
|
|
// Place our children, one at a time, until we are out of children
|
1998-06-03 04:43:53 +04:00
|
|
|
nsSize kidMaxElementSize(0,0);
|
1998-04-23 21:29:07 +04:00
|
|
|
nsSize* pKidMaxElementSize = (nsnull != aMaxElementSize) ? &kidMaxElementSize : nsnull;
|
|
|
|
PRInt32 kidIndex = NextChildOffset();
|
|
|
|
nsIFrame* prevKidFrame;
|
1998-05-22 03:43:18 +04:00
|
|
|
|
|
|
|
nscoord maxTopMargin = 0;
|
|
|
|
nscoord maxBottomMargin = 0;
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
LastChild(prevKidFrame); // XXX remember this...
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
for (;;) {
|
1998-06-29 07:09:14 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(NS_UNCONSTRAINEDSIZE==aState.availSize.width, "bad size");
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
// Get the next content object
|
|
|
|
nsIContent* cell = mContent->ChildAt(kidIndex);
|
1998-04-21 02:49:15 +04:00
|
|
|
if (nsnull == cell) {
|
1998-05-12 08:17:56 +04:00
|
|
|
result = NS_FRAME_COMPLETE;
|
1998-04-14 00:24:54 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
// Make sure we still have room left
|
|
|
|
if (aState.availSize.height <= 0) {
|
1998-05-12 08:17:56 +04:00
|
|
|
// Note: return status was set to NS_FRAME_NOT_COMPLETE above...
|
1998-04-23 21:29:07 +04:00
|
|
|
NS_RELEASE(cell); // cell: REFCNT--(a)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* kidFrame;
|
1998-07-01 00:12:45 +04:00
|
|
|
nsSize kidAvailSize(aState.availSize);
|
1998-06-05 06:36:25 +04:00
|
|
|
// Create a child frame -- always an nsTableCell frame
|
1998-06-17 20:38:24 +04:00
|
|
|
nsIStyleContext* kidStyleContext = aPresContext->ResolveStyleContextFor(cell, this, PR_TRUE);
|
1998-04-23 21:29:07 +04:00
|
|
|
if (nsnull == kidPrevInFlow) {
|
|
|
|
nsIContentDelegate* kidDel = nsnull;
|
1998-04-21 02:49:15 +04:00
|
|
|
kidDel = cell->GetDelegate(aPresContext);
|
1998-05-07 04:08:20 +04:00
|
|
|
nsresult rv = kidDel->CreateFrame(aPresContext, cell,
|
|
|
|
this, kidStyleContext, kidFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_RELEASE(kidDel);
|
1998-04-23 21:29:07 +04:00
|
|
|
} else {
|
1998-05-07 04:08:20 +04:00
|
|
|
kidPrevInFlow->CreateContinuingFrame(aPresContext, this,
|
|
|
|
kidStyleContext, kidFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-06-30 00:38:22 +04:00
|
|
|
// Determine the width we have to work with. By default, it's unconstrained
|
|
|
|
const nsStylePosition* cellPosition = (const nsStylePosition*)
|
|
|
|
(kidStyleContext->GetStyleData(eStyleStruct_Position));
|
|
|
|
if (eStyleUnit_Coord==cellPosition->mWidth.GetUnit())
|
|
|
|
{
|
|
|
|
kidAvailSize.width = cellPosition->mWidth.GetCoordValue();
|
|
|
|
}
|
|
|
|
// free the kid's style context
|
1998-04-23 21:29:07 +04:00
|
|
|
NS_RELEASE(kidStyleContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
|
|
|
|
nsMargin margin(0,0,0,0);
|
|
|
|
nscoord topMargin = 0;
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
if (aState.tableFrame->GetCellMarginData((nsTableCellFrame *)kidFrame, margin) == NS_OK)
|
1998-05-22 03:43:18 +04:00
|
|
|
{
|
|
|
|
topMargin = margin.top;
|
|
|
|
}
|
|
|
|
|
|
|
|
maxTopMargin = PR_MAX(margin.top,maxTopMargin);
|
|
|
|
maxBottomMargin = PR_MAX(margin.bottom,maxBottomMargin);
|
|
|
|
|
1998-06-24 20:35:21 +04:00
|
|
|
// Link child frame into the list of children
|
|
|
|
if (nsnull != prevKidFrame) {
|
|
|
|
prevKidFrame->SetNextSibling(kidFrame);
|
|
|
|
} else {
|
|
|
|
mFirstChild = kidFrame; // our first child
|
|
|
|
SetFirstContentOffset(kidFrame);
|
|
|
|
}
|
|
|
|
mChildCount++;
|
|
|
|
|
1998-06-24 22:09:47 +04:00
|
|
|
// If we're constrained compute the origin for the child frame
|
|
|
|
nscoord x = margin.left;
|
1998-06-24 20:35:21 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
// Try to reflow the child into the available space. It might not
|
|
|
|
// fit or might need continuing.
|
1998-05-25 21:31:49 +04:00
|
|
|
nsReflowMetrics desiredSize(pKidMaxElementSize);
|
1998-06-03 04:43:53 +04:00
|
|
|
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
1998-05-12 08:17:56 +04:00
|
|
|
nsReflowStatus status;
|
1998-06-24 20:35:21 +04:00
|
|
|
|
|
|
|
// Inform the child it's being reflowed
|
|
|
|
kidFrame->WillReflow(*aPresContext);
|
1998-06-24 22:09:47 +04:00
|
|
|
kidFrame->MoveTo(x, topMargin);
|
1998-06-29 07:09:14 +04:00
|
|
|
nsReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize,
|
|
|
|
eReflowReason_Initial);
|
|
|
|
// Reflow the child into the available space (always unconstrained space)
|
|
|
|
status = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
|
|
|
|
nsCellLayoutData *kidLayoutData = new nsCellLayoutData((nsTableCellFrame *)kidFrame, &desiredSize, pKidMaxElementSize);
|
|
|
|
((nsTableCellFrame *)kidFrame)->SetCellLayoutData(kidLayoutData);
|
1998-04-23 21:29:07 +04:00
|
|
|
if (nsnull!=pKidMaxElementSize)
|
1998-04-17 02:21:32 +04:00
|
|
|
{
|
1998-04-23 21:29:07 +04:00
|
|
|
if (gsDebug1)
|
|
|
|
{
|
|
|
|
if (nsnull!=pKidMaxElementSize)
|
|
|
|
printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
|
1998-05-12 08:17:56 +04:00
|
|
|
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
1998-04-23 21:29:07 +04:00
|
|
|
desiredSize.width, desiredSize.height,
|
|
|
|
pKidMaxElementSize->width, pKidMaxElementSize->height);
|
|
|
|
else
|
|
|
|
printf("reflow of cell returned result = %s with desired=%d,%d, min = nsnull\n",
|
1998-05-12 08:17:56 +04:00
|
|
|
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
1998-04-23 21:29:07 +04:00
|
|
|
desiredSize.width, desiredSize.height);
|
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
}
|
1998-04-23 21:29:07 +04:00
|
|
|
NS_RELEASE(cell); // cell: REFCNT--
|
|
|
|
|
|
|
|
// Did the child fit?
|
|
|
|
if ((desiredSize.height > aState.availSize.height) && (nsnull != mFirstChild)) {
|
|
|
|
// The child is too wide to fit in the available space, and it's
|
|
|
|
// not our first child. Add the frame to our overflow list
|
|
|
|
NS_ASSERTION(nsnull == mOverflowList, "bad overflow list");
|
|
|
|
mOverflowList = kidFrame;
|
|
|
|
prevKidFrame->SetNextSibling(nsnull);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-06-24 22:09:47 +04:00
|
|
|
// Update the running x-offset
|
|
|
|
aState.x = x;
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
// Place the child
|
1998-06-24 22:09:47 +04:00
|
|
|
nsRect kidRect (x, topMargin, desiredSize.width, desiredSize.height);
|
1998-04-23 21:29:07 +04:00
|
|
|
PlaceChild(aPresContext, aState, kidFrame, kidRect, aMaxElementSize, *pKidMaxElementSize);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
prevKidFrame = kidFrame;
|
|
|
|
kidIndex++;
|
1998-04-23 21:29:07 +04:00
|
|
|
|
|
|
|
// Did the child complete?
|
1998-05-12 08:17:56 +04:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(status)) {
|
1998-04-23 21:29:07 +04:00
|
|
|
// If the child isn't complete then it means that we've used up
|
|
|
|
// all of our available space
|
1998-04-14 00:24:54 +04:00
|
|
|
mLastContentIsComplete = PR_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
1998-04-23 21:29:07 +04:00
|
|
|
kidPrevInFlow = nsnull;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
SetMaxChildHeight(aState.maxCellHeight, maxTopMargin, maxBottomMargin); // remember height of tallest child who doesn't have a row span
|
1998-04-23 21:29:07 +04:00
|
|
|
|
|
|
|
// Update the content mapping
|
|
|
|
NS_ASSERTION(IsLastChild(prevKidFrame), "bad last child");
|
|
|
|
SetLastContentOffset(prevKidFrame);
|
1998-04-21 22:25:52 +04:00
|
|
|
#ifdef NS_DEBUG
|
1998-04-23 21:29:07 +04:00
|
|
|
PRInt32 len = LengthOf(mFirstChild);
|
|
|
|
NS_ASSERTION(len == mChildCount, "bad child count");
|
|
|
|
#endif
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
VerifyLastIsComplete();
|
|
|
|
#endif
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-07-01 07:03:32 +04:00
|
|
|
#if 0
|
|
|
|
// Recover the reflow state to what it should be if aKidFrame is about
|
|
|
|
// to be reflowed
|
|
|
|
nsresult nsTableRowFrame::RecoverState(RowReflowState& aState,
|
|
|
|
nsIFrame* aKidFrame)
|
|
|
|
{
|
|
|
|
// Get aKidFrame's previous sibling
|
|
|
|
nsIFrame* prevKidFrame = nsnull;
|
|
|
|
for (nsIFrame* frame = mFirstChild; frame != aKidFrame;) {
|
|
|
|
prevKidFrame = frame;
|
|
|
|
frame->GetNextSibling(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != prevKidFrame) {
|
|
|
|
nsRect rect;
|
|
|
|
|
|
|
|
// Set our running x-offset
|
|
|
|
prevKidFrame->GetRect(rect);
|
|
|
|
aState.x = rect.XMost();
|
|
|
|
|
|
|
|
// Adjust the available space
|
|
|
|
if (PR_FALSE == aState.unconstrainedWidth) {
|
|
|
|
aState.availSize.width -= aState.x;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the previous frame's bottom margin
|
|
|
|
const nsStyleSpacing* kidSpacing;
|
|
|
|
prevKidFrame->GetStyleData(eStyleStruct_Spacing, (nsStyleStruct *&)kidSpacing);
|
|
|
|
nsMargin margin;
|
|
|
|
kidSpacing->CalcMarginFor(prevKidFrame, margin);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the inner table max size
|
|
|
|
nsSize innerTableSize(0,0);
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-07-01 07:03:32 +04:00
|
|
|
mInnerTableFrame->GetSize(innerTableSize);
|
|
|
|
aState.innerTableMaxSize.width = innerTableSize.width;
|
|
|
|
aState.innerTableMaxSize.height = aState.reflowState.maxSize.height;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
/** Layout the entire row.
|
|
|
|
* This method stacks rows horizontally according to HTML 4.0 rules.
|
|
|
|
* Rows are responsible for layout of their children (cells).
|
|
|
|
*/
|
|
|
|
NS_METHOD
|
1998-05-25 21:31:49 +04:00
|
|
|
nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
|
|
|
|
nsReflowMetrics& aDesiredSize,
|
|
|
|
const nsReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
|
|
|
if (gsDebug1==PR_TRUE)
|
1998-05-25 21:31:49 +04:00
|
|
|
printf("nsTableRowFrame::Reflow - aMaxSize = %d, %d\n",
|
|
|
|
aReflowState.maxSize.width, aReflowState.maxSize.height);
|
1998-04-23 21:29:07 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
PreReflowCheck();
|
1998-04-21 22:25:52 +04:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-23 09:43:27 +04:00
|
|
|
RowReflowState state(aPresContext, aReflowState);
|
|
|
|
mContentParent->GetContentParent((nsIFrame*&)(state.tableFrame));
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-06-23 09:43:27 +04:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
1998-07-01 07:03:32 +04:00
|
|
|
// XXX Deal with the case where the reflow command is targeted at us
|
1998-06-25 02:05:59 +04:00
|
|
|
nsIFrame* target;
|
|
|
|
aReflowState.reflowCommand->GetTarget(target);
|
|
|
|
if (this == target) {
|
|
|
|
NS_NOTYETIMPLEMENTED("unexpected reflow command");
|
|
|
|
}
|
|
|
|
|
1998-07-01 07:03:32 +04:00
|
|
|
// Get the next frame in the reflow chain
|
1998-06-23 09:43:27 +04:00
|
|
|
nsIFrame* kidFrame;
|
|
|
|
aReflowState.reflowCommand->GetNext(kidFrame);
|
|
|
|
|
1998-07-01 07:03:32 +04:00
|
|
|
// Recover our reflow state
|
|
|
|
// RecoverState(state, kidFrame);
|
|
|
|
|
1998-06-23 09:43:27 +04:00
|
|
|
// Pass along the reflow command. Reflow the child with an unconstrained
|
|
|
|
// width and get its maxElementSize
|
|
|
|
nsSize kidMaxElementSize;
|
|
|
|
nsReflowMetrics desiredSize(&kidMaxElementSize);
|
|
|
|
// XXX Correctly compute the available height...
|
1998-06-24 08:38:52 +04:00
|
|
|
nsSize availSpace(aReflowState.maxSize);
|
1998-06-23 09:43:27 +04:00
|
|
|
nsReflowState kidReflowState(kidFrame, aReflowState, availSpace);
|
|
|
|
kidFrame->WillReflow(*aPresContext);
|
1998-06-24 08:38:52 +04:00
|
|
|
|
|
|
|
// XXX Unfortunately we need to reflow the child several times.
|
|
|
|
// The first time is for the incremental reflow command. We can't pass in
|
|
|
|
// a max width of NS_UNCONSTRAINEDSIZE, because the max width must match
|
|
|
|
// the width of the previous reflow...
|
|
|
|
aStatus = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
|
|
|
|
|
|
|
|
// Now do the regular pass 1 reflow and gather the max width and max element
|
|
|
|
// size.
|
|
|
|
// XXX It would be nice if we could skip this step and the next step if the
|
|
|
|
// column width isn't dependent on the max cell width...
|
|
|
|
kidReflowState.reason = eReflowReason_Resize;
|
|
|
|
kidReflowState.reflowCommand = nsnull;
|
|
|
|
kidReflowState.maxSize.width = NS_UNCONSTRAINEDSIZE;
|
1998-06-23 09:43:27 +04:00
|
|
|
aStatus = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState);
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-06-24 08:38:52 +04:00
|
|
|
// Update the cell layout data. Note that we need to do this for both
|
|
|
|
// the data the cell maintains AND the data the table maintains...
|
|
|
|
nsCellLayoutData *kidLayoutData = ((nsTableCellFrame *)kidFrame)->GetCellLayoutData();
|
|
|
|
|
|
|
|
kidLayoutData->SetDesiredSize(&desiredSize);
|
|
|
|
kidLayoutData->SetMaxElementSize(&kidMaxElementSize);
|
|
|
|
|
|
|
|
kidLayoutData = state.tableFrame->GetCellLayoutData((nsTableCellFrame*)kidFrame);
|
|
|
|
kidLayoutData->SetDesiredSize(&desiredSize);
|
|
|
|
kidLayoutData->SetMaxElementSize(&kidMaxElementSize);
|
|
|
|
|
|
|
|
// Now reflow the cell again this time constraining the width
|
|
|
|
// XXX Skip this for the time being, because the table code is going to
|
|
|
|
// reflow the entire table anyway...
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-06-23 09:43:27 +04:00
|
|
|
// XXX Compute desired size...
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-06-23 09:43:27 +04:00
|
|
|
} else {
|
|
|
|
// Initialize out parameter
|
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
1998-06-23 09:43:27 +04:00
|
|
|
|
|
|
|
// Initialize our internal data
|
|
|
|
ResetMaxChildHeight();
|
|
|
|
|
|
|
|
PRBool reflowMappedOK = PR_TRUE;
|
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
|
|
|
// Check for an overflow list
|
|
|
|
MoveOverflowToChildList();
|
|
|
|
|
|
|
|
// Reflow the existing frames
|
|
|
|
if (nsnull != mFirstChild) {
|
|
|
|
reflowMappedOK = ReflowMappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
|
|
|
|
if (PR_FALSE == reflowMappedOK) {
|
1998-05-12 08:17:56 +04:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
1998-06-23 09:43:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Did we successfully relow our mapped children?
|
|
|
|
if (PR_TRUE == reflowMappedOK) {
|
|
|
|
// Any space left?
|
|
|
|
if (state.availSize.height <= 0) {
|
|
|
|
// No space left. Don't try to pull-up children or reflow unmapped
|
1998-04-23 21:29:07 +04:00
|
|
|
if (NextChildOffset() < mContent->ChildCount()) {
|
1998-06-23 09:43:27 +04:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
} else if (NextChildOffset() < mContent->ChildCount()) {
|
|
|
|
// Try and pull-up some children from a next-in-flow
|
|
|
|
if (PullUpChildren(aPresContext, state, aDesiredSize.maxElementSize)) {
|
|
|
|
// If we still have unmapped children then create some new frames
|
|
|
|
if (NextChildOffset() < mContent->ChildCount()) {
|
|
|
|
aStatus = ReflowUnmappedChildren(aPresContext, state, aDesiredSize.maxElementSize);
|
1998-06-24 23:13:19 +04:00
|
|
|
GetMinRowSpan();
|
|
|
|
FixMinCellHeight();
|
1998-06-23 09:43:27 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// We were unable to pull-up all the existing frames from the
|
|
|
|
// next in flow
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-06-23 09:43:27 +04:00
|
|
|
|
|
|
|
// Return our desired rect
|
|
|
|
aDesiredSize.width = state.x;
|
|
|
|
aDesiredSize.height = state.maxCellVertSpace;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#ifdef NS_DEBUG
|
1998-04-17 05:41:24 +04:00
|
|
|
PostReflowCheck(aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif
|
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
if (gsDebug1==PR_TRUE)
|
|
|
|
{
|
1998-05-25 21:31:49 +04:00
|
|
|
if (nsnull!=aDesiredSize.maxElementSize)
|
1998-04-15 01:45:28 +04:00
|
|
|
printf("nsTableRowFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
|
1998-05-12 08:17:56 +04:00
|
|
|
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
|
1998-04-15 01:45:28 +04:00
|
|
|
aDesiredSize.width, aDesiredSize.height,
|
1998-05-25 21:31:49 +04:00
|
|
|
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
|
1998-04-15 01:45:28 +04:00
|
|
|
else
|
|
|
|
printf("nsTableRowFrame::RR returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
|
1998-05-12 08:17:56 +04:00
|
|
|
NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
|
1998-04-15 01:45:28 +04:00
|
|
|
aDesiredSize.width, aDesiredSize.height);
|
|
|
|
}
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-05-07 04:08:20 +04:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aStyleContext,
|
|
|
|
nsIFrame*& aContinuingFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-15 01:45:28 +04:00
|
|
|
if (gsDebug1==PR_TRUE) printf("nsTableRowFrame::CreateContinuingFrame\n");
|
1998-05-06 03:56:50 +04:00
|
|
|
nsTableRowFrame* cf = new nsTableRowFrame(mContent, aParent);
|
1998-05-07 04:08:20 +04:00
|
|
|
if (nsnull == cf) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
|
1998-04-17 05:41:24 +04:00
|
|
|
aContinuingFrame = cf;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsTableRowFrame::NewFrame( nsIFrame** aInstancePtrResult,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
|
|
|
if (nsnull == aInstancePtrResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1998-05-06 03:56:50 +04:00
|
|
|
nsIFrame* it = new nsTableRowFrame(aContent, aParent);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
*aInstancePtrResult = it;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(kTableRowFrameCID)) {
|
|
|
|
*aInstancePtr = (void*) (this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return nsContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
|
|
|
// For Debugging ONLY
|
|
|
|
NS_METHOD nsTableRowFrame::MoveTo(nscoord aX, nscoord aY)
|
|
|
|
{
|
|
|
|
if ((aX != mRect.x) || (aY != mRect.y)) {
|
|
|
|
mRect.x = aX;
|
|
|
|
mRect.y = aY;
|
|
|
|
|
|
|
|
nsIView* view;
|
|
|
|
GetView(view);
|
|
|
|
|
|
|
|
// Let the view know
|
|
|
|
if (nsnull != view) {
|
|
|
|
// Position view relative to it's parent, not relative to our
|
|
|
|
// parent frame (our parent frame may not have a view).
|
|
|
|
nsIView* parentWithView;
|
|
|
|
nsPoint origin;
|
|
|
|
GetOffsetFromView(origin, parentWithView);
|
|
|
|
view->SetPosition(origin.x, origin.y);
|
|
|
|
NS_IF_RELEASE(parentWithView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsTableRowFrame::SizeTo(nscoord aWidth, nscoord aHeight)
|
|
|
|
{
|
|
|
|
mRect.width = aWidth;
|
|
|
|
mRect.height = aHeight;
|
|
|
|
|
|
|
|
nsIView* view;
|
|
|
|
GetView(view);
|
|
|
|
|
|
|
|
// Let the view know
|
|
|
|
if (nsnull != view) {
|
|
|
|
view->SetDimensions(aWidth, aHeight);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|