2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04: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-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.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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
|
2004-04-18 18:30:37 +04: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-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** 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"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsTableFrame.h"
|
|
|
|
#include "nsTableCellFrame.h"
|
1998-07-21 03:56:17 +04:00
|
|
|
#include "nsCSSRendering.h"
|
1999-07-28 12:09:02 +04:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsTableColGroupFrame.h"
|
|
|
|
#include "nsTableColFrame.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
1998-04-23 21:29:07 +04:00
|
|
|
|
2000-05-05 03:16:42 +04:00
|
|
|
struct nsTableCellReflowState : public nsHTMLReflowState
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsTableCellReflowState(nsPresContext* aPresContext,
|
2000-05-05 03:16:42 +04:00
|
|
|
const nsHTMLReflowState& aParentReflowState,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const nsSize& aAvailableSpace,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
PRBool aInit = PR_TRUE)
|
|
|
|
: nsHTMLReflowState(aPresContext, aParentReflowState, aFrame,
|
|
|
|
aAvailableSpace, -1, -1, aInit)
|
|
|
|
{
|
|
|
|
}
|
2000-05-05 03:16:42 +04:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
void FixUp(const nsSize& aAvailSpace);
|
2000-05-05 03:16:42 +04:00
|
|
|
};
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
void nsTableCellReflowState::FixUp(const nsSize& aAvailSpace)
|
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
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aAvailSpace.width,
|
|
|
|
"unconstrained available width in reflow");
|
2007-01-26 03:05:12 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != ComputedWidth()) {
|
2007-08-02 22:08:05 +04:00
|
|
|
nscoord computedWidth =
|
|
|
|
aAvailSpace.width - mComputedBorderPadding.LeftRight();
|
2007-01-26 03:05:12 +03:00
|
|
|
computedWidth = PR_MAX(0, computedWidth);
|
|
|
|
SetComputedWidth(computedWidth);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
2007-08-02 22:08:05 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != ComputedHeight() &&
|
|
|
|
NS_UNCONSTRAINEDSIZE != aAvailSpace.height) {
|
|
|
|
nscoord computedHeight =
|
|
|
|
aAvailSpace.height - mComputedBorderPadding.TopBottom();
|
|
|
|
computedHeight = PR_MAX(0, computedHeight);
|
|
|
|
SetComputedHeight(computedHeight);
|
2002-02-19 18:48:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowFrame::InitChildReflowState(nsPresContext& aPresContext,
|
2002-02-19 18:48:28 +03:00
|
|
|
const nsSize& aAvailSize,
|
|
|
|
PRBool aBorderCollapse,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsTableCellReflowState& aReflowState)
|
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) {
|
2007-02-07 10:46:44 +03:00
|
|
|
pCollapseBorder = bcCellFrame->GetBorderWidth(collapseBorder);
|
2002-02-19 18:48:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
aReflowState.Init(&aPresContext, -1, -1, pCollapseBorder);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
aReflowState.FixUp(aAvailSize);
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------- nsTableRowFrame ---------- */
|
1998-04-23 21:29:07 +04:00
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsTableRowFrame::nsTableRowFrame(nsStyleContext* aContext)
|
|
|
|
: nsHTMLContainerFrame(aContext)
|
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
|
|
|
}
|
|
|
|
|
|
|
|
nsTableRowFrame::~nsTableRowFrame()
|
|
|
|
{
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-25 08:31:15 +03:00
|
|
|
NS_IMETHODIMP
|
2006-03-09 21:55:21 +03:00
|
|
|
nsTableRowFrame::Init(nsIContent* aContent,
|
1999-02-25 08:31:15 +03:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
2005-11-21 01:05:24 +03:00
|
|
|
// Let the base class do its initialization
|
2006-03-27 01:30:36 +04:00
|
|
|
rv = nsHTMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
1999-02-25 08:31:15 +03:00
|
|
|
|
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
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableRowFrame::AppendFrames(nsIAtom* aListName,
|
1999-08-03 06:41:27 +04:00
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Append the frames
|
|
|
|
mFrames.AppendFrames(nsnull, aFrameList);
|
|
|
|
|
|
|
|
// Add the new cell frames to the table
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame *tableFrame = nsTableFrame::GetTableFrame(this);
|
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
|
2005-02-07 04:58:25 +03:00
|
|
|
tableFrame->AppendCell((nsTableCellFrame&)*childFrame, GetRowIndex());
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-06 23:16:51 +04:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2006-12-13 06:45:28 +03:00
|
|
|
tableFrame->SetGeometryDirty();
|
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
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableRowFrame::InsertFrames(nsIAtom* aListName,
|
1999-08-03 06:41:27 +04:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Get the table frame
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
1999-08-03 06:41:27 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// gather the new frames (only those which are cells) into an array
|
2006-12-26 20:47:52 +03:00
|
|
|
nsIAtom* cellFrameType = (tableFrame->IsBorderCollapse()) ? nsGkAtoms::bcTableCellFrame : nsGkAtoms::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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// insert the cells into the cell map
|
|
|
|
PRInt32 colIndex = -1;
|
|
|
|
if (prevCellFrame) {
|
|
|
|
prevCellFrame->GetColIndex(colIndex);
|
|
|
|
}
|
2005-02-07 04:58:25 +03:00
|
|
|
tableFrame->InsertCells(cellChildren, GetRowIndex(), colIndex);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
// Insert the frames in the frame list
|
1999-08-03 06:41:27 +04:00
|
|
|
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
|
|
|
|
|
2007-05-06 23:16:51 +04:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2006-12-13 06:45:28 +03:00
|
|
|
tableFrame->SetGeometryDirty();
|
1999-08-03 06:41:27 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableRowFrame::RemoveFrame(nsIAtom* aListName,
|
1999-08-03 06:41:27 +04:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
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
|
2005-02-07 04:58:25 +03:00
|
|
|
tableFrame->RemoveCell(cellFrame, GetRowIndex());
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
// Remove the frame and destroy it
|
2006-04-10 04:16:29 +04:00
|
|
|
mFrames.DestroyFrame(aOldFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2007-05-06 23:16:51 +04:00
|
|
|
PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2006-12-13 06:45:28 +03:00
|
|
|
tableFrame->SetGeometryDirty();
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
2006-06-29 06:32:36 +04:00
|
|
|
else {
|
|
|
|
NS_ERROR("unexpected frame type");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2006-12-14 02:04:57 +03:00
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsTableRowFrame::GetUsedMargin() const
|
|
|
|
{
|
|
|
|
return nsMargin(0,0,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsTableRowFrame::GetUsedBorder() const
|
|
|
|
{
|
|
|
|
return nsMargin(0,0,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsTableRowFrame::GetUsedPadding() const
|
|
|
|
{
|
|
|
|
return nsMargin(0,0,0,0);
|
|
|
|
}
|
|
|
|
|
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);) {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::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
|
2007-01-28 01:22:24 +03:00
|
|
|
nsTableRowFrame::DidResize()
|
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
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return;
|
2003-09-13 20:26:30 +04:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsTableIterator iter(*this);
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame* childFrame = iter.First();
|
2003-09-13 20:26:30 +04:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsHTMLReflowMetrics desiredSize;
|
2003-09-13 20:26:30 +04:00
|
|
|
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
|
2008-02-08 12:36:32 +03:00
|
|
|
nsRect cellRect = cellFrame->GetRect();
|
|
|
|
if (cellRect.height != cellHeight)
|
1998-11-20 04:01:25 +03:00
|
|
|
{
|
2008-02-08 12:36:32 +03:00
|
|
|
cellFrame->SetSize(nsSize(cellRect.width, cellHeight));
|
|
|
|
nsTableFrame::InvalidateFrame(cellFrame, cellRect, PR_FALSE);
|
1998-07-03 00:35:23 +04:00
|
|
|
}
|
2008-02-08 12:36:32 +03:00
|
|
|
|
|
|
|
// realign cell content based on the new height. We might be able to
|
|
|
|
// skip this if the height didn't change... maybe. Hard to tell.
|
|
|
|
cellFrame->VerticallyAlignChild(mMaxCellAscent);
|
|
|
|
|
|
|
|
// Always store the overflow, even if the height didn't change, since
|
|
|
|
// we'll lose part of our overflow area otherwise.
|
|
|
|
ConsiderChildOverflow(desiredSize.mOverflowArea, cellFrame);
|
|
|
|
|
|
|
|
// Note that if the cell's *content* needs to change in response
|
|
|
|
// to this height, it will get a special height reflow.
|
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
|
|
|
}
|
2004-07-16 20:56:21 +04:00
|
|
|
FinishAndStoreOverflow(&desiredSize);
|
2004-04-14 10:22:52 +04:00
|
|
|
if (HasView()) {
|
2007-03-31 01:11:41 +04:00
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(PresContext(), this, GetView(), &desiredSize.mOverflowArea, 0);
|
2004-04-14 10:22:52 +04:00
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2007-01-23 07:06:56 +03:00
|
|
|
nscoord nsTableRowFrame::GetRowBaseline()
|
2005-10-04 19:47:21 +04:00
|
|
|
{
|
|
|
|
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
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsTableIterator iter(*this);
|
2005-10-04 19:47:21 +04:00
|
|
|
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 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
|
|
|
{
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return 0;
|
2000-05-26 02:40:21 +04:00
|
|
|
|
2007-08-02 22:08:05 +04:00
|
|
|
nscoord computedHeight = (NS_UNCONSTRAINEDSIZE == aReflowState.ComputedHeight())
|
|
|
|
? 0 : aReflowState.ComputedHeight();
|
2001-11-05 03:15:51 +03:00
|
|
|
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();
|
2006-02-22 00:33:47 +03:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) && !GetPrevInFlow()) {
|
2001-11-29 18:41:07 +03:00
|
|
|
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
|
2005-10-04 19:47:21 +04:00
|
|
|
nscoord ascent;
|
|
|
|
if (!kidFrame->GetFirstChild(nsnull)->GetFirstChild(nsnull))
|
|
|
|
ascent = desSize.height;
|
|
|
|
else
|
2007-01-23 07:06:56 +03:00
|
|
|
ascent = ((nsTableCellFrame *)kidFrame)->GetCellBaseline();
|
2000-06-05 12:25:11 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03: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 23:43:18 +03:00
|
|
|
nsDisplayTableRowBackground(nsTableRowFrame* aFrame) : nsDisplayItem(aFrame) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayTableRowBackground);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayTableRowBackground() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayTableRowBackground);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-26 05:29:17 +03: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.
|
2007-07-08 11:08:04 +04:00
|
|
|
return static_cast<nsTableRowFrame*>(mFrame)->GetOverflowRect() +
|
2006-03-14 23:43:18 +03:00
|
|
|
aBuilder->ToReferenceFrame(mFrame);
|
2001-01-27 17:09:34 +03:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
|
|
|
const nsRect& aDirtyRect);
|
|
|
|
NS_DISPLAY_DECL_NAME("TableRowBackground")
|
|
|
|
};
|
1999-11-02 01:12:45 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
void
|
|
|
|
nsDisplayTableRowBackground::Paint(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIRenderingContext* aCtx, const nsRect& aDirtyRect) {
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(mFrame);
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsPoint pt = aBuilder->ToReferenceFrame(mFrame);
|
|
|
|
nsIRenderingContext::AutoPushTranslation translate(aCtx, pt.x, pt.y);
|
|
|
|
TableBackgroundPainter painter(tableFrame,
|
|
|
|
TableBackgroundPainter::eOrigin_TableRow,
|
2007-03-31 01:11:41 +04:00
|
|
|
mFrame->PresContext(), *aCtx,
|
2006-01-26 05:29:17 +03:00
|
|
|
aDirtyRect - pt);
|
2007-07-08 11:08:04 +04:00
|
|
|
painter.PaintRow(static_cast<nsTableRowFrame*>(mFrame));
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2004-03-09 09:48:35 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
if (!IsVisibleInSelection(aBuilder))
|
|
|
|
return NS_OK;
|
1999-06-08 01:10:25 +04:00
|
|
|
|
2006-04-18 02:16:24 +04:00
|
|
|
PRBool isRoot = aBuilder->IsAtRootOfPseudoStackingContext();
|
|
|
|
if (isRoot) {
|
2006-01-26 05:29:17 +03: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 08:36:16 +03:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2006-04-18 02:16:24 +04:00
|
|
|
return nsTableFrame::DisplayGenericTablePart(aBuilder, this, aDirtyRect, aLists, isRoot);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
PRIntn
|
|
|
|
nsTableRowFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
2006-02-22 00:33:47 +03:00
|
|
|
if (nsnull != GetPrevInFlow()) {
|
1998-10-20 21:45:07 +04:00
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
2006-02-22 00:33:47 +03:00
|
|
|
if (nsnull != GetNextInFlow()) {
|
1998-10-20 21:45:07 +04:00
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2001-11-05 03:15:51 +03:00
|
|
|
|
|
|
|
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,
|
|
|
|
nsTableCellFrame& aCellFrame,
|
|
|
|
nscoord aCellSpacingX,
|
|
|
|
nscoord& aColAvailWidth,
|
|
|
|
nscoord& aCellAvailWidth)
|
1999-08-22 00:16:32 +04:00
|
|
|
{
|
2004-10-29 21:31:53 +04:00
|
|
|
aColAvailWidth = aCellAvailWidth = NS_UNCONSTRAINEDSIZE;
|
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);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aColAvailWidth) {
|
|
|
|
aColAvailWidth = colWidth;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aColAvailWidth += colWidth;
|
2002-09-09 22:46:06 +04:00
|
|
|
}
|
|
|
|
if ((spanX > 0) && (aTableFrame.GetNumCellsOriginatingInCol(colIndex + spanX) > 0)) {
|
|
|
|
cellSpacing += aCellSpacingX;
|
2001-10-26 06:30:38 +04:00
|
|
|
}
|
|
|
|
}
|
2004-10-29 21:31:53 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aColAvailWidth) {
|
2002-09-09 22:46:06 +04:00
|
|
|
aColAvailWidth += cellSpacing;
|
|
|
|
}
|
|
|
|
aCellAvailWidth = aColAvailWidth;
|
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,
|
2006-03-04 08:26:57 +03:00
|
|
|
PRBool aIsLeftToRight,
|
|
|
|
PRBool aCheckVisibility)
|
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++) {
|
2006-03-04 08:26:57 +03: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 09:38:59 +03:00
|
|
|
space += aCellSpacingX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
PRInt32 lastCol = aColIndex + aColSpan - 1;
|
|
|
|
for (colX = aPrevColIndex - 1; colX > lastCol; colX--) {
|
2006-03-04 08:26:57 +03: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 09:38:59 +03:00
|
|
|
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
|
|
|
|
2002-03-27 08:50:24 +03:00
|
|
|
// subtract the heights of aRow's prev in flows from the unpaginated height
|
|
|
|
static
|
2004-08-01 03:15:21 +04:00
|
|
|
nscoord CalcHeightFromUnpaginatedHeight(nsPresContext* aPresContext,
|
2002-03-27 08:50:24 +03:00
|
|
|
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;
|
2004-09-14 06:28:03 +04:00
|
|
|
prevInFlow = prevInFlow->GetPrevInFlow()) {
|
2003-07-07 06:01:29 +04:00
|
|
|
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
|
|
|
NS_METHOD
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsReflowStatus& aStatus)
|
2001-03-13 09:38:59 +03:00
|
|
|
{
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-11-20 04:01:25 +03:00
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool borderCollapse = (((nsTableFrame*)aTableFrame.GetFirstInFlow())->IsBorderCollapse());
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// XXXldb Should we be checking constrained height instead?
|
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
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsTableIterator iter(*this);
|
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
|
|
|
|
2001-11-15 17:58:27 +03:00
|
|
|
nscoord paginatedHeight = 0;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
1998-07-11 02:56:13 +04:00
|
|
|
// Reflow each of our existing cell frames
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
for (nsIFrame* kidFrame = iter.First(); kidFrame; kidFrame = iter.Next()) {
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom* frameType = kidFrame->GetType();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (!IS_TABLE_CELL(frameType)) {
|
|
|
|
// XXXldb nsCSSFrameConstructor needs to enforce this!
|
|
|
|
NS_NOTREACHED("yikes, a non-row child");
|
|
|
|
|
|
|
|
// it's an unknown frame type, give it a generic reflow and ignore the results
|
|
|
|
nsTableCellReflowState kidReflowState(aPresContext, aReflowState,
|
|
|
|
kidFrame, nsSize(0,0), PR_FALSE);
|
2007-02-07 10:46:44 +03:00
|
|
|
InitChildReflowState(*aPresContext, nsSize(0,0), PR_FALSE, kidReflowState);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsHTMLReflowMetrics desiredSize;
|
|
|
|
nsReflowStatus status;
|
|
|
|
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, 0, 0, 0, status);
|
|
|
|
kidFrame->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-07-08 11:08:04 +04:00
|
|
|
nsTableCellFrame* cellFrame = static_cast<nsTableCellFrame*>(kidFrame);
|
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;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (!aReflowState.ShouldReflowAllKids() &&
|
2006-12-13 06:45:28 +03:00
|
|
|
!aTableFrame.IsGeometryDirty() &&
|
2007-05-06 23:16:51 +04:00
|
|
|
!NS_SUBTREE_DIRTY(kidFrame)) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (!aReflowState.mFlags.mSpecialHeightReflow)
|
|
|
|
doReflowChild = PR_FALSE;
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
else if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight)) {
|
2002-10-03 18:33:23 +04:00
|
|
|
// We don't reflow a rowspan >1 cell here with a constrained height.
|
|
|
|
// That happens in nsTableRowGroupFrame::SplitSpanningCells.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (aTableFrame.GetEffectiveRowSpan(*cellFrame) > 1) {
|
2002-10-03 18:33:23 +04:00
|
|
|
doReflowChild = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2001-12-07 17:51:12 +03:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (!isPaginated && !(cellFrame->GetStateBits() &
|
|
|
|
NS_FRAME_CONTAINS_RELATIVE_HEIGHT)) {
|
2001-11-05 03:15:51 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
PRInt32 cellColIndex;
|
|
|
|
cellFrame->GetColIndex(cellColIndex);
|
|
|
|
cellColSpan = aTableFrame.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, aTableFrame,
|
|
|
|
cellSpacingX, iter.IsLeftToRight(), PR_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// remember the rightmost (ltr) or leftmost (rtl) column this cell spans into
|
|
|
|
prevColIndex = (iter.IsLeftToRight()) ? cellColIndex + (cellColSpan - 1) : cellColIndex;
|
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Reflow the child frame
|
2008-02-08 12:36:32 +03:00
|
|
|
nsRect kidRect = kidFrame->GetRect();
|
|
|
|
PRBool firstReflow =
|
|
|
|
(kidFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
|
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
if (doReflowChild) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// Calculate the available width for the table cell using the known column widths
|
|
|
|
nscoord availColWidth, availCellWidth;
|
2007-01-28 01:22:24 +03:00
|
|
|
CalcAvailWidth(aTableFrame, *cellFrame, cellSpacingX,
|
|
|
|
availColWidth, availCellWidth);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
nsHTMLReflowMetrics desiredSize;
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
// XXXldb Why is this condition distinct from doReflowChild above?
|
|
|
|
nsSize cellDesiredSize = cellFrame->GetDesiredSize();
|
|
|
|
if ((availCellWidth != cellFrame->GetPriorAvailWidth()) ||
|
|
|
|
(cellDesiredSize.width > cellFrame->GetPriorAvailWidth()) ||
|
|
|
|
(GetStateBits() & NS_FRAME_IS_DIRTY) ||
|
|
|
|
isPaginated ||
|
2007-05-06 23:16:51 +04:00
|
|
|
NS_SUBTREE_DIRTY(cellFrame) ||
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// See if it needs a special reflow, or if it had one that we need to undo.
|
|
|
|
(cellFrame->GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_HEIGHT) ||
|
|
|
|
HasPctHeight()) {
|
|
|
|
// Reflow the cell to fit the available width, height
|
|
|
|
// XXX The old IR_ChildIsDirty code used availCellWidth here.
|
|
|
|
nsSize kidAvailSize(availColWidth, aReflowState.availableHeight);
|
|
|
|
|
|
|
|
// Reflow the child
|
|
|
|
nsTableCellReflowState kidReflowState(aPresContext, aReflowState,
|
|
|
|
kidFrame, kidAvailSize, PR_FALSE);
|
2007-02-07 10:46:44 +03:00
|
|
|
InitChildReflowState(*aPresContext, kidAvailSize, borderCollapse,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
kidReflowState);
|
|
|
|
|
|
|
|
nsReflowStatus status;
|
|
|
|
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
|
2008-02-08 12:36:32 +03:00
|
|
|
x, 0, NS_FRAME_INVALIDATE_ON_MOVE, status);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
// allow the table to determine if/how the table needs to be rebalanced
|
|
|
|
// 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;
|
1998-10-06 04:27:22 +04:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
|
|
|
else {
|
2008-02-08 12:36:32 +03:00
|
|
|
if (x != kidRect.x) {
|
|
|
|
kidFrame->InvalidateOverflowRect();
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
desiredSize.width = cellDesiredSize.width;
|
|
|
|
desiredSize.height = cellDesiredSize.height;
|
|
|
|
nsRect *overflowArea =
|
|
|
|
cellFrame->GetOverflowAreaProperty();
|
|
|
|
if (overflowArea)
|
|
|
|
desiredSize.mOverflowArea = *overflowArea;
|
|
|
|
else
|
|
|
|
desiredSize.mOverflowArea.SetRect(0, 0, cellDesiredSize.width,
|
|
|
|
cellDesiredSize.height);
|
2001-11-15 17:58:27 +03:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03: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
|
|
|
|
if (!aTableFrame.GetStyleDisplay()->IsFloating()) {
|
|
|
|
// 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(kidFrame);
|
2001-11-15 17:58:27 +03:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
|
|
|
|
if (!GetPrevInFlow()) {
|
|
|
|
// 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
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// height may have changed, adjust descent to absorb any excess difference
|
|
|
|
nscoord ascent;
|
|
|
|
if (!kidFrame->GetFirstChild(nsnull)->GetFirstChild(nsnull))
|
|
|
|
ascent = desiredSize.height;
|
|
|
|
else
|
2007-01-23 07:06:56 +03:00
|
|
|
ascent = ((nsTableCellFrame *)kidFrame)->GetCellBaseline();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nscoord descent = desiredSize.height - ascent;
|
|
|
|
UpdateHeight(desiredSize.height, ascent, descent, &aTableFrame, cellFrame);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
paginatedHeight = PR_MAX(paginatedHeight, desiredSize.height);
|
|
|
|
PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan((nsTableCellFrame&)*kidFrame);
|
|
|
|
if (1 == rowSpan) {
|
|
|
|
SetContentHeight(paginatedHeight);
|
2001-10-26 06:30:38 +04:00
|
|
|
}
|
1998-09-16 04:48:14 +04:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
// Place the child
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != availColWidth) {
|
|
|
|
desiredSize.width = PR_MAX(availCellWidth, availColWidth);
|
1998-09-16 04:48:14 +04:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
FinishReflowChild(kidFrame, aPresContext, nsnull, desiredSize, x, 0, 0);
|
2008-02-08 12:36:32 +03:00
|
|
|
|
|
|
|
nsTableFrame::InvalidateFrame(kidFrame, kidRect, firstReflow);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
x += desiredSize.width;
|
1998-10-23 21:24:57 +04:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
else {
|
|
|
|
if (kidRect.x != x) {
|
2008-02-08 12:36:32 +03:00
|
|
|
// Invalidate the old position
|
|
|
|
kidFrame->InvalidateOverflowRect();
|
|
|
|
// move to the new position
|
|
|
|
kidFrame->SetPosition(nsPoint(x, kidRect.y));
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsTableFrame::RePositionViews(kidFrame);
|
2008-02-08 12:36:32 +03:00
|
|
|
// invalidate the new position
|
|
|
|
kidFrame->InvalidateOverflowRect();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
2000-11-15 17:59:47 +03:00
|
|
|
// we need to account for the cell's width even if it isn't reflowed
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
x += kidRect.width;
|
|
|
|
|
|
|
|
if (kidFrame->GetNextInFlow()) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
2000-11-15 17:59:47 +03:00
|
|
|
}
|
2004-12-27 18:05:18 +03:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowArea, kidFrame);
|
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);
|
2006-02-22 00:33:47 +03:00
|
|
|
if (GetPrevInFlow()) {
|
2002-03-27 08:50:24 +03: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 20:26:30 +04:00
|
|
|
nsRect rowRect(0, 0, aDesiredSize.width, aDesiredSize.height);
|
|
|
|
aDesiredSize.mOverflowArea.UnionRect(aDesiredSize.mOverflowArea, rowRect);
|
2004-07-16 20:56:21 +04:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
1998-10-20 19:59:56 +04:00
|
|
|
return rv;
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableRowFrame");
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1999-08-19 23:52:37 +04:00
|
|
|
nsresult rv = NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-02 02:01:37 +04:00
|
|
|
|
2004-04-28 20:42:59 +04:00
|
|
|
const nsStyleVisibility* rowVis = GetStyleVisibility();
|
|
|
|
PRBool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
|
|
|
|
if (collapseRow) {
|
2006-03-04 08:26:57 +03:00
|
|
|
tableFrame->SetNeedToCollapse(PR_TRUE);
|
2004-04-28 20:42:59 +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
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState);
|
|
|
|
|
2007-06-26 00:34:35 +04:00
|
|
|
// See if we have a cell with specified/pct height
|
|
|
|
InitHasCellWithStyleHeight(tableFrame);
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame,
|
|
|
|
aStatus);
|
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
|
|
|
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowFrame::ReflowCellFrame(nsPresContext* aPresContext,
|
2001-04-16 18:51:52 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2007-02-21 22:42:21 +03:00
|
|
|
PRBool aIsTopOfPage,
|
2001-04-16 18:51:52 +04:00
|
|
|
nsTableCellFrame* aCellFrame,
|
|
|
|
nscoord aAvailableHeight,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-02-22 06:28:00 +03:00
|
|
|
{
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
ABORT1(NS_ERROR_NULL_POINTER);
|
2002-02-19 18:48:28 +03:00
|
|
|
|
1999-02-22 06:28:00 +03:00
|
|
|
// Reflow the cell frame with the specified height. Use the existing width
|
2008-02-08 12:36:32 +03:00
|
|
|
nsRect cellRect = aCellFrame->GetRect();
|
1999-02-22 06:28:00 +03:00
|
|
|
|
2008-02-08 12:36:32 +03:00
|
|
|
nsSize availSize(cellRect.width, aAvailableHeight);
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool borderCollapse = ((nsTableFrame*)tableFrame->GetFirstInFlow())->IsBorderCollapse();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsTableCellReflowState cellReflowState(aPresContext, aReflowState,
|
|
|
|
aCellFrame, availSize, PR_FALSE);
|
2007-02-07 10:46:44 +03:00
|
|
|
InitChildReflowState(*aPresContext, availSize, borderCollapse, cellReflowState);
|
2007-02-21 22:42:21 +03:00
|
|
|
cellReflowState.mFlags.mIsTopOfPage = aIsTopOfPage;
|
2002-02-19 18:48:28 +03:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsHTMLReflowMetrics desiredSize;
|
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);
|
2007-12-02 22:19:00 +03:00
|
|
|
if (fullyComplete) {
|
|
|
|
desiredSize.height = aAvailableHeight;
|
|
|
|
}
|
2008-02-08 12:36:32 +03:00
|
|
|
aCellFrame->SetSize(nsSize(cellRect.width, desiredSize.height));
|
2001-04-16 18:51:52 +04:00
|
|
|
|
2008-02-08 12:36:32 +03:00
|
|
|
nsTableFrame::InvalidateFrame(aCellFrame, cellRect,
|
|
|
|
(aCellFrame->GetStateBits() &
|
|
|
|
NS_FRAME_FIRST_REFLOW) != 0);
|
|
|
|
|
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) {
|
2007-01-28 01:22:24 +03:00
|
|
|
aCellFrame->VerticallyAlignChild(mMaxCellAscent);
|
2002-10-03 18:33:23 +04:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nscoord
|
|
|
|
nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset,
|
|
|
|
nscoord aWidth,
|
|
|
|
PRBool aCollapseGroup,
|
|
|
|
PRBool& aDidCollapse)
|
|
|
|
{
|
|
|
|
const nsStyleVisibility* rowVis = GetStyleVisibility();
|
|
|
|
PRBool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
|
2007-07-08 11:08:04 +04:00
|
|
|
nsTableFrame* tableFrame = static_cast<nsTableFrame*>(nsTableFrame::GetTableFrame(this)->GetFirstInFlow());
|
2006-03-04 08:26:57 +03:00
|
|
|
if (!tableFrame)
|
|
|
|
return 0;
|
|
|
|
if (collapseRow) {
|
|
|
|
tableFrame->SetNeedToCollapse(PR_TRUE);
|
|
|
|
}
|
|
|
|
|
2008-02-08 12:36:32 +03:00
|
|
|
if (aRowOffset != 0) {
|
|
|
|
// We're moving, so invalidate our old position
|
|
|
|
InvalidateOverflowRect();
|
|
|
|
}
|
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nsRect rowRect = GetRect();
|
2008-02-08 12:36:32 +03:00
|
|
|
nsRect oldRect = rowRect;
|
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
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 19:58:34 +04:00
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
if (aCollapseGroup || collapseRow) {
|
2006-03-26 19:58:34 +04:00
|
|
|
nsTableCellFrame* cellFrame = GetFirstCell();
|
2006-03-04 08:26:57 +03:00
|
|
|
aDidCollapse = PR_TRUE;
|
|
|
|
shift = rowRect.height + cellSpacingY;
|
|
|
|
while (cellFrame) {
|
|
|
|
nsRect cRect = cellFrame->GetRect();
|
2008-02-08 12:36:32 +03:00
|
|
|
// If aRowOffset != 0, there's no point in invalidating the cells, since
|
|
|
|
// we've already invalidated our overflow area. Note that we _do_ still
|
|
|
|
// need to invalidate if our row is not moving, because the cell might
|
|
|
|
// span out of this row, so invalidating our row rect won't do enough.
|
|
|
|
if (aRowOffset == 0) {
|
|
|
|
Invalidate(cRect);
|
|
|
|
}
|
2006-03-04 08:26:57 +03:00
|
|
|
cRect.height = 0;
|
|
|
|
cellFrame->SetRect(cRect);
|
|
|
|
cellFrame = cellFrame->GetNextCell();
|
|
|
|
}
|
|
|
|
rowRect.height = 0;
|
|
|
|
}
|
|
|
|
else { // row is not collapsed
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsTableIterator iter(*this);
|
2006-03-04 08:26:57 +03:00
|
|
|
// remember the col index of the previous cell to handle rowspans into this
|
|
|
|
// row
|
|
|
|
PRInt32 firstPrevColIndex = (iter.IsLeftToRight()) ? -1 :
|
|
|
|
tableFrame->GetColCount();
|
|
|
|
PRInt32 prevColIndex = firstPrevColIndex;
|
|
|
|
nscoord x = 0; // running total of children x offset
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2008-02-08 12:36:32 +03:00
|
|
|
nsRect cRect(x, 0, 0, rowRect.height);
|
2006-03-04 08:26:57 +03:00
|
|
|
|
|
|
|
// remember the rightmost (ltr) or leftmost (rtl) column this cell
|
|
|
|
// spans into
|
|
|
|
prevColIndex = (iter.IsLeftToRight()) ?
|
|
|
|
cellColIndex + (cellColSpan - 1) : cellColIndex;
|
2006-03-26 19:58:34 +04:00
|
|
|
PRInt32 startIndex = (iter.IsLeftToRight()) ?
|
|
|
|
cellColIndex : cellColIndex + (cellColSpan - 1);
|
2006-03-04 08:26:57 +03:00
|
|
|
PRInt32 actualColSpan = cellColSpan;
|
|
|
|
PRBool isVisible = PR_FALSE;
|
2006-03-26 19:58:34 +04:00
|
|
|
for (PRInt32 colX = startIndex; actualColSpan > 0;
|
2006-03-04 08:26:57 +03: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();
|
|
|
|
}
|
2008-02-08 12:36:32 +03:00
|
|
|
|
|
|
|
nsRect oldCellRect = cellFrame->GetRect();
|
|
|
|
|
|
|
|
if (aRowOffset == 0 && cRect.TopLeft() != oldCellRect.TopLeft()) {
|
|
|
|
// We're moving the cell. Invalidate the old overflow area
|
|
|
|
cellFrame->InvalidateOverflowRect();
|
|
|
|
}
|
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
cellFrame->SetRect(cRect);
|
2008-02-08 12:36:32 +03:00
|
|
|
|
|
|
|
// XXXbz This looks completely bogus in the cases when we didn't
|
|
|
|
// collapse the cell!
|
2006-03-04 08:26:57 +03:00
|
|
|
nsRect cellOverflow = nsRect(0, 0, cRect.width, cRect.height);
|
|
|
|
cellFrame->FinishAndStoreOverflow(&cellOverflow, nsSize(cRect.width,
|
|
|
|
cRect.height));
|
|
|
|
nsTableFrame::RePositionViews(cellFrame);
|
|
|
|
ConsiderChildOverflow(overflowArea, cellFrame);
|
2008-02-08 12:36:32 +03:00
|
|
|
|
|
|
|
if (aRowOffset == 0) {
|
|
|
|
nsTableFrame::InvalidateFrame(cellFrame, oldCellRect, PR_FALSE);
|
|
|
|
}
|
2006-03-04 08:26:57 +03:00
|
|
|
}
|
|
|
|
kidFrame = iter.Next(); // Get the next child
|
|
|
|
}
|
|
|
|
}
|
2008-02-08 12:36:32 +03:00
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
SetRect(rowRect);
|
|
|
|
overflowArea.UnionRect(nsRect(0,0,rowRect.width, rowRect.height),
|
|
|
|
overflowArea);
|
|
|
|
FinishAndStoreOverflow(&overflowArea, nsSize(rowRect.width,
|
|
|
|
rowRect.height));
|
2008-02-08 12:36:32 +03:00
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame::RePositionViews(this);
|
2008-02-08 12:36:32 +03:00
|
|
|
nsTableFrame::InvalidateFrame(this, oldRect, PR_FALSE);
|
2006-03-04 08:26:57 +03:00
|
|
|
return shift;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::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) {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::tableRowFrame == childFrame->GetType()) {
|
2005-10-04 19:47:21 +04:00
|
|
|
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_ROW == childFrame->GetStyleDisplay()->mDisplay, "wrong display type on rowframe");
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowFrame::SetUnpaginatedHeight(nsPresContext* aPresContext,
|
2001-11-29 18:41:07 +03:00
|
|
|
nscoord aValue)
|
|
|
|
{
|
2006-02-22 00:33:47 +03:00
|
|
|
NS_ASSERTION(!GetPrevInFlow(), "program error");
|
2001-11-29 18:41:07 +03:00
|
|
|
// Get the property
|
2006-12-26 20:47:52 +03:00
|
|
|
nscoord* value = (nscoord*)nsTableFrame::GetProperty(this, nsGkAtoms::rowUnpaginatedHeightProperty, PR_TRUE);
|
2001-11-29 18:41:07 +03:00
|
|
|
if (value) {
|
|
|
|
*value = aValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowFrame::GetUnpaginatedHeight(nsPresContext* aPresContext)
|
2001-11-29 18:41:07 +03:00
|
|
|
{
|
|
|
|
// See if the property is set
|
2006-12-26 20:47:52 +03:00
|
|
|
nscoord* value = (nscoord*)nsTableFrame::GetProperty(GetFirstInFlow(), nsGkAtoms::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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-26 00:34:35 +04:00
|
|
|
/**
|
|
|
|
* Sets the NS_ROW_HAS_CELL_WITH_STYLE_HEIGHT bit to indicate whether
|
|
|
|
* this row has any cells that have non-auto-height. (Row-spanning
|
|
|
|
* cells are ignored.)
|
|
|
|
*/
|
|
|
|
void nsTableRowFrame::InitHasCellWithStyleHeight(nsTableFrame* aTableFrame)
|
|
|
|
{
|
|
|
|
nsTableIterator iter(*this);
|
|
|
|
|
|
|
|
for (nsIFrame* kidFrame = iter.First(); kidFrame; kidFrame = iter.Next()) {
|
|
|
|
nsIAtom* frameType = kidFrame->GetType();
|
|
|
|
if (!IS_TABLE_CELL(frameType)) {
|
|
|
|
NS_NOTREACHED("Table row has a non-cell child.");
|
|
|
|
continue;
|
|
|
|
}
|
2007-07-08 11:08:04 +04:00
|
|
|
nsTableCellFrame* cellFrame = static_cast<nsTableCellFrame*>(kidFrame);
|
2007-06-26 00:34:35 +04:00
|
|
|
// Ignore row-spanning cells
|
|
|
|
if (aTableFrame->GetEffectiveRowSpan(*cellFrame) == 1 &&
|
|
|
|
cellFrame->GetStylePosition()->mHeight.GetUnit() != eStyleUnit_Auto) {
|
|
|
|
AddStateBits(NS_ROW_HAS_CELL_WITH_STYLE_HEIGHT);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RemoveStateBits(NS_ROW_HAS_CELL_WITH_STYLE_HEIGHT);
|
|
|
|
}
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewTableRowFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsTableRowFrame(aContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
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
|