1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-14 00:24:54 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
#include "nsTableRowFrame.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
1999-07-28 12:09:02 +04:00
|
|
|
#include "nsIPresShell.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#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-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"
|
1999-02-24 08:54:31 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-07-28 12:09:02 +04:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsTableColGroupFrame.h"
|
|
|
|
#include "nsTableColFrame.h"
|
|
|
|
#include "nsCOMPtr.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"
|
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
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
|
2000-05-05 03:16:42 +04:00
|
|
|
struct nsTableCellReflowState : public nsHTMLReflowState
|
|
|
|
{
|
|
|
|
nsTableCellReflowState(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aParentReflowState,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsSize& aAvailableSpace,
|
|
|
|
nsReflowReason aReason);
|
|
|
|
|
|
|
|
nsTableCellReflowState(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aParentReflowState,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsSize& aAvailableSpace);
|
|
|
|
|
|
|
|
void FixUp(const nsSize& aAvailSpace);
|
|
|
|
};
|
|
|
|
|
|
|
|
nsTableCellReflowState::nsTableCellReflowState(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aParentRS,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsSize& aAvailSpace,
|
|
|
|
nsReflowReason aReason)
|
|
|
|
:nsHTMLReflowState(aPresContext, aParentRS, aFrame, aAvailSpace, aReason)
|
|
|
|
{
|
|
|
|
FixUp(aAvailSpace);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableCellReflowState::nsTableCellReflowState(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aParentRS,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsSize& aAvailSpace)
|
|
|
|
:nsHTMLReflowState(aPresContext, aParentRS, aFrame, aAvailSpace)
|
|
|
|
{
|
|
|
|
FixUp(aAvailSpace);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableCellReflowState::FixUp(const nsSize& aAvailSpace)
|
|
|
|
{
|
|
|
|
// fix the mComputed values during a pass 2 reflow since the cell can be a percentage base
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aAvailSpace.width) {
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != mComputedWidth) {
|
|
|
|
mComputedWidth = aAvailSpace.width - mComputedBorderPadding.left - mComputedBorderPadding.right;
|
|
|
|
mComputedWidth = PR_MAX(0, mComputedWidth);
|
|
|
|
}
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != mComputedHeight) {
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aAvailSpace.height) {
|
|
|
|
mComputedHeight = aAvailSpace.height - mComputedBorderPadding.top - mComputedBorderPadding.bottom;
|
|
|
|
mComputedHeight = PR_MAX(0, mComputedHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
// 'old' is old cached cell's desired size
|
|
|
|
// 'new' is new cell's size including style constraints
|
|
|
|
static PRBool
|
|
|
|
TallestCellGotShorter(nscoord aOld,
|
|
|
|
nscoord aNew,
|
|
|
|
nscoord aTallest)
|
|
|
|
{
|
2000-12-22 02:03:42 +03:00
|
|
|
return ((aNew < aOld) && (aOld == aTallest));
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
/* ----------- nsTableRowpFrame ---------- */
|
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsTableRowFrame::nsTableRowFrame()
|
|
|
|
: nsHTMLContainerFrame(),
|
1999-10-24 03:08:30 +04:00
|
|
|
mAllBits(0)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-10-24 03:08:30 +04:00
|
|
|
mBits.mMinRowSpan = 1;
|
1999-12-14 01:56:31 +03:00
|
|
|
mBits.mRowIndex = 0;
|
2000-08-24 09:03:18 +04:00
|
|
|
ResetTallestCell(0);
|
2001-01-25 18:55:51 +03:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
mTimer = new nsReflowTimer(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableRowFrame::~nsTableRowFrame()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflowDone(this);
|
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-25 08:31:15 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowFrame::Init(nsIPresContext* aPresContext,
|
1999-02-25 08:31:15 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Let the the base class do its initialization
|
|
|
|
rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext,
|
|
|
|
aPrevInFlow);
|
|
|
|
|
2001-02-23 15:35:34 +03:00
|
|
|
// record that children that are ignorable whitespace should be excluded
|
|
|
|
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
|
|
|
|
|
1999-02-25 08:31:15 +03:00
|
|
|
if (aPrevInFlow) {
|
|
|
|
// Set the row index
|
|
|
|
nsTableRowFrame* rowFrame = (nsTableRowFrame*)aPrevInFlow;
|
|
|
|
|
|
|
|
SetRowIndex(rowFrame->GetRowIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowFrame::AppendFrames(nsIPresContext* aPresContext,
|
1999-08-03 06:41:27 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
// Append the frames
|
|
|
|
mFrames.AppendFrames(nsnull, aFrameList);
|
|
|
|
|
|
|
|
// Add the new cell frames to the table
|
|
|
|
nsTableFrame *tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
for (nsIFrame* childFrame = aFrameList; childFrame; childFrame->GetNextSibling(&childFrame)) {
|
2001-03-13 09:38:59 +03:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
childFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableCellFrame == frameType.get()) {
|
1999-08-03 06:41:27 +04:00
|
|
|
// Add the cell to the cell map
|
1999-12-14 01:56:31 +03:00
|
|
|
tableFrame->AppendCell(*aPresContext, (nsTableCellFrame&)*childFrame, GetRowIndex());
|
2001-03-13 09:38:59 +03:00
|
|
|
// XXX this could be optimized with some effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
2001-03-13 09:38:59 +03:00
|
|
|
tableFrame->AppendDirtyReflowCommand(&aPresShell, this);
|
1999-08-03 06:41:27 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowFrame::InsertFrames(nsIPresContext* aPresContext,
|
1999-08-03 06:41:27 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
// Get the table frame
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// gather the new frames (only those which are cells) into an array
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableCellFrame* prevCellFrame = (nsTableCellFrame *)nsTableFrame::GetFrameAtOrBefore(aPresContext, this, aPrevFrame, nsLayoutAtoms::tableCellFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
nsVoidArray cellChildren;
|
|
|
|
for (nsIFrame* childFrame = aFrameList; childFrame; childFrame->GetNextSibling(&childFrame)) {
|
2001-03-13 09:38:59 +03:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
childFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableCellFrame == frameType.get()) {
|
1999-12-14 01:56:31 +03:00
|
|
|
cellChildren.AppendElement(childFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
// XXX this could be optimized with some effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// insert the cells into the cell map
|
|
|
|
PRInt32 colIndex = -1;
|
|
|
|
if (prevCellFrame) {
|
|
|
|
prevCellFrame->GetColIndex(colIndex);
|
|
|
|
}
|
|
|
|
tableFrame->InsertCells(*aPresContext, cellChildren, GetRowIndex(), colIndex);
|
|
|
|
|
|
|
|
// Insert the frames in the frame list
|
1999-08-03 06:41:27 +04:00
|
|
|
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
2001-03-13 09:38:59 +03:00
|
|
|
tableFrame->AppendDirtyReflowCommand(&aPresShell, this);
|
1999-08-03 06:41:27 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowFrame::RemoveFrame(nsIPresContext* aPresContext,
|
1999-08-03 06:41:27 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
// Get the table frame
|
|
|
|
nsTableFrame* tableFrame=nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
if (tableFrame) {
|
2001-03-13 09:38:59 +03:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
aOldFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableCellFrame == frameType.get()) {
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)aOldFrame;
|
|
|
|
PRInt32 colIndex;
|
|
|
|
cellFrame->GetColIndex(colIndex);
|
2001-03-13 09:38:59 +03:00
|
|
|
// remove the cell from the cell map
|
1999-12-14 01:56:31 +03:00
|
|
|
tableFrame->RemoveCell(*aPresContext, cellFrame, GetRowIndex());
|
2001-03-13 09:38:59 +03:00
|
|
|
// XXX this could be optimized with some effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
// Remove the frame and destroy it
|
|
|
|
mFrames.DestroyFrame(aPresContext, aOldFrame);
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// XXX This could probably be optimized with much effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
|
|
|
// Generate a reflow command so we reflow the table itself.
|
2000-03-09 11:45:26 +03:00
|
|
|
// Target the row so that it gets a dirty reflow before a resize reflow
|
|
|
|
// in case another cell gets added to the row during a reflow coallesce.
|
2001-03-13 09:38:59 +03:00
|
|
|
tableFrame->AppendDirtyReflowCommand(&aPresShell, this);
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
|
|
|
}
|
1998-09-16 21:19:20 +04:00
|
|
|
|
1999-08-30 04:01:09 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-09-05 18:57:34 +04:00
|
|
|
nscoord
|
|
|
|
GetHeightOfRowsSpannedBelowFirst(nsTableCellFrame& aTableCellFrame,
|
|
|
|
nsTableFrame& aTableFrame)
|
|
|
|
{
|
|
|
|
nscoord height = 0;
|
|
|
|
nscoord cellSpacingY = aTableFrame.GetCellSpacingY();
|
|
|
|
PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan(aTableCellFrame);
|
|
|
|
// add in height of rows spanned beyond the 1st one
|
|
|
|
nsIFrame* nextRow = nsnull;
|
|
|
|
aTableCellFrame.GetParent((nsIFrame **)&nextRow);
|
|
|
|
nextRow->GetNextSibling(&nextRow);
|
|
|
|
for (PRInt32 rowX = 1; ((rowX < rowSpan) && nextRow);) {
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
nextRow->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType.get()) {
|
|
|
|
nsRect rect;
|
|
|
|
nextRow->GetRect(rect);
|
|
|
|
height += rect.height;
|
|
|
|
rowX++;
|
|
|
|
}
|
|
|
|
height += cellSpacingY;
|
|
|
|
nextRow->GetNextSibling(&nextRow);
|
|
|
|
}
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-07-03 00:35:23 +04:00
|
|
|
/**
|
|
|
|
* Post-reflow hook. This is where the table row does its post-processing
|
|
|
|
*/
|
1998-11-20 04:01:25 +03:00
|
|
|
void
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowFrame::DidResize(nsIPresContext* aPresContext,
|
1998-11-20 04:01:25 +03:00
|
|
|
const nsHTMLReflowState& aReflowState)
|
1998-07-03 00:35:23 +04:00
|
|
|
{
|
1998-11-20 04:01:25 +03:00
|
|
|
// Resize and re-align the cell frames based on our row height
|
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
2000-04-29 01:05:31 +04:00
|
|
|
if (!tableFrame) return;
|
1999-05-04 23:15:56 +04:00
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableIterator iter(aPresContext, *this, eTableDIR);
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame* childFrame = iter.First();
|
1999-05-04 23:15:56 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
while (childFrame) {
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
childFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableCellFrame == frameType.get()) {
|
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)childFrame;
|
|
|
|
nscoord cellHeight = mRect.height + GetHeightOfRowsSpannedBelowFirst(*cellFrame, *tableFrame);
|
1999-05-04 23:15:56 +04:00
|
|
|
|
|
|
|
// resize the cell's height
|
|
|
|
nsSize cellFrameSize;
|
|
|
|
cellFrame->GetSize(cellFrameSize);
|
|
|
|
//if (cellFrameSize.height!=cellHeight)
|
1998-11-20 04:01:25 +03:00
|
|
|
{
|
1999-11-19 18:33:29 +03:00
|
|
|
// XXX If the cell frame has a view, then we need to resize
|
|
|
|
// it as well. We would like to only do that if the cell's size
|
|
|
|
// is changing. Why is the 'if' stmt above commented out?
|
1999-11-24 09:03:41 +03:00
|
|
|
cellFrame->SizeTo(aPresContext, cellFrameSize.width, cellHeight);
|
1999-05-04 23:15:56 +04:00
|
|
|
// realign cell content based on the new height
|
|
|
|
/*nsHTMLReflowMetrics desiredSize(nsnull);
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
|
|
|
|
cellFrame,
|
|
|
|
nsSize(cellFrameSize.width, cellHeight),
|
|
|
|
eReflowReason_Resize);*/
|
|
|
|
//XXX: the following reflow is necessary for any content of the cell
|
|
|
|
// whose height is a percent of the cell's height (maybe indirectly.)
|
|
|
|
// But some content crashes when this reflow is issued, to be investigated
|
|
|
|
//XXX nsReflowStatus status;
|
|
|
|
//ReflowChild(cellFrame, aPresContext, desiredSize, kidReflowState, status);
|
2000-07-28 13:19:26 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
cellFrame->VerticallyAlignChild(aPresContext, aReflowState, mMaxCellAscent);
|
1998-07-03 00:35:23 +04:00
|
|
|
}
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
// Get the next child
|
|
|
|
childFrame = iter.Next();
|
1998-07-03 00:35:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Let our base class do the usual work
|
|
|
|
}
|
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
// returns max-ascent amongst all cells that have 'vertical-align: baseline'
|
2000-07-28 13:19:26 +04:00
|
|
|
// *including* cells with rowspans
|
2000-06-05 12:25:11 +04:00
|
|
|
nscoord nsTableRowFrame::GetMaxCellAscent() const
|
|
|
|
{
|
|
|
|
return mMaxCellAscent;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0 // nobody uses this
|
|
|
|
// returns max-descent amongst all cells that have 'vertical-align: baseline'
|
|
|
|
// does *not* include cells with rowspans
|
|
|
|
nscoord nsTableRowFrame::GetMaxCellDescent() const
|
|
|
|
{
|
|
|
|
return mMaxCellDescent;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-05-26 02:40:21 +04:00
|
|
|
/** returns the height of the tallest child in this row (ignoring any cell with rowspans) */
|
|
|
|
nscoord nsTableRowFrame::GetTallestCell() const
|
|
|
|
{
|
|
|
|
return mTallestCell;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-08-24 09:03:18 +04:00
|
|
|
nsTableRowFrame::ResetTallestCell(nscoord aRowStyleHeight)
|
2000-05-26 02:40:21 +04:00
|
|
|
{
|
2000-08-24 09:03:18 +04:00
|
|
|
mTallestCell = (NS_UNCONSTRAINEDSIZE == aRowStyleHeight) ? 0 : aRowStyleHeight;
|
2000-06-05 12:25:11 +04:00
|
|
|
mMaxCellAscent = 0;
|
|
|
|
mMaxCellDescent = 0;
|
2000-05-26 02:40:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableRowFrame::SetTallestCell(nscoord aHeight,
|
2000-06-05 12:25:11 +04:00
|
|
|
nscoord aAscent,
|
|
|
|
nscoord aDescent,
|
2000-05-26 02:40:21 +04:00
|
|
|
nsTableFrame* aTableFrame,
|
|
|
|
nsTableCellFrame* aCellFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2000-06-05 12:25:11 +04:00
|
|
|
NS_ASSERTION((aTableFrame && aCellFrame) , "invalid call");
|
|
|
|
if (aHeight != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
if (!(aCellFrame->HasVerticalAlignBaseline())) { // only the cell's height matters
|
|
|
|
if (mTallestCell < aHeight) {
|
|
|
|
PRInt32 rowSpan = aTableFrame->GetEffectiveRowSpan(*aCellFrame);
|
|
|
|
if (rowSpan == 1) {
|
|
|
|
mTallestCell = aHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // the alignment on the baseline can change the height
|
|
|
|
NS_ASSERTION((aAscent != NS_UNCONSTRAINEDSIZE) && (aDescent != NS_UNCONSTRAINEDSIZE), "invalid call");
|
|
|
|
// see if this is a long ascender
|
|
|
|
if (mMaxCellAscent < aAscent) {
|
|
|
|
mMaxCellAscent = aAscent;
|
|
|
|
}
|
|
|
|
// see if this is a long descender and without rowspan
|
|
|
|
if (mMaxCellDescent < aDescent) {
|
|
|
|
PRInt32 rowSpan = aTableFrame->GetEffectiveRowSpan(*aCellFrame);
|
|
|
|
if (rowSpan == 1) {
|
|
|
|
mMaxCellDescent = aDescent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// keep the tallest height in sync
|
|
|
|
if (mTallestCell < mMaxCellAscent + mMaxCellDescent) {
|
|
|
|
mTallestCell = mMaxCellAscent + mMaxCellDescent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2000-05-26 02:40:21 +04:00
|
|
|
void
|
|
|
|
nsTableRowFrame::CalcTallestCell()
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2000-05-26 02:40:21 +04:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv)) return;
|
|
|
|
|
2000-08-24 09:03:18 +04:00
|
|
|
ResetTallestCell(0);
|
2000-05-26 02:40:21 +04:00
|
|
|
|
|
|
|
for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame; kidFrame->GetNextSibling(&kidFrame)) {
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
kidFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableCellFrame == frameType.get()) {
|
2000-06-05 12:25:11 +04:00
|
|
|
nscoord availWidth = ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth();
|
|
|
|
nsSize desSize = ((nsTableCellFrame *)kidFrame)->GetDesiredSize();
|
|
|
|
CalculateCellActualSize(kidFrame, desSize.width, desSize.height, availWidth);
|
|
|
|
// height may have changed, adjust descent to absorb any excess difference
|
|
|
|
nscoord ascent = ((nsTableCellFrame *)kidFrame)->GetDesiredAscent();
|
|
|
|
nscoord descent = desSize.height - ascent;
|
|
|
|
SetTallestCell(desSize.height, ascent, descent, tableFrame, (nsTableCellFrame*)kidFrame);
|
2000-05-26 02:40:21 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2001-03-21 08:32:22 +03:00
|
|
|
#if 0
|
1999-08-20 17:32:23 +04:00
|
|
|
static
|
2000-01-22 04:16:50 +03:00
|
|
|
PRBool IsFirstRow(nsIPresContext* aPresContext,
|
|
|
|
nsTableFrame& aTable,
|
1999-06-08 01:10:25 +04:00
|
|
|
nsTableRowFrame& aRow)
|
|
|
|
{
|
|
|
|
nsIFrame* firstRowGroup = nsnull;
|
2000-01-22 04:16:50 +03:00
|
|
|
aTable.FirstChild(aPresContext, nsnull, &firstRowGroup);
|
1999-06-08 01:10:25 +04:00
|
|
|
nsIFrame* rowGroupFrame = nsnull;
|
|
|
|
nsresult rv = aRow.GetParent(&rowGroupFrame);
|
|
|
|
if (NS_SUCCEEDED(rv) && (rowGroupFrame == firstRowGroup)) {
|
|
|
|
nsIFrame* firstRow;
|
2000-01-22 04:16:50 +03:00
|
|
|
rowGroupFrame->FirstChild(aPresContext, nsnull, &firstRow);
|
1999-06-08 01:10:25 +04:00
|
|
|
return (&aRow == firstRow);
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2001-03-21 08:32:22 +03:00
|
|
|
#endif
|
1999-06-08 01:10:25 +04:00
|
|
|
|
2001-09-19 16:35:19 +04:00
|
|
|
NS_METHOD nsTableRowFrame::Paint(nsIPresContext* aPresContext,
|
1999-06-08 01:10:25 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1999-06-08 01:10:25 +04:00
|
|
|
{
|
2001-01-27 17:09:34 +03:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-09-19 16:35:19 +04:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) &&
|
|
|
|
!(aFlags && (NS_ROW_FRAME_PAINT_SKIP_ROW == aFlags))) {
|
1999-06-08 01:10:25 +04:00
|
|
|
nsCompatibility mode;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetCompatibilityMode(&mode);
|
1999-06-08 01:10:25 +04:00
|
|
|
if (eCompatibility_Standard == mode) {
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleVisibility* vis =
|
|
|
|
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
|
|
|
|
if (vis->IsVisibleOrCollapsed()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
const nsStyleBorder* border =
|
|
|
|
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleBackground* color =
|
2001-06-20 08:48:34 +04:00
|
|
|
(const nsStyleBackground*)mStyleContext->GetStyleData(eStyleStruct_Background);
|
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
1999-06-08 01:10:25 +04:00
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
2001-02-07 12:57:26 +03:00
|
|
|
aDirtyRect, rect, *color, *border, 0, 0);
|
1999-06-08 01:10:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
1999-06-08 01:10:25 +04:00
|
|
|
// for debug...
|
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0,255,0));
|
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-06-08 01:10:25 +04:00
|
|
|
|
2001-09-19 16:35:19 +04:00
|
|
|
if (!(aFlags && (NS_ROW_FRAME_PAINT_SKIP_CELLS == aFlags))) {
|
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
|
|
|
}
|
1999-06-11 01:08:17 +04:00
|
|
|
return NS_OK;
|
1999-06-08 01:10:25 +04:00
|
|
|
|
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
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
void nsTableRowFrame::PaintChildren(nsIPresContext* aPresContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
2001-09-19 16:35:19 +04:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
1998-04-14 00:24:54 +04:00
|
|
|
while (nsnull != kid) {
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIView *pView;
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
kid->GetView(aPresContext, &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);
|
1998-12-18 18:54:23 +03:00
|
|
|
kid->Paint(aPresContext, aRenderingContext, kidDamageArea,
|
|
|
|
aWhichLayer);
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1999-03-26 03:39:35 +03:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) &&
|
1998-12-18 18:54:23 +03:00
|
|
|
GetShowFrameBorders()) {
|
1998-06-14 04:45:21 +04:00
|
|
|
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
|
|
|
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
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
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
kid->GetNextSibling(&kid);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-22 05:43:08 +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.
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
2000-03-22 05:43:08 +03:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame** aFrame)
|
2000-03-22 05:43:08 +03:00
|
|
|
{
|
|
|
|
// XXX This would not need to exist (except as a one-liner, to make this
|
|
|
|
// frame work like a block frame) if rows with rowspan cells made the
|
|
|
|
// the NS_FRAME_OUTSIDE_CHILDREN bit of mState set correctly (see
|
|
|
|
// nsIFrame.h).
|
|
|
|
|
|
|
|
// I imagine fixing this would help performance of GetFrameForPoint in
|
|
|
|
// tables. It may also fix problems with relative positioning.
|
|
|
|
|
|
|
|
// This is basically copied from nsContainerFrame::GetFrameForPointUsing,
|
|
|
|
// except for one bit removed
|
|
|
|
|
|
|
|
nsIFrame *kid, *hit;
|
|
|
|
nsPoint tmp;
|
|
|
|
|
|
|
|
PRBool inThisFrame = mRect.Contains(aPoint);
|
|
|
|
|
|
|
|
FirstChild(aPresContext, nsnull, &kid);
|
|
|
|
*aFrame = nsnull;
|
|
|
|
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
|
|
|
|
while (nsnull != kid) {
|
|
|
|
nsresult rv = kid->GetFrameForPoint(aPresContext, tmp, aWhichLayer, &hit);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && hit) {
|
|
|
|
*aFrame = hit;
|
|
|
|
}
|
|
|
|
kid->GetNextSibling(&kid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*aFrame) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( inThisFrame && (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND)) {
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleVisibility* vis =
|
|
|
|
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
|
|
|
|
if (vis->IsVisible()) {
|
2000-03-22 05:43:08 +03:00
|
|
|
*aFrame = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1998-06-24 23:13:19 +04:00
|
|
|
/* GetMinRowSpan is needed for deviant cases where every cell in a row has a rowspan > 1.
|
2001-03-13 09:38:59 +03:00
|
|
|
* It sets mMinRowSpan, which is used in FixMinCellHeight
|
1998-06-24 23:13:19 +04:00
|
|
|
*/
|
1998-07-24 04:43:09 +04:00
|
|
|
void nsTableRowFrame::GetMinRowSpan(nsTableFrame *aTableFrame)
|
1998-06-24 23:13:19 +04:00
|
|
|
{
|
|
|
|
PRInt32 minRowSpan=-1;
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame* frame = mFrames.FirstChild();
|
|
|
|
while (frame)
|
1998-06-24 23:13:19 +04:00
|
|
|
{
|
1998-09-24 20:37:22 +04:00
|
|
|
const nsStyleDisplay *kidDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
frame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)kidDisplay));
|
1998-09-24 20:37:22 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay)
|
|
|
|
{
|
2000-02-01 06:23:29 +03:00
|
|
|
PRInt32 rowSpan = aTableFrame->GetEffectiveRowSpan((nsTableCellFrame &)*frame);
|
1998-09-24 20:37:22 +04:00
|
|
|
if (-1==minRowSpan)
|
|
|
|
minRowSpan = rowSpan;
|
|
|
|
else if (minRowSpan>rowSpan)
|
|
|
|
minRowSpan = rowSpan;
|
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
frame->GetNextSibling(&frame);
|
1998-06-24 23:13:19 +04:00
|
|
|
}
|
1999-10-24 03:08:30 +04:00
|
|
|
mBits.mMinRowSpan = unsigned(minRowSpan);
|
1998-06-24 23:13:19 +04:00
|
|
|
}
|
|
|
|
|
1998-07-24 04:43:09 +04:00
|
|
|
void nsTableRowFrame::FixMinCellHeight(nsTableFrame *aTableFrame)
|
1998-06-24 23:13:19 +04:00
|
|
|
{
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame* frame = mFrames.FirstChild();
|
|
|
|
while (frame) {
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
frame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableCellFrame == frameType.get()) {
|
2000-02-01 06:23:29 +03:00
|
|
|
PRInt32 rowSpan = aTableFrame->GetEffectiveRowSpan((nsTableCellFrame &)*frame);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (PRInt32(mBits.mMinRowSpan) == rowSpan) {
|
1998-09-24 20:37:22 +04:00
|
|
|
nsRect rect;
|
|
|
|
frame->GetRect(rect);
|
|
|
|
if (rect.height > mTallestCell)
|
|
|
|
mTallestCell = rect.height;
|
|
|
|
}
|
1998-06-24 23:13:19 +04:00
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
frame->GetNextSibling(&frame);
|
1998-06-24 23:13:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-22 00:16:32 +04:00
|
|
|
// Calculate the cell's actual size given its pass2 desired width and height.
|
|
|
|
// Takes into account the specified height (in the style), and any special logic
|
|
|
|
// needed for backwards compatibility.
|
|
|
|
// Modifies the desired width and height that are passed in.
|
|
|
|
nsresult
|
2000-05-26 02:40:21 +04:00
|
|
|
nsTableRowFrame::CalculateCellActualSize(nsIFrame* aCellFrame,
|
|
|
|
nscoord& aDesiredWidth,
|
|
|
|
nscoord& aDesiredHeight,
|
|
|
|
nscoord aAvailWidth)
|
1999-08-22 00:16:32 +04:00
|
|
|
{
|
|
|
|
nscoord specifiedHeight = 0;
|
|
|
|
const nsStylePosition* position;
|
|
|
|
|
|
|
|
// Get the height specified in the style information
|
|
|
|
aCellFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)position);
|
|
|
|
|
|
|
|
switch (position->mHeight.GetUnit()) {
|
2001-03-13 09:38:59 +03:00
|
|
|
case eStyleUnit_Coord:
|
|
|
|
specifiedHeight = position->mHeight.GetCoordValue();
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Percent: {
|
1999-08-26 01:49:18 +04:00
|
|
|
nsTableFrame* table = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, table);
|
|
|
|
if (table) {
|
|
|
|
nscoord basis = table->GetPercentBasisForRows();
|
|
|
|
if (basis > 0) {
|
|
|
|
float percent = position->mHeight.GetPercentValue();
|
|
|
|
specifiedHeight = NSToCoordRound(percent * ((float)basis));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
case eStyleUnit_Inherit:
|
|
|
|
// XXX for now, do nothing
|
|
|
|
case eStyleUnit_Auto:
|
|
|
|
default:
|
|
|
|
break;
|
1999-08-22 00:16:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If the specified height is greater than the desired height, then use the
|
|
|
|
// specified height
|
|
|
|
if (specifiedHeight > aDesiredHeight)
|
|
|
|
aDesiredHeight = specifiedHeight;
|
2000-05-26 02:40:21 +04:00
|
|
|
|
|
|
|
if (0 == aDesiredWidth) { // special Nav4 compatibility code for the width
|
1999-08-22 00:16:32 +04:00
|
|
|
aDesiredWidth = aAvailWidth;
|
2000-05-26 02:40:21 +04:00
|
|
|
}
|
1999-08-22 00:16:32 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculates the available width for the table cell based on the known
|
|
|
|
// column widths taking into account column spans and column spacing
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord
|
|
|
|
CalcCellAvailWidth(nsTableFrame& aTableFrame,
|
|
|
|
nsTableCellFrame& aCellFrame,
|
|
|
|
nscoord aCellSpacingX)
|
1999-08-22 00:16:32 +04:00
|
|
|
{
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord cellWidth = 0;
|
|
|
|
PRInt32 colIndex;
|
|
|
|
aCellFrame.GetColIndex(colIndex);
|
|
|
|
PRInt32 colspan = aTableFrame.GetEffectiveColSpan(aCellFrame);
|
|
|
|
|
|
|
|
for (PRInt32 spanX = 0; spanX < colspan; spanX++) {
|
|
|
|
nscoord colWidth = aTableFrame.GetColumnWidth(colIndex + spanX);
|
|
|
|
if (colWidth > 0) {
|
|
|
|
cellWidth += colWidth;
|
|
|
|
}
|
|
|
|
if ((spanX > 0) && (aTableFrame.GetNumCellsOriginatingInCol(colIndex + spanX) > 0)) {
|
|
|
|
cellWidth += aCellSpacingX;
|
1999-08-22 00:16:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
return cellWidth;
|
1999-08-22 00:16:32 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord
|
|
|
|
GetSpaceBetween(PRInt32 aPrevColIndex,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
PRInt32 aColSpan,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nscoord aCellSpacingX,
|
|
|
|
PRBool aIsLeftToRight)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord space = 0;
|
|
|
|
PRInt32 colX;
|
|
|
|
if (aIsLeftToRight) {
|
|
|
|
for (colX = aPrevColIndex + 1; aColIndex > colX; colX++) {
|
|
|
|
space += aTableFrame.GetColumnWidth(colX);
|
|
|
|
if (aTableFrame.GetNumCellsOriginatingInCol(colX) > 0) {
|
|
|
|
space += aCellSpacingX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PRInt32 lastCol = aColIndex + aColSpan - 1;
|
|
|
|
for (colX = aPrevColIndex - 1; colX > lastCol; colX--) {
|
|
|
|
space += aTableFrame.GetColumnWidth(colX);
|
|
|
|
if (aTableFrame.GetNumCellsOriginatingInCol(colX) > 0) {
|
|
|
|
space += aCellSpacingX;
|
|
|
|
}
|
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
return space;
|
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
|
1999-10-17 07:17:53 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// Called for a dirty or resize reflow. Reflows all the existing table cell
|
|
|
|
// frames unless aDirtyOnly is PR_TRUE in which case only reflow the dirty frames
|
1999-10-17 07:17:53 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowFrame::ReflowChildren(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
PRBool aDirtyOnly)
|
|
|
|
{
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
if (!mFrames.FirstChild()) return NS_OK;
|
1998-11-20 04:01:25 +03:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableFrame* tableFrame = &aTableFrame;
|
|
|
|
if (!tableFrame) return NS_ERROR_NULL_POINTER;
|
2001-03-22 18:59:37 +03:00
|
|
|
nsIFrame* tablePrevInFlow;
|
|
|
|
tableFrame->GetPrevInFlow(&tablePrevInFlow);
|
2001-04-02 07:21:58 +04:00
|
|
|
PRBool isPaginated;
|
|
|
|
aPresContext->IsPaginated(&isPaginated);
|
2001-03-13 09:38:59 +03:00
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
nscoord cellSpacingX = tableFrame->GetCellSpacingX();
|
|
|
|
PRInt32 cellColSpan = 1; // must be defined here so it's set properly for non-cell kids
|
|
|
|
|
|
|
|
nsTableIteration dir = (aReflowState.availableWidth == NS_UNCONSTRAINEDSIZE)
|
1999-05-04 23:15:56 +04:00
|
|
|
? eTableLTR : eTableDIR;
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableIterator iter(aPresContext, *this, dir);
|
2001-03-13 09:38:59 +03:00
|
|
|
// remember the col index of the previous cell to handle rowspans into this row
|
|
|
|
PRInt32 firstPrevColIndex = (iter.IsLeftToRight()) ? -1 : tableFrame->GetColCount();
|
|
|
|
PRInt32 prevColIndex = firstPrevColIndex;
|
|
|
|
nscoord x = 0; // running total of children x offset
|
1999-05-04 23:15:56 +04:00
|
|
|
|
2000-11-15 17:59:47 +03:00
|
|
|
PRBool isAutoLayout = tableFrame->IsAutoLayout();
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool needToNotifyTable = PR_TRUE;
|
1998-07-11 02:56:13 +04:00
|
|
|
// Reflow each of our existing cell frames
|
1999-04-22 07:51:58 +04:00
|
|
|
nsIFrame* kidFrame = iter.First();
|
2001-03-13 09:38:59 +03:00
|
|
|
while (kidFrame) {
|
1999-08-03 06:41:27 +04:00
|
|
|
// Get the frame state bits
|
|
|
|
nsFrameState frameState;
|
|
|
|
kidFrame->GetFrameState(&frameState);
|
|
|
|
|
|
|
|
// See if we should only reflow the dirty child frames
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool doReflowChild = PR_TRUE;
|
|
|
|
if (aDirtyOnly && ((frameState & NS_FRAME_IS_DIRTY) == 0)) {
|
|
|
|
doReflowChild = PR_FALSE;
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
kidFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Reflow the child frame
|
|
|
|
if (doReflowChild) {
|
2001-03-13 09:38:59 +03:00
|
|
|
if (nsLayoutAtoms::tableCellFrame == frameType.get()) {
|
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)kidFrame;
|
1999-08-03 06:41:27 +04:00
|
|
|
PRInt32 cellColIndex;
|
2001-03-13 09:38:59 +03:00
|
|
|
cellFrame->GetColIndex(cellColIndex);
|
|
|
|
cellColSpan = tableFrame->GetEffectiveColSpan(*cellFrame);
|
1999-08-03 06:41:27 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
x += cellSpacingX;
|
|
|
|
// If the adjacent cell is in a prior row (because of a rowspan) add in the space
|
|
|
|
if ((iter.IsLeftToRight() && (prevColIndex != (cellColIndex - 1))) ||
|
|
|
|
(!iter.IsLeftToRight() && (prevColIndex != cellColIndex + cellColSpan))) {
|
|
|
|
x += GetSpaceBetween(prevColIndex, cellColIndex, cellColSpan, *tableFrame,
|
|
|
|
cellSpacingX, iter.IsLeftToRight());
|
1998-09-16 04:48:14 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
// Calculate the available width for the table cell using the known column widths
|
|
|
|
nscoord availWidth = CalcCellAvailWidth(*tableFrame, *cellFrame, cellSpacingX);
|
|
|
|
if (0 == availWidth) {
|
1999-10-05 03:48:05 +04:00
|
|
|
availWidth = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// remember the rightmost (ltr) or leftmost (rtl) column this cell spans into
|
|
|
|
prevColIndex = (iter.IsLeftToRight()) ? cellColIndex + (cellColSpan - 1) : cellColIndex;
|
2001-03-13 09:38:59 +03:00
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
1999-08-03 06:41:27 +04:00
|
|
|
|
2001-08-06 18:04:58 +04:00
|
|
|
// If the avail width is not the same as last time we reflowed the cell or
|
|
|
|
// the cell wants to be bigger than what was available last time or
|
|
|
|
// it is a style change reflow or we are printing, then we must reflow the
|
|
|
|
// cell. Otherwise we can skip the reflow.
|
1999-08-03 06:41:27 +04:00
|
|
|
nsIFrame* kidNextInFlow;
|
|
|
|
kidFrame->GetNextInFlow(&kidNextInFlow);
|
2001-08-06 18:04:58 +04:00
|
|
|
nsSize cellDesiredSize = cellFrame->GetDesiredSize();
|
|
|
|
if ((availWidth != cellFrame->GetPriorAvailWidth()) ||
|
|
|
|
(cellDesiredSize.width > cellFrame->GetPriorAvailWidth()) ||
|
|
|
|
(eReflowReason_StyleChange == aReflowState.reason) ||
|
2001-04-02 07:21:58 +04:00
|
|
|
isPaginated) {
|
2001-03-13 09:38:59 +03:00
|
|
|
// Reflow the cell to fit the available width, height
|
|
|
|
nsSize kidAvailSize(availWidth, aReflowState.availableHeight);
|
|
|
|
nsReflowReason reason = eReflowReason_Resize;
|
2001-03-26 00:06:29 +04:00
|
|
|
PRBool cellToWatch = PR_FALSE;
|
2001-03-13 09:38:59 +03:00
|
|
|
nsSize maxElementSize;
|
1999-08-03 06:41:27 +04:00
|
|
|
// If it's a dirty frame, then check whether it's the initial reflow
|
2001-03-13 09:38:59 +03:00
|
|
|
if (frameState & NS_FRAME_FIRST_REFLOW) {
|
|
|
|
reason = eReflowReason_Initial;
|
2001-03-26 00:06:29 +04:00
|
|
|
cellToWatch = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (eReflowReason_StyleChange == aReflowState.reason) {
|
|
|
|
reason = eReflowReason_StyleChange;
|
|
|
|
cellToWatch = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (cellToWatch) {
|
2001-03-13 09:38:59 +03:00
|
|
|
cellFrame->DidSetStyleContext(aPresContext); // XXX check this
|
2001-03-22 18:59:37 +03:00
|
|
|
if (!tablePrevInFlow && isAutoLayout) {
|
2001-03-13 09:38:59 +03:00
|
|
|
// request the maximum width if availWidth is constrained
|
|
|
|
// XXX we could just do this always, but blocks have some problems
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != availWidth) {
|
|
|
|
desiredSize.mFlags |= NS_REFLOW_CALC_MAX_WIDTH;
|
|
|
|
}
|
|
|
|
// request to get the max element size
|
|
|
|
desiredSize.maxElementSize = &maxElementSize;
|
2001-03-26 00:06:29 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
cellToWatch = PR_FALSE;
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord oldMaxWidth = cellFrame->GetMaximumWidth();
|
|
|
|
nscoord oldMaxElemWidth = cellFrame->GetPass1MaxElementSize().width;
|
2000-05-05 03:16:42 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// Reflow the child
|
|
|
|
nsTableCellReflowState kidReflowState(aPresContext, aReflowState,
|
|
|
|
kidFrame, kidAvailSize, reason);
|
1999-08-03 06:41:27 +04:00
|
|
|
nsReflowStatus status;
|
1999-11-19 18:33:29 +03:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
|
2001-03-13 09:38:59 +03:00
|
|
|
x, 0, 0, status);
|
|
|
|
|
2001-03-26 00:06:29 +04:00
|
|
|
if (cellToWatch) {
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord maxWidth = (NS_UNCONSTRAINEDSIZE == availWidth)
|
|
|
|
? desiredSize.width : desiredSize.mMaximumWidth;
|
|
|
|
// save the max element width and max width
|
|
|
|
cellFrame->SetPass1MaxElementSize(desiredSize.width, *desiredSize.maxElementSize);
|
|
|
|
if (desiredSize.maxElementSize->width > desiredSize.width) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "max element width exceeded desired width");
|
|
|
|
desiredSize.width = desiredSize.maxElementSize->width;
|
|
|
|
}
|
|
|
|
cellFrame->SetMaximumWidth(maxWidth);
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// allow the table to determine if/how the table needs to be rebalanced
|
2001-03-26 00:06:29 +04:00
|
|
|
if (cellToWatch && needToNotifyTable) {
|
2001-03-13 09:38:59 +03:00
|
|
|
needToNotifyTable = !tableFrame->CellChangedWidth(*cellFrame, oldMaxWidth, oldMaxElemWidth);
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If any of the cells are not complete, then we're not complete
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(status)) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
else {
|
|
|
|
nsSize priorSize = cellFrame->GetDesiredSize();
|
1999-08-03 06:41:27 +04:00
|
|
|
desiredSize.width = priorSize.width;
|
|
|
|
desiredSize.height = priorSize.height;
|
1999-12-02 04:02:53 +03:00
|
|
|
|
|
|
|
// Because we may have moved the frame we need to make sure any views are
|
|
|
|
// positioned properly. We have to do this, because any one of our parent
|
|
|
|
// frames could have moved and we have no way of knowing...
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableFrame::RePositionViews(aPresContext, kidFrame);
|
1998-10-06 04:27:22 +04:00
|
|
|
}
|
1999-08-03 06:41:27 +04:00
|
|
|
|
1999-08-22 00:16:32 +04:00
|
|
|
// Calculate the cell's actual size given its pass2 size. This function
|
|
|
|
// takes into account the specified height (in the style), and any special
|
|
|
|
// logic needed for backwards compatibility
|
2000-02-03 17:04:49 +03:00
|
|
|
CalculateCellActualSize(kidFrame, desiredSize.width,
|
1999-08-26 01:49:18 +04:00
|
|
|
desiredSize.height, availWidth);
|
2000-07-28 13:19:26 +04:00
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
// height may have changed, adjust descent to absorb any excess difference
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord ascent = cellFrame->GetDesiredAscent();
|
2000-06-05 12:25:11 +04:00
|
|
|
nscoord descent = desiredSize.height - ascent;
|
2001-03-13 09:38:59 +03:00
|
|
|
SetTallestCell(desiredSize.height, ascent, descent, tableFrame, cellFrame);
|
2000-06-05 12:25:11 +04:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Place the child
|
2001-03-13 09:38:59 +03:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, desiredSize, x, 0, 0);
|
|
|
|
x += desiredSize.width;
|
1998-09-16 04:48:14 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
else {// it's an unknown frame type, give it a generic reflow and ignore the results
|
|
|
|
nsTableCellReflowState kidReflowState(aPresContext, aReflowState,
|
2000-05-05 03:16:42 +04:00
|
|
|
kidFrame, nsSize(0,0), eReflowReason_Resize);
|
1999-08-03 06:41:27 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
|
|
|
nsReflowStatus status;
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, 0, 0, 0, status);
|
|
|
|
kidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
1998-09-16 04:48:14 +04:00
|
|
|
}
|
1998-10-23 21:24:57 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
else if (nsLayoutAtoms::tableCellFrame == frameType.get()) {
|
2000-11-15 17:59:47 +03:00
|
|
|
// we need to account for the cell's width even if it isn't reflowed
|
|
|
|
nsRect rect;
|
|
|
|
kidFrame->GetRect(rect);
|
2001-03-13 09:38:59 +03:00
|
|
|
x += rect.width;
|
2000-11-15 17:59:47 +03:00
|
|
|
}
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1999-04-22 07:51:58 +04:00
|
|
|
kidFrame = iter.Next(); // Get the next child
|
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
|
2001-03-13 09:38:59 +03:00
|
|
|
if (!kidFrame && (cellColSpan > 1))
|
2000-04-29 01:05:31 +04:00
|
|
|
x += cellSpacingX;
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// just set our width to what was available. The table will calculate the width and not use our value.
|
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
CalcTallestCell();
|
2000-05-26 02:40:21 +04:00
|
|
|
aDesiredSize.height = GetTallestCell();
|
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
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD nsTableRowFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-07-01 07:03:32 +04:00
|
|
|
{
|
2001-03-13 09:38:59 +03:00
|
|
|
nsresult rv = NS_OK;
|
2000-05-26 02:40:21 +04:00
|
|
|
CalcTallestCell(); // need to recalculate it based on last reflow sizes
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// determine if this frame is the target or not
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame* target = nsnull;
|
|
|
|
rv = aReflowState.reflowCommand->GetTarget(target);
|
|
|
|
if (target) {
|
|
|
|
if (this == target)
|
|
|
|
rv = IR_TargetIsMe(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus);
|
|
|
|
else {
|
1998-10-14 20:32:45 +04:00
|
|
|
// Get the next frame in the reflow chain
|
|
|
|
nsIFrame* nextFrame;
|
2001-03-13 09:38:59 +03:00
|
|
|
aReflowState.reflowCommand->GetNext(nextFrame);
|
|
|
|
rv = IR_TargetIsChild(aPresContext, aDesiredSize, aReflowState, aTableFrame, 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
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowFrame::IR_TargetIsMe(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_FRAME_COMPLETE;
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowCommand->GetType(type);
|
|
|
|
switch (type) {
|
|
|
|
case nsIReflowCommand::ReflowDirty: {
|
|
|
|
// Reflow the dirty child frames. Typically this is newly added frames.
|
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus, PR_TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case nsIReflowCommand::StyleChanged :
|
|
|
|
rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus);
|
|
|
|
break;
|
|
|
|
case nsIReflowCommand::ContentChanged :
|
|
|
|
NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTYETIMPLEMENTED("unexpected reflow command type");
|
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
1998-10-06 04:27:22 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowFrame::IR_StyleChanged(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-30 10:57:44 +03:00
|
|
|
{
|
|
|
|
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
|
2001-03-13 09:38:59 +03:00
|
|
|
aTableFrame.SetNeedStrategyInit(PR_TRUE);
|
1998-10-30 10:57:44 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame* aNextFrame)
|
1998-10-14 20:32:45 +04:00
|
|
|
|
|
|
|
{
|
2001-03-13 09:38:59 +03:00
|
|
|
if (!aNextFrame) return NS_ERROR_NULL_POINTER;
|
|
|
|
nsresult rv = NS_OK;
|
1998-10-14 20:32:45 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool isAutoLayout = aTableFrame.IsAutoLayout();
|
1998-10-14 20:32:45 +04:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
aNextFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == childDisplay->mDisplay) {
|
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)aNextFrame;
|
|
|
|
// Get the x coord of the cell
|
|
|
|
nsPoint cellOrigin;
|
|
|
|
cellFrame->GetOrigin(cellOrigin);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1999-08-22 01:24:42 +04:00
|
|
|
// At this point, we know the column widths. Compute the cell available width
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 cellColIndex;
|
2001-03-13 09:38:59 +03:00
|
|
|
cellFrame->GetColIndex(cellColIndex);
|
|
|
|
PRInt32 cellColSpan = aTableFrame.GetEffectiveColSpan(*cellFrame);
|
|
|
|
nscoord cellSpacingX = aTableFrame.GetCellSpacingX();
|
1999-08-22 00:16:32 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord cellAvailWidth = CalcCellAvailWidth(aTableFrame, *cellFrame, cellSpacingX);
|
1998-10-14 20:32:45 +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
|
2001-03-13 09:38:59 +03:00
|
|
|
nsSize cellAvailSize(cellAvailWidth, NS_UNCONSTRAINEDSIZE);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
|
|
|
// Pass along the reflow command
|
1999-08-31 02:30:32 +04:00
|
|
|
nsSize kidMaxElementSize;
|
2000-01-11 18:55:31 +03:00
|
|
|
// Unless this is a fixed-layout table, then have the cell incrementally
|
2001-03-13 09:38:59 +03:00
|
|
|
// update its maximum width.
|
|
|
|
nsHTMLReflowMetrics cellMet(&kidMaxElementSize, isAutoLayout ?
|
|
|
|
NS_REFLOW_CALC_MAX_WIDTH : 0);
|
|
|
|
nsTableCellReflowState kidRS(aPresContext, aReflowState, aNextFrame, cellAvailSize);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1999-08-29 08:18:00 +04:00
|
|
|
// Remember the current desired size, we'll need it later
|
2001-03-13 09:38:59 +03:00
|
|
|
nsSize oldCellMinSize = cellFrame->GetPass1MaxElementSize();
|
|
|
|
nscoord oldCellMaximumWidth = cellFrame->GetMaximumWidth();
|
|
|
|
nsSize oldCellDesSize = cellFrame->GetDesiredSize();
|
|
|
|
nscoord oldCellDesAscent = cellFrame->GetDesiredAscent();
|
2000-06-05 12:25:11 +04:00
|
|
|
nscoord oldCellDesDescent = oldCellDesSize.height - oldCellDesAscent;
|
1999-08-29 08:18:00 +04:00
|
|
|
|
|
|
|
// Reflow the cell passing it the incremental reflow command. We can't pass
|
|
|
|
// in a max width of NS_UNCONSTRAINEDSIZE, because the max width must match
|
1998-10-14 20:32:45 +04:00
|
|
|
// the width of the previous reflow...
|
2000-05-26 02:40:21 +04:00
|
|
|
rv = ReflowChild(aNextFrame, aPresContext, cellMet, kidRS,
|
2001-03-13 09:38:59 +03:00
|
|
|
cellOrigin.x, 0, 0, aStatus);
|
2000-05-26 02:40:21 +04:00
|
|
|
nsSize initCellDesSize(cellMet.width, cellMet.height);
|
2000-06-05 12:25:11 +04:00
|
|
|
nscoord initCellDesAscent = cellMet.ascent;
|
|
|
|
nscoord initCellDesDescent = cellMet.descent;
|
1999-08-29 08:18:00 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// cache the max-elem and maximum widths
|
|
|
|
cellFrame->SetPass1MaxElementSize(cellMet.width, kidMaxElementSize);
|
|
|
|
cellFrame->SetMaximumWidth(cellMet.mMaximumWidth);
|
2000-01-11 18:55:31 +03:00
|
|
|
|
1999-08-22 00:16:32 +04:00
|
|
|
// Calculate the cell's actual size given its pass2 size. This function
|
|
|
|
// takes into account the specified height (in the style), and any special
|
|
|
|
// logic needed for backwards compatibility
|
2000-05-26 02:40:21 +04:00
|
|
|
CalculateCellActualSize(aNextFrame, cellMet.width, cellMet.height, cellAvailWidth);
|
2000-07-28 13:19:26 +04:00
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
// height may have changed, adjust descent to absorb any excess difference
|
|
|
|
cellMet.descent = cellMet.height - cellMet.ascent;
|
2000-05-26 02:40:21 +04:00
|
|
|
|
|
|
|
// if the cell got shorter and it may have been the tallest, recalc the tallest cell
|
|
|
|
PRBool tallestCellGotShorter = PR_FALSE;
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool hasVerticalAlignBaseline = cellFrame->HasVerticalAlignBaseline();
|
2000-06-05 12:25:11 +04:00
|
|
|
if (!hasVerticalAlignBaseline) {
|
|
|
|
// only the height matters
|
|
|
|
tallestCellGotShorter =
|
2000-12-22 02:03:42 +03:00
|
|
|
TallestCellGotShorter(oldCellDesSize.height, cellMet.height, mTallestCell);
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// the ascent matters
|
|
|
|
tallestCellGotShorter =
|
2000-12-22 02:03:42 +03:00
|
|
|
TallestCellGotShorter(oldCellDesAscent, cellMet.ascent, mMaxCellAscent);
|
2000-06-05 12:25:11 +04:00
|
|
|
// the descent of cells without rowspan also matters
|
|
|
|
if (!tallestCellGotShorter) {
|
2001-03-13 09:38:59 +03:00
|
|
|
PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan(*cellFrame);
|
2000-06-05 12:25:11 +04:00
|
|
|
if (rowSpan == 1) {
|
|
|
|
tallestCellGotShorter =
|
2000-12-22 02:03:42 +03:00
|
|
|
TallestCellGotShorter(oldCellDesAscent, cellMet.descent, mMaxCellDescent);
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tallestCellGotShorter) {
|
|
|
|
CalcTallestCell();
|
|
|
|
}
|
|
|
|
else {
|
2001-03-13 09:38:59 +03:00
|
|
|
SetTallestCell(cellMet.height, cellMet.ascent, cellMet.descent, &aTableFrame, cellFrame);
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
1998-08-07 06:11:51 +04:00
|
|
|
|
2000-05-26 02:40:21 +04:00
|
|
|
// if the cell's desired size didn't changed, our height is unchanged
|
|
|
|
aDesiredSize.mNothingChanged = PR_FALSE;
|
2001-03-13 09:38:59 +03:00
|
|
|
PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan(*cellFrame);
|
2001-07-14 03:49:30 +04:00
|
|
|
if ((initCellDesSize.width == oldCellDesSize.width) &&
|
|
|
|
(initCellDesSize.height == oldCellDesSize.height) &&
|
|
|
|
(oldCellMaximumWidth == cellMet.mMaximumWidth)) {
|
2000-06-05 12:25:11 +04:00
|
|
|
if (!hasVerticalAlignBaseline) { // only the cell's height matters
|
2000-09-05 18:57:34 +04:00
|
|
|
aDesiredSize.mNothingChanged = PR_TRUE;
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
|
|
|
else { // cell's ascent and cell's descent matter
|
|
|
|
if (initCellDesAscent == oldCellDesAscent) {
|
|
|
|
if ((rowSpan == 1) && (initCellDesDescent == oldCellDesDescent)) {
|
|
|
|
aDesiredSize.mNothingChanged = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aDesiredSize.height = (aDesiredSize.mNothingChanged) ? mRect.height : GetTallestCell();
|
2000-09-05 18:57:34 +04:00
|
|
|
if (1 == rowSpan) {
|
|
|
|
cellMet.height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
else {
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord heightOfRows = aDesiredSize.height + GetHeightOfRowsSpannedBelowFirst(*cellFrame, aTableFrame);
|
2000-09-05 18:57:34 +04:00
|
|
|
cellMet.height = PR_MAX(cellMet.height, heightOfRows);
|
|
|
|
// XXX need to check what happens when this height differs from height of the cell's previous mRect.height
|
|
|
|
}
|
2000-07-28 13:19:26 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// Now place the child
|
2001-03-13 09:38:59 +03:00
|
|
|
FinishReflowChild(aNextFrame, aPresContext, cellMet, cellOrigin.x, 0, 0);
|
|
|
|
|
|
|
|
// Notify the table if the cell width changed so it can decide whether to rebalance
|
|
|
|
if (!aDesiredSize.mNothingChanged) {
|
|
|
|
aTableFrame.CellChangedWidth(*cellFrame, oldCellMinSize.width, oldCellMaximumWidth);
|
2000-10-06 01:05:06 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// Return our desired size. Note that our desired width is just whatever width
|
|
|
|
// we were given by the row group frame
|
2001-03-13 09:38:59 +03:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
2000-05-26 02:40:21 +04:00
|
|
|
if (!aDesiredSize.mNothingChanged) {
|
|
|
|
if (aDesiredSize.height == mRect.height) { // our height didn't change
|
2001-03-13 09:38:59 +03:00
|
|
|
cellFrame->VerticallyAlignChild(aPresContext, aReflowState, mMaxCellAscent);
|
2000-05-26 02:40:21 +04:00
|
|
|
nsRect dirtyRect;
|
2001-03-13 09:38:59 +03:00
|
|
|
cellFrame->GetRect(dirtyRect);
|
2000-05-26 02:40:21 +04:00
|
|
|
dirtyRect.height = mRect.height;
|
|
|
|
Invalidate(aPresContext, dirtyRect);
|
|
|
|
}
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // pass reflow to unknown frame child
|
|
|
|
// aDesiredSize does not change
|
|
|
|
}
|
2000-01-17 20:45:17 +03:00
|
|
|
|
|
|
|
// When returning whether we're complete we need to look at each of our cell
|
|
|
|
// frames. If any of them has a continuing frame, then we're not complete. We
|
|
|
|
// can't just return the status of the cell frame we just reflowed...
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
if (mNextInFlow) {
|
|
|
|
for (nsIFrame* cell = mFrames.FirstChild(); cell; cell->GetNextSibling(&cell)) {
|
|
|
|
nsIFrame* contFrame;
|
|
|
|
|
|
|
|
cell->GetNextInFlow(&contFrame);
|
|
|
|
if (contFrame) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
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
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
2000-04-22 01:36:33 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableRowFrame", aReflowState.reason);
|
2001-01-25 18:55:51 +03:00
|
|
|
#if defined DEBUG_TABLE_REFLOW | DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState);
|
|
|
|
#endif
|
1999-08-19 23:52:37 +04:00
|
|
|
nsresult rv = NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
1998-10-14 20:32:45 +04:00
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (!tableFrame) return NS_ERROR_NULL_POINTER;
|
1999-08-02 02:01:37 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
switch (aReflowState.reason) {
|
1998-07-11 02:56:13 +04:00
|
|
|
case eReflowReason_Initial:
|
2001-04-02 07:21:58 +04:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE);
|
2001-03-13 09:38:59 +03:00
|
|
|
#ifdef WHY
|
|
|
|
if (!tableFrame->IsAutoLayout()) {
|
|
|
|
// this resize reflow is necessary to place the cells correctly in the case of rowspans and colspans.
|
1999-01-03 22:20:13 +03:00
|
|
|
// It is very efficient. It does not actually need to pass a reflow down to the cells.
|
1999-01-06 02:31:18 +03:00
|
|
|
nsSize availSpace(aReflowState.availableWidth, aReflowState.availableHeight);
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState resizeReflowState(aPresContext,
|
1999-01-03 22:20:13 +03:00
|
|
|
(const nsHTMLReflowState&)(*(aReflowState.parentReflowState)),
|
1999-03-05 07:19:09 +03:00
|
|
|
(nsIFrame *)this,
|
1999-01-06 02:31:18 +03:00
|
|
|
availSpace,
|
1999-01-03 22:20:13 +03:00
|
|
|
eReflowReason_Resize);
|
|
|
|
RowReflowState rowResizeReflowState(resizeReflowState, tableFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, rowResizeReflowState, aStatus);
|
1999-01-03 22:20:13 +03:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
#endif
|
2000-05-26 02:40:21 +04:00
|
|
|
//GetMinRowSpan(tableFrame);
|
|
|
|
//FixMinCellHeight(tableFrame);
|
1998-12-15 19:39:09 +03:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-07-11 02:56:13 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eReflowReason_Resize:
|
1999-09-09 00:29:56 +04:00
|
|
|
case eReflowReason_StyleChange:
|
2001-03-13 09:38:59 +03:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE);
|
1998-07-11 02:56:13 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eReflowReason_Incremental:
|
2001-03-13 09:38:59 +03:00
|
|
|
rv = IncrementalReflow(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus);
|
1998-07-11 02:56:13 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-07-02 09:39:10 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// just set our width to what was available. The table will calculate the width and not use our value.
|
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
1999-08-31 02:30:32 +04:00
|
|
|
|
2001-01-25 18:55:51 +03:00
|
|
|
#if defined DEBUG_TABLE_REFLOW | DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState, &aDesiredSize, aStatus);
|
|
|
|
#endif
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
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.
|
|
|
|
*/
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool
|
|
|
|
nsTableRowFrame::Contains(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint)
|
1998-11-07 03:36:37 +03:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
// first, check the row rect and see if the point is in their
|
|
|
|
if (mRect.Contains(aPoint)) {
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
// if that fails, check the cells, they might span outside the row rect
|
|
|
|
else {
|
|
|
|
nsIFrame* kid;
|
2000-01-22 04:16:50 +03:00
|
|
|
FirstChild(aPresContext, nsnull, &kid);
|
1998-11-07 03:36:37 +03:00
|
|
|
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 (kidRect.Contains(point)) {
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
kid->GetNextSibling(&kid);
|
1998-11-07 03:36:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-02-22 06:28:00 +03:00
|
|
|
/**
|
|
|
|
* This function is called by the row group frame's SplitRowGroup() code when
|
|
|
|
* pushing a row frame that has cell frames that span into it. The cell frame
|
|
|
|
* should be reflowed with the specified height
|
|
|
|
*/
|
2001-04-16 18:51:52 +04:00
|
|
|
nscoord
|
|
|
|
nsTableRowFrame::ReflowCellFrame(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableCellFrame* aCellFrame,
|
|
|
|
nscoord aAvailableHeight,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-02-22 06:28:00 +03:00
|
|
|
{
|
|
|
|
// Reflow the cell frame with the specified height. Use the existing width
|
|
|
|
nsSize cellSize;
|
|
|
|
aCellFrame->GetSize(cellSize);
|
|
|
|
|
|
|
|
nsSize availSize(cellSize.width, aAvailableHeight);
|
2000-05-05 03:16:42 +04:00
|
|
|
nsTableCellReflowState cellReflowState(aPresContext, aReflowState, aCellFrame, availSize,
|
|
|
|
eReflowReason_Resize);
|
1999-02-22 06:28:00 +03:00
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(aCellFrame, aPresContext, desiredSize, cellReflowState,
|
|
|
|
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
1999-11-24 09:03:41 +03:00
|
|
|
aCellFrame->SizeTo(aPresContext, cellSize.width, aAvailableHeight);
|
2001-04-16 18:51:52 +04:00
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
// XXX What happens if this cell has 'vertical-align: baseline' ?
|
|
|
|
// XXX Why is it assumed that the cell's ascent hasn't changed ?
|
|
|
|
aCellFrame->VerticallyAlignChild(aPresContext, aReflowState, mMaxCellAscent);
|
1999-11-19 18:33:29 +03:00
|
|
|
aCellFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
2001-04-16 18:51:52 +04:00
|
|
|
|
|
|
|
return desiredSize.height;
|
1999-02-22 06:28:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2001-04-16 18:51:52 +04:00
|
|
|
* These 3 functions are called by the row group frame's SplitRowGroup() code when
|
|
|
|
* it creates a continuing cell frame and wants to insert it into the row's child list
|
1999-02-22 06:28:00 +03:00
|
|
|
*/
|
2001-04-16 18:51:52 +04:00
|
|
|
void
|
|
|
|
nsTableRowFrame::InsertCellFrame(nsTableCellFrame* aFrame,
|
|
|
|
nsTableCellFrame* aPrevSibling)
|
1999-02-22 06:28:00 +03:00
|
|
|
{
|
|
|
|
mFrames.InsertFrame(nsnull, aPrevSibling, aFrame);
|
2001-04-16 18:51:52 +04:00
|
|
|
aFrame->SetParent(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableRowFrame::InsertCellFrame(nsTableCellFrame* aFrame,
|
|
|
|
PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
// Find the cell frame where col index < aColIndex
|
|
|
|
nsTableCellFrame* priorCell = nsnull;
|
|
|
|
for (nsIFrame* child = mFrames.FirstChild(); child; child->GetNextSibling(&child)) {
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
child->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableCellFrame != frameType.get()) {
|
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)child;
|
|
|
|
PRInt32 colIndex;
|
|
|
|
cellFrame->GetColIndex(colIndex);
|
|
|
|
if (colIndex < aColIndex) {
|
|
|
|
priorCell = cellFrame;
|
|
|
|
}
|
|
|
|
else break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
InsertCellFrame(aFrame, priorCell);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableRowFrame::RemoveCellFrame(nsTableCellFrame* aFrame)
|
|
|
|
{
|
|
|
|
mFrames.RemoveFrame(aFrame);
|
1999-02-22 06:28:00 +03:00
|
|
|
}
|
|
|
|
|
1999-02-24 08:54:31 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::tableRowFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewTableRowFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsTableRowFrame* it = new (aPresShell) nsTableRowFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowFrame::GetFrameName(nsString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName("TableRow", aResult);
|
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
|
1999-08-31 07:09:40 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
|
|
|
{
|
1999-09-01 05:02:16 +04:00
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
PRUint32 sum = sizeof(*this);
|
|
|
|
*aResult = sum;
|
|
|
|
return NS_OK;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|