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"
|
1998-08-26 21:26:38 +04:00
|
|
|
#include "nsIHTMLAttributes.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsTableFrame.h"
|
|
|
|
#include "nsTableCellFrame.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-07-21 03:56:17 +04:00
|
|
|
#include "nsCSSRendering.h"
|
1998-10-01 08:46:11 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1998-09-01 01:23:28 +04:00
|
|
|
// the following header files are required for style optimizations that work only when the child content is really a cell
|
1998-09-15 21:58:24 +04:00
|
|
|
#include "nsIHTMLTableCellElement.h"
|
|
|
|
static NS_DEFINE_IID(kIHTMLTableCellElementIID, NS_IHTMLTABLECELLELEMENT_IID);
|
1998-09-01 01:23:28 +04:00
|
|
|
// end includes for style optimizations that require real content knowledge
|
1998-06-03 04:43:53 +04:00
|
|
|
|
|
|
|
NS_DEF_PTR(nsIStyleContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
1998-08-07 06:11:51 +04:00
|
|
|
static PRBool gsDebug = PR_FALSE;
|
1998-10-14 20:32:45 +04:00
|
|
|
static PRBool gsDebugIR = PR_FALSE;
|
1998-04-14 00:24:54 +04:00
|
|
|
#else
|
1998-08-07 06:11:51 +04:00
|
|
|
static const PRBool gsDebug = PR_FALSE;
|
1998-10-14 20:32:45 +04:00
|
|
|
static const PRBool gsDebugIR = PR_FALSE;
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
/* ----------- RowReflowState ---------- */
|
|
|
|
|
|
|
|
struct RowReflowState {
|
1998-05-30 00:36:05 +04:00
|
|
|
// Our reflow state
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& reflowState;
|
1998-05-30 00:36:05 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
// The body's available size (computed from the body's parent)
|
|
|
|
nsSize availSize;
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
// the running x-offset
|
|
|
|
nscoord x;
|
|
|
|
|
1998-07-01 08:55:15 +04:00
|
|
|
// Height of tallest cell (excluding cells with rowspan > 1)
|
|
|
|
nscoord maxCellHeight; // just the height of the cell frame
|
|
|
|
nscoord maxCellVertSpace; // the maximum MAX(cellheight + topMargin + bottomMargin)
|
1998-04-23 21:29:07 +04:00
|
|
|
|
|
|
|
nsTableFrame *tableFrame;
|
|
|
|
|
|
|
|
|
1998-10-02 08:10:00 +04:00
|
|
|
RowReflowState(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame* aTableFrame)
|
1998-05-30 00:36:05 +04:00
|
|
|
: 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-07-01 08:55:15 +04:00
|
|
|
maxCellHeight = 0;
|
|
|
|
maxCellVertSpace = 0;
|
1998-07-11 02:56:13 +04:00
|
|
|
tableFrame = aTableFrame;
|
1998-07-11 04:00:31 +04:00
|
|
|
x=0;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------- nsTableRowpFrame ---------- */
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
nsTableRowFrame::nsTableRowFrame(nsIContent* aContent,
|
1998-04-23 21:29:07 +04:00
|
|
|
nsIFrame* aParentFrame)
|
1998-10-20 21:45:07 +04:00
|
|
|
: nsHTMLContainerFrame(aContent, aParentFrame),
|
1998-05-22 03:43:18 +04:00
|
|
|
mTallestCell(0),
|
|
|
|
mCellMaxTopMargin(0),
|
1998-06-24 23:13:19 +04:00
|
|
|
mCellMaxBottomMargin(0),
|
1998-10-14 20:32:45 +04:00
|
|
|
mMinRowSpan(1),
|
|
|
|
mInitializedChildren(PR_FALSE)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableRowFrame::~nsTableRowFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-09-16 21:19:20 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
|
|
|
|
{
|
|
|
|
mFirstChild = aChildList;
|
1998-10-14 20:32:45 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowFrame::InitChildren(PRInt32 aRowIndex)
|
|
|
|
{
|
1998-10-22 02:29:00 +04:00
|
|
|
if (gsDebug) printf("Row InitChildren: begin\n");
|
1998-09-24 01:48:26 +04:00
|
|
|
nsTableFrame* table = nsnull;
|
1998-10-14 20:32:45 +04:00
|
|
|
nsresult result=NS_OK;
|
1998-09-24 01:48:26 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// each child cell can only be added to the table one time.
|
|
|
|
// for now, we remember globally whether we've added all or none
|
|
|
|
if (PR_FALSE==mInitializedChildren)
|
1998-09-24 01:48:26 +04:00
|
|
|
{
|
1998-10-22 02:29:00 +04:00
|
|
|
if (gsDebug) printf("Row InitChildren: mInitializedChildren=PR_FALSE\n");
|
1998-10-14 20:32:45 +04:00
|
|
|
result = nsTableFrame::GetTableFrame(this, table);
|
|
|
|
if ((NS_OK==result) && (table != nsnull))
|
1998-09-24 01:48:26 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
mInitializedChildren=PR_TRUE;
|
|
|
|
PRInt32 rowIndex;
|
|
|
|
if (-1==aRowIndex)
|
|
|
|
rowIndex = table->GetNextAvailRowIndex();
|
|
|
|
else
|
|
|
|
rowIndex = aRowIndex;
|
|
|
|
SetRowIndex(rowIndex);
|
1998-10-22 02:29:00 +04:00
|
|
|
if (gsDebug) printf("Row InitChildren: set row index to %d\n", rowIndex);
|
1998-10-14 20:32:45 +04:00
|
|
|
PRInt32 colIndex = 0;
|
|
|
|
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame))
|
1998-09-24 20:37:22 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
const nsStyleDisplay *kidDisplay;
|
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)kidDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
// what column does this cell belong to?
|
|
|
|
colIndex = table->GetNextAvailColIndex(mRowIndex, colIndex);
|
1998-10-22 02:29:00 +04:00
|
|
|
if (gsDebug) printf("Row InitChildren: cell given colIndex %d\n", colIndex);
|
1998-10-14 20:32:45 +04:00
|
|
|
/* for style context optimization, set the content's column index if possible.
|
|
|
|
* this can only be done if we really have an nsTableCell.
|
|
|
|
* other tags mapped to table cell display won't benefit from this optimization
|
|
|
|
* see nsHTMLStyleSheet::RulesMatching
|
|
|
|
*/
|
|
|
|
nsIContent* cell;
|
|
|
|
kidFrame->GetContent(cell);
|
|
|
|
nsIHTMLTableCellElement *cellContent = nsnull;
|
|
|
|
nsresult rv = cell->QueryInterface(kIHTMLTableCellElementIID,
|
|
|
|
(void **)&cellContent); // cellContent: REFCNT++
|
|
|
|
NS_RELEASE(cell);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
{ // we know it's a table cell
|
|
|
|
cellContent->SetColIndex(colIndex);
|
|
|
|
if (gsDebug) printf("%p : set cell content %p to col index = %d\n", this, cellContent, colIndex);
|
|
|
|
NS_RELEASE(cellContent);
|
|
|
|
}
|
1998-09-24 20:37:22 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// this sets the frame's notion of it's column index
|
|
|
|
((nsTableCellFrame *)kidFrame)->InitCellFrame(colIndex);
|
|
|
|
if (gsDebug) printf("%p : set cell frame %p to col index = %d\n", this, kidFrame, colIndex);
|
|
|
|
// add the cell frame to the table's cell map
|
1998-10-22 02:29:00 +04:00
|
|
|
if (gsDebug) printf("Row InitChildren: calling AddCellToTable...\n");
|
1998-10-14 20:32:45 +04:00
|
|
|
table->AddCellToTable(this, (nsTableCellFrame *)kidFrame, kidFrame == mFirstChild);
|
|
|
|
}
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-10-22 02:29:00 +04:00
|
|
|
if (gsDebug) printf("Row InitChildren: end\n");
|
1998-09-16 21:19:20 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-03 00:35:23 +04:00
|
|
|
/**
|
|
|
|
* Post-reflow hook. This is where the table row does its post-processing
|
|
|
|
*/
|
|
|
|
NS_METHOD
|
|
|
|
nsTableRowFrame::DidReflow(nsIPresContext& aPresContext,
|
|
|
|
nsDidReflowStatus aStatus)
|
|
|
|
{
|
1998-11-02 21:32:14 +03:00
|
|
|
if (gsDebug) printf("Row %p DidReflow: begin mRect.h=%d, mCellMTM=%d, mCellMBM=%d\n",
|
|
|
|
this, mRect.height, mCellMaxTopMargin, mCellMaxBottomMargin);
|
1998-07-03 00:35:23 +04:00
|
|
|
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
|
|
|
|
// Resize and re-align the cell frames based on our row height
|
1998-11-02 21:32:14 +03:00
|
|
|
nscoord cellHeight = mRect.height - mCellMaxTopMargin - mCellMaxBottomMargin;
|
|
|
|
if (gsDebug) printf("Row DidReflow: cellHeight=%d\n", cellHeight);
|
1998-09-24 20:37:22 +04:00
|
|
|
nsIFrame *cellFrame = mFirstChild;
|
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
1998-07-03 00:35:23 +04:00
|
|
|
while (nsnull != cellFrame)
|
|
|
|
{
|
1998-09-24 20:37:22 +04:00
|
|
|
const nsStyleDisplay *kidDisplay;
|
|
|
|
cellFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)kidDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay)
|
1998-07-03 00:35:23 +04:00
|
|
|
{
|
1998-09-24 20:37:22 +04:00
|
|
|
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(mRowIndex, (nsTableCellFrame *)cellFrame);
|
1998-11-02 21:32:14 +03:00
|
|
|
if (gsDebug) printf("Row DidReflow: cellFrame %p ", cellFrame);
|
1998-09-24 20:37:22 +04:00
|
|
|
if (1==rowSpan)
|
|
|
|
{
|
|
|
|
// resize the cell's height
|
|
|
|
nsSize cellFrameSize;
|
|
|
|
cellFrame->GetSize(cellFrameSize);
|
|
|
|
cellFrame->SizeTo(cellFrameSize.width, cellHeight);
|
1998-11-02 21:32:14 +03:00
|
|
|
if (gsDebug) printf("given height %d\n", cellHeight);
|
1998-09-24 20:37:22 +04:00
|
|
|
// realign cell content based on the new height
|
|
|
|
((nsTableCellFrame *)cellFrame)->VerticallyAlignChild(&aPresContext);
|
|
|
|
}
|
1998-11-02 21:32:14 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gsDebug)
|
|
|
|
{
|
|
|
|
nsSize cellFrameSize;
|
|
|
|
cellFrame->GetSize(cellFrameSize);
|
|
|
|
printf("has rowspan %d and height %d, unchanged.\n", rowSpan, cellFrameSize.height);
|
|
|
|
}
|
|
|
|
}
|
1998-07-03 00:35:23 +04:00
|
|
|
}
|
1998-09-24 20:37:22 +04:00
|
|
|
// Get the next cell
|
|
|
|
cellFrame->GetNextSibling(cellFrame);
|
1998-07-03 00:35:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Let our base class do the usual work
|
1998-11-02 21:32:14 +03:00
|
|
|
if (gsDebug) printf("Row DidReflow: returning superclass DidReflow.\n");
|
1998-07-03 00:35:23 +04:00
|
|
|
return nsContainerFrame::DidReflow(aPresContext, aStatus);
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
void nsTableRowFrame::ResetMaxChildHeight()
|
|
|
|
{
|
1998-10-22 02:29:00 +04:00
|
|
|
if (gsDebug) printf("Row ResetMaxChildHeight\n");
|
1998-04-14 00:24:54 +04:00
|
|
|
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
|
|
|
{
|
1998-10-23 01:59:13 +04:00
|
|
|
if (gsDebug) printf("Row SetMaxChildHeight to %d\n", aChildHeight);
|
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
|
|
|
{
|
1998-08-07 06:11:51 +04:00
|
|
|
/*
|
1998-07-21 03:56:17 +04:00
|
|
|
const nsStyleColor* myColor =
|
|
|
|
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
if (nsnull != myColor) {
|
1998-07-22 09:02:07 +04:00
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
1998-07-21 03:56:17 +04:00
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
1998-07-22 09:02:07 +04:00
|
|
|
aDirtyRect, rect, *myColor);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-08-07 06:11:51 +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
|
|
|
}
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
PRIntn
|
|
|
|
nsTableRowFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/** 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) {
|
1998-10-30 05:08:25 +03:00
|
|
|
PRBool clipState;
|
1998-06-14 04:45:21 +04:00
|
|
|
// 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);
|
|
|
|
}
|
1998-10-30 05:08:25 +03:00
|
|
|
aRenderingContext.PopState(clipState);
|
1998-04-15 01:49:29 +04:00
|
|
|
}
|
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-09-24 20:37:22 +04:00
|
|
|
nsIFrame *cell=mFirstChild;
|
|
|
|
while (nsnull!=cell)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *kidDisplay;
|
|
|
|
cell->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)kidDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
sum += ((nsTableCellFrame *)cell)->GetColSpan();
|
|
|
|
}
|
|
|
|
cell->GetNextSibling(cell);
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
|
|
|
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
|
|
|
|
*/
|
1998-07-24 04:43:09 +04:00
|
|
|
void nsTableRowFrame::GetMinRowSpan(nsTableFrame *aTableFrame)
|
1998-06-24 23:13:19 +04:00
|
|
|
{
|
|
|
|
PRInt32 minRowSpan=-1;
|
|
|
|
nsIFrame *frame=mFirstChild;
|
|
|
|
while (nsnull!=frame)
|
|
|
|
{
|
1998-09-24 20:37:22 +04:00
|
|
|
const nsStyleDisplay *kidDisplay;
|
|
|
|
frame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)kidDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
PRInt32 rowSpan = aTableFrame->GetEffectiveRowSpan(mRowIndex, ((nsTableCellFrame *)frame));
|
|
|
|
if (-1==minRowSpan)
|
|
|
|
minRowSpan = rowSpan;
|
|
|
|
else if (minRowSpan>rowSpan)
|
|
|
|
minRowSpan = rowSpan;
|
|
|
|
}
|
1998-06-24 23:13:19 +04:00
|
|
|
frame->GetNextSibling(frame);
|
|
|
|
}
|
|
|
|
mMinRowSpan = minRowSpan;
|
|
|
|
}
|
|
|
|
|
1998-07-24 04:43:09 +04:00
|
|
|
void nsTableRowFrame::FixMinCellHeight(nsTableFrame *aTableFrame)
|
1998-06-24 23:13:19 +04:00
|
|
|
{
|
|
|
|
nsIFrame *frame=mFirstChild;
|
|
|
|
while (nsnull!=frame)
|
|
|
|
{
|
1998-09-24 20:37:22 +04:00
|
|
|
const nsStyleDisplay *kidDisplay;
|
|
|
|
frame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)kidDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay)
|
1998-06-24 23:13:19 +04:00
|
|
|
{
|
1998-09-24 20:37:22 +04:00
|
|
|
PRInt32 rowSpan = aTableFrame->GetEffectiveRowSpan(mRowIndex, ((nsTableCellFrame *)frame));
|
|
|
|
if (mMinRowSpan==rowSpan)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
frame->GetRect(rect);
|
|
|
|
if (rect.height > mTallestCell)
|
|
|
|
mTallestCell = rect.height;
|
|
|
|
}
|
1998-06-24 23:13:19 +04:00
|
|
|
}
|
|
|
|
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.
|
1998-07-15 21:05:21 +04:00
|
|
|
void nsTableRowFrame::PlaceChild(nsIPresContext& aPresContext,
|
1998-10-14 20:32:45 +04:00
|
|
|
RowReflowState& aReflowState,
|
1998-04-23 21:29:07 +04:00
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
const nsRect& aKidRect,
|
|
|
|
nsSize* aMaxElementSize,
|
1998-07-02 21:40:56 +04:00
|
|
|
nsSize* aKidMaxElementSize)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
1998-08-07 06:11:51 +04:00
|
|
|
if (PR_TRUE==gsDebug)
|
1998-04-23 21:29:07 +04:00
|
|
|
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-07-11 04:00:31 +04:00
|
|
|
// update the running total for the row width
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.x += aKidRect.width;
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
// Update the maximum element size
|
1998-10-14 20:32:45 +04:00
|
|
|
PRInt32 rowSpan = aReflowState.tableFrame->GetEffectiveRowSpan(mRowIndex,
|
1998-07-24 04:43:09 +04:00
|
|
|
((nsTableCellFrame*)aKidFrame));
|
1998-05-22 03:43:18 +04:00
|
|
|
if (nsnull != aMaxElementSize)
|
|
|
|
{
|
1998-07-02 21:40:56 +04:00
|
|
|
aMaxElementSize->width += aKidMaxElementSize->width;
|
|
|
|
if ((mMinRowSpan==rowSpan) && (aKidMaxElementSize->height>aMaxElementSize->height))
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
1998-07-02 21:40:56 +04:00
|
|
|
aMaxElementSize->height = aKidMaxElementSize->height;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
}
|
1998-07-01 08:55:15 +04:00
|
|
|
|
|
|
|
if (mMinRowSpan == rowSpan)
|
1998-05-22 03:43:18 +04:00
|
|
|
{
|
1998-07-01 08:55:15 +04:00
|
|
|
// Update maxCellHeight
|
1998-10-14 20:32:45 +04:00
|
|
|
if (aKidRect.height > aReflowState.maxCellHeight)
|
|
|
|
aReflowState.maxCellHeight = aKidRect.height;
|
1998-07-01 08:55:15 +04:00
|
|
|
|
|
|
|
// Update maxCellVertSpace
|
|
|
|
nsMargin margin;
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
if (aReflowState.tableFrame->GetCellMarginData((nsTableCellFrame *)aKidFrame, margin) == NS_OK)
|
1998-05-22 03:43:18 +04:00
|
|
|
{
|
|
|
|
nscoord height = aKidRect.height + margin.top + margin.bottom;
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
if (height > aReflowState.maxCellVertSpace)
|
|
|
|
aReflowState.maxCellVertSpace = height;
|
1998-05-22 03:43:18 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
1998-07-11 02:56:13 +04:00
|
|
|
* Called for a resize reflow. Typically because the column widths have
|
|
|
|
* changed. Reflows all the existing table cell frames
|
1998-04-23 21:29:07 +04:00
|
|
|
*/
|
1998-10-20 19:59:56 +04:00
|
|
|
NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-07-17 21:51:43 +04:00
|
|
|
if (nsnull == mFirstChild)
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-23 21:24:57 +04:00
|
|
|
nsresult rv=NS_OK;
|
1998-07-11 08:16:29 +04:00
|
|
|
nsSize kidMaxElementSize;
|
1998-07-11 04:00:31 +04:00
|
|
|
PRInt32 prevColIndex = -1; // remember the col index of the previous cell to handle rowspans into this row
|
1998-07-11 02:56:13 +04:00
|
|
|
nsSize* pKidMaxElementSize = (nsnull != aDesiredSize.maxElementSize) ?
|
|
|
|
&kidMaxElementSize : nsnull;
|
1998-05-22 03:43:18 +04:00
|
|
|
nscoord maxCellTopMargin = 0;
|
|
|
|
nscoord maxCellBottomMargin = 0;
|
1998-10-14 20:32:45 +04:00
|
|
|
nscoord cellSpacing = aReflowState.tableFrame->GetCellSpacing();
|
1998-09-16 04:48:14 +04:00
|
|
|
PRInt32 cellColSpan=1; // must be defined here so it's set properly for non-cell kids
|
1998-10-26 21:42:22 +03:00
|
|
|
if (PR_TRUE==gsDebug) printf("Row %p: Resize Reflow\n", this);
|
1998-07-11 02:56:13 +04:00
|
|
|
// Reflow each of our existing cell frames
|
1998-07-17 03:23:31 +04:00
|
|
|
for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; )
|
|
|
|
{
|
1998-09-16 04:48:14 +04:00
|
|
|
const nsStyleDisplay *kidDisplay;
|
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)kidDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
nsMargin kidMargin;
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.tableFrame->GetCellMarginData((nsTableCellFrame *)kidFrame,kidMargin);
|
1998-09-16 04:48:14 +04:00
|
|
|
if (kidMargin.top > maxCellTopMargin)
|
|
|
|
maxCellTopMargin = kidMargin.top;
|
|
|
|
if (kidMargin.bottom > maxCellBottomMargin)
|
|
|
|
maxCellBottomMargin = kidMargin.bottom;
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-09-16 04:48:14 +04:00
|
|
|
// Compute the x-origin for the child, taking into account straddlers (cells from prior
|
|
|
|
// rows with rowspans > 1)
|
|
|
|
PRInt32 cellColIndex = ((nsTableCellFrame *)kidFrame)->GetColIndex();
|
|
|
|
if (prevColIndex != (cellColIndex-1))
|
|
|
|
{ // if this cell is not immediately adjacent to the previous cell, factor in missing col info
|
|
|
|
for (PRInt32 colIndex=prevColIndex+1; colIndex<cellColIndex; colIndex++)
|
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.x += aReflowState.tableFrame->GetColumnWidth(colIndex);
|
|
|
|
aReflowState.x += cellSpacing;
|
1998-09-16 04:48:14 +04:00
|
|
|
if (PR_TRUE==gsDebug)
|
1998-10-26 21:42:22 +03:00
|
|
|
printf(" Row: in loop, aReflowState.x set to %d from cellSpacing %d and col width\n",
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.x, aReflowState.tableFrame->GetColumnWidth(colIndex), cellSpacing);
|
1998-09-16 04:48:14 +04:00
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.x += cellSpacing;
|
1998-10-26 21:42:22 +03:00
|
|
|
if (PR_TRUE==gsDebug) printf(" Row: past loop, aReflowState.x set to %d\n", aReflowState.x);
|
1998-09-16 04:48:14 +04:00
|
|
|
|
|
|
|
// at this point, we know the column widths.
|
|
|
|
// so we get the avail width from the known column widths
|
1998-10-14 20:32:45 +04:00
|
|
|
cellColSpan = aReflowState.tableFrame->GetEffectiveColSpan(((nsTableCellFrame *)kidFrame)->GetColIndex(),
|
1998-09-16 04:48:14 +04:00
|
|
|
((nsTableCellFrame *)kidFrame));
|
|
|
|
nscoord availWidth = 0;
|
|
|
|
for (PRInt32 numColSpan=0; numColSpan<cellColSpan; numColSpan++)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
availWidth += aReflowState.tableFrame->GetColumnWidth(cellColIndex+numColSpan);
|
1998-09-16 04:48:14 +04:00
|
|
|
if (numColSpan != 0)
|
|
|
|
{
|
|
|
|
availWidth += cellSpacing;
|
|
|
|
}
|
|
|
|
if (PR_TRUE==gsDebug)
|
1998-10-26 21:42:22 +03:00
|
|
|
printf(" Row: in loop, availWidth set to %d from colIndex %d width %d and cellSpacing\n",
|
1998-10-14 20:32:45 +04:00
|
|
|
availWidth, cellColIndex, aReflowState.tableFrame->GetColumnWidth(cellColIndex+numColSpan), cellSpacing);
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
1998-10-26 21:42:22 +03:00
|
|
|
if (PR_TRUE==gsDebug) printf(" Row: availWidth for this cell is %d\n", availWidth);
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-09-16 04:48:14 +04:00
|
|
|
prevColIndex = cellColIndex + (cellColSpan-1); // remember the rightmost column this cell spans into
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(pKidMaxElementSize);
|
1998-07-12 04:19:17 +04:00
|
|
|
|
1998-09-16 04:48:14 +04:00
|
|
|
// If the available width is the same as last time we reflowed the cell,
|
|
|
|
// then just use the previous desired size and max element size.
|
|
|
|
// if we need the max-element-size we don't need to reflow.
|
|
|
|
// we just grab it from the cell frame which remembers it (see the else clause below)
|
|
|
|
if (availWidth != ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth())
|
1998-09-10 00:00:40 +04:00
|
|
|
{
|
1998-09-16 04:48:14 +04:00
|
|
|
// Always let the cell be as high as it wants. We ignore the height that's
|
|
|
|
// passed in and always place the entire row. Let the row group decide
|
|
|
|
// whether we fit or wehther the entire row is pushed
|
|
|
|
nsSize kidAvailSize(availWidth, NS_UNCONSTRAINEDSIZE);
|
|
|
|
|
|
|
|
// Reflow the child
|
1998-10-12 18:48:02 +04:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, kidFrame,
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.reflowState, kidAvailSize,
|
1998-10-06 04:27:22 +04:00
|
|
|
eReflowReason_Resize);
|
1998-10-26 21:42:22 +03:00
|
|
|
if (gsDebug) printf ("Row %p RR: avail=%d\n", this, availWidth);
|
1998-10-06 04:27:22 +04:00
|
|
|
nsReflowStatus status;
|
1998-10-23 21:24:57 +04:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, status);
|
1998-10-26 21:42:22 +03:00
|
|
|
if (gsDebug) printf ("Row %p RR: desired=%d\n", this, desiredSize.width);
|
1998-09-16 04:48:14 +04:00
|
|
|
#ifdef NS_DEBUG
|
1998-10-06 04:27:22 +04:00
|
|
|
if (desiredSize.width > availWidth)
|
|
|
|
{
|
|
|
|
printf("WARNING: cell returned desired width %d given avail width %d\n",
|
|
|
|
desiredSize.width, availWidth);
|
|
|
|
}
|
1998-09-10 00:00:40 +04:00
|
|
|
#endif
|
1998-10-06 04:27:22 +04:00
|
|
|
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "unexpected reflow status");
|
1998-09-16 04:48:14 +04:00
|
|
|
|
1998-10-06 04:27:22 +04:00
|
|
|
if (gsDebug)
|
|
|
|
{
|
|
|
|
if (nsnull!=pKidMaxElementSize)
|
1998-10-26 21:42:22 +03:00
|
|
|
printf("Row: reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
|
1998-10-06 04:27:22 +04:00
|
|
|
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
|
|
|
desiredSize.width, desiredSize.height,
|
|
|
|
pKidMaxElementSize->width, pKidMaxElementSize->height);
|
|
|
|
else
|
1998-10-26 21:42:22 +03:00
|
|
|
printf("Row: reflow of cell returned result = %s with desired=%d,%d, min = nsnull\n",
|
1998-10-06 04:27:22 +04:00
|
|
|
NS_FRAME_IS_COMPLETE(status)?"complete":"NOT complete",
|
|
|
|
desiredSize.width, desiredSize.height);
|
1998-09-16 04:48:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
1998-07-02 21:40:56 +04:00
|
|
|
{
|
1998-09-16 04:48:14 +04:00
|
|
|
nsSize priorSize = ((nsTableCellFrame *)kidFrame)->GetDesiredSize();
|
|
|
|
desiredSize.width = priorSize.width;
|
|
|
|
desiredSize.height = priorSize.height;
|
|
|
|
if (nsnull != pKidMaxElementSize)
|
1998-10-03 00:36:35 +04:00
|
|
|
*pKidMaxElementSize = ((nsTableCellFrame *)kidFrame)->GetPass1MaxElementSize();
|
1998-07-02 21:40:56 +04:00
|
|
|
}
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-09-16 04:48:14 +04:00
|
|
|
// Place the child after taking into account its margin and attributes
|
|
|
|
nscoord specifiedHeight = 0;
|
|
|
|
nscoord cellHeight = desiredSize.height;
|
|
|
|
nsIStyleContextPtr kidSC;
|
1998-11-03 23:33:43 +03:00
|
|
|
kidFrame->GetStyleContext(kidSC.AssignRef());
|
1998-09-16 04:48:14 +04:00
|
|
|
const nsStylePosition* kidPosition = (const nsStylePosition*)
|
|
|
|
kidSC->GetStyleData(eStyleStruct_Position);
|
|
|
|
switch (kidPosition->mHeight.GetUnit()) {
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
specifiedHeight = kidPosition->mHeight.GetCoordValue();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Inherit:
|
|
|
|
// XXX for now, do nothing
|
|
|
|
default:
|
|
|
|
case eStyleUnit_Auto:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (specifiedHeight>cellHeight)
|
|
|
|
cellHeight = specifiedHeight;
|
1998-06-24 03:23:21 +04:00
|
|
|
|
1998-09-16 04:48:14 +04:00
|
|
|
nscoord cellWidth = desiredSize.width;
|
|
|
|
// begin special Nav4 compatibility code
|
|
|
|
if (0==cellWidth)
|
|
|
|
{
|
|
|
|
cellWidth = availWidth;
|
|
|
|
}
|
|
|
|
// end special Nav4 compatibility code
|
1998-06-24 03:23:21 +04:00
|
|
|
|
1998-09-16 04:48:14 +04:00
|
|
|
// Place the child
|
1998-10-14 20:32:45 +04:00
|
|
|
nsRect kidRect (aReflowState.x, kidMargin.top, cellWidth, cellHeight);
|
1998-06-24 03:23:21 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame, kidRect, aDesiredSize.maxElementSize,
|
1998-09-16 04:48:14 +04:00
|
|
|
pKidMaxElementSize);
|
1998-07-17 03:23:31 +04:00
|
|
|
|
1998-10-26 21:42:22 +03:00
|
|
|
if (PR_TRUE==gsDebug) printf("Row: past PlaceChild, aReflowState.x set to %d\n", aReflowState.x);
|
1998-09-16 04:48:14 +04:00
|
|
|
}
|
1998-10-23 21:24:57 +04:00
|
|
|
else
|
|
|
|
{// it's an unknown frame type, give it a generic reflow and ignore the results
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState.reflowState,
|
|
|
|
nsSize(0,0), eReflowReason_Resize);
|
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
1998-10-26 21:42:22 +03:00
|
|
|
if (PR_TRUE==gsDebug) printf("\nRow: Resize Reflow of unknown frame %p of type %d with reason=%d\n",
|
1998-10-23 21:24:57 +04:00
|
|
|
kidFrame, kidDisplay->mDisplay, eReflowReason_Resize);
|
|
|
|
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
|
|
|
}
|
1998-04-23 21:29:07 +04:00
|
|
|
|
|
|
|
// Get the next child
|
|
|
|
kidFrame->GetNextSibling(kidFrame);
|
1998-09-16 04:48:14 +04:00
|
|
|
// if this was the last child, and it had a colspan>1, add in the cellSpacing for the colspan
|
|
|
|
// if the last kid wasn't a colspan, then we still have the colspan of the last real cell
|
|
|
|
if ((nsnull==kidFrame) && (cellColSpan>1))
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.x += cellSpacing;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
SetMaxChildHeight(aReflowState.maxCellHeight,maxCellTopMargin, maxCellBottomMargin); // remember height of tallest child who doesn't have a row span
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-07-11 02:56:13 +04:00
|
|
|
// Return our desired size. Note that our desired width is just whatever width
|
|
|
|
// we were given by the row group frame
|
1998-10-14 20:32:45 +04:00
|
|
|
aDesiredSize.width = aReflowState.x;
|
|
|
|
aDesiredSize.height = aReflowState.maxCellVertSpace;
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-08-07 06:11:51 +04:00
|
|
|
if (gsDebug)
|
1998-10-26 21:42:22 +03:00
|
|
|
printf("Row: RR -- row %p width = %d from maxSize %d\n",
|
1998-10-14 20:32:45 +04:00
|
|
|
this, aDesiredSize.width, aReflowState.reflowState.maxSize.width);
|
1998-09-10 00:00:40 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
if (aDesiredSize.width > aReflowState.reflowState.maxSize.width)
|
1998-09-10 00:00:40 +04:00
|
|
|
{
|
1998-10-23 21:24:57 +04:00
|
|
|
if (gsDebug)
|
|
|
|
{
|
1998-10-26 21:42:22 +03:00
|
|
|
printf ("Row %p error case, desired width = %d, maxSize=%d\n",
|
1998-10-23 21:24:57 +04:00
|
|
|
this, aDesiredSize.width, aReflowState.reflowState.maxSize.width);
|
|
|
|
fflush (stdout);
|
|
|
|
}
|
1998-09-10 00:00:40 +04:00
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_ASSERTION(aDesiredSize.width <= aReflowState.reflowState.maxSize.width, "row calculated to be too wide.");
|
1998-10-23 21:24:57 +04:00
|
|
|
return rv;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
1998-07-11 02:56:13 +04:00
|
|
|
* Called for the initial reflow. Creates each table cell frame, and
|
|
|
|
* reflows it to gets its minimum and maximum sizes
|
1998-04-23 21:29:07 +04:00
|
|
|
*/
|
1998-10-20 19:59:56 +04:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsTableCellFrame * aStartFrame,
|
|
|
|
PRBool aDoSiblings)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
|
|
|
// Place our children, one at a time, until we are out of children
|
1998-09-24 01:48:26 +04:00
|
|
|
nsSize kidMaxElementSize(0,0);
|
1998-07-10 08:00:38 +04:00
|
|
|
PRInt32 kidIndex = 0;
|
1998-09-01 01:23:28 +04:00
|
|
|
PRInt32 colIndex = 0;
|
1998-07-10 08:00:38 +04:00
|
|
|
nsIFrame* prevKidFrame = nsnull;
|
1998-05-22 03:43:18 +04:00
|
|
|
nscoord maxTopMargin = 0;
|
|
|
|
nscoord maxBottomMargin = 0;
|
1998-07-11 02:56:13 +04:00
|
|
|
nscoord x = 0;
|
1998-09-01 01:23:28 +04:00
|
|
|
PRBool isFirst=PR_TRUE;
|
1998-09-24 01:48:26 +04:00
|
|
|
PRBool tableLayoutStrategy=NS_STYLE_TABLE_LAYOUT_AUTO;
|
1998-11-04 23:09:19 +03:00
|
|
|
nsTableFrame* table = aReflowState.tableFrame;
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsStyleTable* tableStyle;
|
|
|
|
table->GetStyleData(eStyleStruct_Table, (nsStyleStruct *&)tableStyle);
|
|
|
|
tableLayoutStrategy = tableStyle->mLayoutStrategy;
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-10-20 19:59:56 +04:00
|
|
|
nsIFrame* kidFrame;
|
|
|
|
if (nsnull==aStartFrame)
|
|
|
|
kidFrame = mFirstChild;
|
|
|
|
else
|
|
|
|
kidFrame = aStartFrame;
|
|
|
|
|
|
|
|
for ( ; nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame))
|
1998-09-24 01:48:26 +04:00
|
|
|
{
|
1998-09-24 20:37:22 +04:00
|
|
|
const nsStyleDisplay *kidDisplay;
|
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)kidDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay)
|
1998-09-16 21:19:20 +04:00
|
|
|
{
|
1998-09-24 20:37:22 +04:00
|
|
|
// Get the child's margins
|
|
|
|
nsMargin margin;
|
|
|
|
nscoord topMargin = 0;
|
1998-10-14 20:32:45 +04:00
|
|
|
if (aReflowState.tableFrame->GetCellMarginData((nsTableCellFrame *)kidFrame, margin) == NS_OK)
|
1998-09-24 20:37:22 +04:00
|
|
|
{
|
|
|
|
topMargin = margin.top;
|
|
|
|
}
|
|
|
|
maxTopMargin = PR_MAX(margin.top, maxTopMargin);
|
|
|
|
maxBottomMargin = PR_MAX(margin.bottom, maxBottomMargin);
|
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
// get border padding values
|
|
|
|
nsMargin borderPadding;
|
|
|
|
const nsStyleSpacing* cellSpacing;
|
|
|
|
kidFrame->GetStyleData(eStyleStruct_Spacing , ((nsStyleStruct *&)cellSpacing));
|
|
|
|
cellSpacing->CalcBorderPaddingFor(kidFrame, borderPadding);
|
|
|
|
|
1998-09-24 20:37:22 +04:00
|
|
|
// Because we're not splittable always allow the child to be as high as
|
|
|
|
// it wants. The default available width is also unconstrained so we can
|
|
|
|
// get the child's maximum width
|
|
|
|
nsSize kidAvailSize;
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics kidSize(nsnull);
|
1998-09-24 20:37:22 +04:00
|
|
|
if (NS_STYLE_TABLE_LAYOUT_AUTO==tableLayoutStrategy)
|
|
|
|
{
|
|
|
|
kidAvailSize.SizeTo(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
|
|
|
kidSize.maxElementSize=&kidMaxElementSize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PRInt32 colIndex = ((nsTableCellFrame *)kidFrame)->GetColIndex();
|
|
|
|
kidAvailSize.SizeTo(table->GetColumnWidth(colIndex), NS_UNCONSTRAINEDSIZE);
|
|
|
|
}
|
1998-09-24 01:48:26 +04:00
|
|
|
|
1998-10-12 18:48:02 +04:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, kidFrame,
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.reflowState, kidAvailSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
eReflowReason_Initial);
|
1998-09-16 21:19:20 +04:00
|
|
|
|
1998-10-06 04:27:22 +04:00
|
|
|
if (gsDebug) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width);
|
1998-10-20 19:59:56 +04:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, aStatus);
|
1998-10-06 04:27:22 +04:00
|
|
|
if (gsDebug)
|
|
|
|
printf ("TR %p for cell %p Initial Reflow: desired=%d, MES=%d\n",
|
|
|
|
this, kidFrame, kidSize.width, kidMaxElementSize.width);
|
|
|
|
//XXX: this is a hack, shouldn't it be the case that a min size is
|
|
|
|
// never larger than a desired size?
|
|
|
|
if (kidMaxElementSize.width>kidSize.width)
|
|
|
|
kidSize.width = kidMaxElementSize.width;
|
|
|
|
if (kidMaxElementSize.height>kidSize.height)
|
|
|
|
kidSize.height = kidMaxElementSize.height;
|
1998-10-30 10:57:44 +03:00
|
|
|
kidSize.width += borderPadding.left+borderPadding.right;
|
|
|
|
kidSize.height += borderPadding.top+borderPadding.bottom;
|
|
|
|
kidMaxElementSize.SizeBy(borderPadding.left+borderPadding.right, borderPadding.top+borderPadding.bottom);
|
1998-10-06 04:27:22 +04:00
|
|
|
((nsTableCellFrame *)kidFrame)->SetPass1DesiredSize(kidSize);
|
|
|
|
((nsTableCellFrame *)kidFrame)->SetPass1MaxElementSize(kidMaxElementSize);
|
1998-10-20 19:59:56 +04:00
|
|
|
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "unexpected child reflow status");
|
1998-10-06 04:27:22 +04:00
|
|
|
|
|
|
|
if (gsDebug)
|
|
|
|
{
|
|
|
|
printf("reflow of cell returned result = %s with desired=%d,%d, min = %d,%d\n",
|
1998-10-20 19:59:56 +04:00
|
|
|
NS_FRAME_IS_COMPLETE(aStatus)?"complete":"NOT complete",
|
1998-10-06 04:27:22 +04:00
|
|
|
kidSize.width, kidSize.height,
|
|
|
|
kidMaxElementSize.width, kidMaxElementSize.height);
|
1998-10-01 08:46:11 +04:00
|
|
|
}
|
1998-10-06 04:27:22 +04:00
|
|
|
|
|
|
|
// Place the child
|
|
|
|
x += margin.left;
|
|
|
|
nsRect kidRect(x, topMargin, kidSize.width, kidSize.height);
|
1998-10-14 20:32:45 +04:00
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame, kidRect, aDesiredSize.maxElementSize,
|
1998-10-06 04:27:22 +04:00
|
|
|
&kidMaxElementSize);
|
|
|
|
x += kidSize.width + margin.right;
|
1998-09-24 20:37:22 +04:00
|
|
|
}
|
1998-10-23 21:24:57 +04:00
|
|
|
else
|
|
|
|
{// it's an unknown frame type, give it a generic reflow and ignore the results
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState.reflowState,
|
|
|
|
nsSize(0,0), eReflowReason_Resize);
|
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
|
|
|
if (PR_TRUE==gsDebug) printf("\nTIF : Reflow Pass 2 of unknown frame %p of type %d with reason=%d\n",
|
|
|
|
kidFrame, kidDisplay->mDisplay, eReflowReason_Resize);
|
|
|
|
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
|
|
|
}
|
|
|
|
if (PR_FALSE==aDoSiblings)
|
|
|
|
break;
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
SetMaxChildHeight(aReflowState.maxCellHeight, maxTopMargin, maxBottomMargin); // remember height of tallest child who doesn't have a row span
|
1998-09-16 21:19:20 +04:00
|
|
|
|
|
|
|
// Return our desired size
|
|
|
|
aDesiredSize.width = x;
|
1998-10-14 20:32:45 +04:00
|
|
|
aDesiredSize.height = aReflowState.maxCellVertSpace;
|
1998-07-10 08:00:38 +04:00
|
|
|
|
1998-10-20 19:59:56 +04:00
|
|
|
return rv;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
|
1998-07-01 07:03:32 +04:00
|
|
|
// Recover the reflow state to what it should be if aKidFrame is about
|
|
|
|
// to be reflowed
|
1998-07-11 02:56:13 +04:00
|
|
|
//
|
|
|
|
// The things in the RowReflowState object we need to restore are:
|
|
|
|
// - maxCellHeight
|
|
|
|
// - maxVertCellSpace
|
1998-07-14 19:29:50 +04:00
|
|
|
// - x
|
1998-10-20 19:59:56 +04:00
|
|
|
NS_METHOD nsTableRowFrame::RecoverState(nsIPresContext& aPresContext,
|
|
|
|
RowReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nscoord& aMaxCellTopMargin,
|
|
|
|
nscoord& aMaxCellBottomMargin)
|
1998-07-01 07:03:32 +04:00
|
|
|
{
|
1998-07-15 08:45:58 +04:00
|
|
|
aMaxCellTopMargin = aMaxCellBottomMargin = 0;
|
|
|
|
|
1998-07-14 19:29:50 +04:00
|
|
|
// Walk the list of children looking for aKidFrame. While we're at
|
|
|
|
// it get the maxCellHeight and maxVertCellSpace for all the
|
|
|
|
// frames except aKidFrame
|
1998-10-14 20:32:45 +04:00
|
|
|
for (nsIFrame* frame = mFirstChild; nsnull != frame;)
|
|
|
|
{
|
1998-09-24 20:37:22 +04:00
|
|
|
const nsStyleDisplay *kidDisplay;
|
|
|
|
frame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)kidDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
if (frame != aKidFrame) {
|
|
|
|
// Update the max top and bottom margins
|
|
|
|
nsMargin kidMargin;
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.tableFrame->GetCellMarginData((nsTableCellFrame *)frame, kidMargin);
|
1998-09-24 20:37:22 +04:00
|
|
|
if (kidMargin.top > aMaxCellTopMargin)
|
|
|
|
aMaxCellTopMargin = kidMargin.top;
|
|
|
|
if (kidMargin.bottom > aMaxCellBottomMargin)
|
|
|
|
aMaxCellBottomMargin = kidMargin.bottom;
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
PRInt32 rowSpan = aReflowState.tableFrame->GetEffectiveRowSpan(mRowIndex, ((nsTableCellFrame *)frame));
|
1998-09-24 20:37:22 +04:00
|
|
|
if (mMinRowSpan == rowSpan) {
|
|
|
|
// Get the cell's desired height the last time it was reflowed
|
|
|
|
nsSize desiredSize = ((nsTableCellFrame *)frame)->GetDesiredSize();
|
|
|
|
|
|
|
|
// See if it has a specified height that overrides the desired size
|
|
|
|
nscoord specifiedHeight = 0;
|
|
|
|
nsIStyleContextPtr kidSC;
|
1998-11-03 23:33:43 +03:00
|
|
|
frame->GetStyleContext(kidSC.AssignRef());
|
1998-09-24 20:37:22 +04:00
|
|
|
const nsStylePosition* kidPosition = (const nsStylePosition*)
|
|
|
|
kidSC->GetStyleData(eStyleStruct_Position);
|
|
|
|
switch (kidPosition->mHeight.GetUnit()) {
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
specifiedHeight = kidPosition->mHeight.GetCoordValue();
|
|
|
|
break;
|
1998-07-15 08:45:58 +04:00
|
|
|
|
1998-09-24 20:37:22 +04:00
|
|
|
case eStyleUnit_Inherit:
|
|
|
|
// XXX for now, do nothing
|
|
|
|
default:
|
|
|
|
case eStyleUnit_Auto:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (specifiedHeight > desiredSize.height)
|
|
|
|
desiredSize.height = specifiedHeight;
|
1998-07-14 19:29:50 +04:00
|
|
|
|
1998-09-24 20:37:22 +04:00
|
|
|
// Update maxCellHeight
|
1998-10-14 20:32:45 +04:00
|
|
|
if (desiredSize.height > aReflowState.maxCellHeight) {
|
|
|
|
aReflowState.maxCellHeight = desiredSize.height;
|
1998-09-24 20:37:22 +04:00
|
|
|
}
|
1998-07-01 08:55:15 +04:00
|
|
|
|
1998-09-24 20:37:22 +04:00
|
|
|
// Update maxCellVertHeight
|
|
|
|
nsMargin margin;
|
1998-07-14 19:29:50 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
if (aReflowState.tableFrame->GetCellMarginData((nsTableCellFrame *)frame, margin) == NS_OK)
|
1998-09-24 20:37:22 +04:00
|
|
|
{
|
|
|
|
nscoord height = desiredSize.height + margin.top + margin.bottom;
|
1998-10-14 20:32:45 +04:00
|
|
|
if (height > aReflowState.maxCellVertSpace) {
|
|
|
|
aReflowState.maxCellVertSpace = height;
|
1998-09-24 20:37:22 +04:00
|
|
|
}
|
1998-07-14 19:29:50 +04:00
|
|
|
}
|
1998-07-01 08:55:15 +04:00
|
|
|
}
|
|
|
|
|
1998-09-24 20:37:22 +04:00
|
|
|
// XXX We also need to recover the max element size if requested by the
|
|
|
|
// caller...
|
|
|
|
//
|
|
|
|
// We should be using GetReflowMetrics() to get information from the
|
|
|
|
// table cell, and that will include the max element size...
|
|
|
|
}
|
1998-07-14 19:29:50 +04:00
|
|
|
}
|
1998-07-01 08:55:15 +04:00
|
|
|
|
1998-07-01 07:03:32 +04:00
|
|
|
frame->GetNextSibling(frame);
|
|
|
|
}
|
|
|
|
|
1998-07-14 19:29:50 +04:00
|
|
|
// Update the running x-offset based on the frame's current x-origin
|
|
|
|
nsPoint origin;
|
|
|
|
aKidFrame->GetOrigin(origin);
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.x = origin.x;
|
1998-07-14 19:29:50 +04:00
|
|
|
|
1998-07-02 09:39:10 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
|
|
|
|
|
|
|
|
NS_METHOD nsTableRowFrame::IncrementalReflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-20 19:59:56 +04:00
|
|
|
RowReflowState& aReflowState,
|
1998-10-14 20:32:45 +04:00
|
|
|
nsReflowStatus& aStatus)
|
1998-07-02 09:39:10 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTRF IR: IncrementalReflow\n");
|
|
|
|
nsresult rv = NS_OK;
|
1998-07-02 09:39:10 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// determine if this frame is the target or not
|
|
|
|
nsIFrame *target=nsnull;
|
|
|
|
rv = aReflowState.reflowState.reflowCommand->GetTarget(target);
|
|
|
|
if ((PR_TRUE==NS_SUCCEEDED(rv)) && (nsnull!=target))
|
1998-07-14 19:29:50 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
if (this==target)
|
|
|
|
rv = IR_TargetIsMe(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
else
|
1998-07-14 19:29:50 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
// Get the next frame in the reflow chain
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetNext(nextFrame);
|
|
|
|
rv = IR_TargetIsChild(aPresContext, aDesiredSize, aReflowState, aStatus, nextFrame);
|
1998-07-14 19:29:50 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
1998-07-14 19:29:50 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_METHOD nsTableRowFrame::IR_TargetIsMe(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_FRAME_COMPLETE;
|
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetType(type);
|
|
|
|
nsIFrame *objectFrame;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetChildFrame(objectFrame);
|
1998-10-30 10:57:44 +03:00
|
|
|
const nsStyleDisplay *childDisplay=nsnull;
|
|
|
|
if (nsnull!=objectFrame)
|
|
|
|
objectFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
|
1998-10-14 20:32:45 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TRF IR: IncrementalReflow_TargetIsMe with type=%d\n", type);
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case nsIReflowCommand::FrameInserted :
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_ASSERTION(nsnull!=objectFrame, "bad objectFrame");
|
|
|
|
NS_ASSERTION(nsnull!=childDisplay, "bad childDisplay");
|
1998-10-14 20:32:45 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
rv = IR_CellInserted(aPresContext, aDesiredSize, aReflowState, aStatus,
|
1998-10-20 19:59:56 +04:00
|
|
|
(nsTableCellFrame *)objectFrame, PR_FALSE);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-10-20 21:45:07 +04:00
|
|
|
rv = AddFrame(aReflowState.reflowState, objectFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
break;
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
case nsIReflowCommand::FrameAppended :
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_ASSERTION(nsnull!=objectFrame, "bad objectFrame");
|
|
|
|
NS_ASSERTION(nsnull!=childDisplay, "bad childDisplay");
|
1998-10-14 20:32:45 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == childDisplay->mDisplay)
|
|
|
|
{
|
1998-10-20 19:59:56 +04:00
|
|
|
rv = IR_CellAppended(aPresContext, aDesiredSize, aReflowState, aStatus,
|
|
|
|
(nsTableCellFrame *)objectFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // no optimization to be done for Unknown frame types, so just reuse the Inserted method
|
1998-10-20 21:45:07 +04:00
|
|
|
rv = AddFrame(aReflowState.reflowState, objectFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
case nsIReflowCommand::FrameReplaced :
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
case nsIReflowCommand::FrameRemoved :
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_ASSERTION(nsnull!=objectFrame, "bad objectFrame");
|
|
|
|
NS_ASSERTION(nsnull!=childDisplay, "bad childDisplay");
|
1998-10-14 20:32:45 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
rv = IR_CellRemoved(aPresContext, aDesiredSize, aReflowState, aStatus,
|
1998-10-20 19:59:56 +04:00
|
|
|
(nsTableCellFrame *)objectFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-10-20 21:45:07 +04:00
|
|
|
rv = RemoveFrame(objectFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1998-10-06 04:27:22 +04:00
|
|
|
break;
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
case nsIReflowCommand::StyleChanged :
|
1998-10-30 10:57:44 +03:00
|
|
|
rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-14 20:32:45 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::ContentChanged :
|
|
|
|
NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::PullupReflow:
|
|
|
|
case nsIReflowCommand::PushReflow:
|
|
|
|
case nsIReflowCommand::CheckPullupReflow :
|
|
|
|
case nsIReflowCommand::UserDefined :
|
|
|
|
NS_NOTYETIMPLEMENTED("unimplemented reflow command type");
|
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("TRF IR: reflow command not implemented.\n");
|
1998-10-06 04:27:22 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsTableRowFrame::IR_CellInserted(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-20 19:59:56 +04:00
|
|
|
nsTableCellFrame * aInsertedFrame,
|
1998-10-14 20:32:45 +04:00
|
|
|
PRBool aReplace)
|
|
|
|
{
|
1998-10-20 19:59:56 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTRF IR: IR_CellInserted\n");
|
1998-10-20 21:45:07 +04:00
|
|
|
nsresult rv = AddFrame(aReflowState.reflowState, (nsIFrame*)aInsertedFrame);
|
1998-10-20 19:59:56 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
nsTableFrame *tableFrame=nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv) || nsnull==tableFrame)
|
|
|
|
return rv;
|
1998-10-21 00:05:44 +04:00
|
|
|
|
|
|
|
// do a pass-1 layout of the cell
|
|
|
|
if (PR_TRUE==tableFrame->RequiresPass1Layout())
|
|
|
|
{
|
|
|
|
rv = InitialReflow(aPresContext, aDesiredSize, aReflowState, aStatus,
|
|
|
|
aInsertedFrame, PR_FALSE);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
}
|
1998-10-22 02:29:00 +04:00
|
|
|
|
|
|
|
// set row state
|
|
|
|
GetMinRowSpan(tableFrame);
|
|
|
|
FixMinCellHeight(tableFrame);
|
1998-10-21 00:05:44 +04:00
|
|
|
|
1998-10-22 02:29:00 +04:00
|
|
|
// set table state
|
1998-10-20 19:59:56 +04:00
|
|
|
tableFrame->InvalidateCellMap();
|
|
|
|
tableFrame->InvalidateColumnCache();
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-20 19:59:56 +04:00
|
|
|
NS_METHOD nsTableRowFrame::IR_DidAppendCell(nsTableCellFrame *aRowFrame)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
|
|
|
nsresult rv=NS_OK;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// since we know we're doing an append here, we can optimize
|
|
|
|
NS_METHOD nsTableRowFrame::IR_CellAppended(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-20 19:59:56 +04:00
|
|
|
nsTableCellFrame * aAppendedFrame)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-10-20 19:59:56 +04:00
|
|
|
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTRF IR: IR_CellInserted\n");
|
1998-10-20 21:45:07 +04:00
|
|
|
nsresult rv = AddFrame(aReflowState.reflowState, (nsIFrame*)aAppendedFrame);
|
1998-10-20 19:59:56 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
nsTableFrame *tableFrame=nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv) || nsnull==tableFrame)
|
|
|
|
return rv;
|
1998-10-21 00:05:44 +04:00
|
|
|
|
|
|
|
// do a pass-1 layout of the cell
|
|
|
|
if (PR_TRUE==tableFrame->RequiresPass1Layout())
|
|
|
|
{
|
|
|
|
rv = InitialReflow(aPresContext, aDesiredSize, aReflowState, aStatus,
|
|
|
|
aAppendedFrame, PR_FALSE);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-22 02:29:00 +04:00
|
|
|
// set row state
|
|
|
|
GetMinRowSpan(tableFrame);
|
|
|
|
FixMinCellHeight(tableFrame);
|
|
|
|
|
|
|
|
// set table state
|
|
|
|
|
1998-10-20 19:59:56 +04:00
|
|
|
tableFrame->InvalidateCellMap();
|
|
|
|
tableFrame->InvalidateColumnCache();
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
1998-10-14 20:32:45 +04:00
|
|
|
nsresult rv=NS_OK;
|
|
|
|
// hook aAppendedFrame into the child list
|
|
|
|
nsIFrame *lastChild = mFirstChild;
|
|
|
|
nsIFrame *nextChild = lastChild;
|
|
|
|
nsIFrame *lastRow = nsnull;
|
|
|
|
while (nsnull!=nextChild)
|
1998-10-06 04:27:22 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
// remember the last child that is really a cell
|
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
nextChild->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == childDisplay->mDisplay)
|
|
|
|
lastRow = nextChild;
|
|
|
|
lastChild = nextChild;
|
|
|
|
nextChild->GetNextSibling(nextChild);
|
1998-07-02 09:39:10 +04:00
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
if (nsnull==lastChild)
|
|
|
|
mFirstChild = aAppendedFrame;
|
|
|
|
else
|
|
|
|
lastChild->SetNextSibling(aAppendedFrame);
|
1998-10-06 04:27:22 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.tableFrame->InvalidateFirstPassCache();
|
|
|
|
// the table will see that it's cached info is bogus and rebuild the cell map,
|
|
|
|
// and do a reflow
|
1998-10-06 04:27:22 +04:00
|
|
|
|
1998-10-20 19:59:56 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// find the col index of the new cell
|
|
|
|
|
|
|
|
// account for the new cell
|
|
|
|
nsresult rv = DidAppendCell((nsTableCellFrame*)aAppendedFrame);
|
1998-10-06 04:27:22 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// need to increment the row index of all subsequent rows
|
1998-10-20 19:59:56 +04:00
|
|
|
|
1998-07-02 09:39:10 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
1998-10-20 19:59:56 +04:00
|
|
|
#endif
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1998-07-01 07:03:32 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_METHOD nsTableRowFrame::IR_CellRemoved(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-20 19:59:56 +04:00
|
|
|
nsTableCellFrame * aDeletedFrame)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-10-20 21:45:07 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nRow IR: IR_RowRemoved\n");
|
|
|
|
nsresult rv = RemoveFrame((nsIFrame*)aDeletedFrame);
|
1998-10-20 19:59:56 +04:00
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
{
|
1998-10-22 02:29:00 +04:00
|
|
|
ResetMaxChildHeight();
|
1998-10-20 19:59:56 +04:00
|
|
|
nsTableFrame *tableFrame=nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv) || nsnull==tableFrame)
|
|
|
|
return rv;
|
1998-10-22 02:29:00 +04:00
|
|
|
|
|
|
|
// set row state
|
|
|
|
GetMinRowSpan(tableFrame);
|
|
|
|
FixMinCellHeight(tableFrame);
|
|
|
|
|
|
|
|
// set table state
|
1998-10-20 19:59:56 +04:00
|
|
|
tableFrame->InvalidateCellMap();
|
|
|
|
tableFrame->InvalidateColumnCache();
|
|
|
|
|
|
|
|
// if any column widths have to change due to this, rebalance column widths
|
|
|
|
//XXX need to calculate this, but for now just do it
|
|
|
|
tableFrame->InvalidateColumnWidths();
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_METHOD nsTableRowFrame::IR_StyleChanged(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("Row: IR_StyleChanged for frame %p\n", this);
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// we presume that all the easy optimizations were done in the nsHTMLStyleSheet before we were called here
|
|
|
|
// XXX: we can optimize this when we know which style attribute changed
|
1998-11-04 23:09:19 +03:00
|
|
|
aReflowState.tableFrame->InvalidateFirstPassCache();
|
1998-10-30 10:57:44 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame * aNextFrame)
|
|
|
|
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
aNextFrame->GetStyleData(eStyleStruct_Display, ((nsStyleStruct *&)childDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
// Recover our reflow state
|
|
|
|
nscoord maxCellTopMargin, maxCellBottomMargin;
|
|
|
|
RecoverState(aPresContext, aReflowState, aNextFrame, maxCellTopMargin, maxCellBottomMargin);
|
|
|
|
|
|
|
|
// Get the frame's margins
|
|
|
|
nsMargin kidMargin;
|
|
|
|
aReflowState.tableFrame->GetCellMarginData((nsTableCellFrame *)aNextFrame, kidMargin);
|
|
|
|
if (kidMargin.top > maxCellTopMargin)
|
|
|
|
maxCellTopMargin = kidMargin.top;
|
|
|
|
if (kidMargin.bottom > maxCellBottomMargin)
|
|
|
|
maxCellBottomMargin = kidMargin.bottom;
|
|
|
|
|
|
|
|
// At this point, we know the column widths. Get the available width
|
|
|
|
// from the known column widths
|
|
|
|
PRInt32 cellColIndex = ((nsTableCellFrame *)aNextFrame)->GetColIndex();
|
|
|
|
PRInt32 cellColSpan = aReflowState.tableFrame->GetEffectiveColSpan(((nsTableCellFrame *)aNextFrame)->GetColIndex(),
|
|
|
|
((nsTableCellFrame *)aNextFrame));
|
|
|
|
nscoord availWidth = 0;
|
|
|
|
for (PRInt32 numColSpan = 0; numColSpan < cellColSpan; numColSpan++)
|
|
|
|
{
|
|
|
|
availWidth += aReflowState.tableFrame->GetColumnWidth(cellColIndex+numColSpan);
|
|
|
|
if (0<numColSpan)
|
|
|
|
{
|
|
|
|
availWidth += kidMargin.right;
|
|
|
|
if (0!=cellColIndex)
|
|
|
|
availWidth += kidMargin.left;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Always let the cell be as high as it wants. We ignore the height that's
|
|
|
|
// passed in and always place the entire row. Let the row group decide
|
|
|
|
// whether we fit or wehther the entire row is pushed
|
|
|
|
nsSize kidAvailSize(availWidth, NS_UNCONSTRAINEDSIZE);
|
|
|
|
|
|
|
|
// Pass along the reflow command
|
|
|
|
nsSize kidMaxElementSize;
|
|
|
|
nsHTMLReflowMetrics desiredSize(&kidMaxElementSize);
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aNextFrame, aReflowState.reflowState,
|
|
|
|
kidAvailSize);
|
|
|
|
|
|
|
|
// 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...
|
|
|
|
rv = ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
rv = ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
|
|
|
if (gsDebug)
|
|
|
|
printf ("TR %p for cell %p Incremental Reflow: desired=%d, MES=%d\n",
|
|
|
|
this, aNextFrame, desiredSize.width, kidMaxElementSize.width);
|
|
|
|
// Update the cell layout data.
|
|
|
|
//XXX: this is a hack, shouldn't it be the case that a min size is
|
|
|
|
// never larger than a desired size?
|
|
|
|
if (kidMaxElementSize.width>desiredSize.width)
|
|
|
|
desiredSize.width = kidMaxElementSize.width;
|
|
|
|
if (kidMaxElementSize.height>desiredSize.height)
|
|
|
|
desiredSize.height = kidMaxElementSize.height;
|
|
|
|
((nsTableCellFrame *)aNextFrame)->SetPass1DesiredSize(desiredSize);
|
|
|
|
((nsTableCellFrame *)aNextFrame)->SetPass1MaxElementSize(kidMaxElementSize);
|
|
|
|
|
|
|
|
// Now reflow the cell again this time constraining the width
|
|
|
|
// XXX Ignore for now the possibility that the column width has changed...
|
|
|
|
kidReflowState.maxSize.width = availWidth;
|
|
|
|
rv = ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
|
|
|
|
|
|
|
// Place the child after taking into account it's margin and attributes
|
|
|
|
// XXX We need to ask the table (or the table layout strategy) if the column
|
|
|
|
// widths have changed. If so, we just bail and return a status indicating
|
|
|
|
// what happened and let the table reflow all the table cells...
|
|
|
|
nscoord specifiedHeight = 0;
|
|
|
|
nscoord cellHeight = desiredSize.height;
|
|
|
|
nsIStyleContextPtr kidSC;
|
1998-11-03 23:33:43 +03:00
|
|
|
aNextFrame->GetStyleContext(kidSC.AssignRef());
|
1998-10-14 20:32:45 +04:00
|
|
|
const nsStylePosition* kidPosition = (const nsStylePosition*)
|
|
|
|
kidSC->GetStyleData(eStyleStruct_Position);
|
|
|
|
switch (kidPosition->mHeight.GetUnit()) {
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
specifiedHeight = kidPosition->mHeight.GetCoordValue();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Inherit:
|
|
|
|
// XXX for now, do nothing
|
|
|
|
default:
|
|
|
|
case eStyleUnit_Auto:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (specifiedHeight>cellHeight)
|
|
|
|
cellHeight = specifiedHeight;
|
|
|
|
|
|
|
|
nscoord cellWidth = desiredSize.width;
|
|
|
|
// begin special Nav4 compatibility code
|
|
|
|
if (0==cellWidth)
|
|
|
|
{
|
|
|
|
cellWidth = aReflowState.tableFrame->GetColumnWidth(cellColIndex);
|
|
|
|
}
|
|
|
|
// end special Nav4 compatibility code
|
1998-08-07 06:11:51 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// Now place the child
|
|
|
|
nsRect kidRect (aReflowState.x, kidMargin.top, cellWidth, cellHeight);
|
|
|
|
|
|
|
|
PlaceChild(aPresContext, aReflowState, aNextFrame, kidRect, aDesiredSize.maxElementSize,
|
|
|
|
&kidMaxElementSize);
|
|
|
|
|
|
|
|
SetMaxChildHeight(aReflowState.maxCellHeight, maxCellTopMargin, maxCellBottomMargin);
|
|
|
|
|
|
|
|
// Return our desired size. Note that our desired width is just whatever width
|
|
|
|
// we were given by the row group frame
|
|
|
|
aDesiredSize.width = aReflowState.availSize.width;
|
|
|
|
aDesiredSize.height = aReflowState.maxCellVertSpace;
|
|
|
|
|
|
|
|
if (gsDebug)
|
|
|
|
printf("incr -- row %p width = %d MES=%d from maxSize %d\n",
|
1998-10-22 09:27:11 +04:00
|
|
|
this, aDesiredSize.width,
|
|
|
|
aDesiredSize.maxElementSize ? aDesiredSize.maxElementSize->width : -1,
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.reflowState.maxSize.width);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // pass reflow to unknown frame child
|
|
|
|
// aDesiredSize does not change
|
|
|
|
}
|
|
|
|
return rv;
|
1998-07-01 07:03:32 +04:00
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
/** Layout the entire row.
|
1998-07-02 09:39:10 +04:00
|
|
|
* This method stacks cells horizontally according to HTML 4.0 rules.
|
1998-04-23 21:29:07 +04:00
|
|
|
*/
|
|
|
|
NS_METHOD
|
1998-10-02 08:10:00 +04:00
|
|
|
nsTableRowFrame::Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
nsresult rv=NS_OK;
|
1998-08-07 06:11:51 +04:00
|
|
|
if (gsDebug==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-14 00:24:54 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// Initialize 'out' parameters (aStatus set below, undefined if rv returns an error)
|
1998-07-11 02:56:13 +04:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
1998-07-11 02:56:13 +04:00
|
|
|
|
|
|
|
// Initialize our internal data
|
|
|
|
ResetMaxChildHeight();
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// Create a reflow state
|
|
|
|
nsTableFrame *tableFrame=nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv) || nsnull==tableFrame)
|
|
|
|
return rv;
|
1998-07-15 08:45:58 +04:00
|
|
|
RowReflowState state(aReflowState, tableFrame);
|
1998-07-11 02:56:13 +04:00
|
|
|
|
|
|
|
// Do the reflow
|
|
|
|
switch (aReflowState.reason) {
|
|
|
|
case eReflowReason_Initial:
|
1998-10-20 19:59:56 +04:00
|
|
|
rv = InitialReflow(aPresContext, aDesiredSize, state, aStatus, nsnull, PR_TRUE);
|
1998-07-24 04:43:09 +04:00
|
|
|
GetMinRowSpan(tableFrame);
|
|
|
|
FixMinCellHeight(tableFrame);
|
1998-07-11 02:56:13 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eReflowReason_Resize:
|
1998-10-20 19:59:56 +04:00
|
|
|
rv = ResizeReflow(aPresContext, aDesiredSize, state, aStatus);
|
1998-07-11 02:56:13 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eReflowReason_Incremental:
|
1998-10-14 20:32:45 +04:00
|
|
|
rv = IncrementalReflow(aPresContext, aDesiredSize, state, aStatus);
|
1998-07-11 02:56:13 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-07-02 09:39:10 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE; // we're never continued
|
|
|
|
|
1998-08-07 06:11:51 +04:00
|
|
|
if (gsDebug==PR_TRUE)
|
1998-04-15 01:45:28 +04:00
|
|
|
{
|
1998-05-25 21:31:49 +04:00
|
|
|
if (nsnull!=aDesiredSize.maxElementSize)
|
1998-09-10 00:00:40 +04:00
|
|
|
printf("%p: Row::RR returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
|
|
|
|
this, 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
|
1998-09-10 00:00:40 +04:00
|
|
|
printf("%p: Row::RR returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
|
|
|
|
this, 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-10-14 20:32:45 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-05-07 04:08:20 +04:00
|
|
|
NS_METHOD
|
1998-07-15 07:23:23 +04:00
|
|
|
nsTableRowFrame::CreateContinuingFrame(nsIPresContext& aPresContext,
|
1998-05-07 04:08:20 +04:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aStyleContext,
|
|
|
|
nsIFrame*& aContinuingFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-07-11 08:16:29 +04:00
|
|
|
// Because rows are always complete we should never be asked to create
|
|
|
|
// a continuing frame
|
|
|
|
NS_ERROR("Unexpected request");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-11-07 03:36:37 +03:00
|
|
|
/* we overload this here because rows have children that can span outside of themselves.
|
|
|
|
* so the default "get the child rect, see if it contains the event point" action isn't
|
|
|
|
* sufficient. We have to ask the row if it has a child that contains the point.
|
|
|
|
*/
|
|
|
|
PRBool nsTableRowFrame::Contains(nsPoint& aPoint)
|
|
|
|
{
|
|
|
|
if (gsDebug) printf("Row %p index %d ::Contains aPoint(%d,%d) and row rect (%d,%d,%d,%d)\n",
|
|
|
|
this, mRowIndex,
|
|
|
|
aPoint.x, aPoint.y,
|
|
|
|
mRect.x, mRect.y, mRect.width, mRect.height);
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
// first, check the row rect and see if the point is in their
|
|
|
|
if (mRect.Contains(aPoint)) {
|
|
|
|
if (gsDebug) printf("%p Row::Contains point.\n");
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
// if that fails, check the cells, they might span outside the row rect
|
|
|
|
else {
|
|
|
|
nsIFrame* kid;
|
|
|
|
FirstChild(kid);
|
|
|
|
while (nsnull != kid) {
|
|
|
|
nsRect kidRect;
|
|
|
|
kid->GetRect(kidRect);
|
|
|
|
nsPoint point(aPoint);
|
|
|
|
point.MoveBy(-mRect.x, -mRect.y); // offset the point to check by the row container
|
|
|
|
if (gsDebug) printf("Row %p checking point (%d,%d) vs. cell rect (%d,%d,%d,%d)\n",
|
|
|
|
point.x, point.y,
|
|
|
|
kidRect.x, kidRect.y, kidRect.width, kidRect.height);
|
|
|
|
if (kidRect.Contains(point)) {
|
|
|
|
if (gsDebug) printf("cell contains point.\n");
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
kid->GetNextSibling(kid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gsDebug) printf("%p Row::Contains returning %d\n", this, result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewTableRowFrame(nsIContent* aContent,
|
|
|
|
nsIFrame* aParentFrame,
|
|
|
|
nsIFrame*& aResult)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-09-15 21:58:24 +04:00
|
|
|
nsIFrame* it = new nsTableRowFrame(aContent, aParentFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1998-09-15 21:58:24 +04:00
|
|
|
aResult = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-03 01:59:54 +04:00
|
|
|
/* ----- debugging methods ----- */
|
|
|
|
NS_METHOD nsTableRowFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const
|
|
|
|
{
|
|
|
|
// if a filter is present, only output this frame if the filter says we should
|
|
|
|
// since this could be any "tag" with the right display type, we'll
|
|
|
|
// just pretend it's a row
|
|
|
|
if (nsnull==aFilter)
|
|
|
|
return nsContainerFrame::List(out, aIndent, aFilter);
|
|
|
|
|
|
|
|
nsAutoString tagString("tr");
|
|
|
|
PRBool outputMe = aFilter->OutputTag(&tagString);
|
|
|
|
if (PR_TRUE==outputMe)
|
|
|
|
{
|
|
|
|
// Indent
|
|
|
|
for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
|
|
|
|
// Output the tag and rect
|
|
|
|
nsIAtom* tag;
|
|
|
|
mContent->GetTag(tag);
|
|
|
|
if (tag != nsnull) {
|
|
|
|
nsAutoString buf;
|
|
|
|
tag->ToString(buf);
|
|
|
|
fputs(buf, out);
|
|
|
|
NS_RELEASE(tag);
|
|
|
|
}
|
|
|
|
|
1998-10-09 00:35:16 +04:00
|
|
|
fprintf(out, "(%d)", ContentIndexInContainer(this));
|
1998-09-03 01:59:54 +04:00
|
|
|
out << mRect;
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
|
|
|
}
|
|
|
|
fputs("\n", out);
|
|
|
|
}
|
|
|
|
// Output the children
|
1998-09-21 07:40:32 +04:00
|
|
|
if (nsnull != mFirstChild) {
|
1998-09-03 01:59:54 +04:00
|
|
|
if (PR_TRUE==outputMe)
|
|
|
|
{
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]\n", mState);
|
|
|
|
}
|
|
|
|
}
|
1998-09-19 07:24:26 +04:00
|
|
|
for (nsIFrame* child = mFirstChild; child; child->GetNextSibling(child)) {
|
1998-09-03 01:59:54 +04:00
|
|
|
child->List(out, aIndent + 1, aFilter);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (PR_TRUE==outputMe)
|
|
|
|
{
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]\n", mState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|