2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsTableRowFrame.h"
|
2001-11-05 18:15:24 +03:00
|
|
|
#include "nsTableRowGroupFrame.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIRenderingContext.h"
|
1999-07-28 12:09:02 +04:00
|
|
|
#include "nsIPresShell.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIPresContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsStyleConsts.h"
|
1998-08-26 21:26:38 +04:00
|
|
|
#include "nsHTMLAtoms.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsTableFrame.h"
|
|
|
|
#include "nsTableCellFrame.h"
|
1998-04-15 01:49:29 +04:00
|
|
|
#include "nsIView.h"
|
2002-05-10 22:22:41 +04:00
|
|
|
#include "nsReflowPath.h"
|
1998-07-21 03:56:17 +04:00
|
|
|
#include "nsCSSRendering.h"
|
1999-02-24 08:54:31 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-07-28 12:09:02 +04:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsTableColGroupFrame.h"
|
|
|
|
#include "nsTableColFrame.h"
|
|
|
|
#include "nsCOMPtr.h"
|
1998-09-01 01:23:28 +04:00
|
|
|
// the following header files are required for style optimizations that work only when the child content is really a cell
|
1998-09-15 21:58:24 +04:00
|
|
|
#include "nsIHTMLTableCellElement.h"
|
1998-09-01 01:23:28 +04:00
|
|
|
// end includes for style optimizations that require real content knowledge
|
1998-06-03 04:43:53 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
|
2000-05-05 03:16:42 +04:00
|
|
|
struct nsTableCellReflowState : public nsHTMLReflowState
|
|
|
|
{
|
|
|
|
nsTableCellReflowState(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aParentReflowState,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsSize& aAvailableSpace,
|
|
|
|
nsReflowReason aReason);
|
|
|
|
|
2002-09-09 22:46:06 +04:00
|
|
|
void FixUp(const nsSize& aAvailSpace,
|
|
|
|
PRBool aResetComputedWidth);
|
2000-05-05 03:16:42 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
nsTableCellReflowState::nsTableCellReflowState(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aParentRS,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsSize& aAvailSpace,
|
|
|
|
nsReflowReason aReason)
|
|
|
|
:nsHTMLReflowState(aPresContext, aParentRS, aFrame, aAvailSpace, aReason)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-09-09 22:46:06 +04:00
|
|
|
void nsTableCellReflowState::FixUp(const nsSize& aAvailSpace,
|
|
|
|
PRBool aResetComputedWidth)
|
2000-05-05 03:16:42 +04:00
|
|
|
{
|
2002-02-19 18:48:28 +03: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 22:46:06 +04:00
|
|
|
if (aResetComputedWidth) {
|
|
|
|
mComputedWidth = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
|
|
|
else if (NS_UNCONSTRAINEDSIZE != mComputedWidth) {
|
2002-02-19 18:48:28 +03: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
|
|
|
|
nsTableRowFrame::InitChildReflowState(nsIPresContext& aPresContext,
|
|
|
|
const nsSize& aAvailSize,
|
|
|
|
PRBool aBorderCollapse,
|
|
|
|
float aPixelsToTwips,
|
2002-09-09 22:46:06 +04:00
|
|
|
nsTableCellReflowState& aReflowState,
|
|
|
|
PRBool aResetComputedWidth)
|
2002-02-19 18:48:28 +03: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 22:46:06 +04:00
|
|
|
aReflowState.FixUp(aAvailSize, aResetComputedWidth);
|
2000-05-05 03:16:42 +04:00
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
void
|
|
|
|
nsTableRowFrame::SetFixedHeight(nscoord aValue)
|
|
|
|
{
|
2003-01-05 17:16:58 +03:00
|
|
|
nscoord height = PR_MAX(0, aValue);
|
|
|
|
if (HasFixedHeight()) {
|
|
|
|
if (height > mStyleFixedHeight) {
|
|
|
|
mStyleFixedHeight = height;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
2003-01-05 17:16:58 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
mStyleFixedHeight = height;
|
|
|
|
if (height > 0) {
|
|
|
|
SetHasFixedHeight(PR_TRUE);
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-11-05 18:15:24 +03:00
|
|
|
nsTableRowFrame::SetPctHeight(float aPctValue,
|
|
|
|
PRBool aForce)
|
2001-11-05 03:15:51 +03:00
|
|
|
{
|
|
|
|
nscoord height = PR_MAX(0, NSToCoordRound(aPctValue * 100.0f));
|
|
|
|
if (HasPctHeight()) {
|
2003-01-05 17:16:58 +03:00
|
|
|
if ((height > mStylePctHeight) || aForce) {
|
|
|
|
mStylePctHeight = height;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2003-01-05 17:16:58 +03:00
|
|
|
mStylePctHeight = height;
|
2001-11-05 03:15:51 +03:00
|
|
|
if (height > 0.0f) {
|
|
|
|
SetHasPctHeight(PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
// 'old' is old cached cell's desired size
|
|
|
|
// 'new' is new cell's size including style constraints
|
|
|
|
static PRBool
|
|
|
|
TallestCellGotShorter(nscoord aOld,
|
|
|
|
nscoord aNew,
|
|
|
|
nscoord aTallest)
|
|
|
|
{
|
2000-12-22 02:03:42 +03:00
|
|
|
return ((aNew < aOld) && (aOld == aTallest));
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
/* ----------- nsTableRowFrame ---------- */
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsTableRowFrame::nsTableRowFrame()
|
2001-11-05 03:15:51 +03:00
|
|
|
: nsHTMLContainerFrame()
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2001-11-05 03:15:51 +03:00
|
|
|
mBits.mRowIndex = mBits.mFirstInserted = 0;
|
|
|
|
ResetHeight(0);
|
2001-01-25 18:55:51 +03:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
mTimer = new nsReflowTimer(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableRowFrame::~nsTableRowFrame()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflowDone(this);
|
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-25 08:31:15 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowFrame::Init(nsIPresContext* aPresContext,
|
1999-02-25 08:31:15 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
1999-02-25 08:31:15 +03:00
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Let the the base class do its initialization
|
|
|
|
rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext,
|
|
|
|
aPrevInFlow);
|
|
|
|
|
2001-02-23 15:35:34 +03:00
|
|
|
// record that children that are ignorable whitespace should be excluded
|
|
|
|
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
|
|
|
|
|
1999-02-25 08:31:15 +03:00
|
|
|
if (aPrevInFlow) {
|
|
|
|
// Set the row index
|
|
|
|
nsTableRowFrame* rowFrame = (nsTableRowFrame*)aPrevInFlow;
|
|
|
|
|
|
|
|
SetRowIndex(rowFrame->GetRowIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowFrame::AppendFrames(nsIPresContext* aPresContext,
|
1999-08-03 06:41:27 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
// Append the frames
|
|
|
|
mFrames.AppendFrames(nsnull, aFrameList);
|
|
|
|
|
|
|
|
// Add the new cell frames to the table
|
|
|
|
nsTableFrame *tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
2003-07-07 06:01:29 +04:00
|
|
|
for (nsIFrame* childFrame = aFrameList; childFrame;
|
|
|
|
childFrame = childFrame->GetNextSibling()) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (IS_TABLE_CELL(childFrame->GetType())) {
|
1999-08-03 06:41:27 +04:00
|
|
|
// Add the cell to the cell map
|
1999-12-14 01:56:31 +03:00
|
|
|
tableFrame->AppendCell(*aPresContext, (nsTableCellFrame&)*childFrame, GetRowIndex());
|
2001-03-13 09:38:59 +03:00
|
|
|
// XXX this could be optimized with some effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
2001-03-13 09:38:59 +03:00
|
|
|
tableFrame->AppendDirtyReflowCommand(&aPresShell, this);
|
1999-08-03 06:41:27 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowFrame::InsertFrames(nsIPresContext* aPresContext,
|
1999-08-03 06:41:27 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
// Get the table frame
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// gather the new frames (only those which are cells) into an array
|
2002-02-19 18:48:28 +03:00
|
|
|
nsIAtom* cellFrameType = (tableFrame->IsBorderCollapse()) ? nsLayoutAtoms::bcTableCellFrame : nsLayoutAtoms::tableCellFrame;
|
2004-01-18 13:28:40 +03:00
|
|
|
nsTableCellFrame* prevCellFrame = (nsTableCellFrame *)nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame, cellFrameType);
|
1999-12-14 01:56:31 +03:00
|
|
|
nsVoidArray cellChildren;
|
2003-07-07 06:01:29 +04:00
|
|
|
for (nsIFrame* childFrame = aFrameList; childFrame;
|
2003-07-07 09:15:41 +04:00
|
|
|
childFrame = childFrame->GetNextSibling()) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (IS_TABLE_CELL(childFrame->GetType())) {
|
1999-12-14 01:56:31 +03:00
|
|
|
cellChildren.AppendElement(childFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
// XXX this could be optimized with some effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// insert the cells into the cell map
|
|
|
|
PRInt32 colIndex = -1;
|
|
|
|
if (prevCellFrame) {
|
|
|
|
prevCellFrame->GetColIndex(colIndex);
|
|
|
|
}
|
|
|
|
tableFrame->InsertCells(*aPresContext, cellChildren, GetRowIndex(), colIndex);
|
|
|
|
|
|
|
|
// Insert the frames in the frame list
|
1999-08-03 06:41:27 +04:00
|
|
|
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
2001-03-13 09:38:59 +03:00
|
|
|
tableFrame->AppendDirtyReflowCommand(&aPresShell, this);
|
1999-08-03 06:41:27 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowFrame::RemoveFrame(nsIPresContext* aPresContext,
|
1999-08-03 06:41:27 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
// Get the table frame
|
|
|
|
nsTableFrame* tableFrame=nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
if (tableFrame) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (IS_TABLE_CELL(aOldFrame->GetType())) {
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)aOldFrame;
|
|
|
|
PRInt32 colIndex;
|
|
|
|
cellFrame->GetColIndex(colIndex);
|
2001-03-13 09:38:59 +03:00
|
|
|
// remove the cell from the cell map
|
1999-12-14 01:56:31 +03:00
|
|
|
tableFrame->RemoveCell(*aPresContext, cellFrame, GetRowIndex());
|
2001-03-13 09:38:59 +03:00
|
|
|
// XXX this could be optimized with some effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
// Remove the frame and destroy it
|
|
|
|
mFrames.DestroyFrame(aPresContext, aOldFrame);
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// XXX This could probably be optimized with much effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
|
|
|
// Generate a reflow command so we reflow the table itself.
|
2000-03-09 11:45:26 +03:00
|
|
|
// Target the row so that it gets a dirty reflow before a resize reflow
|
|
|
|
// in case another cell gets added to the row during a reflow coallesce.
|
2001-03-13 09:38:59 +03:00
|
|
|
tableFrame->AppendDirtyReflowCommand(&aPresShell, this);
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
|
|
|
}
|
1998-09-16 21:19:20 +04:00
|
|
|
|
1999-08-30 04:01:09 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-09-05 18:57:34 +04:00
|
|
|
nscoord
|
|
|
|
GetHeightOfRowsSpannedBelowFirst(nsTableCellFrame& aTableCellFrame,
|
|
|
|
nsTableFrame& aTableFrame)
|
|
|
|
{
|
|
|
|
nscoord height = 0;
|
|
|
|
nscoord cellSpacingY = aTableFrame.GetCellSpacingY();
|
|
|
|
PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan(aTableCellFrame);
|
|
|
|
// add in height of rows spanned beyond the 1st one
|
2003-07-07 06:01:29 +04:00
|
|
|
nsIFrame* nextRow = aTableCellFrame.GetParent()->GetNextSibling();
|
2000-09-05 18:57:34 +04:00
|
|
|
for (PRInt32 rowX = 1; ((rowX < rowSpan) && nextRow);) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == nextRow->GetType()) {
|
2003-07-07 06:01:29 +04:00
|
|
|
height += nextRow->GetSize().height;
|
2000-09-05 18:57:34 +04:00
|
|
|
rowX++;
|
|
|
|
}
|
|
|
|
height += cellSpacingY;
|
2003-07-07 06:01:29 +04:00
|
|
|
nextRow = nextRow->GetNextSibling();
|
2000-09-05 18:57:34 +04:00
|
|
|
}
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableCellFrame*
|
|
|
|
nsTableRowFrame::GetFirstCell()
|
|
|
|
{
|
|
|
|
nsIFrame* childFrame = mFrames.FirstChild();
|
|
|
|
while (childFrame) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (IS_TABLE_CELL(childFrame->GetType())) {
|
2001-11-05 03:15:51 +03:00
|
|
|
return (nsTableCellFrame*)childFrame;
|
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
2000-09-05 18:57:34 +04:00
|
|
|
|
1998-07-03 00:35:23 +04:00
|
|
|
/**
|
|
|
|
* Post-reflow hook. This is where the table row does its post-processing
|
|
|
|
*/
|
1998-11-20 04:01:25 +03:00
|
|
|
void
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowFrame::DidResize(nsIPresContext* aPresContext,
|
1998-11-20 04:01:25 +03:00
|
|
|
const nsHTMLReflowState& aReflowState)
|
1998-07-03 00:35:23 +04:00
|
|
|
{
|
1998-11-20 04:01:25 +03:00
|
|
|
// Resize and re-align the cell frames based on our row height
|
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
2000-04-29 01:05:31 +04:00
|
|
|
if (!tableFrame) return;
|
2003-09-13 20:26:30 +04:00
|
|
|
|
2004-01-18 13:28:40 +03:00
|
|
|
nsTableIterator iter(*this, eTableDIR);
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame* childFrame = iter.First();
|
2003-09-13 20:26:30 +04: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 23:15:56 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
while (childFrame) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (IS_TABLE_CELL(childFrame->GetType())) {
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)childFrame;
|
|
|
|
nscoord cellHeight = mRect.height + GetHeightOfRowsSpannedBelowFirst(*cellFrame, *tableFrame);
|
1999-05-04 23:15:56 +04:00
|
|
|
|
|
|
|
// resize the cell's height
|
|
|
|
//if (cellFrameSize.height!=cellHeight)
|
1998-11-20 04:01:25 +03:00
|
|
|
{
|
1999-11-19 18:33:29 +03:00
|
|
|
// XXX If the cell frame has a view, then we need to resize
|
|
|
|
// it as well. We would like to only do that if the cell's size
|
|
|
|
// is changing. Why is the 'if' stmt above commented out?
|
2003-07-07 06:01:29 +04:00
|
|
|
cellFrame->SetSize(nsSize(cellFrame->GetSize().width, cellHeight));
|
1999-05-04 23:15:56 +04:00
|
|
|
// realign cell content based on the new height
|
|
|
|
/*nsHTMLReflowMetrics desiredSize(nsnull);
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
|
|
|
|
cellFrame,
|
|
|
|
nsSize(cellFrameSize.width, cellHeight),
|
|
|
|
eReflowReason_Resize);*/
|
|
|
|
//XXX: the following reflow is necessary for any content of the cell
|
|
|
|
// whose height is a percent of the cell's height (maybe indirectly.)
|
|
|
|
// But some content crashes when this reflow is issued, to be investigated
|
|
|
|
//XXX nsReflowStatus status;
|
|
|
|
//ReflowChild(cellFrame, aPresContext, desiredSize, kidReflowState, status);
|
2000-07-28 13:19:26 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
cellFrame->VerticallyAlignChild(aPresContext, aReflowState, mMaxCellAscent);
|
2003-09-13 20:26:30 +04:00
|
|
|
ConsiderChildOverflow(aPresContext, desiredSize.mOverflowArea, cellFrame);
|
1998-07-03 00:35:23 +04:00
|
|
|
}
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
// Get the next child
|
|
|
|
childFrame = iter.Next();
|
1998-07-03 00:35:23 +04:00
|
|
|
}
|
2003-09-13 20:26:30 +04:00
|
|
|
StoreOverflow(aPresContext, desiredSize);
|
2004-04-14 10:22:52 +04:00
|
|
|
if (HasView()) {
|
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, this, GetView(), &desiredSize.mOverflowArea, 0);
|
|
|
|
}
|
1998-07-03 00:35:23 +04:00
|
|
|
// Let our base class do the usual work
|
|
|
|
}
|
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
// returns max-ascent amongst all cells that have 'vertical-align: baseline'
|
2000-07-28 13:19:26 +04:00
|
|
|
// *including* cells with rowspans
|
2000-06-05 12:25:11 +04:00
|
|
|
nscoord nsTableRowFrame::GetMaxCellAscent() const
|
|
|
|
{
|
|
|
|
return mMaxCellAscent;
|
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord
|
|
|
|
nsTableRowFrame::GetHeight(nscoord aPctBasis) const
|
2000-05-26 02:40:21 +04:00
|
|
|
{
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord height = 0;
|
|
|
|
if ((aPctBasis > 0) && HasPctHeight()) {
|
|
|
|
height = NSToCoordRound(GetPctHeight() * (float)aPctBasis);
|
|
|
|
}
|
2003-01-05 17:16:58 +03:00
|
|
|
if (HasFixedHeight()) {
|
|
|
|
height = PR_MAX(height, GetFixedHeight());
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
return PR_MAX(height, GetContentHeight());
|
2000-05-26 02:40:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableRowFrame::ResetHeight(nscoord aFixedHeight)
|
2000-05-26 02:40:21 +04:00
|
|
|
{
|
2001-11-05 03:15:51 +03:00
|
|
|
SetHasFixedHeight(PR_FALSE);
|
|
|
|
SetHasPctHeight(PR_FALSE);
|
|
|
|
SetFixedHeight(0);
|
2003-01-05 17:16:58 +03:00
|
|
|
SetPctHeight(0);
|
2001-11-05 03:15:51 +03:00
|
|
|
SetContentHeight(0);
|
|
|
|
|
|
|
|
if (aFixedHeight > 0) {
|
|
|
|
SetFixedHeight(aFixedHeight);
|
|
|
|
}
|
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
mMaxCellAscent = 0;
|
|
|
|
mMaxCellDescent = 0;
|
2000-05-26 02:40:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableRowFrame::UpdateHeight(nscoord aHeight,
|
|
|
|
nscoord aAscent,
|
|
|
|
nscoord aDescent,
|
|
|
|
nsTableFrame* aTableFrame,
|
|
|
|
nsTableCellFrame* aCellFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2001-11-05 03:15:51 +03:00
|
|
|
if (!aTableFrame || !aCellFrame) {
|
|
|
|
NS_ASSERTION(PR_FALSE , "invalid call");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
if (aHeight != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
if (!(aCellFrame->HasVerticalAlignBaseline())) { // only the cell's height matters
|
2001-11-05 03:15:51 +03:00
|
|
|
if (GetHeight() < aHeight) {
|
2000-06-05 12:25:11 +04:00
|
|
|
PRInt32 rowSpan = aTableFrame->GetEffectiveRowSpan(*aCellFrame);
|
|
|
|
if (rowSpan == 1) {
|
2001-11-05 03:15:51 +03:00
|
|
|
SetContentHeight(aHeight);
|
2000-06-05 12:25:11 +04: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 03:15:51 +03:00
|
|
|
if (GetHeight() < mMaxCellAscent + mMaxCellDescent) {
|
|
|
|
SetContentHeight(mMaxCellAscent + mMaxCellDescent);
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord
|
|
|
|
nsTableRowFrame::CalcHeight(const nsHTMLReflowState& aReflowState)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2000-05-26 02:40:21 +04:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
2003-04-05 19:36:31 +04:00
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-11-05 03:15:51 +03:00
|
|
|
if (!tableFrame) return 0;
|
2000-05-26 02:40:21 +04:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord computedHeight = (NS_UNCONSTRAINEDSIZE == aReflowState.mComputedHeight)
|
|
|
|
? 0 : aReflowState.mComputedHeight;
|
|
|
|
ResetHeight(computedHeight);
|
2000-05-26 02:40:21 +04:00
|
|
|
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStylePosition* position = GetStylePosition();
|
2001-11-05 18:15:24 +03: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 06:01:29 +04:00
|
|
|
for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame;
|
|
|
|
kidFrame = kidFrame->GetNextSibling()) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (IS_TABLE_CELL(kidFrame->GetType())) {
|
2000-06-05 12:25:11 +04:00
|
|
|
nscoord availWidth = ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth();
|
|
|
|
nsSize desSize = ((nsTableCellFrame *)kidFrame)->GetDesiredSize();
|
2001-11-29 18:41:07 +03:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) && !mPrevInFlow) {
|
|
|
|
CalculateCellActualSize(kidFrame, desSize.width, desSize.height, availWidth);
|
|
|
|
}
|
2000-06-05 12:25:11 +04:00
|
|
|
// height may have changed, adjust descent to absorb any excess difference
|
|
|
|
nscoord ascent = ((nsTableCellFrame *)kidFrame)->GetDesiredAscent();
|
|
|
|
nscoord descent = desSize.height - ascent;
|
2001-11-05 03:15:51 +03:00
|
|
|
UpdateHeight(desSize.height, ascent, descent, tableFrame, (nsTableCellFrame*)kidFrame);
|
2000-05-26 02:40:21 +04:00
|
|
|
}
|
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
return GetHeight();
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2001-09-19 16:35:19 +04:00
|
|
|
NS_METHOD nsTableRowFrame::Paint(nsIPresContext* aPresContext,
|
1999-06-08 01:10:25 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1999-06-08 01:10:25 +04:00
|
|
|
{
|
2001-01-27 17:09:34 +03:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
1999-06-08 01:10:25 +04:00
|
|
|
// for debug...
|
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0,255,0));
|
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
2004-03-09 09:48:35 +03:00
|
|
|
|
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
|
|
|
|
//direct (not table-called) background paint
|
|
|
|
!(aFlags & (NS_PAINT_FLAG_TABLE_BG_PAINT | NS_PAINT_FLAG_TABLE_CELL_BG_PASS))) {
|
|
|
|
//Quirks inherits bg into cells & paints them there
|
|
|
|
if (eCompatibility_NavQuirks != aPresContext->CompatibilityMode()) {
|
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
NS_ASSERTION(tableFrame, "null table frame");
|
|
|
|
|
|
|
|
TableBackgroundPainter painter(tableFrame,
|
|
|
|
TableBackgroundPainter::eOrigin_TableRow,
|
|
|
|
aPresContext, aRenderingContext,
|
|
|
|
aDirtyRect);
|
|
|
|
nsresult rv = painter.PaintRow(this);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
|
|
|
|
}
|
|
|
|
}
|
1999-06-08 01:10:25 +04:00
|
|
|
|
2003-12-13 02:00:54 +03:00
|
|
|
PRUint8 overflow = GetStyleDisplay()->mOverflow;
|
|
|
|
PRBool clip = overflow == NS_STYLE_OVERFLOW_HIDDEN ||
|
|
|
|
overflow == NS_STYLE_OVERFLOW_SCROLLBARS_NONE;
|
|
|
|
if (clip) {
|
2002-02-21 08:36:16 +03:00
|
|
|
aRenderingContext.PushState();
|
|
|
|
SetOverflowClipRect(aRenderingContext);
|
|
|
|
}
|
2004-03-09 09:48:35 +03:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect,
|
|
|
|
aWhichLayer, aFlags);
|
2003-12-13 02:00:54 +03:00
|
|
|
if (clip) {
|
2002-02-21 08:36:16 +03:00
|
|
|
PRBool clipState;
|
|
|
|
aRenderingContext.PopState(clipState);
|
2001-09-19 16:35:19 +04:00
|
|
|
}
|
1999-06-11 01:08:17 +04:00
|
|
|
return NS_OK;
|
1999-06-08 01:10:25 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
PRIntn
|
|
|
|
nsTableRowFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-03-22 05:43:08 +03:00
|
|
|
/* we overload this here because rows have children that can span outside of themselves.
|
|
|
|
* so the default "get the child rect, see if it contains the event point" action isn't
|
|
|
|
* sufficient. We have to ask the row if it has a child that contains the point.
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
2000-03-22 05:43:08 +03:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame** aFrame)
|
2000-03-22 05:43:08 +03:00
|
|
|
{
|
|
|
|
// XXX This would not need to exist (except as a one-liner, to make this
|
|
|
|
// frame work like a block frame) if rows with rowspan cells made the
|
|
|
|
// the NS_FRAME_OUTSIDE_CHILDREN bit of mState set correctly (see
|
|
|
|
// nsIFrame.h).
|
|
|
|
|
2003-12-13 01:58:25 +03:00
|
|
|
// XXXldb Do we need this anymore?
|
|
|
|
|
2000-03-22 05:43:08 +03:00
|
|
|
// I imagine fixing this would help performance of GetFrameForPoint in
|
|
|
|
// tables. It may also fix problems with relative positioning.
|
|
|
|
|
|
|
|
// This is basically copied from nsContainerFrame::GetFrameForPointUsing,
|
|
|
|
// except for one bit removed
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame *hit;
|
2000-03-22 05:43:08 +03:00
|
|
|
nsPoint tmp;
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame* kid = GetFirstChild(nsnull);
|
2000-03-22 05:43:08 +03:00
|
|
|
*aFrame = nsnull;
|
|
|
|
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
|
|
|
|
while (nsnull != kid) {
|
|
|
|
nsresult rv = kid->GetFrameForPoint(aPresContext, tmp, aWhichLayer, &hit);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && hit) {
|
|
|
|
*aFrame = hit;
|
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
kid = kid->GetNextSibling();
|
2000-03-22 05:43:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*aFrame) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-08-22 00:16:32 +04:00
|
|
|
// Calculate the cell's actual size given its pass2 desired width and height.
|
|
|
|
// Takes into account the specified height (in the style), and any special logic
|
|
|
|
// needed for backwards compatibility.
|
|
|
|
// Modifies the desired width and height that are passed in.
|
|
|
|
nsresult
|
2000-05-26 02:40:21 +04:00
|
|
|
nsTableRowFrame::CalculateCellActualSize(nsIFrame* aCellFrame,
|
|
|
|
nscoord& aDesiredWidth,
|
|
|
|
nscoord& aDesiredHeight,
|
|
|
|
nscoord aAvailWidth)
|
1999-08-22 00:16:32 +04:00
|
|
|
{
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord specifiedHeight = 0;
|
1999-08-22 00:16:32 +04:00
|
|
|
|
|
|
|
// Get the height specified in the style information
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStylePosition* position = aCellFrame->GetStylePosition();
|
2001-11-05 03:15:51 +03:00
|
|
|
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (!tableFrame) return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan((nsTableCellFrame&)*aCellFrame);
|
1999-08-22 00:16:32 +04:00
|
|
|
|
|
|
|
switch (position->mHeight.GetUnit()) {
|
2001-03-13 09:38:59 +03:00
|
|
|
case eStyleUnit_Coord:
|
|
|
|
specifiedHeight = position->mHeight.GetCoordValue();
|
2001-11-05 03:15:51 +03:00
|
|
|
if (1 == rowSpan)
|
|
|
|
SetFixedHeight(specifiedHeight);
|
2001-03-13 09:38:59 +03:00
|
|
|
break;
|
|
|
|
case eStyleUnit_Percent: {
|
2001-11-05 03:15:51 +03: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-26 01:49:18 +04:00
|
|
|
break;
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
case eStyleUnit_Auto:
|
|
|
|
default:
|
|
|
|
break;
|
1999-08-22 00:16:32 +04:00
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
// If the specified height is greater than the desired height, then use the specified height
|
1999-08-22 00:16:32 +04:00
|
|
|
if (specifiedHeight > aDesiredHeight)
|
|
|
|
aDesiredHeight = specifiedHeight;
|
2000-05-26 02:40:21 +04:00
|
|
|
|
2001-09-26 17:49:26 +04:00
|
|
|
if ((0 == aDesiredWidth) && (NS_UNCONSTRAINEDSIZE != aAvailWidth)) { // special Nav4 compatibility code for the width
|
1999-08-22 00:16:32 +04:00
|
|
|
aDesiredWidth = aAvailWidth;
|
2000-05-26 02:40:21 +04:00
|
|
|
}
|
1999-08-22 00:16:32 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculates the available width for the table cell based on the known
|
|
|
|
// column widths taking into account column spans and column spacing
|
2001-10-26 06:30:38 +04:00
|
|
|
static void
|
|
|
|
CalcAvailWidth(nsTableFrame& aTableFrame,
|
|
|
|
nscoord aTableComputedWidth,
|
2003-03-21 22:35:36 +03:00
|
|
|
float aPixelToTwips,
|
2001-10-26 06:30:38 +04:00
|
|
|
nsTableCellFrame& aCellFrame,
|
|
|
|
nscoord aCellSpacingX,
|
|
|
|
nscoord& aColAvailWidth,
|
|
|
|
nscoord& aCellAvailWidth)
|
1999-08-22 00:16:32 +04:00
|
|
|
{
|
2001-10-26 06:30:38 +04:00
|
|
|
aColAvailWidth = aCellAvailWidth = 0;
|
2002-09-09 22:46:06 +04: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);
|
|
|
|
if (colWidth > 0) {
|
|
|
|
aColAvailWidth += colWidth;
|
|
|
|
}
|
|
|
|
if ((spanX > 0) && (aTableFrame.GetNumCellsOriginatingInCol(colIndex + spanX) > 0)) {
|
|
|
|
cellSpacing += aCellSpacingX;
|
2001-10-26 06:30:38 +04:00
|
|
|
}
|
|
|
|
}
|
2002-09-09 22:46:06 +04:00
|
|
|
if (aColAvailWidth > 0) {
|
|
|
|
aColAvailWidth += cellSpacing;
|
|
|
|
}
|
|
|
|
aCellAvailWidth = aColAvailWidth;
|
2001-10-26 06:30:38 +04:00
|
|
|
|
2002-06-14 18:21:03 +04: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 06:01:29 +04:00
|
|
|
if ((aCellFrame.GetStateBits() & NS_FRAME_FIRST_REFLOW)
|
|
|
|
&& (aTableFrame.GetEffectiveColSpan(aCellFrame) > 1)) {
|
2001-10-26 06:30:38 +04:00
|
|
|
// see if the cell has a style width specified
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStylePosition* cellPosition = aCellFrame.GetStylePosition();
|
2001-10-26 06:30:38 +04:00
|
|
|
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
|
|
|
|
// need to add padding into fixed width
|
2003-03-21 22:35:36 +03:00
|
|
|
nsMargin borderPadding(0,0,0,0);
|
2001-10-26 06:30:38 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aTableComputedWidth) {
|
2003-03-21 22:35:36 +03:00
|
|
|
borderPadding = nsTableFrame::GetBorderPadding(nsSize(aTableComputedWidth, 0),
|
|
|
|
aPixelToTwips, &aCellFrame);
|
2001-10-26 06:30:38 +04:00
|
|
|
}
|
2003-03-21 22:35:36 +03:00
|
|
|
nscoord fixWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
|
2001-10-26 06:30:38 +04:00
|
|
|
aCellAvailWidth = PR_MIN(aColAvailWidth, fixWidth);
|
1999-08-22 00:16:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord
|
|
|
|
GetSpaceBetween(PRInt32 aPrevColIndex,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
PRInt32 aColSpan,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nscoord aCellSpacingX,
|
|
|
|
PRBool aIsLeftToRight)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord space = 0;
|
|
|
|
PRInt32 colX;
|
|
|
|
if (aIsLeftToRight) {
|
|
|
|
for (colX = aPrevColIndex + 1; aColIndex > colX; colX++) {
|
|
|
|
space += aTableFrame.GetColumnWidth(colX);
|
|
|
|
if (aTableFrame.GetNumCellsOriginatingInCol(colX) > 0) {
|
|
|
|
space += aCellSpacingX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PRInt32 lastCol = aColIndex + aColSpan - 1;
|
|
|
|
for (colX = aPrevColIndex - 1; colX > lastCol; colX--) {
|
|
|
|
space += aTableFrame.GetColumnWidth(colX);
|
|
|
|
if (aTableFrame.GetNumCellsOriginatingInCol(colX) > 0) {
|
|
|
|
space += aCellSpacingX;
|
|
|
|
}
|
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
return space;
|
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
|
2001-10-26 06:30:38 +04: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 07:17:53 +04:00
|
|
|
|
2002-03-27 08:50:24 +03:00
|
|
|
// subtract the heights of aRow's prev in flows from the unpaginated height
|
|
|
|
static
|
|
|
|
nscoord CalcHeightFromUnpaginatedHeight(nsIPresContext* aPresContext,
|
|
|
|
nsTableRowFrame& aRow)
|
|
|
|
{
|
|
|
|
nscoord height = 0;
|
2003-07-07 06:01:29 +04:00
|
|
|
nsTableRowFrame* firstInFlow = (nsTableRowFrame*)aRow.GetFirstInFlow();
|
|
|
|
if (!firstInFlow) ABORT1(0);
|
2002-03-27 08:50:24 +03:00
|
|
|
if (firstInFlow->HasUnpaginatedHeight()) {
|
|
|
|
height = firstInFlow->GetUnpaginatedHeight(aPresContext);
|
2003-07-07 06:01:29 +04:00
|
|
|
for (nsIFrame* prevInFlow = aRow.GetPrevInFlow(); prevInFlow;
|
|
|
|
prevInFlow->GetPrevInFlow(&prevInFlow)) {
|
|
|
|
height -= prevInFlow->GetSize().height;
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_MAX(height, 0);
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// Called for a dirty or resize reflow. Reflows all the existing table cell
|
|
|
|
// frames unless aDirtyOnly is PR_TRUE in which case only reflow the dirty frames
|
1999-10-17 07:17:53 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowFrame::ReflowChildren(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
PRBool aDirtyOnly)
|
|
|
|
{
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-11-20 04:01:25 +03:00
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
|
|
|
PRBool borderCollapse = (((nsTableFrame*)aTableFrame.GetFirstInFlow())->IsBorderCollapse());
|
|
|
|
|
2001-03-22 18:59:37 +03:00
|
|
|
nsIFrame* tablePrevInFlow;
|
2002-02-19 18:48:28 +03:00
|
|
|
aTableFrame.GetPrevInFlow(&tablePrevInFlow);
|
2004-03-03 21:24:20 +03:00
|
|
|
PRBool isPaginated = aPresContext->IsPaginated();
|
2001-03-13 09:38:59 +03:00
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
nscoord cellSpacingX = aTableFrame.GetCellSpacingX();
|
2001-03-13 09:38:59 +03: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 23:15:56 +04:00
|
|
|
? eTableLTR : eTableDIR;
|
2004-01-18 13:28:40 +03:00
|
|
|
nsTableIterator iter(*this, dir);
|
2001-03-13 09:38:59 +03:00
|
|
|
// remember the col index of the previous cell to handle rowspans into this row
|
2002-02-19 18:48:28 +03:00
|
|
|
PRInt32 firstPrevColIndex = (iter.IsLeftToRight()) ? -1 : aTableFrame.GetColCount();
|
2001-03-13 09:38:59 +03:00
|
|
|
PRInt32 prevColIndex = firstPrevColIndex;
|
|
|
|
nscoord x = 0; // running total of children x offset
|
1999-05-04 23:15:56 +04:00
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool isAutoLayout = aTableFrame.IsAutoLayout();
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool needToNotifyTable = PR_TRUE;
|
2001-11-15 17:58:27 +03:00
|
|
|
nscoord paginatedHeight = 0;
|
2001-11-14 14:40:03 +03: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 22:22:41 +04:00
|
|
|
|
2001-11-14 14:40:03 +03:00
|
|
|
PRBool notifyStyleChange = PR_FALSE;
|
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowCommand* command = aReflowState.path->mReflowCommand;
|
|
|
|
if (command) {
|
2001-12-18 01:39:59 +03:00
|
|
|
nsReflowType type;
|
2002-05-10 22:22:41 +04:00
|
|
|
command->GetType(type);
|
2001-12-18 01:39:59 +03:00
|
|
|
if (eReflowType_StyleChanged == type) {
|
2001-11-14 14:40:03 +03:00
|
|
|
notifyStyleChange = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-07-11 02:56:13 +04:00
|
|
|
// Reflow each of our existing cell frames
|
1999-04-22 07:51:58 +04:00
|
|
|
nsIFrame* kidFrame = iter.First();
|
2001-03-13 09:38:59 +03:00
|
|
|
while (kidFrame) {
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom* frameType = kidFrame->GetType();
|
2001-11-05 03:15:51 +03:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// See if we should only reflow the dirty child frames
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool doReflowChild = PR_TRUE;
|
2003-07-07 06:01:29 +04:00
|
|
|
if (aDirtyOnly && ((kidFrame->GetStateBits() & NS_FRAME_IS_DIRTY) == 0)) {
|
2001-03-13 09:38:59 +03:00
|
|
|
doReflowChild = PR_FALSE;
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
2002-10-03 18:33:23 +04: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 17:51:12 +03:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (!isPaginated && (IS_TABLE_CELL(frameType) &&
|
2001-11-05 03:15:51 +03:00
|
|
|
!((nsTableCellFrame*)kidFrame)->NeedSpecialReflow())) {
|
|
|
|
kidFrame = iter.Next();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Reflow the child frame
|
|
|
|
if (doReflowChild) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (IS_TABLE_CELL(frameType)) {
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)kidFrame;
|
1999-08-03 06:41:27 +04:00
|
|
|
PRInt32 cellColIndex;
|
2001-03-13 09:38:59 +03:00
|
|
|
cellFrame->GetColIndex(cellColIndex);
|
2002-02-19 18:48:28 +03:00
|
|
|
cellColSpan = aTableFrame.GetEffectiveColSpan(*cellFrame);
|
2004-03-09 09:48:35 +03:00
|
|
|
|
2001-03-13 09:38:59 +03: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 18:48:28 +03:00
|
|
|
x += GetSpaceBetween(prevColIndex, cellColIndex, cellColSpan, aTableFrame,
|
2001-03-13 09:38:59 +03:00
|
|
|
cellSpacingX, iter.IsLeftToRight());
|
1998-09-16 04:48:14 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
// Calculate the available width for the table cell using the known column widths
|
2001-10-26 06:30:38 +04:00
|
|
|
nscoord availColWidth, availCellWidth;
|
2003-03-21 22:35:36 +03:00
|
|
|
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame), p2t,
|
2001-10-26 06:30:38 +04:00
|
|
|
*cellFrame, cellSpacingX, availColWidth, availCellWidth);
|
|
|
|
if (0 == availColWidth) availColWidth = NS_UNCONSTRAINEDSIZE;
|
|
|
|
if (0 == availCellWidth) availCellWidth = NS_UNCONSTRAINEDSIZE;
|
2001-03-13 09:38:59 +03:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// remember the rightmost (ltr) or leftmost (rtl) column this cell spans into
|
|
|
|
prevColIndex = (iter.IsLeftToRight()) ? cellColIndex + (cellColSpan - 1) : cellColIndex;
|
2003-09-13 20:26:30 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(PR_FALSE);
|
1999-08-03 06:41:27 +04:00
|
|
|
|
2001-08-06 18:04:58 +04:00
|
|
|
// If the avail width is not the same as last time we reflowed the cell or
|
|
|
|
// the cell wants to be bigger than what was available last time or
|
|
|
|
// it is a style change reflow or we are printing, then we must reflow the
|
|
|
|
// cell. Otherwise we can skip the reflow.
|
1999-08-03 06:41:27 +04:00
|
|
|
nsIFrame* kidNextInFlow;
|
|
|
|
kidFrame->GetNextInFlow(&kidNextInFlow);
|
2001-08-06 18:04:58 +04:00
|
|
|
nsSize cellDesiredSize = cellFrame->GetDesiredSize();
|
2002-04-11 01:32:41 +04:00
|
|
|
if ((availCellWidth != cellFrame->GetPriorAvailWidth()) ||
|
2001-08-06 18:04:58 +04:00
|
|
|
(cellDesiredSize.width > cellFrame->GetPriorAvailWidth()) ||
|
|
|
|
(eReflowReason_StyleChange == aReflowState.reason) ||
|
2001-11-05 03:15:51 +03:00
|
|
|
isPaginated ||
|
2002-05-09 18:44:02 +04:00
|
|
|
(cellFrame->NeedPass2Reflow() &&
|
|
|
|
NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) ||
|
2001-12-07 17:51:12 +03:00
|
|
|
(aReflowState.mFlags.mSpecialHeightReflow && cellFrame->NeedSpecialReflow()) ||
|
2002-04-11 01:32:41 +04:00
|
|
|
(!aReflowState.mFlags.mSpecialHeightReflow && cellFrame->HadSpecialReflow()) ||
|
|
|
|
HasPctHeight() ||
|
|
|
|
notifyStyleChange) {
|
2001-03-13 09:38:59 +03:00
|
|
|
// Reflow the cell to fit the available width, height
|
2001-10-26 06:30:38 +04:00
|
|
|
nsSize kidAvailSize(availColWidth, aReflowState.availableHeight);
|
2001-03-13 09:38:59 +03:00
|
|
|
nsReflowReason reason = eReflowReason_Resize;
|
2001-03-26 00:06:29 +04:00
|
|
|
PRBool cellToWatch = PR_FALSE;
|
1999-08-03 06:41:27 +04:00
|
|
|
// If it's a dirty frame, then check whether it's the initial reflow
|
2003-07-07 06:01:29 +04:00
|
|
|
if (kidFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
2001-03-13 09:38:59 +03:00
|
|
|
reason = eReflowReason_Initial;
|
2001-03-26 00:06:29 +04:00
|
|
|
cellToWatch = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (eReflowReason_StyleChange == aReflowState.reason) {
|
|
|
|
reason = eReflowReason_StyleChange;
|
|
|
|
cellToWatch = PR_TRUE;
|
|
|
|
}
|
2001-11-14 14:40:03 +03:00
|
|
|
else if (notifyStyleChange) {
|
|
|
|
reason = eReflowReason_StyleChange;
|
|
|
|
cellToWatch = PR_TRUE;
|
|
|
|
}
|
2001-03-26 00:06:29 +04:00
|
|
|
if (cellToWatch) {
|
2001-03-13 09:38:59 +03:00
|
|
|
cellFrame->DidSetStyleContext(aPresContext); // XXX check this
|
2001-03-22 18:59:37 +03:00
|
|
|
if (!tablePrevInFlow && isAutoLayout) {
|
2001-03-13 09:38:59 +03:00
|
|
|
// request the maximum width if availWidth is constrained
|
|
|
|
// XXX we could just do this always, but blocks have some problems
|
2001-10-26 06:30:38 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != availCellWidth) {
|
2001-03-13 09:38:59 +03:00
|
|
|
desiredSize.mFlags |= NS_REFLOW_CALC_MAX_WIDTH;
|
|
|
|
}
|
|
|
|
// request to get the max element size
|
2003-01-09 17:26:32 +03:00
|
|
|
desiredSize.mComputeMEW = PR_TRUE;
|
2001-03-26 00:06:29 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
cellToWatch = PR_FALSE;
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord oldMaxWidth = cellFrame->GetMaximumWidth();
|
2001-11-30 18:05:51 +03:00
|
|
|
nscoord oldMaxElemWidth = cellFrame->GetPass1MaxElementWidth();
|
2000-05-05 03:16:42 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// Reflow the child
|
|
|
|
nsTableCellReflowState kidReflowState(aPresContext, aReflowState,
|
|
|
|
kidFrame, kidAvailSize, reason);
|
2002-02-19 18:48:28 +03:00
|
|
|
InitChildReflowState(*aPresContext, kidAvailSize, borderCollapse, p2t, kidReflowState);
|
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
nsReflowStatus status;
|
1999-11-19 18:33:29 +03:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
|
2001-03-13 09:38:59 +03:00
|
|
|
x, 0, 0, status);
|
|
|
|
|
2001-03-26 00:06:29 +04:00
|
|
|
if (cellToWatch) {
|
2001-10-26 06:30:38 +04:00
|
|
|
nscoord maxWidth = (NS_UNCONSTRAINEDSIZE == availCellWidth)
|
2001-03-13 09:38:59 +03:00
|
|
|
? desiredSize.width : desiredSize.mMaximumWidth;
|
|
|
|
// save the max element width and max width
|
2003-01-09 17:26:32 +03:00
|
|
|
if (desiredSize.mComputeMEW) {
|
|
|
|
cellFrame->SetPass1MaxElementWidth(desiredSize.width, desiredSize.mMaxElementWidth);
|
|
|
|
if (desiredSize.mMaxElementWidth > desiredSize.width) {
|
2001-11-30 18:05:51 +03:00
|
|
|
NS_ASSERTION(PR_FALSE, "max element width exceeded desired width");
|
2003-01-09 17:26:32 +03:00
|
|
|
desiredSize.width = desiredSize.mMaxElementWidth;
|
2001-11-30 18:05:51 +03:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
}
|
|
|
|
cellFrame->SetMaximumWidth(maxWidth);
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// allow the table to determine if/how the table needs to be rebalanced
|
2001-03-26 00:06:29 +04:00
|
|
|
if (cellToWatch && needToNotifyTable) {
|
2002-02-19 18:48:28 +03:00
|
|
|
needToNotifyTable = !aTableFrame.CellChangedWidth(*cellFrame, oldMaxWidth, oldMaxElemWidth);
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If any of the cells are not complete, then we're not complete
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(status)) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
else {
|
2003-12-13 01:58:25 +03:00
|
|
|
desiredSize.width = cellDesiredSize.width;
|
|
|
|
desiredSize.height = cellDesiredSize.height;
|
|
|
|
nsRect *overflowArea =
|
|
|
|
cellFrame->GetOverflowAreaProperty(aPresContext);
|
|
|
|
if (overflowArea)
|
|
|
|
desiredSize.mOverflowArea = *overflowArea;
|
|
|
|
else
|
|
|
|
desiredSize.mOverflowArea.SetRect(0, 0, cellDesiredSize.width,
|
|
|
|
cellDesiredSize.height);
|
2003-09-13 20:26:30 +04:00
|
|
|
|
2002-04-07 22:26:35 +04: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 07:42:21 +04:00
|
|
|
if (!aTableFrame.GetStyleDisplay()->IsFloating()) {
|
2002-04-07 22:26:35 +04: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...
|
|
|
|
nsTableFrame::RePositionViews(aPresContext, kidFrame);
|
|
|
|
}
|
1998-10-06 04:27:22 +04:00
|
|
|
}
|
2001-11-15 17:58:27 +03:00
|
|
|
|
2002-03-27 08:50:24 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
|
|
|
|
if (!mPrevInFlow) {
|
|
|
|
// 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 17:58:27 +03:00
|
|
|
// height may have changed, adjust descent to absorb any excess difference
|
|
|
|
nscoord ascent = cellFrame->GetDesiredAscent();
|
|
|
|
nscoord descent = desiredSize.height - ascent;
|
2002-02-19 18:48:28 +03:00
|
|
|
UpdateHeight(desiredSize.height, ascent, descent, &aTableFrame, cellFrame);
|
2001-11-15 17:58:27 +03:00
|
|
|
}
|
|
|
|
else {
|
2002-03-27 08:50:24 +03:00
|
|
|
paginatedHeight = PR_MAX(paginatedHeight, desiredSize.height);
|
2002-02-19 18:48:28 +03:00
|
|
|
PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan((nsTableCellFrame&)*kidFrame);
|
2002-03-27 08:50:24 +03:00
|
|
|
if (1 == rowSpan) {
|
2001-11-15 17:58:27 +03:00
|
|
|
SetContentHeight(paginatedHeight);
|
|
|
|
}
|
|
|
|
}
|
2000-06-05 12:25:11 +04:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Place the child
|
2001-10-26 06:30:38 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != availColWidth) {
|
|
|
|
desiredSize.width = PR_MAX(availCellWidth, availColWidth);
|
|
|
|
}
|
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, nsnull, desiredSize, x, 0, 0);
|
2003-09-13 20:26:30 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
x += desiredSize.width;
|
1998-09-16 04:48:14 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
else {// it's an unknown frame type, give it a generic reflow and ignore the results
|
|
|
|
nsTableCellReflowState kidReflowState(aPresContext, aReflowState,
|
2000-05-05 03:16:42 +04:00
|
|
|
kidFrame, nsSize(0,0), eReflowReason_Resize);
|
2002-02-19 18:48:28 +03:00
|
|
|
InitChildReflowState(*aPresContext, nsSize(0,0), PR_FALSE, p2t, kidReflowState);
|
2003-09-13 20:26:30 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(PR_FALSE);
|
1999-08-03 06:41:27 +04:00
|
|
|
nsReflowStatus status;
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, 0, 0, 0, status);
|
2001-12-07 17:51:12 +03:00
|
|
|
kidFrame->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
|
1998-09-16 04:48:14 +04:00
|
|
|
}
|
1998-10-23 21:24:57 +04:00
|
|
|
}
|
2003-10-31 23:19:18 +03:00
|
|
|
else if (IS_TABLE_CELL(frameType)) {
|
2000-11-15 17:59:47 +03:00
|
|
|
// we need to account for the cell's width even if it isn't reflowed
|
2003-07-07 06:01:29 +04:00
|
|
|
x += kidFrame->GetSize().width;
|
2000-11-15 17:59:47 +03:00
|
|
|
}
|
2003-09-13 20:26:30 +04:00
|
|
|
ConsiderChildOverflow(aPresContext, aDesiredSize.mOverflowArea, kidFrame);
|
1999-04-22 07:51:58 +04:00
|
|
|
kidFrame = iter.Next(); // Get the next child
|
2004-03-09 09:48:35 +03:00
|
|
|
x += cellSpacingX;
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// just set our width to what was available. The table will calculate the width and not use our value.
|
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
2002-03-27 08:50:24 +03:00
|
|
|
|
2002-03-31 21:44:57 +04:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
|
|
|
aDesiredSize.height = mRect.height;
|
|
|
|
}
|
|
|
|
else if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
|
2002-03-27 08:50:24 +03:00
|
|
|
aDesiredSize.height = CalcHeight(aReflowState);
|
|
|
|
if (mPrevInFlow) {
|
|
|
|
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 20:26:30 +04:00
|
|
|
nsRect rowRect(0, 0, aDesiredSize.width, aDesiredSize.height);
|
|
|
|
aDesiredSize.mOverflowArea.UnionRect(aDesiredSize.mOverflowArea, rowRect);
|
|
|
|
StoreOverflow(aPresContext, aDesiredSize);
|
1998-10-20 19:59:56 +04:00
|
|
|
return rv;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD nsTableRowFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-07-01 07:03:32 +04:00
|
|
|
{
|
2001-11-05 03:15:51 +03:00
|
|
|
CalcHeight(aReflowState); // need to recalculate it based on last reflow sizes
|
2000-05-26 02:40:21 +04:00
|
|
|
|
2002-05-10 22:22:41 +04: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 20:32:45 +04:00
|
|
|
}
|
1998-07-14 19:29:50 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowFrame::IR_TargetIsMe(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_FRAME_COMPLETE;
|
|
|
|
|
2001-12-18 01:39:59 +03:00
|
|
|
nsReflowType type;
|
2002-05-10 22:22:41 +04:00
|
|
|
aReflowState.path->mReflowCommand->GetType(type);
|
2001-03-13 09:38:59 +03:00
|
|
|
switch (type) {
|
2001-12-18 01:39:59 +03:00
|
|
|
case eReflowType_ReflowDirty:
|
2001-03-13 09:38:59 +03:00
|
|
|
// Reflow the dirty child frames. Typically this is newly added frames.
|
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus, PR_TRUE);
|
|
|
|
break;
|
2001-12-18 01:39:59 +03:00
|
|
|
case eReflowType_StyleChanged :
|
2001-03-13 09:38:59 +03:00
|
|
|
rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus);
|
|
|
|
break;
|
2001-12-18 01:39:59 +03:00
|
|
|
case eReflowType_ContentChanged :
|
2001-03-13 09:38:59 +03: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 04:27:22 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowFrame::IR_StyleChanged(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-30 10:57:44 +03:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// we presume that all the easy optimizations were done in the nsHTMLStyleSheet before we were called here
|
|
|
|
// XXX: we can optimize this when we know which style attribute changed
|
2001-03-13 09:38:59 +03:00
|
|
|
aTableFrame.SetNeedStrategyInit(PR_TRUE);
|
2001-11-14 14:40:03 +03:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus, PR_FALSE);
|
1998-10-30 10:57:44 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame* aNextFrame)
|
1998-10-14 20:32:45 +04:00
|
|
|
|
|
|
|
{
|
2001-03-13 09:38:59 +03:00
|
|
|
if (!aNextFrame) return NS_ERROR_NULL_POINTER;
|
|
|
|
nsresult rv = NS_OK;
|
1998-10-14 20:32:45 +04:00
|
|
|
|
2003-03-21 22:35:36 +03:00
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool isAutoLayout = aTableFrame.IsAutoLayout();
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleDisplay* childDisplay = aNextFrame->GetStyleDisplay();
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == childDisplay->mDisplay) {
|
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)aNextFrame;
|
|
|
|
// Get the x coord of the cell
|
2003-07-07 06:01:29 +04:00
|
|
|
nsPoint cellOrigin = cellFrame->GetPosition();
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1999-08-22 01:24:42 +04:00
|
|
|
// At this point, we know the column widths. Compute the cell available width
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 cellColIndex;
|
2001-03-13 09:38:59 +03:00
|
|
|
cellFrame->GetColIndex(cellColIndex);
|
|
|
|
nscoord cellSpacingX = aTableFrame.GetCellSpacingX();
|
1999-08-22 00:16:32 +04:00
|
|
|
|
2001-10-26 06:30:38 +04:00
|
|
|
nscoord colAvailWidth, cellAvailWidth;
|
2003-03-21 22:35:36 +03:00
|
|
|
CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame), p2t,
|
2001-10-26 06:30:38 +04:00
|
|
|
*cellFrame, cellSpacingX, colAvailWidth, cellAvailWidth);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
|
|
|
// Always let the cell be as high as it wants. We ignore the height that's
|
|
|
|
// passed in and always place the entire row. Let the row group decide
|
|
|
|
// whether we fit or wehther the entire row is pushed
|
2001-03-13 09:38:59 +03:00
|
|
|
nsSize cellAvailSize(cellAvailWidth, NS_UNCONSTRAINEDSIZE);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
|
|
|
// Pass along the reflow command
|
2000-01-11 18:55:31 +03:00
|
|
|
// Unless this is a fixed-layout table, then have the cell incrementally
|
2001-03-13 09:38:59 +03:00
|
|
|
// update its maximum width.
|
2003-01-09 17:26:32 +03:00
|
|
|
nsHTMLReflowMetrics cellMet(PR_TRUE,
|
|
|
|
isAutoLayout ? NS_REFLOW_CALC_MAX_WIDTH : 0);
|
2002-02-19 18:48:28 +03:00
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
|
|
|
nsTableCellReflowState kidRS(aPresContext, aReflowState, aNextFrame, cellAvailSize,
|
|
|
|
aReflowState.reason);
|
2002-09-09 22:46:06 +04: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();
|
|
|
|
InitChildReflowState(*aPresContext, cellAvailSize, aTableFrame.IsBorderCollapse(),
|
|
|
|
p2t, kidRS, resetComputedWidth);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1999-08-29 08:18:00 +04:00
|
|
|
// Remember the current desired size, we'll need it later
|
2001-11-30 18:05:51 +03:00
|
|
|
nscoord oldCellMinWidth = cellFrame->GetPass1MaxElementWidth();
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord oldCellMaximumWidth = cellFrame->GetMaximumWidth();
|
|
|
|
nsSize oldCellDesSize = cellFrame->GetDesiredSize();
|
|
|
|
nscoord oldCellDesAscent = cellFrame->GetDesiredAscent();
|
2000-06-05 12:25:11 +04:00
|
|
|
nscoord oldCellDesDescent = oldCellDesSize.height - oldCellDesAscent;
|
1999-08-29 08:18:00 +04:00
|
|
|
|
|
|
|
// Reflow the cell passing it the incremental reflow command. We can't pass
|
|
|
|
// in a max width of NS_UNCONSTRAINEDSIZE, because the max width must match
|
1998-10-14 20:32:45 +04:00
|
|
|
// the width of the previous reflow...
|
2000-05-26 02:40:21 +04:00
|
|
|
rv = ReflowChild(aNextFrame, aPresContext, cellMet, kidRS,
|
2001-03-13 09:38:59 +03:00
|
|
|
cellOrigin.x, 0, 0, aStatus);
|
2000-05-26 02:40:21 +04:00
|
|
|
nsSize initCellDesSize(cellMet.width, cellMet.height);
|
2000-06-05 12:25:11 +04:00
|
|
|
nscoord initCellDesAscent = cellMet.ascent;
|
|
|
|
nscoord initCellDesDescent = cellMet.descent;
|
1999-08-29 08:18:00 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// cache the max-elem and maximum widths
|
2003-01-09 17:26:32 +03:00
|
|
|
cellFrame->SetPass1MaxElementWidth(cellMet.width, cellMet.mMaxElementWidth);
|
2001-03-13 09:38:59 +03:00
|
|
|
cellFrame->SetMaximumWidth(cellMet.mMaximumWidth);
|
2000-01-11 18:55:31 +03:00
|
|
|
|
1999-08-22 00:16:32 +04:00
|
|
|
// Calculate the cell's actual size given its pass2 size. This function
|
|
|
|
// takes into account the specified height (in the style), and any special
|
|
|
|
// logic needed for backwards compatibility
|
2000-05-26 02:40:21 +04:00
|
|
|
CalculateCellActualSize(aNextFrame, cellMet.width, cellMet.height, cellAvailWidth);
|
2000-07-28 13:19:26 +04:00
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
// height may have changed, adjust descent to absorb any excess difference
|
|
|
|
cellMet.descent = cellMet.height - cellMet.ascent;
|
2000-05-26 02:40:21 +04:00
|
|
|
|
|
|
|
// if the cell got shorter and it may have been the tallest, recalc the tallest cell
|
|
|
|
PRBool tallestCellGotShorter = PR_FALSE;
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool hasVerticalAlignBaseline = cellFrame->HasVerticalAlignBaseline();
|
2000-06-05 12:25:11 +04:00
|
|
|
if (!hasVerticalAlignBaseline) {
|
|
|
|
// only the height matters
|
|
|
|
tallestCellGotShorter =
|
2001-11-05 03:15:51 +03:00
|
|
|
TallestCellGotShorter(oldCellDesSize.height, cellMet.height, GetHeight());
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// the ascent matters
|
|
|
|
tallestCellGotShorter =
|
2000-12-22 02:03:42 +03:00
|
|
|
TallestCellGotShorter(oldCellDesAscent, cellMet.ascent, mMaxCellAscent);
|
2000-06-05 12:25:11 +04:00
|
|
|
// the descent of cells without rowspan also matters
|
|
|
|
if (!tallestCellGotShorter) {
|
2001-03-13 09:38:59 +03:00
|
|
|
PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan(*cellFrame);
|
2000-06-05 12:25:11 +04:00
|
|
|
if (rowSpan == 1) {
|
|
|
|
tallestCellGotShorter =
|
2002-10-01 23:40:28 +04:00
|
|
|
TallestCellGotShorter(oldCellDesDescent, cellMet.descent, mMaxCellDescent);
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tallestCellGotShorter) {
|
2001-11-05 03:15:51 +03:00
|
|
|
CalcHeight(aReflowState);
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
|
|
|
else {
|
2001-11-05 03:15:51 +03:00
|
|
|
UpdateHeight(cellMet.height, cellMet.ascent, cellMet.descent, &aTableFrame, cellFrame);
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
1998-08-07 06:11:51 +04:00
|
|
|
|
2000-05-26 02:40:21 +04:00
|
|
|
// if the cell's desired size didn't changed, our height is unchanged
|
|
|
|
aDesiredSize.mNothingChanged = PR_FALSE;
|
2001-03-13 09:38:59 +03:00
|
|
|
PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan(*cellFrame);
|
2001-07-14 03:49:30 +04:00
|
|
|
if ((initCellDesSize.width == oldCellDesSize.width) &&
|
|
|
|
(initCellDesSize.height == oldCellDesSize.height) &&
|
|
|
|
(oldCellMaximumWidth == cellMet.mMaximumWidth)) {
|
2000-06-05 12:25:11 +04:00
|
|
|
if (!hasVerticalAlignBaseline) { // only the cell's height matters
|
2000-09-05 18:57:34 +04:00
|
|
|
aDesiredSize.mNothingChanged = PR_TRUE;
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
|
|
|
else { // cell's ascent and cell's descent matter
|
|
|
|
if (initCellDesAscent == oldCellDesAscent) {
|
|
|
|
if ((rowSpan == 1) && (initCellDesDescent == oldCellDesDescent)) {
|
|
|
|
aDesiredSize.mNothingChanged = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
aDesiredSize.height = (aDesiredSize.mNothingChanged) ? mRect.height : GetHeight();
|
2000-09-05 18:57:34 +04:00
|
|
|
if (1 == rowSpan) {
|
|
|
|
cellMet.height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
else {
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord heightOfRows = aDesiredSize.height + GetHeightOfRowsSpannedBelowFirst(*cellFrame, aTableFrame);
|
2000-09-05 18:57:34 +04:00
|
|
|
cellMet.height = PR_MAX(cellMet.height, heightOfRows);
|
|
|
|
// XXX need to check what happens when this height differs from height of the cell's previous mRect.height
|
|
|
|
}
|
2000-07-28 13:19:26 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// Now place the child
|
2001-10-26 06:30:38 +04:00
|
|
|
cellMet.width = colAvailWidth;
|
2001-12-07 17:51:12 +03:00
|
|
|
FinishReflowChild(aNextFrame, aPresContext, nsnull, cellMet, cellOrigin.x, 0, 0);
|
2001-03-13 09:38:59 +03:00
|
|
|
|
|
|
|
// Notify the table if the cell width changed so it can decide whether to rebalance
|
|
|
|
if (!aDesiredSize.mNothingChanged) {
|
2001-11-30 18:05:51 +03:00
|
|
|
aTableFrame.CellChangedWidth(*cellFrame, oldCellMinWidth, oldCellMaximumWidth);
|
2000-10-06 01:05:06 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// Return our desired size. Note that our desired width is just whatever width
|
|
|
|
// we were given by the row group frame
|
2001-03-13 09:38:59 +03:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
2000-05-26 02:40:21 +04:00
|
|
|
if (!aDesiredSize.mNothingChanged) {
|
|
|
|
if (aDesiredSize.height == mRect.height) { // our height didn't change
|
2001-03-13 09:38:59 +03:00
|
|
|
cellFrame->VerticallyAlignChild(aPresContext, aReflowState, mMaxCellAscent);
|
2003-07-07 06:01:29 +04:00
|
|
|
nsRect dirtyRect = cellFrame->GetRect();
|
2000-05-26 02:40:21 +04:00
|
|
|
dirtyRect.height = mRect.height;
|
2003-09-13 20:26:30 +04:00
|
|
|
ConsiderChildOverflow(aPresContext, aDesiredSize.mOverflowArea, cellFrame);
|
|
|
|
dirtyRect.UnionRect(dirtyRect, aDesiredSize.mOverflowArea);
|
2004-03-10 06:09:05 +03:00
|
|
|
Invalidate(dirtyRect);
|
2000-05-26 02:40:21 +04:00
|
|
|
}
|
|
|
|
}
|
2004-01-28 21:44:41 +03:00
|
|
|
else { // we dont realign vertical but we need to update the overflow area
|
|
|
|
nsIFrame* cellKidFrame = cellFrame->GetFirstChild(nsnull);
|
|
|
|
if (cellKidFrame) {
|
|
|
|
cellFrame->ConsiderChildOverflow(aPresContext, cellMet.mOverflowArea, cellKidFrame);
|
|
|
|
cellFrame->StoreOverflow(aPresContext, cellMet);
|
2004-03-28 19:13:31 +04:00
|
|
|
if (cellFrame->HasView()) {
|
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, cellFrame, cellFrame->GetView(), &cellMet.mOverflowArea, 0);
|
|
|
|
}
|
|
|
|
}
|
2004-01-28 21:44:41 +03:00
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // pass reflow to unknown frame child
|
|
|
|
// aDesiredSize does not change
|
|
|
|
}
|
2004-01-28 21:44:41 +03:00
|
|
|
|
|
|
|
// recover the overflow area
|
|
|
|
aDesiredSize.mOverflowArea = nsRect(0, 0, mRect.width, mRect.height);
|
|
|
|
for (nsIFrame* cell = mFrames.FirstChild(); cell; cell = cell->GetNextSibling()) {
|
|
|
|
ConsiderChildOverflow(aPresContext, aDesiredSize.mOverflowArea, cell);
|
|
|
|
}
|
|
|
|
StoreOverflow(aPresContext, aDesiredSize);
|
2000-01-17 20:45:17 +03:00
|
|
|
// When returning whether we're complete we need to look at each of our cell
|
|
|
|
// frames. If any of them has a continuing frame, then we're not complete. We
|
|
|
|
// can't just return the status of the cell frame we just reflowed...
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
if (mNextInFlow) {
|
2003-07-07 06:01:29 +04:00
|
|
|
for (nsIFrame* cell = mFrames.FirstChild(); cell;
|
|
|
|
cell = cell->GetNextSibling()) {
|
2000-01-17 20:45:17 +03:00
|
|
|
nsIFrame* contFrame;
|
|
|
|
|
|
|
|
cell->GetNextInFlow(&contFrame);
|
|
|
|
if (contFrame) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
1998-07-01 07:03:32 +04:00
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
/** Layout the entire row.
|
1998-07-02 09:39:10 +04:00
|
|
|
* This method stacks cells horizontally according to HTML 4.0 rules.
|
1998-04-23 21:29:07 +04:00
|
|
|
*/
|
|
|
|
NS_METHOD
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
2000-04-22 01:36:33 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableRowFrame", aReflowState.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2001-10-29 04:43:59 +03:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 18:55:51 +03:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState);
|
|
|
|
#endif
|
1999-08-19 23:52:37 +04:00
|
|
|
nsresult rv = NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
1998-10-14 20:32:45 +04:00
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (!tableFrame) return NS_ERROR_NULL_POINTER;
|
1999-08-02 02:01:37 +04:00
|
|
|
|
2002-04-01 10:46:17 +04:00
|
|
|
// see if a special height reflow needs to occur due to having a pct height
|
2002-04-11 01:32:41 +04:00
|
|
|
if (!NeedSpecialReflow())
|
|
|
|
nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState);
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
switch (aReflowState.reason) {
|
1998-07-11 02:56:13 +04:00
|
|
|
case eReflowReason_Initial:
|
2001-04-02 07:21:58 +04:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE);
|
1998-07-11 02:56:13 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eReflowReason_Resize:
|
2002-11-08 08:29:34 +03:00
|
|
|
case eReflowReason_StyleChange:
|
|
|
|
case eReflowReason_Dirty:
|
2001-03-13 09:38:59 +03:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE);
|
1998-07-11 02:56:13 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eReflowReason_Incremental:
|
2001-03-13 09:38:59 +03:00
|
|
|
rv = IncrementalReflow(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus);
|
1998-07-11 02:56:13 +04:00
|
|
|
break;
|
2001-11-25 23:38:30 +03:00
|
|
|
default:
|
|
|
|
NS_ASSERTION(PR_FALSE , "we should handle this reflow reason");
|
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
1998-07-11 02:56:13 +04:00
|
|
|
}
|
1998-07-02 09:39:10 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// just set our width to what was available. The table will calculate the width and not use our value.
|
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
1999-08-31 02:30:32 +04:00
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
2001-11-05 03:15:51 +03:00
|
|
|
SetNeedSpecialReflow(PR_FALSE);
|
|
|
|
}
|
|
|
|
|
2001-10-29 04:43:59 +03:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 18:55:51 +03:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState, &aDesiredSize, aStatus);
|
|
|
|
#endif
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-22 06:28:00 +03:00
|
|
|
/**
|
|
|
|
* This function is called by the row group frame's SplitRowGroup() code when
|
|
|
|
* pushing a row frame that has cell frames that span into it. The cell frame
|
|
|
|
* should be reflowed with the specified height
|
|
|
|
*/
|
2001-04-16 18:51:52 +04:00
|
|
|
nscoord
|
|
|
|
nsTableRowFrame::ReflowCellFrame(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableCellFrame* aCellFrame,
|
|
|
|
nscoord aAvailableHeight,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-02-22 06:28:00 +03:00
|
|
|
{
|
2002-02-19 18:48:28 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame); if (!tableFrame) ABORT1(0);
|
|
|
|
|
1999-02-22 06:28:00 +03:00
|
|
|
// Reflow the cell frame with the specified height. Use the existing width
|
2003-07-07 06:01:29 +04:00
|
|
|
nsSize cellSize = aCellFrame->GetSize();
|
1999-02-22 06:28:00 +03:00
|
|
|
|
|
|
|
nsSize availSize(cellSize.width, aAvailableHeight);
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool borderCollapse = ((nsTableFrame*)tableFrame->GetFirstInFlow())->IsBorderCollapse();
|
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
2000-05-05 03:16:42 +04:00
|
|
|
nsTableCellReflowState cellReflowState(aPresContext, aReflowState, aCellFrame, availSize,
|
|
|
|
eReflowReason_Resize);
|
2002-02-19 18:48:28 +03:00
|
|
|
InitChildReflowState(*aPresContext, availSize, borderCollapse, p2t, cellReflowState);
|
|
|
|
|
2003-09-13 20:26:30 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(PR_FALSE);
|
1999-02-22 06:28:00 +03:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(aCellFrame, aPresContext, desiredSize, cellReflowState,
|
|
|
|
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
2002-10-03 18:33:23 +04:00
|
|
|
PRBool fullyComplete = NS_FRAME_IS_COMPLETE(aStatus) && !NS_FRAME_IS_TRUNCATED(aStatus);
|
|
|
|
|
2003-07-07 06:01:29 +04:00
|
|
|
aCellFrame->SetSize(
|
|
|
|
nsSize(cellSize.width, fullyComplete ? aAvailableHeight : desiredSize.height));
|
2001-04-16 18:51:52 +04:00
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
// XXX What happens if this cell has 'vertical-align: baseline' ?
|
|
|
|
// XXX Why is it assumed that the cell's ascent hasn't changed ?
|
2002-10-03 18:33:23 +04:00
|
|
|
if (fullyComplete) {
|
|
|
|
aCellFrame->VerticallyAlignChild(aPresContext, aReflowState, mMaxCellAscent);
|
|
|
|
}
|
2001-12-07 17:51:12 +03:00
|
|
|
aCellFrame->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
|
2001-04-16 18:51:52 +04:00
|
|
|
|
|
|
|
return desiredSize.height;
|
1999-02-22 06:28:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2001-04-16 18:51:52 +04:00
|
|
|
* These 3 functions are called by the row group frame's SplitRowGroup() code when
|
|
|
|
* it creates a continuing cell frame and wants to insert it into the row's child list
|
1999-02-22 06:28:00 +03:00
|
|
|
*/
|
2001-04-16 18:51:52 +04:00
|
|
|
void
|
|
|
|
nsTableRowFrame::InsertCellFrame(nsTableCellFrame* aFrame,
|
|
|
|
nsTableCellFrame* aPrevSibling)
|
1999-02-22 06:28:00 +03:00
|
|
|
{
|
|
|
|
mFrames.InsertFrame(nsnull, aPrevSibling, aFrame);
|
2001-04-16 18:51:52 +04:00
|
|
|
aFrame->SetParent(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableRowFrame::InsertCellFrame(nsTableCellFrame* aFrame,
|
|
|
|
PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
// Find the cell frame where col index < aColIndex
|
|
|
|
nsTableCellFrame* priorCell = nsnull;
|
2003-07-07 06:01:29 +04:00
|
|
|
for (nsIFrame* child = mFrames.FirstChild(); child;
|
|
|
|
child = child->GetNextSibling()) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (!IS_TABLE_CELL(child->GetType())) {
|
2001-04-16 18:51:52 +04: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 18:48:56 +03:00
|
|
|
if (!mFrames.RemoveFrame(aFrame))
|
|
|
|
NS_ASSERTION(PR_FALSE, "frame not in list");
|
1999-02-22 06:28:00 +03:00
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsTableRowFrame::GetType() const
|
1999-02-24 08:54:31 +03:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::tableRowFrame;
|
1999-02-24 08:54:31 +03:00
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableRowFrame*
|
|
|
|
nsTableRowFrame::GetNextRow() const
|
|
|
|
{
|
2003-07-07 06:01:29 +04:00
|
|
|
nsIFrame* childFrame = GetNextSibling();
|
2001-11-05 03:15:51 +03:00
|
|
|
while (childFrame) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == childFrame->GetType()) {
|
2001-11-05 03:15:51 +03:00
|
|
|
return (nsTableRowFrame*)childFrame;
|
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
1999-02-24 08:54:31 +03:00
|
|
|
|
2001-11-29 18:41:07 +03:00
|
|
|
void
|
|
|
|
nsTableRowFrame::SetUnpaginatedHeight(nsIPresContext* aPresContext,
|
|
|
|
nscoord aValue)
|
|
|
|
{
|
2002-03-27 08:50:24 +03:00
|
|
|
NS_ASSERTION(!mPrevInFlow, "program error");
|
2001-11-29 18:41:07 +03:00
|
|
|
// Get the property
|
|
|
|
nscoord* value = (nscoord*)nsTableFrame::GetProperty(aPresContext, this, nsLayoutAtoms::rowUnpaginatedHeightProperty, PR_TRUE);
|
|
|
|
if (value) {
|
|
|
|
*value = aValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsTableRowFrame::GetUnpaginatedHeight(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
// See if the property is set
|
2002-03-27 08:50:24 +03:00
|
|
|
nscoord* value = (nscoord*)nsTableFrame::GetProperty(aPresContext, GetFirstInFlow(), nsLayoutAtoms::rowUnpaginatedHeightProperty);
|
2001-11-29 18:41:07 +03:00
|
|
|
if (value)
|
|
|
|
return *value;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-03-09 09:48:35 +03: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 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewTableRowFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsTableRowFrame* it = new (aPresShell) nsTableRowFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsTableRowFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 20:22:29 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableRow"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|