2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00: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-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsTableRowFrame.h"
|
2001-11-05 15:15:24 +00:00
|
|
|
#include "nsTableRowGroupFrame.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIRenderingContext.h"
|
1999-07-28 08:09:02 +00:00
|
|
|
#include "nsIPresShell.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsStyleConsts.h"
|
1998-08-26 17:26:38 +00:00
|
|
|
#include "nsHTMLAtoms.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsTableFrame.h"
|
|
|
|
#include "nsTableCellFrame.h"
|
1998-04-14 21:49:29 +00:00
|
|
|
#include "nsIView.h"
|
2002-05-10 18:22:41 +00:00
|
|
|
#include "nsReflowPath.h"
|
1998-07-20 23:56:17 +00:00
|
|
|
#include "nsCSSRendering.h"
|
1999-02-24 05:54:31 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-07-28 08:09:02 +00:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsTableColGroupFrame.h"
|
|
|
|
#include "nsTableColFrame.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
1998-04-23 17:29:07 +00:00
|
|
|
|
2000-05-04 23:16:42 +00:00
|
|
|
struct nsTableCellReflowState : public nsHTMLReflowState
|
|
|
|
{
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableCellReflowState(nsPresContext* aPresContext,
|
2000-05-04 23:16:42 +00:00
|
|
|
const nsHTMLReflowState& aParentReflowState,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsSize& aAvailableSpace,
|
|
|
|
nsReflowReason aReason);
|
|
|
|
|
2002-09-09 18:46:06 +00:00
|
|
|
void FixUp(const nsSize& aAvailSpace,
|
|
|
|
PRBool aResetComputedWidth);
|
2000-05-04 23:16:42 +00:00
|
|
|
};
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableCellReflowState::nsTableCellReflowState(nsPresContext* aPresContext,
|
2000-05-04 23:16:42 +00:00
|
|
|
const nsHTMLReflowState& aParentRS,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsSize& aAvailSpace,
|
|
|
|
nsReflowReason aReason)
|
|
|
|
:nsHTMLReflowState(aPresContext, aParentRS, aFrame, aAvailSpace, aReason)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-09-09 18:46:06 +00:00
|
|
|
void nsTableCellReflowState::FixUp(const nsSize& aAvailSpace,
|
|
|
|
PRBool aResetComputedWidth)
|
2000-05-04 23:16:42 +00:00
|
|
|
{
|
2002-02-19 15:48:28 +00:00
|
|
|
// fix the mComputed values during a pass 2 reflow since the cell can be a percentage base
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aAvailSpace.width) {
|
2002-09-09 18:46:06 +00:00
|
|
|
if (aResetComputedWidth) {
|
|
|
|
mComputedWidth = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
|
|
|
else if (NS_UNCONSTRAINEDSIZE != mComputedWidth) {
|
2002-02-19 15:48:28 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableRowFrame::InitChildReflowState(nsPresContext& aPresContext,
|
2002-02-19 15:48:28 +00:00
|
|
|
const nsSize& aAvailSize,
|
|
|
|
PRBool aBorderCollapse,
|
|
|
|
float aPixelsToTwips,
|
2002-09-09 18:46:06 +00:00
|
|
|
nsTableCellReflowState& aReflowState,
|
|
|
|
PRBool aResetComputedWidth)
|
2002-02-19 15:48:28 +00:00
|
|
|
{
|
|
|
|
nsMargin collapseBorder;
|
|
|
|
nsMargin* pCollapseBorder = nsnull;
|
|
|
|
if (aBorderCollapse) {
|
|
|
|
// we only reflow cells, so don't need to check frame type
|
|
|
|
nsBCTableCellFrame* bcCellFrame = (nsBCTableCellFrame*)aReflowState.frame;
|
|
|
|
if (bcCellFrame) {
|
|
|
|
pCollapseBorder = bcCellFrame->GetBorderWidth(aPixelsToTwips, collapseBorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aReflowState.Init(&aPresContext, -1, -1, pCollapseBorder);
|
2002-09-09 18:46:06 +00:00
|
|
|
aReflowState.FixUp(aAvailSize, aResetComputedWidth);
|
2000-05-04 23:16:42 +00:00
|
|
|
}
|
|
|
|
|
2001-11-05 00:15:51 +00:00
|
|
|
void
|
|
|
|
nsTableRowFrame::SetFixedHeight(nscoord aValue)
|
|
|
|
{
|
2003-01-05 14:16:58 +00:00
|
|
|
nscoord height = PR_MAX(0, aValue);
|
|
|
|
if (HasFixedHeight()) {
|
|
|
|
if (height > mStyleFixedHeight) {
|
|
|
|
mStyleFixedHeight = height;
|
2001-11-05 00:15:51 +00:00
|
|
|
}
|
2003-01-05 14:16:58 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
mStyleFixedHeight = height;
|
|
|
|
if (height > 0) {
|
|
|
|
SetHasFixedHeight(PR_TRUE);
|
2001-11-05 00:15:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-11-05 15:15:24 +00:00
|
|
|
nsTableRowFrame::SetPctHeight(float aPctValue,
|
|
|
|
PRBool aForce)
|
2001-11-05 00:15:51 +00:00
|
|
|
{
|
|
|
|
nscoord height = PR_MAX(0, NSToCoordRound(aPctValue * 100.0f));
|
|
|
|
if (HasPctHeight()) {
|
2003-01-05 14:16:58 +00:00
|
|
|
if ((height > mStylePctHeight) || aForce) {
|
|
|
|
mStylePctHeight = height;
|
2001-11-05 00:15:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2003-01-05 14:16:58 +00:00
|
|
|
mStylePctHeight = height;
|
2001-11-05 00:15:51 +00:00
|
|
|
if (height > 0.0f) {
|
|
|
|
SetHasPctHeight(PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-05 08:25:11 +00: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-21 23:03:42 +00:00
|
|
|
return ((aNew < aOld) && (aOld == aTallest));
|
2000-06-05 08:25:11 +00:00
|
|
|
}
|
|
|
|
|
2001-11-05 00:15:51 +00:00
|
|
|
/* ----------- nsTableRowFrame ---------- */
|
1998-04-23 17:29:07 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsTableRowFrame::nsTableRowFrame(nsStyleContext* aContext)
|
|
|
|
: nsHTMLContainerFrame(aContext)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2001-11-05 00:15:51 +00:00
|
|
|
mBits.mRowIndex = mBits.mFirstInserted = 0;
|
|
|
|
ResetHeight(0);
|
2001-01-25 15:55:51 +00:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
mTimer = new nsReflowTimer(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableRowFrame::~nsTableRowFrame()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflowDone(this);
|
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-02-25 05:31:15 +00:00
|
|
|
NS_IMETHODIMP
|
2006-03-09 18:55:21 +00:00
|
|
|
nsTableRowFrame::Init(nsIContent* aContent,
|
1999-02-25 05:31:15 +00:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
2005-11-20 22:05:24 +00:00
|
|
|
// Let the base class do its initialization
|
2006-03-26 21:30:36 +00:00
|
|
|
rv = nsHTMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
1999-02-25 05:31:15 +00:00
|
|
|
|
2001-02-23 12:35:34 +00:00
|
|
|
// record that children that are ignorable whitespace should be excluded
|
|
|
|
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
|
|
|
|
|
1999-02-25 05:31:15 +00:00
|
|
|
if (aPrevInFlow) {
|
|
|
|
// Set the row index
|
|
|
|
nsTableRowFrame* rowFrame = (nsTableRowFrame*)aPrevInFlow;
|
|
|
|
|
|
|
|
SetRowIndex(rowFrame->GetRowIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsTableRowFrame::AppendFrames(nsIAtom* aListName,
|
1999-08-03 02:41:27 +00:00
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
// Append the frames
|
|
|
|
mFrames.AppendFrames(nsnull, aFrameList);
|
|
|
|
|
|
|
|
// Add the new cell frames to the table
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame *tableFrame = nsTableFrame::GetTableFrame(this);
|
2003-07-07 02:01:29 +00:00
|
|
|
for (nsIFrame* childFrame = aFrameList; childFrame;
|
|
|
|
childFrame = childFrame->GetNextSibling()) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (IS_TABLE_CELL(childFrame->GetType())) {
|
1999-08-03 02:41:27 +00:00
|
|
|
// Add the cell to the cell map
|
2005-02-07 01:58:25 +00:00
|
|
|
tableFrame->AppendCell((nsTableCellFrame&)*childFrame, GetRowIndex());
|
2001-03-13 06:38:59 +00:00
|
|
|
// XXX this could be optimized with some effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-08-03 02:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
2005-02-07 01:58:25 +00:00
|
|
|
tableFrame->AppendDirtyReflowCommand(this);
|
1999-08-03 02:41:27 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsTableRowFrame::InsertFrames(nsIAtom* aListName,
|
1999-08-03 02:41:27 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
// Get the table frame
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
1999-08-03 02:41:27 +00:00
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
// gather the new frames (only those which are cells) into an array
|
2002-02-19 15:48:28 +00:00
|
|
|
nsIAtom* cellFrameType = (tableFrame->IsBorderCollapse()) ? nsLayoutAtoms::bcTableCellFrame : nsLayoutAtoms::tableCellFrame;
|
2004-01-18 10:28:40 +00:00
|
|
|
nsTableCellFrame* prevCellFrame = (nsTableCellFrame *)nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame, cellFrameType);
|
1999-12-13 22:56:31 +00:00
|
|
|
nsVoidArray cellChildren;
|
2003-07-07 02:01:29 +00:00
|
|
|
for (nsIFrame* childFrame = aFrameList; childFrame;
|
2003-07-07 05:15:41 +00:00
|
|
|
childFrame = childFrame->GetNextSibling()) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (IS_TABLE_CELL(childFrame->GetType())) {
|
1999-12-13 22:56:31 +00:00
|
|
|
cellChildren.AppendElement(childFrame);
|
2001-03-13 06:38:59 +00:00
|
|
|
// XXX this could be optimized with some effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// insert the cells into the cell map
|
|
|
|
PRInt32 colIndex = -1;
|
|
|
|
if (prevCellFrame) {
|
|
|
|
prevCellFrame->GetColIndex(colIndex);
|
|
|
|
}
|
2005-02-07 01:58:25 +00:00
|
|
|
tableFrame->InsertCells(cellChildren, GetRowIndex(), colIndex);
|
1999-12-13 22:56:31 +00:00
|
|
|
|
|
|
|
// Insert the frames in the frame list
|
1999-08-03 02:41:27 +00:00
|
|
|
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
|
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
2005-02-07 01:58:25 +00:00
|
|
|
tableFrame->AppendDirtyReflowCommand(this);
|
1999-08-03 02:41:27 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsTableRowFrame::RemoveFrame(nsIAtom* aListName,
|
1999-08-03 02:41:27 +00:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
1999-12-13 22:56:31 +00:00
|
|
|
if (tableFrame) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (IS_TABLE_CELL(aOldFrame->GetType())) {
|
1999-12-13 22:56:31 +00:00
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)aOldFrame;
|
|
|
|
PRInt32 colIndex;
|
|
|
|
cellFrame->GetColIndex(colIndex);
|
2001-03-13 06:38:59 +00:00
|
|
|
// remove the cell from the cell map
|
2005-02-07 01:58:25 +00:00
|
|
|
tableFrame->RemoveCell(cellFrame, GetRowIndex());
|
2001-03-13 06:38:59 +00:00
|
|
|
// XXX this could be optimized with some effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-12-13 22:56:31 +00:00
|
|
|
|
|
|
|
// Remove the frame and destroy it
|
2006-04-10 00:16:29 +00:00
|
|
|
mFrames.DestroyFrame(aOldFrame);
|
1999-12-13 22:56:31 +00:00
|
|
|
|
2001-03-13 06:38:59 +00: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 08:45:26 +00: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.
|
2005-02-07 01:58:25 +00:00
|
|
|
tableFrame->AppendDirtyReflowCommand(this);
|
1998-09-23 21:48:26 +00:00
|
|
|
}
|
2006-06-29 02:32:36 +00:00
|
|
|
else {
|
|
|
|
NS_ERROR("unexpected frame type");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
1998-09-23 21:48:26 +00:00
|
|
|
}
|
1998-09-16 17:19:20 +00:00
|
|
|
|
1999-08-30 00:01:09 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-09-05 14:57:34 +00: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
|
2003-07-07 02:01:29 +00:00
|
|
|
nsIFrame* nextRow = aTableCellFrame.GetParent()->GetNextSibling();
|
2000-09-05 14:57:34 +00:00
|
|
|
for (PRInt32 rowX = 1; ((rowX < rowSpan) && nextRow);) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == nextRow->GetType()) {
|
2003-07-07 02:01:29 +00:00
|
|
|
height += nextRow->GetSize().height;
|
2000-09-05 14:57:34 +00:00
|
|
|
rowX++;
|
|
|
|
}
|
|
|
|
height += cellSpacingY;
|
2003-07-07 02:01:29 +00:00
|
|
|
nextRow = nextRow->GetNextSibling();
|
2000-09-05 14:57:34 +00:00
|
|
|
}
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
2001-11-05 00:15:51 +00:00
|
|
|
nsTableCellFrame*
|
|
|
|
nsTableRowFrame::GetFirstCell()
|
|
|
|
{
|
|
|
|
nsIFrame* childFrame = mFrames.FirstChild();
|
|
|
|
while (childFrame) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (IS_TABLE_CELL(childFrame->GetType())) {
|
2001-11-05 00:15:51 +00:00
|
|
|
return (nsTableCellFrame*)childFrame;
|
|
|
|
}
|
2003-07-07 02:01:29 +00:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2001-11-05 00:15:51 +00:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
2000-09-05 14:57:34 +00:00
|
|
|
|
1998-07-02 20:35:23 +00:00
|
|
|
/**
|
|
|
|
* Post-reflow hook. This is where the table row does its post-processing
|
|
|
|
*/
|
1998-11-20 01:01:25 +00:00
|
|
|
void
|
2006-01-21 09:54:07 +00:00
|
|
|
nsTableRowFrame::DidResize(const nsHTMLReflowState& aReflowState)
|
1998-07-02 20:35:23 +00:00
|
|
|
{
|
1998-11-20 01:01:25 +00:00
|
|
|
// Resize and re-align the cell frames based on our row height
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return;
|
2003-09-13 16:26:30 +00:00
|
|
|
|
2004-01-18 10:28:40 +00:00
|
|
|
nsTableIterator iter(*this, eTableDIR);
|
2001-03-13 06:38:59 +00:00
|
|
|
nsIFrame* childFrame = iter.First();
|
2003-09-13 16:26:30 +00:00
|
|
|
|
|
|
|
nsHTMLReflowMetrics desiredSize(PR_FALSE);
|
|
|
|
desiredSize.width = mRect.width;
|
|
|
|
desiredSize.height = mRect.height;
|
|
|
|
desiredSize.mOverflowArea = nsRect(0, 0, desiredSize.width,
|
|
|
|
desiredSize.height);
|
1999-05-04 19:15:56 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
while (childFrame) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (IS_TABLE_CELL(childFrame->GetType())) {
|
2001-03-13 06:38:59 +00:00
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)childFrame;
|
|
|
|
nscoord cellHeight = mRect.height + GetHeightOfRowsSpannedBelowFirst(*cellFrame, *tableFrame);
|
1999-05-04 19:15:56 +00:00
|
|
|
|
|
|
|
// resize the cell's height
|
|
|
|
//if (cellFrameSize.height!=cellHeight)
|
1998-11-20 01:01:25 +00:00
|
|
|
{
|
1999-11-19 15:33:29 +00: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?
|
2003-07-07 02:01:29 +00:00
|
|
|
cellFrame->SetSize(nsSize(cellFrame->GetSize().width, cellHeight));
|
1999-05-04 19:15:56 +00: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 09:19:26 +00:00
|
|
|
|
2005-02-07 01:58:25 +00:00
|
|
|
cellFrame->VerticallyAlignChild(aReflowState, mMaxCellAscent);
|
2004-12-27 15:05:18 +00:00
|
|
|
ConsiderChildOverflow(desiredSize.mOverflowArea, cellFrame);
|
1998-07-02 20:35:23 +00:00
|
|
|
}
|
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
// Get the next child
|
|
|
|
childFrame = iter.Next();
|
1998-07-02 20:35:23 +00:00
|
|
|
}
|
2004-07-16 16:56:21 +00:00
|
|
|
FinishAndStoreOverflow(&desiredSize);
|
2004-04-14 06:22:52 +00:00
|
|
|
if (HasView()) {
|
2006-01-21 09:54:07 +00:00
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(GetPresContext(), this, GetView(), &desiredSize.mOverflowArea, 0);
|
2004-04-14 06:22:52 +00:00
|
|
|
}
|
1998-07-02 20:35:23 +00:00
|
|
|
// Let our base class do the usual work
|
|
|
|
}
|
|
|
|
|
2000-06-05 08:25:11 +00:00
|
|
|
// returns max-ascent amongst all cells that have 'vertical-align: baseline'
|
2000-07-28 09:19:26 +00:00
|
|
|
// *including* cells with rowspans
|
2000-06-05 08:25:11 +00:00
|
|
|
nscoord nsTableRowFrame::GetMaxCellAscent() const
|
|
|
|
{
|
|
|
|
return mMaxCellAscent;
|
|
|
|
}
|
|
|
|
|
2005-10-04 15:47:21 +00:00
|
|
|
nscoord nsTableRowFrame::GetAscent()
|
|
|
|
{
|
|
|
|
if(mMaxCellAscent)
|
|
|
|
return mMaxCellAscent;
|
|
|
|
|
|
|
|
// If we don't have a baseline on any of the cells we go for the lowest
|
|
|
|
// content edge of the inner block frames.
|
|
|
|
// Every table cell has a cell frame with its border and padding. Inside
|
|
|
|
// the cell is a block frame. The cell is as high as the tallest cell in
|
|
|
|
// the parent row. As a consequence the block frame might not touch both
|
|
|
|
// the top and the bottom padding of it parent cell frame at the same time.
|
|
|
|
//
|
|
|
|
// bbbbbbbbbbbbbbbbbb cell border: b
|
|
|
|
// bppppppppppppppppb cell padding: p
|
|
|
|
// bpxxxxxxxxxxxxxxpb inner block: x
|
|
|
|
// bpx xpb
|
|
|
|
// bpx xpb
|
|
|
|
// bpx xpb
|
|
|
|
// bpxxxxxxxxxxxxxxpb base line
|
|
|
|
// bp pb
|
|
|
|
// bp pb
|
|
|
|
// bppppppppppppppppb
|
|
|
|
// bbbbbbbbbbbbbbbbbb
|
|
|
|
|
|
|
|
nsTableIterator iter(*this, eTableDIR);
|
|
|
|
nsIFrame* childFrame = iter.First();
|
|
|
|
nscoord ascent = 0;
|
|
|
|
while (childFrame) {
|
|
|
|
if (IS_TABLE_CELL(childFrame->GetType())) {
|
|
|
|
nsIFrame* firstKid = childFrame->GetFirstChild(nsnull);
|
|
|
|
ascent = PR_MAX(ascent, firstKid->GetRect().YMost());
|
|
|
|
}
|
|
|
|
// Get the next child
|
|
|
|
childFrame = iter.Next();
|
|
|
|
}
|
|
|
|
return ascent;
|
|
|
|
}
|
2001-11-05 00:15:51 +00:00
|
|
|
nscoord
|
|
|
|
nsTableRowFrame::GetHeight(nscoord aPctBasis) const
|
2000-05-25 22:40:21 +00:00
|
|
|
{
|
2001-11-05 00:15:51 +00:00
|
|
|
nscoord height = 0;
|
|
|
|
if ((aPctBasis > 0) && HasPctHeight()) {
|
|
|
|
height = NSToCoordRound(GetPctHeight() * (float)aPctBasis);
|
|
|
|
}
|
2003-01-05 14:16:58 +00:00
|
|
|
if (HasFixedHeight()) {
|
|
|
|
height = PR_MAX(height, GetFixedHeight());
|
2001-11-05 00:15:51 +00:00
|
|
|
}
|
|
|
|
return PR_MAX(height, GetContentHeight());
|
2000-05-25 22:40:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-11-05 00:15:51 +00:00
|
|
|
nsTableRowFrame::ResetHeight(nscoord aFixedHeight)
|
2000-05-25 22:40:21 +00:00
|
|
|
{
|
2001-11-05 00:15:51 +00:00
|
|
|
SetHasFixedHeight(PR_FALSE);
|
|
|
|
SetHasPctHeight(PR_FALSE);
|
|
|
|
SetFixedHeight(0);
|
2003-01-05 14:16:58 +00:00
|
|
|
SetPctHeight(0);
|
2001-11-05 00:15:51 +00:00
|
|
|
SetContentHeight(0);
|
|
|
|
|
|
|
|
if (aFixedHeight > 0) {
|
|
|
|
SetFixedHeight(aFixedHeight);
|
|
|
|
}
|
|
|
|
|
2000-06-05 08:25:11 +00:00
|
|
|
mMaxCellAscent = 0;
|
|
|
|
mMaxCellDescent = 0;
|
2000-05-25 22:40:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-11-05 00:15:51 +00:00
|
|
|
nsTableRowFrame::UpdateHeight(nscoord aHeight,
|
|
|
|
nscoord aAscent,
|
|
|
|
nscoord aDescent,
|
|
|
|
nsTableFrame* aTableFrame,
|
|
|
|
nsTableCellFrame* aCellFrame)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2001-11-05 00:15:51 +00:00
|
|
|
if (!aTableFrame || !aCellFrame) {
|
|
|
|
NS_ASSERTION(PR_FALSE , "invalid call");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-06-05 08:25:11 +00:00
|
|
|
if (aHeight != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
if (!(aCellFrame->HasVerticalAlignBaseline())) { // only the cell's height matters
|
2001-11-05 00:15:51 +00:00
|
|
|
if (GetHeight() < aHeight) {
|
2000-06-05 08:25:11 +00:00
|
|
|
PRInt32 rowSpan = aTableFrame->GetEffectiveRowSpan(*aCellFrame);
|
|
|
|
if (rowSpan == 1) {
|
2001-11-05 00:15:51 +00:00
|
|
|
SetContentHeight(aHeight);
|
2000-06-05 08:25:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
2001-11-05 00:15:51 +00:00
|
|
|
if (GetHeight() < mMaxCellAscent + mMaxCellDescent) {
|
|
|
|
SetContentHeight(mMaxCellAscent + mMaxCellDescent);
|
2000-06-05 08:25:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2001-11-05 00:15:51 +00:00
|
|
|
nscoord
|
|
|
|
nsTableRowFrame::CalcHeight(const nsHTMLReflowState& aReflowState)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return 0;
|
2000-05-25 22:40:21 +00:00
|
|
|
|
2001-11-05 00:15:51 +00:00
|
|
|
nscoord computedHeight = (NS_UNCONSTRAINEDSIZE == aReflowState.mComputedHeight)
|
|
|
|
? 0 : aReflowState.mComputedHeight;
|
|
|
|
ResetHeight(computedHeight);
|
2000-05-25 22:40:21 +00:00
|
|
|
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStylePosition* position = GetStylePosition();
|
2001-11-05 15:15:24 +00:00
|
|
|
if (eStyleUnit_Coord == position->mHeight.GetUnit()) {
|
|
|
|
SetFixedHeight(position->mHeight.GetCoordValue());
|
|
|
|
}
|
|
|
|
else if (eStyleUnit_Percent == position->mHeight.GetUnit()) {
|
|
|
|
SetPctHeight(position->mHeight.GetPercentValue());
|
|
|
|
}
|
|
|
|
|
2003-07-07 02:01:29 +00:00
|
|
|
for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame;
|
|
|
|
kidFrame = kidFrame->GetNextSibling()) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (IS_TABLE_CELL(kidFrame->GetType())) {
|
2000-06-05 08:25:11 +00:00
|
|
|
nscoord availWidth = ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth();
|
|
|
|
nsSize desSize = ((nsTableCellFrame *)kidFrame)->GetDesiredSize();
|
2006-02-21 21:33:47 +00:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) && !GetPrevInFlow()) {
|
2001-11-29 15:41:07 +00:00
|
|
|
CalculateCellActualSize(kidFrame, desSize.width, desSize.height, availWidth);
|
|
|
|
}
|
2000-06-05 08:25:11 +00:00
|
|
|
// height may have changed, adjust descent to absorb any excess difference
|
2005-10-04 15:47:21 +00:00
|
|
|
nscoord ascent;
|
|
|
|
if (!kidFrame->GetFirstChild(nsnull)->GetFirstChild(nsnull))
|
|
|
|
ascent = desSize.height;
|
|
|
|
else
|
|
|
|
ascent = ((nsTableCellFrame *)kidFrame)->GetDesiredAscent();
|
2000-06-05 08:25:11 +00:00
|
|
|
nscoord descent = desSize.height - ascent;
|
2001-11-05 00:15:51 +00:00
|
|
|
UpdateHeight(desSize.height, ascent, descent, tableFrame, (nsTableCellFrame*)kidFrame);
|
2000-05-25 22:40:21 +00:00
|
|
|
}
|
|
|
|
}
|
2001-11-05 00:15:51 +00:00
|
|
|
return GetHeight();
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
/**
|
|
|
|
* We need a custom display item for table row backgrounds. This is only used
|
|
|
|
* when the table row is the root of a stacking context (e.g., has 'opacity').
|
|
|
|
* Table row backgrounds can extend beyond the row frame bounds, when
|
|
|
|
* the row contains row-spanning cells.
|
|
|
|
*/
|
|
|
|
class nsDisplayTableRowBackground : public nsDisplayItem {
|
|
|
|
public:
|
2006-03-14 20:43:18 +00:00
|
|
|
nsDisplayTableRowBackground(nsTableRowFrame* aFrame) : nsDisplayItem(aFrame) {
|
2006-01-29 18:48:58 +00:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayTableRowBackground);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayTableRowBackground() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayTableRowBackground);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder) {
|
|
|
|
// the overflow rect contains any row-spanning cells, so it contains
|
|
|
|
// our background. Note that this means we may not be opaque even if
|
|
|
|
// the background style is a solid color.
|
2006-03-14 20:43:18 +00:00
|
|
|
return NS_STATIC_CAST(nsTableRowFrame*, mFrame)->GetOverflowRect() +
|
|
|
|
aBuilder->ToReferenceFrame(mFrame);
|
2001-01-27 14:09:34 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
|
|
|
const nsRect& aDirtyRect);
|
|
|
|
NS_DISPLAY_DECL_NAME("TableRowBackground")
|
|
|
|
};
|
1999-11-01 22:12:45 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
void
|
|
|
|
nsDisplayTableRowBackground::Paint(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIRenderingContext* aCtx, const nsRect& aDirtyRect) {
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(mFrame);
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsPoint pt = aBuilder->ToReferenceFrame(mFrame);
|
|
|
|
nsIRenderingContext::AutoPushTranslation translate(aCtx, pt.x, pt.y);
|
|
|
|
TableBackgroundPainter painter(tableFrame,
|
|
|
|
TableBackgroundPainter::eOrigin_TableRow,
|
|
|
|
mFrame->GetPresContext(), *aCtx,
|
|
|
|
aDirtyRect - pt);
|
2006-03-14 20:43:18 +00:00
|
|
|
painter.PaintRow(NS_STATIC_CAST(nsTableRowFrame*, mFrame));
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2004-03-09 06:48:35 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
if (!IsVisibleInSelection(aBuilder))
|
|
|
|
return NS_OK;
|
1999-06-07 21:10:25 +00:00
|
|
|
|
2006-04-17 22:16:24 +00:00
|
|
|
PRBool isRoot = aBuilder->IsAtRootOfPseudoStackingContext();
|
|
|
|
if (isRoot) {
|
2006-01-26 02:29:17 +00:00
|
|
|
// This background is created regardless of whether this frame is
|
|
|
|
// visible or not. Visibility decisions are delegated to the
|
|
|
|
// table background painter.
|
|
|
|
// We would use nsDisplayGeneric for this rare case except that we
|
|
|
|
// need the background to be larger than the row frame in some
|
|
|
|
// cases.
|
|
|
|
nsresult rv = aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayTableRowBackground(this));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2002-02-21 05:36:16 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2006-04-17 22:16:24 +00:00
|
|
|
return nsTableFrame::DisplayGenericTablePart(aBuilder, this, aDirtyRect, aLists, isRoot);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-20 17:45:07 +00:00
|
|
|
PRIntn
|
|
|
|
nsTableRowFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
2006-02-21 21:33:47 +00:00
|
|
|
if (nsnull != GetPrevInFlow()) {
|
1998-10-20 17:45:07 +00:00
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
2006-02-21 21:33:47 +00:00
|
|
|
if (nsnull != GetNextInFlow()) {
|
1998-10-20 17:45:07 +00:00
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
1999-08-21 20:16:32 +00: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-25 22:40:21 +00:00
|
|
|
nsTableRowFrame::CalculateCellActualSize(nsIFrame* aCellFrame,
|
|
|
|
nscoord& aDesiredWidth,
|
|
|
|
nscoord& aDesiredHeight,
|
|
|
|
nscoord aAvailWidth)
|
1999-08-21 20:16:32 +00:00
|
|
|
{
|
2001-11-05 00:15:51 +00:00
|
|
|
nscoord specifiedHeight = 0;
|
1999-08-21 20:16:32 +00:00
|
|
|
|
|
|
|
// Get the height specified in the style information
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStylePosition* position = aCellFrame->GetStylePosition();
|
2001-11-05 00:15:51 +00:00
|
|
|
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2001-11-05 00:15:51 +00:00
|
|
|
|
|
|
|
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan((nsTableCellFrame&)*aCellFrame);
|
1999-08-21 20:16:32 +00:00
|
|
|
|
|
|
|
switch (position->mHeight.GetUnit()) {
|
2001-03-13 06:38:59 +00:00
|
|
|
case eStyleUnit_Coord:
|
|
|
|
specifiedHeight = position->mHeight.GetCoordValue();
|
2001-11-05 00:15:51 +00:00
|
|
|
if (1 == rowSpan)
|
|
|
|
SetFixedHeight(specifiedHeight);
|
2001-03-13 06:38:59 +00:00
|
|
|
break;
|
|
|
|
case eStyleUnit_Percent: {
|
2001-11-05 00:15:51 +00:00
|
|
|
if (1 == rowSpan)
|
|
|
|
SetPctHeight(position->mHeight.GetPercentValue());
|
|
|
|
// pct heights are handled when all of the cells are finished, so don't set specifiedHeight
|
1999-08-25 21:49:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
case eStyleUnit_Auto:
|
|
|
|
default:
|
|
|
|
break;
|
1999-08-21 20:16:32 +00:00
|
|
|
}
|
|
|
|
|
2001-11-05 00:15:51 +00:00
|
|
|
// If the specified height is greater than the desired height, then use the specified height
|
1999-08-21 20:16:32 +00:00
|
|
|
if (specifiedHeight > aDesiredHeight)
|
|
|
|
aDesiredHeight = specifiedHeight;
|
2000-05-25 22:40:21 +00:00
|
|
|
|
2001-09-26 13:49:26 +00:00
|
|
|
if ((0 == aDesiredWidth) && (NS_UNCONSTRAINEDSIZE != aAvailWidth)) { // special Nav4 compatibility code for the width
|
1999-08-21 20:16:32 +00:00
|
|
|
aDesiredWidth = aAvailWidth;
|
2000-05-25 22:40:21 +00:00
|
|
|
}
|
1999-08-21 20:16:32 +00: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-10-26 02:30:38 +00:00
|
|
|
static void
|
|
|
|
CalcAvailWidth(nsTableFrame& aTableFrame,
|
|
|
|
nscoord aTableComputedWidth,
|
2003-03-21 19:35:36 +00:00
|
|
|
float aPixelToTwips,
|
2001-10-26 02:30:38 +00:00
|
|
|
nsTableCellFrame& aCellFrame,
|
|
|
|
nscoord aCellSpacingX,
|
|
|
|
nscoord& aColAvailWidth,
|
|
|
|
nscoord& aCellAvailWidth)
|
1999-08-21 20:16:32 +00:00
|
|
|
{
|
2004-10-29 17:31:53 +00:00
|
|
|
aColAvailWidth = aCellAvailWidth = NS_UNCONSTRAINEDSIZE;
|
2002-09-09 18:46:06 +00:00
|
|
|
PRInt32 colIndex;
|
|
|
|
aCellFrame.GetColIndex(colIndex);
|
|
|
|
PRInt32 colspan = aTableFrame.GetEffectiveColSpan(aCellFrame);
|
|
|
|
nscoord cellSpacing = 0;
|
|
|
|
|
|
|
|
for (PRInt32 spanX = 0; spanX < colspan; spanX++) {
|
|
|
|
nscoord colWidth = aTableFrame.GetColumnWidth(colIndex + spanX);
|
2004-10-29 17:31:53 +00:00
|
|
|
if (colWidth != WIDTH_NOT_SET) {
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == aColAvailWidth) {
|
|
|
|
aColAvailWidth = colWidth;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aColAvailWidth += colWidth;
|
|
|
|
}
|
2002-09-09 18:46:06 +00:00
|
|
|
}
|
|
|
|
if ((spanX > 0) && (aTableFrame.GetNumCellsOriginatingInCol(colIndex + spanX) > 0)) {
|
|
|
|
cellSpacing += aCellSpacingX;
|
2001-10-26 02:30:38 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-29 17:31:53 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aColAvailWidth) {
|
2002-09-09 18:46:06 +00:00
|
|
|
aColAvailWidth += cellSpacing;
|
|
|
|
}
|
|
|
|
aCellAvailWidth = aColAvailWidth;
|
2001-10-26 02:30:38 +00:00
|
|
|
|
2002-06-14 14:21:03 +00:00
|
|
|
// for a cell with a colspan > 1, use its fix width (if set) as the avail width
|
|
|
|
// if this is its initial reflow
|
2003-07-07 02:01:29 +00:00
|
|
|
if ((aCellFrame.GetStateBits() & NS_FRAME_FIRST_REFLOW)
|
|
|
|
&& (aTableFrame.GetEffectiveColSpan(aCellFrame) > 1)) {
|
2001-10-26 02:30:38 +00:00
|
|
|
// see if the cell has a style width specified
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStylePosition* cellPosition = aCellFrame.GetStylePosition();
|
2001-10-26 02:30:38 +00:00
|
|
|
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
|
|
|
|
// need to add padding into fixed width
|
2003-03-21 19:35:36 +00:00
|
|
|
nsMargin borderPadding(0,0,0,0);
|
2001-10-26 02:30:38 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aTableComputedWidth) {
|
2003-03-21 19:35:36 +00:00
|
|
|
borderPadding = nsTableFrame::GetBorderPadding(nsSize(aTableComputedWidth, 0),
|
|
|
|
aPixelToTwips, &aCellFrame);
|
2001-10-26 02:30:38 +00:00
|
|
|
}
|
2003-03-21 19:35:36 +00:00
|
|
|
nscoord fixWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
|
2004-10-29 17:31:53 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aColAvailWidth) {
|
|
|
|
aCellAvailWidth = PR_MIN(aColAvailWidth, fixWidth);
|
|
|
|
} else {
|
|
|
|
aCellAvailWidth = fixWidth;
|
|
|
|
}
|
1999-08-21 20:16:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
nscoord
|
|
|
|
GetSpaceBetween(PRInt32 aPrevColIndex,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
PRInt32 aColSpan,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nscoord aCellSpacingX,
|
2006-03-04 05:26:57 +00:00
|
|
|
PRBool aIsLeftToRight,
|
|
|
|
PRBool aCheckVisibility)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2001-03-13 06:38:59 +00:00
|
|
|
nscoord space = 0;
|
|
|
|
PRInt32 colX;
|
|
|
|
if (aIsLeftToRight) {
|
|
|
|
for (colX = aPrevColIndex + 1; aColIndex > colX; colX++) {
|
2006-03-04 05:26:57 +00:00
|
|
|
PRBool isCollapsed = PR_FALSE;
|
|
|
|
if (!aCheckVisibility) {
|
|
|
|
space += aTableFrame.GetColumnWidth(colX);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsTableColFrame* colFrame = aTableFrame.GetColFrame(colX);
|
|
|
|
const nsStyleVisibility* colVis = colFrame->GetStyleVisibility();
|
|
|
|
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
|
|
|
|
nsIFrame* cgFrame = colFrame->GetParent();
|
|
|
|
const nsStyleVisibility* groupVis = cgFrame->GetStyleVisibility();
|
|
|
|
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE ==
|
|
|
|
groupVis->mVisible);
|
|
|
|
isCollapsed = collapseCol || collapseGroup;
|
|
|
|
if (!isCollapsed)
|
|
|
|
space += aTableFrame.GetColumnWidth(colX);
|
|
|
|
}
|
|
|
|
if (!isCollapsed && (aTableFrame.GetNumCellsOriginatingInCol(colX) > 0)) {
|
2001-03-13 06:38:59 +00:00
|
|
|
space += aCellSpacingX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PRInt32 lastCol = aColIndex + aColSpan - 1;
|
|
|
|
for (colX = aPrevColIndex - 1; colX > lastCol; colX--) {
|
2006-03-04 05:26:57 +00:00
|
|
|
PRBool isCollapsed = PR_FALSE;
|
|
|
|
if (!aCheckVisibility) {
|
|
|
|
space += aTableFrame.GetColumnWidth(colX);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsTableColFrame* colFrame = aTableFrame.GetColFrame(colX);
|
|
|
|
const nsStyleVisibility* colVis = colFrame->GetStyleVisibility();
|
|
|
|
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
|
|
|
|
nsIFrame* cgFrame = colFrame->GetParent();
|
|
|
|
const nsStyleVisibility* groupVis = cgFrame->GetStyleVisibility();
|
|
|
|
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE ==
|
|
|
|
groupVis->mVisible);
|
|
|
|
isCollapsed = collapseCol || collapseGroup;
|
|
|
|
if (!isCollapsed)
|
|
|
|
space += aTableFrame.GetColumnWidth(colX);
|
|
|
|
}
|
|
|
|
if (!isCollapsed && (aTableFrame.GetNumCellsOriginatingInCol(colX) > 0)) {
|
2001-03-13 06:38:59 +00:00
|
|
|
space += aCellSpacingX;
|
|
|
|
}
|
|
|
|
}
|
1999-04-22 03:51:58 +00:00
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
return space;
|
|
|
|
}
|
1999-04-22 03:51:58 +00:00
|
|
|
|
2001-10-26 02:30:38 +00:00
|
|
|
static nscoord
|
|
|
|
GetComputedWidth(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame)
|
|
|
|
{
|
|
|
|
const nsHTMLReflowState* parentReflow = aReflowState.parentReflowState;
|
|
|
|
nscoord computedWidth = 0;
|
|
|
|
while (parentReflow) {
|
|
|
|
if (parentReflow->frame == &aTableFrame) {
|
|
|
|
computedWidth = parentReflow->mComputedWidth;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
parentReflow = parentReflow->parentReflowState;
|
|
|
|
}
|
|
|
|
return computedWidth;
|
|
|
|
}
|
1999-10-17 03:17:53 +00:00
|
|
|
|
2002-03-27 05:50:24 +00:00
|
|
|
// subtract the heights of aRow's prev in flows from the unpaginated height
|
|
|
|
static
|
2004-07-31 23:15:21 +00:00
|
|
|
nscoord CalcHeightFromUnpaginatedHeight(nsPresContext* aPresContext,
|
2002-03-27 05:50:24 +00:00
|
|
|
nsTableRowFrame& aRow)
|
|
|
|
{
|
|
|
|
nscoord height = 0;
|
2003-07-07 02:01:29 +00:00
|
|
|
nsTableRowFrame* firstInFlow = (nsTableRowFrame*)aRow.GetFirstInFlow();
|
|
|
|
if (!firstInFlow) ABORT1(0);
|
2002-03-27 05:50:24 +00:00
|
|
|
if (firstInFlow->HasUnpaginatedHeight()) {
|
|
|
|
height = firstInFlow->GetUnpaginatedHeight(aPresContext);
|
2003-07-07 02:01:29 +00:00
|
|
|
for (nsIFrame* prevInFlow = aRow.GetPrevInFlow(); prevInFlow;
|
2004-09-14 02:28:03 +00:00
|
|
|
prevInFlow = prevInFlow->GetPrevInFlow()) {
|
2003-07-07 02:01:29 +00:00
|
|
|
height -= prevInFlow->GetSize().height;
|
2002-03-27 05:50:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_MAX(height, 0);
|
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00: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 03:17:53 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_METHOD
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
|
2001-03-13 06:38:59 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
PRBool aDirtyOnly)
|
|
|
|
{
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-11-20 01:01:25 +00:00
|
|
|
|
2002-02-19 15:48:28 +00:00
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
|
|
|
PRBool borderCollapse = (((nsTableFrame*)aTableFrame.GetFirstInFlow())->IsBorderCollapse());
|
|
|
|
|
2004-09-14 02:28:03 +00:00
|
|
|
nsIFrame* tablePrevInFlow = aTableFrame.GetPrevInFlow();
|
2004-03-03 18:24:20 +00:00
|
|
|
PRBool isPaginated = aPresContext->IsPaginated();
|
2001-03-13 06:38:59 +00:00
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2002-02-19 15:48:28 +00:00
|
|
|
nscoord cellSpacingX = aTableFrame.GetCellSpacingX();
|
2001-03-13 06:38:59 +00:00
|
|
|
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 19:15:56 +00:00
|
|
|
? eTableLTR : eTableDIR;
|
2004-01-18 10:28:40 +00:00
|
|
|
nsTableIterator iter(*this, dir);
|
2001-03-13 06:38:59 +00:00
|
|
|
// remember the col index of the previous cell to handle rowspans into this row
|
2002-02-19 15:48:28 +00:00
|
|
|
PRInt32 firstPrevColIndex = (iter.IsLeftToRight()) ? -1 : aTableFrame.GetColCount();
|
2001-03-13 06:38:59 +00:00
|
|
|
PRInt32 prevColIndex = firstPrevColIndex;
|
|
|
|
nscoord x = 0; // running total of children x offset
|
1999-05-04 19:15:56 +00:00
|
|
|
|
2002-02-19 15:48:28 +00:00
|
|
|
PRBool isAutoLayout = aTableFrame.IsAutoLayout();
|
2001-03-13 06:38:59 +00:00
|
|
|
PRBool needToNotifyTable = PR_TRUE;
|
2001-11-15 14:58:27 +00:00
|
|
|
nscoord paginatedHeight = 0;
|
2001-11-14 11:40:03 +00:00
|
|
|
// If the incremental reflow command is a StyleChanged reflow and
|
|
|
|
// it's target is the current frame, then make sure we send
|
|
|
|
// StyleChange reflow reasons down to the children so that they
|
|
|
|
// don't over-optimize their reflow.
|
2002-05-10 18:22:41 +00:00
|
|
|
|
2001-11-14 11:40:03 +00:00
|
|
|
PRBool notifyStyleChange = PR_FALSE;
|
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
2002-05-10 18:22:41 +00:00
|
|
|
nsHTMLReflowCommand* command = aReflowState.path->mReflowCommand;
|
|
|
|
if (command) {
|
2001-12-17 22:39:59 +00:00
|
|
|
nsReflowType type;
|
2002-05-10 18:22:41 +00:00
|
|
|
command->GetType(type);
|
2001-12-17 22:39:59 +00:00
|
|
|
if (eReflowType_StyleChanged == type) {
|
2001-11-14 11:40:03 +00:00
|
|
|
notifyStyleChange = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-07-10 22:56:13 +00:00
|
|
|
// Reflow each of our existing cell frames
|
1999-04-22 03:51:58 +00:00
|
|
|
nsIFrame* kidFrame = iter.First();
|
2001-03-13 06:38:59 +00:00
|
|
|
while (kidFrame) {
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom* frameType = kidFrame->GetType();
|
2001-11-05 00:15:51 +00:00
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
// See if we should only reflow the dirty child frames
|
2001-03-13 06:38:59 +00:00
|
|
|
PRBool doReflowChild = PR_TRUE;
|
2003-07-07 02:01:29 +00:00
|
|
|
if (aDirtyOnly && ((kidFrame->GetStateBits() & NS_FRAME_IS_DIRTY) == 0)) {
|
2001-03-13 06:38:59 +00:00
|
|
|
doReflowChild = PR_FALSE;
|
1999-08-03 02:41:27 +00:00
|
|
|
}
|
2002-10-03 14:33:23 +00:00
|
|
|
else if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight) && IS_TABLE_CELL(frameType)) {
|
|
|
|
// We don't reflow a rowspan >1 cell here with a constrained height.
|
|
|
|
// That happens in nsTableRowGroupFrame::SplitSpanningCells.
|
|
|
|
if (aTableFrame.GetEffectiveRowSpan((nsTableCellFrame&)*kidFrame) > 1) {
|
|
|
|
doReflowChild = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2001-12-07 14:51:12 +00:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (!isPaginated && (IS_TABLE_CELL(frameType) &&
|
2001-11-05 00:15:51 +00:00
|
|
|
!((nsTableCellFrame*)kidFrame)->NeedSpecialReflow())) {
|
|
|
|
kidFrame = iter.Next();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
// Reflow the child frame
|
|
|
|
if (doReflowChild) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (IS_TABLE_CELL(frameType)) {
|
2001-03-13 06:38:59 +00:00
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)kidFrame;
|
1999-08-03 02:41:27 +00:00
|
|
|
PRInt32 cellColIndex;
|
2001-03-13 06:38:59 +00:00
|
|
|
cellFrame->GetColIndex(cellColIndex);
|
2002-02-19 15:48:28 +00:00
|
|
|
cellColSpan = aTableFrame.GetEffectiveColSpan(*cellFrame);
|
2004-03-09 06:48:35 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// 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))) {
|
2002-02-19 15:48:28 +00:00
|
|
|
x += GetSpaceBetween(prevColIndex, cellColIndex, cellColSpan, aTableFrame,
|
2006-03-04 05:26:57 +00:00
|
|
|
cellSpacingX, iter.IsLeftToRight(), PR_FALSE);
|
1998-09-16 00:48:14 +00:00
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
// Calculate the available width for the table cell using the known column widths
|
2001-10-26 02:30:38 +00:00
|
|
|
nscoord availColWidth, availCellWidth;
|
2003-03-21 19:35:36 +00:00
|
|
|
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame), p2t,
|
2001-10-26 02:30:38 +00:00
|
|
|
*cellFrame, cellSpacingX, availColWidth, availCellWidth);
|
2001-03-13 06:38:59 +00:00
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
// remember the rightmost (ltr) or leftmost (rtl) column this cell spans into
|
|
|
|
prevColIndex = (iter.IsLeftToRight()) ? cellColIndex + (cellColSpan - 1) : cellColIndex;
|
2004-06-06 20:45:23 +00:00
|
|
|
// always request MEW. Since we may turn MEW on for selected cells during incremental
|
|
|
|
// reflow, we need to request MEW *now* so that those incremental reflows will be
|
|
|
|
// able to build on existing MEW data in the children.
|
|
|
|
nsHTMLReflowMetrics desiredSize(PR_TRUE);
|
1999-08-03 02:41:27 +00:00
|
|
|
|
2001-08-06 14:04:58 +00: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.
|
|
|
|
nsSize cellDesiredSize = cellFrame->GetDesiredSize();
|
2002-04-10 21:32:41 +00:00
|
|
|
if ((availCellWidth != cellFrame->GetPriorAvailWidth()) ||
|
2001-08-06 14:04:58 +00:00
|
|
|
(cellDesiredSize.width > cellFrame->GetPriorAvailWidth()) ||
|
|
|
|
(eReflowReason_StyleChange == aReflowState.reason) ||
|
2001-11-05 00:15:51 +00:00
|
|
|
isPaginated ||
|
2002-05-09 14:44:02 +00:00
|
|
|
(cellFrame->NeedPass2Reflow() &&
|
|
|
|
NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) ||
|
2001-12-07 14:51:12 +00:00
|
|
|
(aReflowState.mFlags.mSpecialHeightReflow && cellFrame->NeedSpecialReflow()) ||
|
2002-04-10 21:32:41 +00:00
|
|
|
(!aReflowState.mFlags.mSpecialHeightReflow && cellFrame->HadSpecialReflow()) ||
|
|
|
|
HasPctHeight() ||
|
|
|
|
notifyStyleChange) {
|
2001-03-13 06:38:59 +00:00
|
|
|
// Reflow the cell to fit the available width, height
|
2001-10-26 02:30:38 +00:00
|
|
|
nsSize kidAvailSize(availColWidth, aReflowState.availableHeight);
|
2001-03-13 06:38:59 +00:00
|
|
|
nsReflowReason reason = eReflowReason_Resize;
|
2001-03-25 20:06:29 +00:00
|
|
|
PRBool cellToWatch = PR_FALSE;
|
1999-08-03 02:41:27 +00:00
|
|
|
// If it's a dirty frame, then check whether it's the initial reflow
|
2003-07-07 02:01:29 +00:00
|
|
|
if (kidFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
2001-03-13 06:38:59 +00:00
|
|
|
reason = eReflowReason_Initial;
|
2001-03-25 20:06:29 +00:00
|
|
|
cellToWatch = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (eReflowReason_StyleChange == aReflowState.reason) {
|
|
|
|
reason = eReflowReason_StyleChange;
|
|
|
|
cellToWatch = PR_TRUE;
|
|
|
|
}
|
2001-11-14 11:40:03 +00:00
|
|
|
else if (notifyStyleChange) {
|
|
|
|
reason = eReflowReason_StyleChange;
|
|
|
|
cellToWatch = PR_TRUE;
|
|
|
|
}
|
2001-03-25 20:06:29 +00:00
|
|
|
if (cellToWatch) {
|
2006-03-09 18:55:21 +00:00
|
|
|
cellFrame->DidSetStyleContext(); // XXX check this
|
2001-03-22 15:59:37 +00:00
|
|
|
if (!tablePrevInFlow && isAutoLayout) {
|
2001-03-13 06:38:59 +00:00
|
|
|
// request the maximum width if availWidth is constrained
|
|
|
|
// XXX we could just do this always, but blocks have some problems
|
2001-10-26 02:30:38 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != availCellWidth) {
|
2001-03-13 06:38:59 +00:00
|
|
|
desiredSize.mFlags |= NS_REFLOW_CALC_MAX_WIDTH;
|
|
|
|
}
|
2001-03-25 20:06:29 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
cellToWatch = PR_FALSE;
|
1999-08-03 02:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
nscoord oldMaxWidth = cellFrame->GetMaximumWidth();
|
2001-11-30 15:05:51 +00:00
|
|
|
nscoord oldMaxElemWidth = cellFrame->GetPass1MaxElementWidth();
|
2000-05-04 23:16:42 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// Reflow the child
|
|
|
|
nsTableCellReflowState kidReflowState(aPresContext, aReflowState,
|
|
|
|
kidFrame, kidAvailSize, reason);
|
2002-02-19 15:48:28 +00:00
|
|
|
InitChildReflowState(*aPresContext, kidAvailSize, borderCollapse, p2t, kidReflowState);
|
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
nsReflowStatus status;
|
1999-11-19 15:33:29 +00:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
|
2001-03-13 06:38:59 +00:00
|
|
|
x, 0, 0, status);
|
|
|
|
|
2001-03-25 20:06:29 +00:00
|
|
|
if (cellToWatch) {
|
2001-10-26 02:30:38 +00:00
|
|
|
nscoord maxWidth = (NS_UNCONSTRAINEDSIZE == availCellWidth)
|
2001-03-13 06:38:59 +00:00
|
|
|
? desiredSize.width : desiredSize.mMaximumWidth;
|
|
|
|
// save the max element width and max width
|
2003-01-09 14:26:32 +00:00
|
|
|
if (desiredSize.mComputeMEW) {
|
|
|
|
cellFrame->SetPass1MaxElementWidth(desiredSize.width, desiredSize.mMaxElementWidth);
|
|
|
|
if (desiredSize.mMaxElementWidth > desiredSize.width) {
|
|
|
|
desiredSize.width = desiredSize.mMaxElementWidth;
|
2001-11-30 15:05:51 +00:00
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
}
|
|
|
|
cellFrame->SetMaximumWidth(maxWidth);
|
1999-08-03 02:41:27 +00:00
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// allow the table to determine if/how the table needs to be rebalanced
|
2001-03-25 20:06:29 +00:00
|
|
|
if (cellToWatch && needToNotifyTable) {
|
2002-02-19 15:48:28 +00:00
|
|
|
needToNotifyTable = !aTableFrame.CellChangedWidth(*cellFrame, oldMaxWidth, oldMaxElemWidth);
|
1999-08-03 02:41:27 +00: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 06:38:59 +00:00
|
|
|
else {
|
2003-12-12 22:58:25 +00:00
|
|
|
desiredSize.width = cellDesiredSize.width;
|
|
|
|
desiredSize.height = cellDesiredSize.height;
|
|
|
|
nsRect *overflowArea =
|
2004-07-16 16:56:21 +00:00
|
|
|
cellFrame->GetOverflowAreaProperty();
|
2003-12-12 22:58:25 +00:00
|
|
|
if (overflowArea)
|
|
|
|
desiredSize.mOverflowArea = *overflowArea;
|
|
|
|
else
|
|
|
|
desiredSize.mOverflowArea.SetRect(0, 0, cellDesiredSize.width,
|
|
|
|
cellDesiredSize.height);
|
2003-09-13 16:26:30 +00:00
|
|
|
|
2002-04-07 18:26:35 +00:00
|
|
|
// if we are in a floated table, our position is not yet established, so we cannot reposition our views
|
|
|
|
// the containing glock will do this for us after positioning the table
|
2003-05-15 03:42:21 +00:00
|
|
|
if (!aTableFrame.GetStyleDisplay()->IsFloating()) {
|
2002-04-07 18:26:35 +00: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...
|
2004-12-27 15:05:18 +00:00
|
|
|
nsTableFrame::RePositionViews(kidFrame);
|
2002-04-07 18:26:35 +00:00
|
|
|
}
|
1998-10-06 00:27:22 +00:00
|
|
|
}
|
2001-11-15 14:58:27 +00:00
|
|
|
|
2002-03-27 05:50:24 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
|
2006-02-21 21:33:47 +00:00
|
|
|
if (!GetPrevInFlow()) {
|
2002-03-27 05:50:24 +00: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
|
|
|
|
CalculateCellActualSize(kidFrame, desiredSize.width,
|
|
|
|
desiredSize.height, availCellWidth);
|
|
|
|
}
|
2001-11-15 14:58:27 +00:00
|
|
|
// height may have changed, adjust descent to absorb any excess difference
|
2005-10-04 15:47:21 +00:00
|
|
|
nscoord ascent;
|
|
|
|
if (!kidFrame->GetFirstChild(nsnull)->GetFirstChild(nsnull))
|
|
|
|
ascent = desiredSize.height;
|
|
|
|
else
|
|
|
|
ascent = ((nsTableCellFrame *)kidFrame)->GetDesiredAscent();
|
2001-11-15 14:58:27 +00:00
|
|
|
nscoord descent = desiredSize.height - ascent;
|
2002-02-19 15:48:28 +00:00
|
|
|
UpdateHeight(desiredSize.height, ascent, descent, &aTableFrame, cellFrame);
|
2001-11-15 14:58:27 +00:00
|
|
|
}
|
|
|
|
else {
|
2002-03-27 05:50:24 +00:00
|
|
|
paginatedHeight = PR_MAX(paginatedHeight, desiredSize.height);
|
2002-02-19 15:48:28 +00:00
|
|
|
PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan((nsTableCellFrame&)*kidFrame);
|
2002-03-27 05:50:24 +00:00
|
|
|
if (1 == rowSpan) {
|
2001-11-15 14:58:27 +00:00
|
|
|
SetContentHeight(paginatedHeight);
|
|
|
|
}
|
|
|
|
}
|
2000-06-05 08:25:11 +00:00
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
// Place the child
|
2001-10-26 02:30:38 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != availColWidth) {
|
|
|
|
desiredSize.width = PR_MAX(availCellWidth, availColWidth);
|
|
|
|
}
|
|
|
|
|
2001-12-07 14:51:12 +00:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, nsnull, desiredSize, x, 0, 0);
|
2006-03-04 05:26:57 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
x += desiredSize.width;
|
1998-09-16 00:48:14 +00:00
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
else {// it's an unknown frame type, give it a generic reflow and ignore the results
|
|
|
|
nsTableCellReflowState kidReflowState(aPresContext, aReflowState,
|
2000-05-04 23:16:42 +00:00
|
|
|
kidFrame, nsSize(0,0), eReflowReason_Resize);
|
2002-02-19 15:48:28 +00:00
|
|
|
InitChildReflowState(*aPresContext, nsSize(0,0), PR_FALSE, p2t, kidReflowState);
|
2003-09-13 16:26:30 +00:00
|
|
|
nsHTMLReflowMetrics desiredSize(PR_FALSE);
|
1999-08-03 02:41:27 +00:00
|
|
|
nsReflowStatus status;
|
1999-11-19 15:33:29 +00:00
|
|
|
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, 0, 0, 0, status);
|
2001-12-07 14:51:12 +00:00
|
|
|
kidFrame->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
|
1998-09-16 00:48:14 +00:00
|
|
|
}
|
1998-10-23 17:24:57 +00:00
|
|
|
}
|
2003-10-31 20:19:18 +00:00
|
|
|
else if (IS_TABLE_CELL(frameType)) {
|
2000-11-15 14:59:47 +00:00
|
|
|
// we need to account for the cell's width even if it isn't reflowed
|
2003-07-07 02:01:29 +00:00
|
|
|
x += kidFrame->GetSize().width;
|
2000-11-15 14:59:47 +00:00
|
|
|
}
|
2004-12-27 15:05:18 +00:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowArea, kidFrame);
|
1999-04-22 03:51:58 +00:00
|
|
|
kidFrame = iter.Next(); // Get the next child
|
2004-03-09 06:48:35 +00:00
|
|
|
x += cellSpacingX;
|
1998-09-16 17:19:20 +00:00
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// just set our width to what was available. The table will calculate the width and not use our value.
|
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
2002-03-27 05:50:24 +00:00
|
|
|
|
2002-03-31 17:44:57 +00:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
|
|
|
aDesiredSize.height = mRect.height;
|
|
|
|
}
|
|
|
|
else if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
|
2002-03-27 05:50:24 +00:00
|
|
|
aDesiredSize.height = CalcHeight(aReflowState);
|
2006-02-21 21:33:47 +00:00
|
|
|
if (GetPrevInFlow()) {
|
2002-03-27 05:50:24 +00:00
|
|
|
nscoord height = CalcHeightFromUnpaginatedHeight(aPresContext, *this);
|
|
|
|
aDesiredSize.height = PR_MAX(aDesiredSize.height, height);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (isPaginated && HasStyleHeight()) {
|
|
|
|
// set the unpaginated height so next in flows can try to honor it
|
|
|
|
SetHasUnpaginatedHeight(PR_TRUE);
|
|
|
|
SetUnpaginatedHeight(aPresContext, aDesiredSize.height);
|
|
|
|
}
|
|
|
|
if (isPaginated && HasUnpaginatedHeight()) {
|
|
|
|
aDesiredSize.height = PR_MAX(aDesiredSize.height, GetUnpaginatedHeight(aPresContext));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // constrained height, paginated
|
|
|
|
aDesiredSize.height = paginatedHeight;
|
|
|
|
if (aDesiredSize.height <= aReflowState.availableHeight) {
|
|
|
|
nscoord height = CalcHeightFromUnpaginatedHeight(aPresContext, *this);
|
|
|
|
aDesiredSize.height = PR_MAX(aDesiredSize.height, height);
|
|
|
|
aDesiredSize.height = PR_MIN(aDesiredSize.height, aReflowState.availableHeight);
|
|
|
|
}
|
|
|
|
}
|
2003-09-13 16:26:30 +00:00
|
|
|
nsRect rowRect(0, 0, aDesiredSize.width, aDesiredSize.height);
|
|
|
|
aDesiredSize.mOverflowArea.UnionRect(aDesiredSize.mOverflowArea, rowRect);
|
2004-07-16 16:56:21 +00:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
1998-10-20 15:59:56 +00:00
|
|
|
return rv;
|
1998-04-23 17:29:07 +00:00
|
|
|
}
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_METHOD nsTableRowFrame::IncrementalReflow(nsPresContext* aPresContext,
|
2001-03-13 06:38:59 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-07-01 03:03:32 +00:00
|
|
|
{
|
2001-11-05 00:15:51 +00:00
|
|
|
CalcHeight(aReflowState); // need to recalculate it based on last reflow sizes
|
2000-05-25 22:40:21 +00:00
|
|
|
|
2002-05-10 18:22:41 +00:00
|
|
|
// the row is a target if its path has a reflow command
|
|
|
|
nsHTMLReflowCommand* command = aReflowState.path->mReflowCommand;
|
|
|
|
if (command)
|
|
|
|
IR_TargetIsMe(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus);
|
|
|
|
|
|
|
|
// see if the chidren are targets as well
|
|
|
|
nsReflowPath::iterator iter = aReflowState.path->FirstChild();
|
|
|
|
nsReflowPath::iterator end = aReflowState.path->EndChildren();
|
|
|
|
for (; iter != end; ++iter)
|
|
|
|
IR_TargetIsChild(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus, *iter);
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-10-14 16:32:45 +00:00
|
|
|
}
|
1998-07-14 15:29:50 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_METHOD
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableRowFrame::IR_TargetIsMe(nsPresContext* aPresContext,
|
2001-03-13 06:38:59 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-14 16:32:45 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_FRAME_COMPLETE;
|
|
|
|
|
2001-12-17 22:39:59 +00:00
|
|
|
nsReflowType type;
|
2002-05-10 18:22:41 +00:00
|
|
|
aReflowState.path->mReflowCommand->GetType(type);
|
2001-03-13 06:38:59 +00:00
|
|
|
switch (type) {
|
2001-12-17 22:39:59 +00:00
|
|
|
case eReflowType_ReflowDirty:
|
2001-03-13 06:38:59 +00:00
|
|
|
// Reflow the dirty child frames. Typically this is newly added frames.
|
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus, PR_TRUE);
|
|
|
|
break;
|
2001-12-17 22:39:59 +00:00
|
|
|
case eReflowType_StyleChanged :
|
2001-03-13 06:38:59 +00:00
|
|
|
rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus);
|
|
|
|
break;
|
2001-12-17 22:39:59 +00:00
|
|
|
case eReflowType_ContentChanged :
|
2001-03-13 06:38:59 +00:00
|
|
|
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 00:27:22 +00:00
|
|
|
}
|
|
|
|
|
1998-10-14 16:32:45 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_METHOD
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableRowFrame::IR_StyleChanged(nsPresContext* aPresContext,
|
2001-03-13 06:38:59 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-30 07:57:44 +00: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 06:38:59 +00:00
|
|
|
aTableFrame.SetNeedStrategyInit(PR_TRUE);
|
2001-11-14 11:40:03 +00:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus, PR_FALSE);
|
1998-10-30 07:57:44 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_METHOD
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableRowFrame::IR_TargetIsChild(nsPresContext* aPresContext,
|
2001-03-13 06:38:59 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame* aNextFrame)
|
1998-10-14 16:32:45 +00:00
|
|
|
|
|
|
|
{
|
2001-03-13 06:38:59 +00:00
|
|
|
if (!aNextFrame) return NS_ERROR_NULL_POINTER;
|
|
|
|
nsresult rv = NS_OK;
|
1998-10-14 16:32:45 +00:00
|
|
|
|
2003-03-21 19:35:36 +00:00
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
2001-03-13 06:38:59 +00:00
|
|
|
PRBool isAutoLayout = aTableFrame.IsAutoLayout();
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleDisplay* childDisplay = aNextFrame->GetStyleDisplay();
|
2001-03-13 06:38:59 +00:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == childDisplay->mDisplay) {
|
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)aNextFrame;
|
|
|
|
// Get the x coord of the cell
|
2003-07-07 02:01:29 +00:00
|
|
|
nsPoint cellOrigin = cellFrame->GetPosition();
|
1998-10-14 16:32:45 +00:00
|
|
|
|
1999-08-21 21:24:42 +00:00
|
|
|
// At this point, we know the column widths. Compute the cell available width
|
1999-02-11 01:16:28 +00:00
|
|
|
PRInt32 cellColIndex;
|
2001-03-13 06:38:59 +00:00
|
|
|
cellFrame->GetColIndex(cellColIndex);
|
|
|
|
nscoord cellSpacingX = aTableFrame.GetCellSpacingX();
|
1999-08-21 20:16:32 +00:00
|
|
|
|
2001-10-26 02:30:38 +00:00
|
|
|
nscoord colAvailWidth, cellAvailWidth;
|
2003-03-21 19:35:36 +00:00
|
|
|
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame), p2t,
|
2001-10-26 02:30:38 +00:00
|
|
|
*cellFrame, cellSpacingX, colAvailWidth, cellAvailWidth);
|
1998-10-14 16:32:45 +00: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 06:38:59 +00:00
|
|
|
nsSize cellAvailSize(cellAvailWidth, NS_UNCONSTRAINEDSIZE);
|
1998-10-14 16:32:45 +00:00
|
|
|
|
|
|
|
// Pass along the reflow command
|
2000-01-11 15:55:31 +00:00
|
|
|
// Unless this is a fixed-layout table, then have the cell incrementally
|
2001-03-13 06:38:59 +00:00
|
|
|
// update its maximum width.
|
2003-01-09 14:26:32 +00:00
|
|
|
nsHTMLReflowMetrics cellMet(PR_TRUE,
|
|
|
|
isAutoLayout ? NS_REFLOW_CALC_MAX_WIDTH : 0);
|
2002-02-19 15:48:28 +00:00
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
|
|
|
nsTableCellReflowState kidRS(aPresContext, aReflowState, aNextFrame, cellAvailSize,
|
|
|
|
aReflowState.reason);
|
2002-09-09 18:46:06 +00:00
|
|
|
// If the table will intialize the strategy (and balance) or balance, make the computed
|
|
|
|
// width unconstrained. This avoids having the cell block compute a bogus max width
|
|
|
|
// which will bias the balancing. Leave the avail width alone, since it is a best guess.
|
|
|
|
// After the table balances, the cell will get reflowed with the correct computed width.
|
|
|
|
PRBool resetComputedWidth = aTableFrame.NeedStrategyInit() || aTableFrame.NeedStrategyBalance();
|
2004-06-05 16:59:46 +00:00
|
|
|
if (resetComputedWidth)
|
|
|
|
cellFrame->SetNeedPass2Reflow(PR_TRUE);
|
2002-09-09 18:46:06 +00:00
|
|
|
InitChildReflowState(*aPresContext, cellAvailSize, aTableFrame.IsBorderCollapse(),
|
|
|
|
p2t, kidRS, resetComputedWidth);
|
1998-10-14 16:32:45 +00:00
|
|
|
|
1999-08-29 04:18:00 +00:00
|
|
|
// Remember the current desired size, we'll need it later
|
2001-11-30 15:05:51 +00:00
|
|
|
nscoord oldCellMinWidth = cellFrame->GetPass1MaxElementWidth();
|
2001-03-13 06:38:59 +00:00
|
|
|
nscoord oldCellMaximumWidth = cellFrame->GetMaximumWidth();
|
|
|
|
nsSize oldCellDesSize = cellFrame->GetDesiredSize();
|
|
|
|
nscoord oldCellDesAscent = cellFrame->GetDesiredAscent();
|
2000-06-05 08:25:11 +00:00
|
|
|
nscoord oldCellDesDescent = oldCellDesSize.height - oldCellDesAscent;
|
1999-08-29 04:18:00 +00: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 16:32:45 +00:00
|
|
|
// the width of the previous reflow...
|
2000-05-25 22:40:21 +00:00
|
|
|
rv = ReflowChild(aNextFrame, aPresContext, cellMet, kidRS,
|
2001-03-13 06:38:59 +00:00
|
|
|
cellOrigin.x, 0, 0, aStatus);
|
2000-05-25 22:40:21 +00:00
|
|
|
nsSize initCellDesSize(cellMet.width, cellMet.height);
|
2000-06-05 08:25:11 +00:00
|
|
|
nscoord initCellDesAscent = cellMet.ascent;
|
|
|
|
nscoord initCellDesDescent = cellMet.descent;
|
1999-08-29 04:18:00 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// cache the max-elem and maximum widths
|
2003-01-09 14:26:32 +00:00
|
|
|
cellFrame->SetPass1MaxElementWidth(cellMet.width, cellMet.mMaxElementWidth);
|
2001-03-13 06:38:59 +00:00
|
|
|
cellFrame->SetMaximumWidth(cellMet.mMaximumWidth);
|
2000-01-11 15:55:31 +00:00
|
|
|
|
1999-08-21 20:16:32 +00: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-25 22:40:21 +00:00
|
|
|
CalculateCellActualSize(aNextFrame, cellMet.width, cellMet.height, cellAvailWidth);
|
2000-07-28 09:19:26 +00:00
|
|
|
|
2000-06-05 08:25:11 +00:00
|
|
|
// height may have changed, adjust descent to absorb any excess difference
|
2005-10-04 15:47:21 +00:00
|
|
|
if (!aNextFrame->GetFirstChild(nsnull)->GetFirstChild(nsnull))
|
|
|
|
cellMet.ascent = cellMet.height;
|
2000-06-05 08:25:11 +00:00
|
|
|
cellMet.descent = cellMet.height - cellMet.ascent;
|
2000-05-25 22:40:21 +00:00
|
|
|
|
|
|
|
// if the cell got shorter and it may have been the tallest, recalc the tallest cell
|
|
|
|
PRBool tallestCellGotShorter = PR_FALSE;
|
2001-03-13 06:38:59 +00:00
|
|
|
PRBool hasVerticalAlignBaseline = cellFrame->HasVerticalAlignBaseline();
|
2000-06-05 08:25:11 +00:00
|
|
|
if (!hasVerticalAlignBaseline) {
|
|
|
|
// only the height matters
|
|
|
|
tallestCellGotShorter =
|
2001-11-05 00:15:51 +00:00
|
|
|
TallestCellGotShorter(oldCellDesSize.height, cellMet.height, GetHeight());
|
2000-06-05 08:25:11 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// the ascent matters
|
|
|
|
tallestCellGotShorter =
|
2000-12-21 23:03:42 +00:00
|
|
|
TallestCellGotShorter(oldCellDesAscent, cellMet.ascent, mMaxCellAscent);
|
2000-06-05 08:25:11 +00:00
|
|
|
// the descent of cells without rowspan also matters
|
|
|
|
if (!tallestCellGotShorter) {
|
2001-03-13 06:38:59 +00:00
|
|
|
PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan(*cellFrame);
|
2000-06-05 08:25:11 +00:00
|
|
|
if (rowSpan == 1) {
|
|
|
|
tallestCellGotShorter =
|
2002-10-01 19:40:28 +00:00
|
|
|
TallestCellGotShorter(oldCellDesDescent, cellMet.descent, mMaxCellDescent);
|
2000-06-05 08:25:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tallestCellGotShorter) {
|
2001-11-05 00:15:51 +00:00
|
|
|
CalcHeight(aReflowState);
|
2000-06-05 08:25:11 +00:00
|
|
|
}
|
|
|
|
else {
|
2001-11-05 00:15:51 +00:00
|
|
|
UpdateHeight(cellMet.height, cellMet.ascent, cellMet.descent, &aTableFrame, cellFrame);
|
2000-06-05 08:25:11 +00:00
|
|
|
}
|
1998-08-07 02:11:51 +00:00
|
|
|
|
2000-05-25 22:40:21 +00:00
|
|
|
// if the cell's desired size didn't changed, our height is unchanged
|
|
|
|
aDesiredSize.mNothingChanged = PR_FALSE;
|
2001-03-13 06:38:59 +00:00
|
|
|
PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan(*cellFrame);
|
2001-07-13 23:49:30 +00:00
|
|
|
if ((initCellDesSize.width == oldCellDesSize.width) &&
|
|
|
|
(initCellDesSize.height == oldCellDesSize.height) &&
|
|
|
|
(oldCellMaximumWidth == cellMet.mMaximumWidth)) {
|
2000-06-05 08:25:11 +00:00
|
|
|
if (!hasVerticalAlignBaseline) { // only the cell's height matters
|
2000-09-05 14:57:34 +00:00
|
|
|
aDesiredSize.mNothingChanged = PR_TRUE;
|
2000-06-05 08:25:11 +00:00
|
|
|
}
|
|
|
|
else { // cell's ascent and cell's descent matter
|
|
|
|
if (initCellDesAscent == oldCellDesAscent) {
|
|
|
|
if ((rowSpan == 1) && (initCellDesDescent == oldCellDesDescent)) {
|
|
|
|
aDesiredSize.mNothingChanged = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-11-05 00:15:51 +00:00
|
|
|
aDesiredSize.height = (aDesiredSize.mNothingChanged) ? mRect.height : GetHeight();
|
2000-09-05 14:57:34 +00:00
|
|
|
if (1 == rowSpan) {
|
|
|
|
cellMet.height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
else {
|
2001-03-13 06:38:59 +00:00
|
|
|
nscoord heightOfRows = aDesiredSize.height + GetHeightOfRowsSpannedBelowFirst(*cellFrame, aTableFrame);
|
2000-09-05 14:57:34 +00: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 09:19:26 +00:00
|
|
|
|
1998-10-14 16:32:45 +00:00
|
|
|
// Now place the child
|
2001-10-26 02:30:38 +00:00
|
|
|
cellMet.width = colAvailWidth;
|
2006-03-04 05:26:57 +00:00
|
|
|
|
2001-12-07 14:51:12 +00:00
|
|
|
FinishReflowChild(aNextFrame, aPresContext, nsnull, cellMet, cellOrigin.x, 0, 0);
|
2001-03-13 06:38:59 +00:00
|
|
|
|
|
|
|
// Notify the table if the cell width changed so it can decide whether to rebalance
|
|
|
|
if (!aDesiredSize.mNothingChanged) {
|
2001-11-30 15:05:51 +00:00
|
|
|
aTableFrame.CellChangedWidth(*cellFrame, oldCellMinWidth, oldCellMaximumWidth);
|
2000-10-05 21:05:06 +00:00
|
|
|
}
|
|
|
|
|
1998-10-14 16:32:45 +00: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 06:38:59 +00:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
2000-05-25 22:40:21 +00:00
|
|
|
if (!aDesiredSize.mNothingChanged) {
|
|
|
|
if (aDesiredSize.height == mRect.height) { // our height didn't change
|
2005-02-07 01:58:25 +00:00
|
|
|
cellFrame->VerticallyAlignChild(aReflowState, mMaxCellAscent);
|
2003-07-07 02:01:29 +00:00
|
|
|
nsRect dirtyRect = cellFrame->GetRect();
|
2000-05-25 22:40:21 +00:00
|
|
|
dirtyRect.height = mRect.height;
|
2004-12-27 15:05:18 +00:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowArea, cellFrame);
|
2003-09-13 16:26:30 +00:00
|
|
|
dirtyRect.UnionRect(dirtyRect, aDesiredSize.mOverflowArea);
|
2004-03-10 03:09:05 +00:00
|
|
|
Invalidate(dirtyRect);
|
2000-05-25 22:40:21 +00:00
|
|
|
}
|
|
|
|
}
|
2004-01-28 18:44:41 +00:00
|
|
|
else { // we dont realign vertical but we need to update the overflow area
|
|
|
|
nsIFrame* cellKidFrame = cellFrame->GetFirstChild(nsnull);
|
|
|
|
if (cellKidFrame) {
|
2004-09-01 13:33:17 +00:00
|
|
|
// XXX This is bogus. The code above changes the cell width
|
|
|
|
// and height but leaves the overflow area alone. How can that
|
|
|
|
// be right?
|
|
|
|
|
|
|
|
// Make sure the overflow area includes the width and height, in any case.
|
|
|
|
cellMet.mOverflowArea.UnionRect(cellMet.mOverflowArea,
|
|
|
|
nsRect(0, 0, cellMet.width, cellMet.height));
|
2004-12-27 15:05:18 +00:00
|
|
|
cellFrame->ConsiderChildOverflow(cellMet.mOverflowArea, cellKidFrame);
|
2004-07-16 16:56:21 +00:00
|
|
|
cellFrame->FinishAndStoreOverflow(&cellMet);
|
2004-03-28 15:13:31 +00:00
|
|
|
if (cellFrame->HasView()) {
|
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, cellFrame, cellFrame->GetView(), &cellMet.mOverflowArea, 0);
|
|
|
|
}
|
|
|
|
}
|
2004-01-28 18:44:41 +00:00
|
|
|
}
|
1998-10-14 16:32:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // pass reflow to unknown frame child
|
|
|
|
// aDesiredSize does not change
|
|
|
|
}
|
2004-01-28 18:44:41 +00:00
|
|
|
|
|
|
|
// recover the overflow area
|
2004-04-15 04:28:28 +00:00
|
|
|
aDesiredSize.mOverflowArea = nsRect(0, 0, aDesiredSize.width, aDesiredSize.height);
|
2004-01-28 18:44:41 +00:00
|
|
|
for (nsIFrame* cell = mFrames.FirstChild(); cell; cell = cell->GetNextSibling()) {
|
2004-12-27 15:05:18 +00:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowArea, cell);
|
2004-01-28 18:44:41 +00:00
|
|
|
}
|
2004-07-16 16:56:21 +00:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
2000-01-17 17:45:17 +00: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;
|
2006-02-21 21:33:47 +00:00
|
|
|
if (GetNextInFlow()) {
|
2003-07-07 02:01:29 +00:00
|
|
|
for (nsIFrame* cell = mFrames.FirstChild(); cell;
|
|
|
|
cell = cell->GetNextSibling()) {
|
2004-09-14 02:28:03 +00:00
|
|
|
nsIFrame* contFrame = cell->GetNextInFlow();
|
2000-01-17 17:45:17 +00:00
|
|
|
if (contFrame) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-10-14 16:32:45 +00:00
|
|
|
return rv;
|
1998-07-01 03:03:32 +00:00
|
|
|
}
|
1998-05-21 23:43:18 +00:00
|
|
|
|
1998-10-14 16:32:45 +00:00
|
|
|
|
1998-04-23 17:29:07 +00:00
|
|
|
/** Layout the entire row.
|
1998-07-02 05:39:10 +00:00
|
|
|
* This method stacks cells horizontally according to HTML 4.0 rules.
|
1998-04-23 17:29:07 +00:00
|
|
|
*/
|
|
|
|
NS_METHOD
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableRowFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 04:10:00 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-23 17:29:07 +00:00
|
|
|
{
|
2000-04-21 21:36:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableRowFrame", aReflowState.reason);
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2001-10-29 01:43:59 +00:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 15:55:51 +00:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState);
|
|
|
|
#endif
|
1999-08-19 19:52:37 +00:00
|
|
|
nsresult rv = NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-01 22:01:37 +00:00
|
|
|
|
2004-04-28 16:42:59 +00:00
|
|
|
const nsStyleVisibility* rowVis = GetStyleVisibility();
|
|
|
|
PRBool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
|
|
|
|
if (collapseRow) {
|
2006-03-04 05:26:57 +00:00
|
|
|
tableFrame->SetNeedToCollapse(PR_TRUE);
|
2004-04-28 16:42:59 +00:00
|
|
|
}
|
|
|
|
|
2002-04-01 06:46:17 +00:00
|
|
|
// see if a special height reflow needs to occur due to having a pct height
|
2002-04-10 21:32:41 +00:00
|
|
|
if (!NeedSpecialReflow())
|
|
|
|
nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState);
|
2001-11-05 00:15:51 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
switch (aReflowState.reason) {
|
1998-07-10 22:56:13 +00:00
|
|
|
case eReflowReason_Initial:
|
2001-04-02 03:21:58 +00:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE);
|
1998-07-10 22:56:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eReflowReason_Resize:
|
2002-11-08 05:29:34 +00:00
|
|
|
case eReflowReason_StyleChange:
|
|
|
|
case eReflowReason_Dirty:
|
2001-03-13 06:38:59 +00:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE);
|
1998-07-10 22:56:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eReflowReason_Incremental:
|
2001-03-13 06:38:59 +00:00
|
|
|
rv = IncrementalReflow(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus);
|
1998-07-10 22:56:13 +00:00
|
|
|
break;
|
2001-11-25 20:38:30 +00:00
|
|
|
default:
|
|
|
|
NS_ASSERTION(PR_FALSE , "we should handle this reflow reason");
|
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
1998-07-10 22:56:13 +00:00
|
|
|
}
|
1998-07-02 05:39:10 +00:00
|
|
|
|
2001-03-13 06:38:59 +00: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-30 22:30:32 +00:00
|
|
|
|
2001-12-07 14:51:12 +00:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
2001-11-05 00:15:51 +00:00
|
|
|
SetNeedSpecialReflow(PR_FALSE);
|
|
|
|
}
|
|
|
|
|
2001-10-29 01:43:59 +00:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 15:55:51 +00:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState, &aDesiredSize, aStatus);
|
|
|
|
#endif
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-10-14 16:32:45 +00:00
|
|
|
return rv;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-02-22 03:28:00 +00: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 14:51:52 +00:00
|
|
|
nscoord
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableRowFrame::ReflowCellFrame(nsPresContext* aPresContext,
|
2001-04-16 14:51:52 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableCellFrame* aCellFrame,
|
|
|
|
nscoord aAvailableHeight,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-02-22 03:28:00 +00:00
|
|
|
{
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
ABORT1(NS_ERROR_NULL_POINTER);
|
2002-02-19 15:48:28 +00:00
|
|
|
|
1999-02-22 03:28:00 +00:00
|
|
|
// Reflow the cell frame with the specified height. Use the existing width
|
2003-07-07 02:01:29 +00:00
|
|
|
nsSize cellSize = aCellFrame->GetSize();
|
1999-02-22 03:28:00 +00:00
|
|
|
|
|
|
|
nsSize availSize(cellSize.width, aAvailableHeight);
|
2002-02-19 15:48:28 +00:00
|
|
|
PRBool borderCollapse = ((nsTableFrame*)tableFrame->GetFirstInFlow())->IsBorderCollapse();
|
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
2000-05-04 23:16:42 +00:00
|
|
|
nsTableCellReflowState cellReflowState(aPresContext, aReflowState, aCellFrame, availSize,
|
|
|
|
eReflowReason_Resize);
|
2002-02-19 15:48:28 +00:00
|
|
|
InitChildReflowState(*aPresContext, availSize, borderCollapse, p2t, cellReflowState);
|
|
|
|
|
2003-09-13 16:26:30 +00:00
|
|
|
nsHTMLReflowMetrics desiredSize(PR_FALSE);
|
1999-02-22 03:28:00 +00:00
|
|
|
|
1999-11-19 15:33:29 +00:00
|
|
|
ReflowChild(aCellFrame, aPresContext, desiredSize, cellReflowState,
|
|
|
|
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
2002-10-03 14:33:23 +00:00
|
|
|
PRBool fullyComplete = NS_FRAME_IS_COMPLETE(aStatus) && !NS_FRAME_IS_TRUNCATED(aStatus);
|
|
|
|
|
2003-07-07 02:01:29 +00:00
|
|
|
aCellFrame->SetSize(
|
|
|
|
nsSize(cellSize.width, fullyComplete ? aAvailableHeight : desiredSize.height));
|
2001-04-16 14:51:52 +00:00
|
|
|
|
2000-06-05 08:25:11 +00:00
|
|
|
// XXX What happens if this cell has 'vertical-align: baseline' ?
|
|
|
|
// XXX Why is it assumed that the cell's ascent hasn't changed ?
|
2002-10-03 14:33:23 +00:00
|
|
|
if (fullyComplete) {
|
2005-02-07 01:58:25 +00:00
|
|
|
aCellFrame->VerticallyAlignChild(aReflowState, mMaxCellAscent);
|
2002-10-03 14:33:23 +00:00
|
|
|
}
|
2001-12-07 14:51:12 +00:00
|
|
|
aCellFrame->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
|
2001-04-16 14:51:52 +00:00
|
|
|
|
|
|
|
return desiredSize.height;
|
1999-02-22 03:28:00 +00:00
|
|
|
}
|
|
|
|
|
2006-03-04 05:26:57 +00:00
|
|
|
nscoord
|
|
|
|
nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset,
|
|
|
|
nscoord aWidth,
|
|
|
|
PRBool aCollapseGroup,
|
|
|
|
PRBool& aDidCollapse)
|
|
|
|
{
|
|
|
|
const nsStyleVisibility* rowVis = GetStyleVisibility();
|
|
|
|
PRBool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
|
2006-12-02 06:52:55 +00:00
|
|
|
nsTableFrame* tableFrame = NS_STATIC_CAST(nsTableFrame*, nsTableFrame::GetTableFrame(this)->GetFirstInFlow());
|
2006-03-04 05:26:57 +00:00
|
|
|
if (!tableFrame)
|
|
|
|
return 0;
|
|
|
|
if (collapseRow) {
|
|
|
|
tableFrame->SetNeedToCollapse(PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect rowRect = GetRect();
|
|
|
|
rowRect.y -= aRowOffset;
|
|
|
|
rowRect.width = aWidth;
|
|
|
|
nsRect overflowArea(0, 0, 0, 0);
|
|
|
|
nscoord shift = 0;
|
|
|
|
nscoord cellSpacingX = tableFrame->GetCellSpacingX();
|
|
|
|
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
|
2006-03-26 15:58:34 +00:00
|
|
|
|
2006-03-04 05:26:57 +00:00
|
|
|
if (aCollapseGroup || collapseRow) {
|
2006-03-26 15:58:34 +00:00
|
|
|
nsTableCellFrame* cellFrame = GetFirstCell();
|
2006-03-04 05:26:57 +00:00
|
|
|
aDidCollapse = PR_TRUE;
|
|
|
|
shift = rowRect.height + cellSpacingY;
|
|
|
|
while (cellFrame) {
|
|
|
|
nsRect cRect = cellFrame->GetRect();
|
|
|
|
cRect.height = 0;
|
|
|
|
cellFrame->SetRect(cRect);
|
|
|
|
cellFrame = cellFrame->GetNextCell();
|
|
|
|
}
|
|
|
|
rowRect.height = 0;
|
|
|
|
}
|
|
|
|
else { // row is not collapsed
|
|
|
|
nsTableIterator iter(*this, eTableDIR);
|
|
|
|
// 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
|
|
|
|
|
|
|
|
PRInt32 colIncrement = iter.IsLeftToRight() ? 1 : -1;
|
|
|
|
|
|
|
|
//nscoord x = cellSpacingX;
|
|
|
|
|
|
|
|
nsIFrame* kidFrame = iter.First();
|
|
|
|
while (kidFrame) {
|
|
|
|
nsIAtom* frameType = kidFrame->GetType();
|
|
|
|
if (IS_TABLE_CELL(frameType)) {
|
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)kidFrame;
|
|
|
|
PRInt32 cellColIndex;
|
|
|
|
cellFrame->GetColIndex(cellColIndex);
|
|
|
|
PRInt32 cellColSpan = tableFrame->GetEffectiveColSpan(*cellFrame);
|
|
|
|
|
|
|
|
// 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(),
|
|
|
|
PR_TRUE);
|
|
|
|
}
|
|
|
|
nsRect cRect(x, 0, 0,rowRect.height);
|
|
|
|
|
|
|
|
// remember the rightmost (ltr) or leftmost (rtl) column this cell
|
|
|
|
// spans into
|
|
|
|
prevColIndex = (iter.IsLeftToRight()) ?
|
|
|
|
cellColIndex + (cellColSpan - 1) : cellColIndex;
|
2006-03-26 15:58:34 +00:00
|
|
|
PRInt32 startIndex = (iter.IsLeftToRight()) ?
|
|
|
|
cellColIndex : cellColIndex + (cellColSpan - 1);
|
2006-03-04 05:26:57 +00:00
|
|
|
PRInt32 actualColSpan = cellColSpan;
|
|
|
|
PRBool isVisible = PR_FALSE;
|
2006-03-26 15:58:34 +00:00
|
|
|
for (PRInt32 colX = startIndex; actualColSpan > 0;
|
2006-03-04 05:26:57 +00:00
|
|
|
colX += colIncrement, actualColSpan--) {
|
|
|
|
|
|
|
|
nsTableColFrame* colFrame = tableFrame->GetColFrame(colX);
|
|
|
|
const nsStyleVisibility* colVis = colFrame->GetStyleVisibility();
|
|
|
|
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE ==
|
|
|
|
colVis->mVisible);
|
|
|
|
nsIFrame* cgFrame = colFrame->GetParent();
|
|
|
|
const nsStyleVisibility* groupVis = cgFrame->GetStyleVisibility();
|
|
|
|
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE ==
|
|
|
|
groupVis->mVisible);
|
|
|
|
PRBool isCollapsed = collapseCol || collapseGroup;
|
|
|
|
if (isCollapsed) {
|
|
|
|
tableFrame->SetNeedToCollapse(PR_TRUE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cRect.width += tableFrame->GetColumnWidth(colX);
|
|
|
|
isVisible = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (!isCollapsed && (actualColSpan > 1)) {
|
|
|
|
nsTableColFrame* nextColFrame =
|
|
|
|
tableFrame->GetColFrame(colX + colIncrement);
|
|
|
|
const nsStyleVisibility* nextColVis =
|
|
|
|
nextColFrame->GetStyleVisibility();
|
|
|
|
if ( (NS_STYLE_VISIBILITY_COLLAPSE != nextColVis->mVisible) &&
|
|
|
|
(tableFrame->GetNumCellsOriginatingInCol(colX + colIncrement) > 0)) {
|
|
|
|
cRect.width += cellSpacingX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
x += cRect.width;
|
|
|
|
if (isVisible)
|
|
|
|
x += cellSpacingX;
|
|
|
|
PRInt32 actualRowSpan = tableFrame->GetEffectiveRowSpan(*cellFrame);
|
|
|
|
nsTableRowFrame* rowFrame = GetNextRow();
|
|
|
|
for (actualRowSpan--; actualRowSpan > 0 && rowFrame; actualRowSpan--) {
|
|
|
|
const nsStyleVisibility* nextRowVis = rowFrame->GetStyleVisibility();
|
|
|
|
PRBool collapseNextRow = (NS_STYLE_VISIBILITY_COLLAPSE ==
|
|
|
|
nextRowVis->mVisible);
|
|
|
|
if (!collapseNextRow) {
|
|
|
|
nsRect nextRect = rowFrame->GetRect();
|
|
|
|
cRect.height += nextRect.height + cellSpacingY;
|
|
|
|
}
|
|
|
|
rowFrame = rowFrame->GetNextRow();
|
|
|
|
}
|
|
|
|
cellFrame->SetRect(cRect);
|
|
|
|
nsRect cellOverflow = nsRect(0, 0, cRect.width, cRect.height);
|
|
|
|
cellFrame->FinishAndStoreOverflow(&cellOverflow, nsSize(cRect.width,
|
|
|
|
cRect.height));
|
|
|
|
nsTableFrame::RePositionViews(cellFrame);
|
|
|
|
ConsiderChildOverflow(overflowArea, cellFrame);
|
|
|
|
|
|
|
|
}
|
|
|
|
kidFrame = iter.Next(); // Get the next child
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetRect(rowRect);
|
|
|
|
overflowArea.UnionRect(nsRect(0,0,rowRect.width, rowRect.height),
|
|
|
|
overflowArea);
|
|
|
|
FinishAndStoreOverflow(&overflowArea, nsSize(rowRect.width,
|
|
|
|
rowRect.height));
|
|
|
|
nsTableFrame::RePositionViews(this);
|
|
|
|
return shift;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-02-22 03:28:00 +00:00
|
|
|
/**
|
2001-04-16 14:51:52 +00: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 03:28:00 +00:00
|
|
|
*/
|
2001-04-16 14:51:52 +00:00
|
|
|
void
|
|
|
|
nsTableRowFrame::InsertCellFrame(nsTableCellFrame* aFrame,
|
|
|
|
nsTableCellFrame* aPrevSibling)
|
1999-02-22 03:28:00 +00:00
|
|
|
{
|
|
|
|
mFrames.InsertFrame(nsnull, aPrevSibling, aFrame);
|
2001-04-16 14:51:52 +00:00
|
|
|
aFrame->SetParent(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableRowFrame::InsertCellFrame(nsTableCellFrame* aFrame,
|
|
|
|
PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
// Find the cell frame where col index < aColIndex
|
|
|
|
nsTableCellFrame* priorCell = nsnull;
|
2003-07-07 02:01:29 +00:00
|
|
|
for (nsIFrame* child = mFrames.FirstChild(); child;
|
|
|
|
child = child->GetNextSibling()) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (!IS_TABLE_CELL(child->GetType())) {
|
2001-04-16 14:51:52 +00:00
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)child;
|
|
|
|
PRInt32 colIndex;
|
|
|
|
cellFrame->GetColIndex(colIndex);
|
|
|
|
if (colIndex < aColIndex) {
|
|
|
|
priorCell = cellFrame;
|
|
|
|
}
|
|
|
|
else break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
InsertCellFrame(aFrame, priorCell);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableRowFrame::RemoveCellFrame(nsTableCellFrame* aFrame)
|
|
|
|
{
|
2002-03-04 15:48:56 +00:00
|
|
|
if (!mFrames.RemoveFrame(aFrame))
|
|
|
|
NS_ASSERTION(PR_FALSE, "frame not in list");
|
1999-02-22 03:28:00 +00:00
|
|
|
}
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsTableRowFrame::GetType() const
|
1999-02-24 05:54:31 +00:00
|
|
|
{
|
2003-10-31 20:19:18 +00:00
|
|
|
return nsLayoutAtoms::tableRowFrame;
|
1999-02-24 05:54:31 +00:00
|
|
|
}
|
|
|
|
|
2001-11-05 00:15:51 +00:00
|
|
|
nsTableRowFrame*
|
|
|
|
nsTableRowFrame::GetNextRow() const
|
|
|
|
{
|
2003-07-07 02:01:29 +00:00
|
|
|
nsIFrame* childFrame = GetNextSibling();
|
2001-11-05 00:15:51 +00:00
|
|
|
while (childFrame) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == childFrame->GetType()) {
|
2005-10-04 15:47:21 +00:00
|
|
|
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_ROW == childFrame->GetStyleDisplay()->mDisplay, "wrong display type on rowframe");
|
2001-11-05 00:15:51 +00:00
|
|
|
return (nsTableRowFrame*)childFrame;
|
|
|
|
}
|
2003-07-07 02:01:29 +00:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2001-11-05 00:15:51 +00:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
1999-02-24 05:54:31 +00:00
|
|
|
|
2001-11-29 15:41:07 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableRowFrame::SetUnpaginatedHeight(nsPresContext* aPresContext,
|
2001-11-29 15:41:07 +00:00
|
|
|
nscoord aValue)
|
|
|
|
{
|
2006-02-21 21:33:47 +00:00
|
|
|
NS_ASSERTION(!GetPrevInFlow(), "program error");
|
2001-11-29 15:41:07 +00:00
|
|
|
// Get the property
|
2005-02-07 01:58:25 +00:00
|
|
|
nscoord* value = (nscoord*)nsTableFrame::GetProperty(this, nsLayoutAtoms::rowUnpaginatedHeightProperty, PR_TRUE);
|
2001-11-29 15:41:07 +00:00
|
|
|
if (value) {
|
|
|
|
*value = aValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableRowFrame::GetUnpaginatedHeight(nsPresContext* aPresContext)
|
2001-11-29 15:41:07 +00:00
|
|
|
{
|
|
|
|
// See if the property is set
|
2005-02-07 01:58:25 +00:00
|
|
|
nscoord* value = (nscoord*)nsTableFrame::GetProperty(GetFirstInFlow(), nsLayoutAtoms::rowUnpaginatedHeightProperty);
|
2001-11-29 15:41:07 +00:00
|
|
|
if (value)
|
|
|
|
return *value;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-03-09 06:48:35 +00:00
|
|
|
void nsTableRowFrame::SetContinuousBCBorderWidth(PRUint8 aForSide,
|
|
|
|
BCPixelSize aPixelValue)
|
|
|
|
{
|
|
|
|
switch (aForSide) {
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
mRightContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
mTopContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
mLeftContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
NS_ERROR("invalid NS_SIDE arg");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-15 17:58:24 +00:00
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewTableRowFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsTableRowFrame(aContext);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsTableRowFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 17:22:29 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableRow"), aResult);
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|