1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-14 00:24:54 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2000-02-03 01:24:56 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1999-12-14 01:56:31 +03:00
|
|
|
#include "nsVoidArray.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsTableFrame.h"
|
1999-10-28 08:09:39 +04:00
|
|
|
#include "nsTableBorderCollapser.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIStyleContext.h"
|
1999-09-02 04:07:14 +04:00
|
|
|
#include "nsStyleConsts.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsCellMap.h"
|
|
|
|
#include "nsTableCellFrame.h"
|
1998-09-15 21:58:24 +04:00
|
|
|
#include "nsHTMLParts.h"
|
1998-06-05 06:36:25 +04:00
|
|
|
#include "nsTableColFrame.h"
|
1998-06-17 20:38:24 +04:00
|
|
|
#include "nsTableColGroupFrame.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsTableRowFrame.h"
|
|
|
|
#include "nsTableRowGroupFrame.h"
|
1998-09-30 03:15:01 +04:00
|
|
|
#include "nsTableOuterFrame.h"
|
1998-09-15 21:58:24 +04:00
|
|
|
#include "nsIHTMLContent.h"
|
1998-04-30 21:57:09 +04:00
|
|
|
|
|
|
|
#include "BasicTableLayoutStrategy.h"
|
1998-09-30 03:15:01 +04:00
|
|
|
#include "FixedTableLayoutStrategy.h"
|
1998-04-30 21:57:09 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsVoidArray.h"
|
1998-05-22 03:43:18 +04:00
|
|
|
#include "nsIView.h"
|
1998-05-27 00:57:24 +04:00
|
|
|
#include "nsHTMLAtoms.h"
|
1998-06-05 06:36:25 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1998-06-23 09:43:27 +04:00
|
|
|
#include "nsIReflowCommand.h"
|
1998-12-09 08:30:17 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-01-18 02:35:56 +03:00
|
|
|
#include "nsIDeviceContext.h"
|
1999-02-24 07:03:50 +03:00
|
|
|
#include "nsIStyleSet.h"
|
|
|
|
#include "nsIPresShell.h"
|
1999-08-01 02:11:50 +04:00
|
|
|
#include "nsIDOMElement.h"
|
1999-08-24 08:17:05 +04:00
|
|
|
#include "nsIDOMHTMLElement.h"
|
|
|
|
#include "nsIDOMHTMLBodyElement.h"
|
1999-10-02 04:02:54 +04:00
|
|
|
#include "nsISizeOfHandler.h"
|
1999-12-07 06:36:05 +03:00
|
|
|
#include "nsIScrollableFrame.h"
|
2000-01-28 05:19:45 +03:00
|
|
|
#include "nsHTMLReflowCommand.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-08-24 08:17:05 +04:00
|
|
|
static NS_DEFINE_IID(kIHTMLElementIID, NS_IDOMHTMLELEMENT_IID);
|
|
|
|
static NS_DEFINE_IID(kIBodyElementIID, NS_IDOMHTMLBODYELEMENT_IID);
|
1999-01-30 18:52:19 +03:00
|
|
|
static NS_DEFINE_IID(kITableRowGroupFrameIID, NS_ITABLEROWGROUPFRAME_IID);
|
1999-12-07 06:36:05 +03:00
|
|
|
static NS_DEFINE_IID(kIScrollableFrameIID, NS_ISCROLLABLE_FRAME_IID);
|
1999-01-30 18:52:19 +03:00
|
|
|
|
1999-10-05 03:48:05 +04:00
|
|
|
static const PRInt32 kColumnWidthIncrement=10;
|
1998-10-10 01:53:07 +04:00
|
|
|
|
1999-08-24 16:01:31 +04:00
|
|
|
#if 1
|
1999-08-27 08:29:05 +04:00
|
|
|
PRBool nsDebugTable::gRflTableOuter = PR_FALSE;
|
|
|
|
PRBool nsDebugTable::gRflTable = PR_FALSE;
|
|
|
|
PRBool nsDebugTable::gRflRowGrp = PR_FALSE;
|
|
|
|
PRBool nsDebugTable::gRflRow = PR_FALSE;
|
|
|
|
PRBool nsDebugTable::gRflCell = PR_FALSE;
|
|
|
|
PRBool nsDebugTable::gRflArea = PR_FALSE;
|
1999-08-24 16:01:31 +04:00
|
|
|
#else
|
1999-08-27 08:29:05 +04:00
|
|
|
PRBool nsDebugTable::gRflTableOuter = PR_TRUE;
|
|
|
|
PRBool nsDebugTable::gRflTable = PR_TRUE;
|
|
|
|
PRBool nsDebugTable::gRflRowGrp = PR_TRUE;
|
|
|
|
PRBool nsDebugTable::gRflRow = PR_TRUE;
|
|
|
|
PRBool nsDebugTable::gRflCell = PR_TRUE;
|
|
|
|
PRBool nsDebugTable::gRflArea = PR_TRUE;
|
1999-08-24 16:01:31 +04:00
|
|
|
#endif
|
2000-01-28 05:19:45 +03:00
|
|
|
static PRInt32 gRflCount = 0;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/* ----------- InnerTableReflowState ---------- */
|
|
|
|
|
|
|
|
struct InnerTableReflowState {
|
|
|
|
|
1998-05-30 00:36:05 +04:00
|
|
|
// Our reflow state
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& reflowState;
|
1998-05-30 00:36:05 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// The body's available size (computed from the body's parent)
|
|
|
|
nsSize availSize;
|
|
|
|
|
|
|
|
// Flags for whether the max size is unconstrained
|
|
|
|
PRBool unconstrainedWidth;
|
|
|
|
PRBool unconstrainedHeight;
|
|
|
|
|
|
|
|
// Running y-offset
|
|
|
|
nscoord y;
|
|
|
|
|
1999-03-05 09:00:40 +03:00
|
|
|
// Pointer to the footer in the table
|
|
|
|
nsIFrame* footerFrame;
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1999-03-05 09:00:40 +03:00
|
|
|
// The first body section row group frame, i.e. not a header or footer
|
|
|
|
nsIFrame* firstBodySection;
|
1998-04-23 21:29:07 +04:00
|
|
|
|
1999-08-03 18:26:00 +04:00
|
|
|
// border/padding
|
|
|
|
nsMargin mBorderPadding;
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
InnerTableReflowState(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
const nsMargin& aBorderPadding)
|
1999-08-03 18:26:00 +04:00
|
|
|
: reflowState(aReflowState), mBorderPadding(aBorderPadding)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-01-05 03:41:40 +03:00
|
|
|
y=0; // border/padding???
|
1998-04-25 22:48:48 +04:00
|
|
|
|
1999-01-06 02:31:18 +03:00
|
|
|
unconstrainedWidth = PRBool(aReflowState.availableWidth == NS_UNCONSTRAINEDSIZE);
|
2000-01-03 01:55:48 +03:00
|
|
|
unconstrainedHeight = PRBool(aReflowState.availableHeight == NS_UNCONSTRAINEDSIZE);
|
|
|
|
|
|
|
|
availSize.width = aReflowState.availableWidth;
|
1998-04-25 22:48:48 +04:00
|
|
|
if (!unconstrainedWidth) {
|
1998-05-13 02:28:01 +04:00
|
|
|
availSize.width -= aBorderPadding.left + aBorderPadding.right;
|
1998-04-25 22:48:48 +04:00
|
|
|
}
|
|
|
|
|
1999-01-06 02:31:18 +03:00
|
|
|
availSize.height = aReflowState.availableHeight;
|
1998-04-25 22:48:48 +04:00
|
|
|
if (!unconstrainedHeight) {
|
1998-05-13 02:28:01 +04:00
|
|
|
availSize.height -= aBorderPadding.top + aBorderPadding.bottom;
|
1998-04-25 22:48:48 +04:00
|
|
|
}
|
|
|
|
|
1999-03-05 09:00:40 +03:00
|
|
|
footerFrame = nsnull;
|
|
|
|
firstBodySection = nsnull;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
1999-10-09 03:18:19 +04:00
|
|
|
|
1999-02-24 08:54:31 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::tableFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
/* --------------------- nsTableFrame -------------------- */
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsTableFrame::nsTableFrame()
|
|
|
|
: nsHTMLContainerFrame(),
|
1999-03-05 07:19:09 +03:00
|
|
|
mCellMap(nsnull),
|
1999-08-26 01:49:18 +04:00
|
|
|
mTableLayoutStrategy(nsnull),
|
|
|
|
mPercentBasisForRows(0)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-10-05 03:48:05 +04:00
|
|
|
mBits.mColumnWidthsSet = PR_FALSE;
|
|
|
|
mBits.mColumnWidthsValid = PR_FALSE;
|
|
|
|
mBits.mFirstPassValid = PR_FALSE;
|
|
|
|
mBits.mIsInvariantWidth = PR_FALSE;
|
1999-10-05 06:41:36 +04:00
|
|
|
// XXX We really shouldn't do this, but if we don't then we'll have a
|
|
|
|
// problem with the tree control...
|
|
|
|
#if 0
|
1999-10-05 03:48:05 +04:00
|
|
|
mColumnWidthsLength = 0;
|
|
|
|
mColumnWidths = nsnull;
|
1999-10-05 06:41:36 +04:00
|
|
|
#else
|
1999-10-14 08:27:01 +04:00
|
|
|
mColumnWidthsLength = 5;
|
1999-10-05 06:41:36 +04:00
|
|
|
mColumnWidths = new PRInt32[mColumnWidthsLength];
|
|
|
|
nsCRT::memset (mColumnWidths, 0, mColumnWidthsLength*sizeof(PRInt32));
|
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-08-01 22:26:45 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsTableFrame, nsHTMLContainerFrame)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsTableFrame, nsHTMLContainerFrame)
|
|
|
|
|
|
|
|
nsresult nsTableFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2000-02-03 01:24:56 +03:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsITableLayout)))
|
1999-08-01 22:26:45 +04:00
|
|
|
{ // note there is no addref here, frames are not addref'd
|
|
|
|
*aInstancePtr = (void*)(nsITableLayout*)this;
|
|
|
|
return NS_OK;
|
|
|
|
} else {
|
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
}
|
1999-08-01 02:11:50 +04:00
|
|
|
|
1998-12-05 08:27:21 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableFrame::Init(nsIPresContext* aPresContext,
|
1998-12-05 08:27:21 +03:00
|
|
|
nsIContent* aContent,
|
1999-01-14 08:16:23 +03:00
|
|
|
nsIFrame* aParent,
|
1999-02-25 06:27:57 +03:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1998-12-05 08:27:21 +03:00
|
|
|
{
|
1999-02-25 08:31:15 +03:00
|
|
|
nsresult rv;
|
1998-12-05 08:27:21 +03:00
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
// Create the cell map
|
|
|
|
// XXX Why do we do this for continuing frames?
|
|
|
|
mCellMap = new nsTableCellMap(aPresContext, *this);
|
|
|
|
|
1999-02-25 08:31:15 +03:00
|
|
|
// Let the base class do its processing
|
|
|
|
rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext,
|
|
|
|
aPrevInFlow);
|
|
|
|
|
|
|
|
if (aPrevInFlow) {
|
|
|
|
// set my width, because all frames in a table flow are the same width and
|
|
|
|
// code in nsTableOuterFrame depends on this being set
|
|
|
|
nsSize size;
|
|
|
|
aPrevInFlow->GetSize(size);
|
|
|
|
mRect.width = size.width;
|
|
|
|
}
|
|
|
|
|
1999-10-28 08:09:39 +04:00
|
|
|
if ((NS_STYLE_BORDER_COLLAPSE == GetBorderCollapseStyle()) && !mBorderCollapser) {
|
|
|
|
mBorderCollapser = new nsTableBorderCollapser(*this);
|
|
|
|
// if new fails then we don't get collapsing borders
|
|
|
|
}
|
|
|
|
|
1999-02-25 08:31:15 +03:00
|
|
|
return rv;
|
1998-12-05 08:27:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
nsTableFrame::~nsTableFrame()
|
|
|
|
{
|
1999-10-28 08:09:39 +04:00
|
|
|
if ((NS_STYLE_BORDER_COLLAPSE == GetBorderCollapseStyle()) && mBorderCollapser) {
|
|
|
|
delete mBorderCollapser;
|
1999-08-07 09:40:09 +04:00
|
|
|
}
|
|
|
|
|
1999-07-01 11:12:46 +04:00
|
|
|
if (nsnull!=mCellMap) {
|
|
|
|
delete mCellMap;
|
|
|
|
mCellMap = nsnull;
|
|
|
|
}
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1999-07-01 11:12:46 +04:00
|
|
|
if (nsnull!=mColumnWidths) {
|
1998-04-14 00:24:54 +04:00
|
|
|
delete [] mColumnWidths;
|
1999-07-01 11:12:46 +04:00
|
|
|
mColumnWidths = nsnull;
|
|
|
|
}
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1999-07-01 11:12:46 +04:00
|
|
|
if (nsnull!=mTableLayoutStrategy) {
|
1998-04-30 21:57:09 +04:00
|
|
|
delete mTableLayoutStrategy;
|
1999-07-01 11:12:46 +04:00
|
|
|
mTableLayoutStrategy = nsnull;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-12-04 06:14:28 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableFrame::Destroy(nsIPresContext* aPresContext)
|
1998-12-04 06:14:28 +03:00
|
|
|
{
|
1999-07-22 08:00:57 +04:00
|
|
|
mColGroups.DestroyFrames(aPresContext);
|
1999-07-22 06:24:52 +04:00
|
|
|
return nsHTMLContainerFrame::Destroy(aPresContext);
|
1998-12-04 06:14:28 +03:00
|
|
|
}
|
|
|
|
|
2000-01-04 08:31:56 +03:00
|
|
|
// Helper function. It marks the table frame as dirty and generates
|
|
|
|
// a reflow command
|
|
|
|
nsresult
|
|
|
|
nsTableFrame::AddTableDirtyReflowCommand(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aTableFrame)
|
|
|
|
{
|
|
|
|
nsFrameState frameState;
|
|
|
|
nsIFrame* tableParentFrame;
|
|
|
|
nsIReflowCommand* reflowCmd;
|
|
|
|
nsresult rv;
|
|
|
|
nsIPresShell* presShell;
|
|
|
|
|
|
|
|
aPresContext->GetShell(&presShell);
|
|
|
|
|
|
|
|
// Mark the table frame as dirty
|
|
|
|
aTableFrame->GetFrameState(&frameState);
|
|
|
|
frameState |= NS_FRAME_IS_DIRTY;
|
|
|
|
aTableFrame->SetFrameState(frameState);
|
|
|
|
|
|
|
|
// Target the reflow comamnd at its parent frame
|
|
|
|
aTableFrame->GetParent(&tableParentFrame);
|
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, tableParentFrame,
|
|
|
|
nsIReflowCommand::ReflowDirty);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// Add the reflow command
|
|
|
|
rv = presShell->AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_RELEASE(presShell);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// XXX this needs to be cleaned up so that the frame constructor breaks out col group
|
|
|
|
// frames into a separate child list.
|
1998-09-16 21:19:20 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
1998-11-10 09:05:32 +03:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-09-16 21:19:20 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
nsresult rv=NS_OK;
|
1999-01-16 01:52:05 +03:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// I know now that I have all my children, so build the cell map
|
1998-12-03 21:01:35 +03:00
|
|
|
nsIFrame *childFrame = aChildList;
|
|
|
|
nsIFrame *prevMainChild = nsnull;
|
|
|
|
nsIFrame *prevColGroupChild = nsnull;
|
|
|
|
for ( ; nsnull!=childFrame; )
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-12-03 21:01:35 +03:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-05 04:47:37 +03:00
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)childDisplay);
|
1999-12-14 01:56:31 +03:00
|
|
|
// XXX this if should go away
|
1998-12-03 21:01:35 +03:00
|
|
|
if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
|
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
if (mFrames.IsEmpty())
|
1999-01-16 01:52:05 +03:00
|
|
|
mFrames.SetFrames(childFrame);
|
1998-12-03 21:01:35 +03:00
|
|
|
else
|
|
|
|
prevMainChild->SetNextSibling(childFrame);
|
|
|
|
prevMainChild = childFrame;
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == childDisplay->mDisplay)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1999-01-16 01:52:05 +03:00
|
|
|
if (mColGroups.IsEmpty())
|
|
|
|
mColGroups.SetFrames(childFrame);
|
1998-12-03 21:01:35 +03:00
|
|
|
else
|
|
|
|
prevColGroupChild->SetNextSibling(childFrame);
|
|
|
|
prevColGroupChild = childFrame;
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1998-12-03 21:01:35 +03:00
|
|
|
else
|
|
|
|
{ // unknown frames go on the main list for now
|
1999-01-16 01:52:05 +03:00
|
|
|
if (mFrames.IsEmpty())
|
|
|
|
mFrames.SetFrames(childFrame);
|
1998-12-03 21:01:35 +03:00
|
|
|
else
|
|
|
|
prevMainChild->SetNextSibling(childFrame);
|
|
|
|
prevMainChild = childFrame;
|
|
|
|
}
|
|
|
|
nsIFrame *prevChild = childFrame;
|
1999-02-10 09:13:38 +03:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
1998-12-03 21:01:35 +03:00
|
|
|
prevChild->SetNextSibling(nsnull);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1998-12-03 21:01:35 +03:00
|
|
|
if (nsnull!=prevMainChild)
|
|
|
|
prevMainChild->SetNextSibling(nsnull);
|
|
|
|
if (nsnull!=prevColGroupChild)
|
|
|
|
prevColGroupChild->SetNextSibling(nsnull);
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// If we have a prev-in-flow, then we're a table that has been split and
|
|
|
|
// so don't treat this like an append
|
|
|
|
if (!mPrevInFlow) {
|
|
|
|
// process col groups first so that real cols get constructed before
|
|
|
|
// anonymous ones due to cells in rows.
|
|
|
|
InsertColGroups(*aPresContext, 0, mColGroups.FirstChild());
|
|
|
|
AppendRowGroups(*aPresContext, mFrames.FirstChild());
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
1998-12-03 21:01:35 +03:00
|
|
|
|
1999-09-02 04:07:14 +04:00
|
|
|
if (HasGroupRules()) {
|
|
|
|
ProcessGroupRules(aPresContext);
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
2000-02-12 04:55:40 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableFrame::IsPercentageBase(PRBool& aBase) const
|
|
|
|
{
|
|
|
|
aBase = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-04 08:31:56 +03:00
|
|
|
void nsTableFrame::AttributeChangedFor(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIAtom* aAttribute)
|
|
|
|
{
|
|
|
|
nsIAtom* frameType;
|
|
|
|
aFrame->GetFrameType(&frameType);
|
|
|
|
if (nsLayoutAtoms::tableCellFrame == frameType) {
|
|
|
|
if ((nsHTMLAtoms::rowspan == aAttribute) ||
|
|
|
|
(nsHTMLAtoms::colspan == aAttribute)) {
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
2000-01-04 08:31:56 +03:00
|
|
|
if (cellMap) {
|
|
|
|
// for now just remove the cell from the map and reinsert it
|
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)aFrame;
|
|
|
|
PRInt32 rowIndex, colIndex;
|
|
|
|
cellFrame->GetRowIndex(rowIndex);
|
|
|
|
cellFrame->GetColIndex(colIndex);
|
|
|
|
RemoveCell(*aPresContext, cellFrame, rowIndex);
|
|
|
|
nsVoidArray cells;
|
|
|
|
cells.AppendElement(cellFrame);
|
|
|
|
InsertCells(*aPresContext, cells, rowIndex, colIndex - 1);
|
|
|
|
// invalidate the column widths and generate a reflow command
|
|
|
|
InvalidateColumnWidths();
|
|
|
|
AddTableDirtyReflowCommand(aPresContext, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
/* ****** CellMap methods ******* */
|
|
|
|
|
|
|
|
/* counts columns in column groups */
|
|
|
|
PRInt32 nsTableFrame::GetSpecifiedColumnCount ()
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
PRInt32 colCount = 0;
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame * childFrame = mColGroups.FirstChild();
|
1999-07-28 12:09:02 +04:00
|
|
|
while (nsnull!=childFrame) {
|
1999-12-14 01:56:31 +03:00
|
|
|
colCount += ((nsTableColGroupFrame *)childFrame)->GetColCount();
|
1999-02-10 09:13:38 +03:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
return colCount;
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
|
|
|
|
1998-11-20 04:01:25 +03:00
|
|
|
PRInt32 nsTableFrame::GetRowCount () const
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
|
|
|
PRInt32 rowCount = 0;
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap *cellMap = GetCellMap();
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_ASSERTION(nsnull!=cellMap, "GetRowCount null cellmap");
|
|
|
|
if (nsnull!=cellMap)
|
|
|
|
rowCount = cellMap->GetRowCount();
|
1998-06-17 20:38:24 +04:00
|
|
|
return rowCount;
|
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-07-24 20:51:16 +04:00
|
|
|
/* return the effective col count */
|
1998-07-22 07:53:43 +04:00
|
|
|
PRInt32 nsTableFrame::GetColCount ()
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
PRInt32 colCount = 0;
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-07-28 12:09:02 +04:00
|
|
|
NS_ASSERTION(nsnull != cellMap, "GetColCount null cellmap");
|
|
|
|
if (nsnull != cellMap)
|
|
|
|
colCount = cellMap->GetColCount();
|
|
|
|
return colCount;
|
1998-07-24 20:51:16 +04:00
|
|
|
}
|
1998-07-22 07:53:43 +04:00
|
|
|
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableColFrame* nsTableFrame::GetColFrame(PRInt32 aColIndex)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
return (nsTableColFrame *)mColFrames.ElementAt(aColIndex);
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// can return nsnull
|
1999-08-19 23:52:37 +04:00
|
|
|
nsTableCellFrame* nsTableFrame::GetCellFrameAt(PRInt32 aRowIndex, PRInt32 aColIndex)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-08-19 23:52:37 +04:00
|
|
|
if (cellMap)
|
|
|
|
return cellMap->GetCellInfoAt(aRowIndex, aColIndex);
|
|
|
|
return nsnull;
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
|
2000-02-01 06:23:29 +03:00
|
|
|
PRInt32 nsTableFrame::GetEffectiveRowSpan(PRInt32 aRowIndex,
|
|
|
|
const nsTableCellFrame& aCell) const
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
2000-02-01 06:23:29 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
|
|
|
NS_PRECONDITION (nsnull != cellMap, "bad call, cellMap not yet allocated.");
|
1999-07-28 12:09:02 +04:00
|
|
|
|
2000-02-01 06:23:29 +03:00
|
|
|
PRInt32 colIndex;
|
|
|
|
aCell.GetColIndex(colIndex);
|
|
|
|
return cellMap->GetEffectiveRowSpan(aRowIndex, colIndex);
|
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
|
2000-02-01 06:23:29 +03:00
|
|
|
PRInt32 nsTableFrame::GetEffectiveRowSpan(const nsTableCellFrame& aCell) const
|
1998-07-17 03:23:31 +04:00
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-07-28 12:09:02 +04:00
|
|
|
NS_PRECONDITION (nsnull != cellMap, "bad call, cellMap not yet allocated.");
|
1998-07-17 03:23:31 +04:00
|
|
|
|
2000-02-01 06:23:29 +03:00
|
|
|
PRInt32 colIndex, rowIndex;
|
|
|
|
aCell.GetColIndex(colIndex);
|
|
|
|
aCell.GetRowIndex(rowIndex);
|
|
|
|
return cellMap->GetEffectiveRowSpan(rowIndex, colIndex);
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
|
|
|
|
2000-01-15 23:10:00 +03:00
|
|
|
PRInt32 nsTableFrame::GetEffectiveColSpan(const nsTableCellFrame& aCell) const
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-07-28 12:09:02 +04:00
|
|
|
NS_PRECONDITION (nsnull != cellMap, "bad call, cellMap not yet allocated.");
|
|
|
|
|
2000-02-01 06:23:29 +03:00
|
|
|
PRInt32 colIndex, rowIndex;
|
|
|
|
aCell.GetColIndex(colIndex);
|
|
|
|
aCell.GetRowIndex(rowIndex);
|
|
|
|
return cellMap->GetEffectiveColSpan(rowIndex, colIndex);
|
1998-07-17 03:23:31 +04:00
|
|
|
}
|
|
|
|
|
1998-07-22 07:53:43 +04:00
|
|
|
PRInt32 nsTableFrame::GetEffectiveCOLSAttribute()
|
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap *cellMap = GetCellMap();
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_PRECONDITION (nsnull!=cellMap, "null cellMap.");
|
1998-07-22 07:53:43 +04:00
|
|
|
PRInt32 result;
|
1998-12-02 19:45:20 +03:00
|
|
|
const nsStyleTable *tableStyle=nsnull;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
1998-07-22 07:53:43 +04:00
|
|
|
result = tableStyle->mCols;
|
|
|
|
PRInt32 numCols = GetColCount();
|
|
|
|
if (result>numCols)
|
|
|
|
result = numCols;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-09-02 04:07:14 +04:00
|
|
|
PRBool nsTableFrame::HasGroupRules() const
|
|
|
|
{
|
|
|
|
const nsStyleTable* tableStyle = nsnull;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
|
|
|
if (NS_STYLE_TABLE_RULES_GROUPS == tableStyle->mRules) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this won't work until bug 12948 is resolved and col groups are considered
|
1999-11-24 09:03:41 +03:00
|
|
|
void nsTableFrame::ProcessGroupRules(nsIPresContext* aPresContext)
|
1999-09-02 04:07:14 +04:00
|
|
|
{
|
|
|
|
PRInt32 numCols = GetColCount();
|
|
|
|
|
|
|
|
// process row groups
|
|
|
|
nsIFrame* iFrame;
|
|
|
|
for (iFrame = mFrames.FirstChild(); iFrame; iFrame->GetNextSibling(&iFrame)) {
|
|
|
|
nsIAtom* frameType;
|
|
|
|
iFrame->GetFrameType(&frameType);
|
|
|
|
if (nsLayoutAtoms::tableRowGroupFrame == frameType) {
|
|
|
|
nsTableRowGroupFrame* rgFrame = (nsTableRowGroupFrame *)iFrame;
|
|
|
|
PRInt32 startRow = rgFrame->GetStartRowIndex();
|
|
|
|
PRInt32 numGroupRows;
|
|
|
|
rgFrame->GetRowCount(numGroupRows, PR_FALSE);
|
|
|
|
PRInt32 endRow = startRow + numGroupRows - 1;
|
|
|
|
if (startRow == endRow) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for (PRInt32 rowX = startRow; rowX <= endRow; rowX++) {
|
|
|
|
for (PRInt32 colX = 0; colX < numCols; colX++) {
|
|
|
|
PRBool originates;
|
|
|
|
nsTableCellFrame* cell = GetCellInfoAt(rowX, colX, &originates);
|
|
|
|
if (originates) {
|
|
|
|
nsCOMPtr<nsIStyleContext> styleContext;
|
|
|
|
cell->GetStyleContext(getter_AddRefs(styleContext));
|
|
|
|
nsStyleSpacing* spacing = (nsStyleSpacing*)styleContext->GetMutableStyleData(eStyleStruct_Spacing);
|
|
|
|
if (rowX == startRow) {
|
|
|
|
spacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
}
|
|
|
|
else if (rowX == endRow) {
|
|
|
|
spacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
spacing->SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
spacing->SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
}
|
1999-11-24 09:03:41 +03:00
|
|
|
styleContext->RecalcAutomaticData(aPresContext);
|
1999-09-02 04:07:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
void nsTableFrame::AdjustRowIndices(nsIPresContext* aPresContext,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aAdjustment)
|
1999-12-14 01:56:31 +03:00
|
|
|
{
|
|
|
|
// Iterate over the row groups and adjust the row indices of all rows
|
|
|
|
// whose index is >= aRowIndex.
|
|
|
|
nsIFrame* rowGroupFrame = mFrames.FirstChild();
|
|
|
|
for ( ; rowGroupFrame; rowGroupFrame->GetNextSibling(&rowGroupFrame)) {
|
|
|
|
const nsStyleDisplay *rowGroupDisplay;
|
|
|
|
rowGroupFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)rowGroupDisplay);
|
|
|
|
if (IsRowGroup(rowGroupDisplay->mDisplay)) {
|
2000-01-22 04:16:50 +03:00
|
|
|
AdjustRowIndices(aPresContext, rowGroupFrame, aRowIndex, aAdjustment);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
NS_IMETHODIMP nsTableFrame::AdjustRowIndices(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aRowGroup,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 anAdjustment)
|
1999-08-30 04:01:09 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsIFrame *rowFrame;
|
2000-01-22 04:16:50 +03:00
|
|
|
aRowGroup->FirstChild(aPresContext, nsnull, &rowFrame);
|
1999-08-30 04:01:09 +04:00
|
|
|
for ( ; nsnull!=rowFrame; rowFrame->GetNextSibling(&rowFrame))
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *rowDisplay;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)rowDisplay);
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW==rowDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
PRInt32 index = ((nsTableRowFrame*)rowFrame)->GetRowIndex();
|
|
|
|
if (index >= aRowIndex)
|
|
|
|
((nsTableRowFrame *)rowFrame)->SetRowIndex(index+anAdjustment);
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP==rowDisplay->mDisplay)
|
|
|
|
{
|
2000-01-22 04:16:50 +03:00
|
|
|
AdjustRowIndices(aPresContext, rowFrame, aRowIndex, anAdjustment);
|
1999-08-30 04:01:09 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
void nsTableFrame::InsertColGroups(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aStartColIndex,
|
|
|
|
nsIFrame* aFirstFrame,
|
|
|
|
nsIFrame* aLastFrame)
|
|
|
|
{
|
|
|
|
PRInt32 colIndex = aStartColIndex;
|
|
|
|
nsTableColGroupFrame* firstColGroupToReset = nsnull;
|
|
|
|
nsIFrame* kidFrame = aFirstFrame;
|
|
|
|
PRBool didLastFrame = PR_FALSE;
|
|
|
|
while (kidFrame) {
|
|
|
|
nsIAtom* kidType;
|
|
|
|
kidFrame->GetFrameType(&kidType);
|
|
|
|
if (nsLayoutAtoms::tableColGroupFrame == kidType) {
|
|
|
|
if (didLastFrame) {
|
|
|
|
firstColGroupToReset = (nsTableColGroupFrame*)kidFrame;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsTableColGroupFrame* cgFrame = (nsTableColGroupFrame*)kidFrame;
|
|
|
|
cgFrame->SetStartColumnIndex(colIndex);
|
|
|
|
nsIFrame* firstCol;
|
2000-01-22 04:16:50 +03:00
|
|
|
kidFrame->FirstChild(&aPresContext, nsnull, &firstCol);
|
1999-12-14 01:56:31 +03:00
|
|
|
cgFrame->AddColsToTable(aPresContext, colIndex, PR_FALSE, firstCol);
|
|
|
|
PRInt32 numCols = cgFrame->GetColCount();
|
|
|
|
colIndex += numCols;
|
|
|
|
}
|
1999-08-30 04:01:09 +04:00
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
NS_IF_RELEASE(kidType);
|
|
|
|
if (kidFrame == aLastFrame) {
|
|
|
|
didLastFrame = PR_TRUE;
|
|
|
|
}
|
|
|
|
kidFrame->GetNextSibling(&kidFrame);
|
1999-08-30 04:01:09 +04:00
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
if (firstColGroupToReset) {
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableColGroupFrame::ResetColIndices(&aPresContext, firstColGroupToReset, aStartColIndex);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
1999-08-30 04:01:09 +04:00
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
void nsTableFrame::InsertCol(nsIPresContext& aPresContext,
|
|
|
|
nsTableColFrame& aColFrame,
|
|
|
|
PRInt32 aColIndex)
|
1999-08-30 04:01:09 +04:00
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
mColFrames.InsertElementAt(&aColFrame, aColIndex);
|
|
|
|
nsTableColType insertedColType = aColFrame.GetType();
|
|
|
|
PRInt32 numCacheCols = mColFrames.Count();
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-12-14 01:56:31 +03:00
|
|
|
if (cellMap) {
|
|
|
|
PRInt32 numMapCols = cellMap->GetColCount();
|
|
|
|
if (numCacheCols > numMapCols) {
|
|
|
|
PRBool removedFromCache = PR_FALSE;
|
|
|
|
if (eColAnonymousCell != insertedColType) {
|
|
|
|
nsTableColFrame* lastCol = (nsTableColFrame *)mColFrames.ElementAt(numCacheCols - 1);
|
|
|
|
if (lastCol) {
|
|
|
|
nsTableColType lastColType = lastCol->GetType();
|
|
|
|
if (eColAnonymousCell == lastColType) {
|
|
|
|
// remove the col from the cache
|
|
|
|
mColFrames.RemoveElementAt(numCacheCols - 1);
|
|
|
|
// remove the col from the eColGroupAnonymousCell col group
|
|
|
|
nsTableColGroupFrame* lastColGroup = (nsTableColGroupFrame *)mColGroups.LastChild();
|
|
|
|
if (lastColGroup) {
|
|
|
|
lastColGroup->RemoveChild(aPresContext, *lastCol, PR_FALSE);
|
|
|
|
}
|
|
|
|
// remove the col group if it is empty
|
|
|
|
if (lastColGroup->GetColCount() <= 0) {
|
|
|
|
mColGroups.DestroyFrame(&aPresContext, (nsIFrame*)lastColGroup);
|
|
|
|
}
|
|
|
|
removedFromCache = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!removedFromCache) {
|
2000-01-13 08:29:38 +03:00
|
|
|
cellMap->AddColsAtEnd(1);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
1999-08-30 04:01:09 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
void nsTableFrame::RemoveCol(nsIPresContext& aPresContext,
|
|
|
|
nsTableColGroupFrame* aColGroupFrame,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
PRBool aRemoveFromCache,
|
|
|
|
PRBool aRemoveFromCellMap)
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
if (aRemoveFromCache) {
|
|
|
|
mColFrames.RemoveElementAt(aColIndex);
|
1998-12-03 21:01:35 +03:00
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
if (aRemoveFromCellMap) {
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-07-28 12:09:02 +04:00
|
|
|
if (cellMap) {
|
1999-12-14 01:56:31 +03:00
|
|
|
// check to see if the cell map can remove the col
|
|
|
|
if (cellMap->RemoveUnusedCols(1) < 1) {
|
|
|
|
// it couldn't be removed so we need a new anonymous col frame
|
|
|
|
CreateAnonymousColFrames(aPresContext, 1, eColAnonymousCell, PR_TRUE);
|
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
|
|
|
}
|
1998-09-01 01:23:28 +04:00
|
|
|
}
|
|
|
|
|
1998-08-14 20:16:43 +04:00
|
|
|
/** Get the cell map for this table frame. It is not always mCellMap.
|
|
|
|
* Only the firstInFlow has a legit cell map
|
|
|
|
*/
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap * nsTableFrame::GetCellMap() const
|
1998-08-14 20:16:43 +04:00
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
if (this!=firstInFlow)
|
|
|
|
{
|
|
|
|
return firstInFlow->GetCellMap();
|
|
|
|
}
|
|
|
|
return mCellMap;
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// XXX this needs to be moved to nsCSSFrameConstructor
|
|
|
|
nsTableColGroupFrame*
|
|
|
|
nsTableFrame::CreateAnonymousColGroupFrame(nsIPresContext& aPresContext,
|
|
|
|
nsTableColGroupType aColGroupType)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> colGroupContent;
|
|
|
|
GetContent(getter_AddRefs(colGroupContent));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStyleContext> colGroupStyle;
|
|
|
|
aPresContext.ResolvePseudoStyleContextFor(colGroupContent,
|
|
|
|
nsHTMLAtoms::tableColGroupPseudo,
|
|
|
|
mStyleContext,
|
|
|
|
PR_FALSE,
|
|
|
|
getter_AddRefs(colGroupStyle));
|
|
|
|
// Create a col group frame
|
|
|
|
nsIFrame* newFrame;
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext.GetShell(getter_AddRefs(presShell));
|
|
|
|
nsresult result = NS_NewTableColGroupFrame(presShell, &newFrame);
|
|
|
|
if (NS_SUCCEEDED(result) && newFrame) {
|
|
|
|
((nsTableColGroupFrame *)newFrame)->SetType(aColGroupType);
|
|
|
|
newFrame->Init(&aPresContext, colGroupContent, this, colGroupStyle, nsnull);
|
|
|
|
}
|
|
|
|
return (nsTableColGroupFrame *)newFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableFrame::CreateAnonymousColFrames(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aNumColsToAdd,
|
|
|
|
nsTableColType aColType,
|
|
|
|
PRBool aDoAppend,
|
|
|
|
nsIFrame* aPrevColIn)
|
|
|
|
{
|
|
|
|
// get the last col group frame
|
|
|
|
nsTableColGroupFrame* colGroupFrame = nsnull;
|
|
|
|
nsIFrame* childFrame = mColGroups.FirstChild();
|
|
|
|
while (childFrame) {
|
|
|
|
nsIAtom* frameType = nsnull;
|
|
|
|
childFrame->GetFrameType(&frameType);
|
|
|
|
if (nsLayoutAtoms::tableColGroupFrame == frameType) {
|
|
|
|
colGroupFrame = (nsTableColGroupFrame *)childFrame;
|
|
|
|
}
|
|
|
|
childFrame->GetNextSibling(&childFrame);
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableColGroupType lastColGroupType = eColGroupContent;
|
|
|
|
nsTableColGroupType newColGroupType = eColGroupContent;
|
|
|
|
if (colGroupFrame) {
|
|
|
|
lastColGroupType = colGroupFrame->GetType();
|
|
|
|
}
|
|
|
|
if (eColAnonymousCell == aColType) {
|
|
|
|
if (eColGroupAnonymousCell != lastColGroupType) {
|
|
|
|
newColGroupType = eColGroupAnonymousCell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (eColAnonymousCol == aColType) {
|
|
|
|
if (eColGroupAnonymousCol != lastColGroupType) {
|
|
|
|
newColGroupType = eColGroupAnonymousCol;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(PR_FALSE, "CreateAnonymousColFrames called incorrectly");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eColGroupContent != newColGroupType) {
|
|
|
|
PRInt32 colIndex = (colGroupFrame) ? colGroupFrame->GetStartColumnIndex() + colGroupFrame->GetColCount()
|
|
|
|
: 0;
|
|
|
|
colGroupFrame = CreateAnonymousColGroupFrame(aPresContext, newColGroupType);
|
|
|
|
if (!colGroupFrame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mColGroups.AppendFrame(this, colGroupFrame); // add the new frame to the child list
|
|
|
|
colGroupFrame->SetStartColumnIndex(colIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* prevCol = (aDoAppend) ? colGroupFrame->GetChildList().LastChild() : aPrevColIn;
|
|
|
|
|
|
|
|
nsIFrame* firstNewFrame;
|
|
|
|
CreateAnonymousColFrames(aPresContext, *colGroupFrame, aNumColsToAdd,
|
|
|
|
aColType, PR_TRUE, prevCol, &firstNewFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX this needs to be moved to nsCSSFrameConstructor
|
|
|
|
// Right now it only creates the col frames at the end
|
|
|
|
void
|
|
|
|
nsTableFrame::CreateAnonymousColFrames(nsIPresContext& aPresContext,
|
|
|
|
nsTableColGroupFrame& aColGroupFrame,
|
|
|
|
PRInt32 aNumColsToAdd,
|
|
|
|
nsTableColType aColType,
|
|
|
|
PRBool aAddToColGroupAndTable,
|
|
|
|
nsIFrame* aPrevFrameIn,
|
|
|
|
nsIFrame** aFirstNewFrame)
|
|
|
|
{
|
|
|
|
*aFirstNewFrame = nsnull;
|
|
|
|
nsIFrame* lastColFrame = nsnull;
|
|
|
|
nsIFrame* childFrame;
|
|
|
|
|
|
|
|
// Get the last col frame
|
2000-01-22 04:16:50 +03:00
|
|
|
aColGroupFrame.FirstChild(&aPresContext, nsnull, &childFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
while (childFrame) {
|
|
|
|
nsIAtom* frameType = nsnull;
|
|
|
|
childFrame->GetFrameType(&frameType);
|
|
|
|
if (nsLayoutAtoms::tableColFrame == frameType) {
|
|
|
|
lastColFrame = (nsTableColGroupFrame *)childFrame;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
childFrame->GetNextSibling(&childFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 startIndex = mColFrames.Count();
|
|
|
|
PRInt32 lastIndex = startIndex + aNumColsToAdd - 1;
|
|
|
|
|
|
|
|
for (PRInt32 childX = startIndex; childX <= lastIndex; childX++) {
|
|
|
|
nsCOMPtr<nsIContent> iContent;
|
|
|
|
nsCOMPtr<nsIStyleContext> styleContext;
|
|
|
|
|
|
|
|
if ((aColType == eColAnonymousCol) && aPrevFrameIn) {
|
|
|
|
// a col due to a span in a previous col uses the style context of the col
|
|
|
|
aPrevFrameIn->GetStyleContext(getter_AddRefs(styleContext));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// all other anonymous cols use a pseudo style context of the col group
|
|
|
|
aColGroupFrame.GetContent(getter_AddRefs(iContent));
|
|
|
|
aPresContext.ResolvePseudoStyleContextFor(iContent, nsHTMLAtoms::tableColPseudo,
|
|
|
|
styleContext, PR_FALSE, getter_AddRefs(styleContext));
|
|
|
|
}
|
|
|
|
// create the new col frame
|
|
|
|
nsIFrame* colFrame;
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext.GetShell(getter_AddRefs(presShell));
|
|
|
|
NS_NewTableColFrame(presShell, &colFrame);
|
|
|
|
((nsTableColFrame *) colFrame)->SetType(aColType);
|
|
|
|
colFrame->Init(&aPresContext, iContent, &aColGroupFrame,
|
|
|
|
styleContext, nsnull);
|
|
|
|
colFrame->SetInitialChildList(&aPresContext, nsnull, nsnull);
|
|
|
|
((nsTableColFrame *)colFrame)->SetType(aColType);
|
|
|
|
|
|
|
|
// Add the col to the sibling chain
|
|
|
|
if (lastColFrame) {
|
|
|
|
lastColFrame->SetNextSibling(colFrame);
|
|
|
|
}
|
|
|
|
lastColFrame = colFrame;
|
|
|
|
if (childX == startIndex) {
|
|
|
|
*aFirstNewFrame = colFrame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aAddToColGroupAndTable) {
|
|
|
|
nsFrameList& cols = aColGroupFrame.GetChildList();
|
|
|
|
// the chain already exists, now add it to the col group child list
|
|
|
|
if (!aPrevFrameIn) {
|
|
|
|
cols.AppendFrames(&aColGroupFrame, *aFirstNewFrame);
|
|
|
|
}
|
|
|
|
// get the starting col index in the cache
|
|
|
|
PRInt32 startColIndex = aColGroupFrame.GetStartColumnIndex();
|
|
|
|
if (aPrevFrameIn) {
|
|
|
|
nsTableColFrame* colFrame =
|
2000-01-22 04:16:50 +03:00
|
|
|
(nsTableColFrame*)nsTableFrame::GetFrameAtOrBefore(&aPresContext,
|
|
|
|
(nsIFrame*)&aColGroupFrame, aPrevFrameIn,
|
1999-12-14 01:56:31 +03:00
|
|
|
nsLayoutAtoms::tableColFrame);
|
|
|
|
if (colFrame) {
|
|
|
|
startColIndex = colFrame->GetColIndex();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aColGroupFrame.AddColsToTable(aPresContext, startColIndex, PR_TRUE,
|
|
|
|
*aFirstNewFrame, lastColFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 nsTableFrame::AppendCell(nsIPresContext& aPresContext,
|
|
|
|
nsTableCellFrame& aCellFrame,
|
|
|
|
PRInt32 aRowIndex)
|
|
|
|
{
|
|
|
|
PRInt32 colIndex = 0;
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-12-14 01:56:31 +03:00
|
|
|
if (cellMap) {
|
2000-01-13 08:29:38 +03:00
|
|
|
colIndex = cellMap->AppendCell(aCellFrame, aRowIndex, PR_TRUE);
|
1999-12-14 01:56:31 +03:00
|
|
|
PRInt32 numColsInMap = GetColCount();
|
|
|
|
PRInt32 numColsInCache = mColFrames.Count();
|
|
|
|
PRInt32 numColsToAdd = numColsInMap - numColsInCache;
|
|
|
|
if (numColsToAdd > 0) {
|
|
|
|
// this sets the child list, updates the col cache and cell map
|
|
|
|
CreateAnonymousColFrames(aPresContext, numColsToAdd, eColAnonymousCell, PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return colIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableFrame::InsertCells(nsIPresContext& aPresContext,
|
|
|
|
nsVoidArray& aCellFrames,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndexBefore)
|
1998-06-17 20:38:24 +04:00
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-12-14 01:56:31 +03:00
|
|
|
if (cellMap) {
|
|
|
|
cellMap->InsertCells(aCellFrames, aRowIndex, aColIndexBefore);
|
|
|
|
PRInt32 numColsInMap = GetColCount();
|
|
|
|
PRInt32 numColsInCache = mColFrames.Count();
|
|
|
|
PRInt32 numColsToAdd = numColsInMap - numColsInCache;
|
|
|
|
if (numColsToAdd > 0) {
|
|
|
|
// this sets the child list, updates the col cache and cell map
|
|
|
|
CreateAnonymousColFrames(aPresContext, numColsToAdd, eColAnonymousCell, PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// this removes the frames from the col group and table, but not the cell map
|
|
|
|
PRInt32
|
|
|
|
nsTableFrame::DestroyAnonymousColFrames(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aNumFrames)
|
|
|
|
{
|
|
|
|
// only remove cols that are of type eTypeAnonymous cell (they are at the end)
|
|
|
|
PRInt32 endIndex = mColFrames.Count() - 1;
|
|
|
|
PRInt32 startIndex = (endIndex - aNumFrames) + 1;
|
|
|
|
PRInt32 numColsRemoved = 0;
|
|
|
|
for (PRInt32 colX = endIndex; colX >= startIndex; colX--) {
|
|
|
|
nsTableColFrame* colFrame = GetColFrame(colX);
|
|
|
|
if (colFrame && (eColAnonymousCell == colFrame->GetType())) {
|
|
|
|
nsTableColGroupFrame* cgFrame;
|
|
|
|
colFrame->GetParent((nsIFrame**)&cgFrame);
|
|
|
|
// remove the frame from the colgroup
|
|
|
|
cgFrame->RemoveChild(aPresContext, *colFrame, PR_FALSE);
|
|
|
|
// remove the frame from the cache, but not the cell map
|
|
|
|
RemoveCol(aPresContext, nsnull, colX, PR_TRUE, PR_FALSE);
|
|
|
|
numColsRemoved++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (aNumFrames - numColsRemoved);
|
|
|
|
}
|
1998-09-01 01:23:28 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
void nsTableFrame::RemoveCell(nsIPresContext& aPresContext,
|
|
|
|
nsTableCellFrame* aCellFrame,
|
|
|
|
PRInt32 aRowIndex)
|
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-12-14 01:56:31 +03:00
|
|
|
if (cellMap) {
|
|
|
|
cellMap->RemoveCell(aCellFrame, aRowIndex);
|
|
|
|
PRInt32 numColsInMap = GetColCount(); // cell map's notion of num cols
|
|
|
|
PRInt32 numColsInCache = mColFrames.Count();
|
|
|
|
PRInt32 numColsNotRemoved = DestroyAnonymousColFrames(aPresContext, numColsInCache - numColsInMap);
|
|
|
|
// if the cell map has fewer cols than the cache, correct it
|
|
|
|
if (numColsNotRemoved > 0) {
|
|
|
|
cellMap->AddColsAtEnd(numColsNotRemoved);
|
|
|
|
}
|
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
1998-07-02 02:22:28 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// this cannot extend beyond a single row group
|
2000-01-13 08:29:38 +03:00
|
|
|
void nsTableFrame::AppendRows(nsIPresContext& aPresContext,
|
|
|
|
nsTableRowGroupFrame& aRowGroupFrame,
|
|
|
|
nsVoidArray& aRowFrames)
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-12-14 01:56:31 +03:00
|
|
|
if (cellMap) {
|
|
|
|
PRInt32 rowIndex = cellMap->GetRowCount();
|
2000-01-13 08:29:38 +03:00
|
|
|
InsertRows(aPresContext, aRowGroupFrame, aRowFrames, rowIndex, PR_TRUE);
|
1998-06-17 20:38:24 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
PRInt32
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableFrame::InsertRow(nsIPresContext& aPresContext,
|
|
|
|
nsTableRowGroupFrame& aRowGroupFrame,
|
|
|
|
nsIFrame& aRowFrame,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRBool aConsiderSpans)
|
1999-06-14 12:01:00 +04:00
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
nsVoidArray rows;
|
|
|
|
rows.AppendElement(&aRowFrame);
|
2000-01-13 08:29:38 +03:00
|
|
|
return InsertRows(aPresContext, aRowGroupFrame, rows, aRowIndex, aConsiderSpans);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// this cannot extend beyond a single row group
|
|
|
|
PRInt32
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableFrame::InsertRows(nsIPresContext& aPresContext,
|
|
|
|
nsTableRowGroupFrame& aRowGroupFrame,
|
|
|
|
nsVoidArray& aRowFrames,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRBool aConsiderSpans)
|
1999-12-14 01:56:31 +03:00
|
|
|
{
|
|
|
|
//printf("insertRowsBefore firstRow=%d \n", aRowIndex);
|
|
|
|
//Dump(PR_TRUE, PR_FALSE, PR_TRUE);
|
|
|
|
|
|
|
|
PRInt32 numColsToAdd = 0;
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-12-14 01:56:31 +03:00
|
|
|
if (cellMap) {
|
|
|
|
PRInt32 origNumRows = cellMap->GetRowCount();
|
|
|
|
PRInt32 numNewRows = aRowFrames.Count();
|
2000-01-22 04:16:50 +03:00
|
|
|
cellMap->InsertRows(&aPresContext, aRowGroupFrame, aRowFrames, aRowIndex, aConsiderSpans);
|
1999-12-14 01:56:31 +03:00
|
|
|
PRInt32 numColsInMap = GetColCount(); // cell map's notion of num cols
|
|
|
|
PRInt32 numColsInCache = mColFrames.Count();
|
|
|
|
numColsToAdd = numColsInMap - numColsInCache;
|
|
|
|
if (numColsToAdd > 0) {
|
|
|
|
// this sets the child list, updates the col cache and cell map
|
|
|
|
CreateAnonymousColFrames(aPresContext, numColsToAdd, eColAnonymousCell,
|
|
|
|
PR_TRUE);
|
1999-06-14 12:01:00 +04:00
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
if (aRowIndex < origNumRows) {
|
2000-01-22 04:16:50 +03:00
|
|
|
AdjustRowIndices(&aPresContext, aRowIndex, numNewRows);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
// assign the correct row indices to the new rows. If they were adjusted above
|
|
|
|
// it may not have been done correctly because each row is constructed with index 0
|
|
|
|
for (PRInt32 rowX = 0; rowX < numNewRows; rowX++) {
|
|
|
|
nsTableRowFrame* rowFrame = (nsTableRowFrame *) aRowFrames.ElementAt(rowX);
|
|
|
|
rowFrame->SetRowIndex(aRowIndex + rowX);
|
1999-06-14 12:01:00 +04:00
|
|
|
}
|
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
//printf("insertRowsAfter \n");
|
|
|
|
//Dump(PR_TRUE, PR_FALSE, PR_TRUE);
|
|
|
|
|
|
|
|
return numColsToAdd;
|
1999-06-14 12:01:00 +04:00
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// this cannot extend beyond a single row group
|
|
|
|
void nsTableFrame::RemoveRows(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aFirstRowIndex,
|
|
|
|
PRInt32 aNumRowsToRemove,
|
|
|
|
PRBool aConsiderSpans)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
//printf("removeRowsBefore firstRow=%d numRows=%d\n", aFirstRowIndex, aNumRowsToRemove);
|
|
|
|
//Dump(PR_TRUE, PR_FALSE, PR_TRUE);
|
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-12-14 01:56:31 +03:00
|
|
|
if (cellMap) {
|
2000-01-22 04:16:50 +03:00
|
|
|
cellMap->RemoveRows(&aPresContext, aFirstRowIndex, aNumRowsToRemove, aConsiderSpans);
|
1999-12-14 01:56:31 +03:00
|
|
|
// only remove cols that are of type eTypeAnonymous cell (they are at the end)
|
|
|
|
PRInt32 numColsInMap = GetColCount(); // cell map's notion of num cols
|
|
|
|
PRInt32 numColsInCache = mColFrames.Count();
|
|
|
|
PRInt32 numColsNotRemoved = DestroyAnonymousColFrames(aPresContext, numColsInCache - numColsInMap);
|
|
|
|
// if the cell map has fewer cols than the cache, correct it
|
|
|
|
if (numColsNotRemoved > 0) {
|
|
|
|
cellMap->AddColsAtEnd(numColsNotRemoved);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
}
|
2000-01-22 04:16:50 +03:00
|
|
|
AdjustRowIndices(&aPresContext, aFirstRowIndex, -aNumRowsToRemove);
|
1999-12-14 01:56:31 +03:00
|
|
|
//printf("removeRowsAfter\n");
|
|
|
|
//Dump(PR_TRUE, PR_FALSE, PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableFrame::AppendRowGroups(nsIPresContext& aPresContext,
|
|
|
|
nsIFrame* aFirstRowGroupFrame)
|
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-12-14 01:56:31 +03:00
|
|
|
if (cellMap) {
|
|
|
|
PRInt32 rowIndex = cellMap->GetRowCount();
|
|
|
|
InsertRowGroups(aPresContext, aFirstRowGroupFrame, rowIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableRowGroupFrame*
|
|
|
|
nsTableFrame::GetRowGroupFrame(nsIFrame* aFrame,
|
|
|
|
nsIAtom* aFrameTypeIn)
|
|
|
|
{
|
|
|
|
nsIFrame* rgFrame = nsnull;
|
|
|
|
nsIAtom* frameType = aFrameTypeIn;
|
|
|
|
if (!aFrameTypeIn) {
|
|
|
|
aFrame->GetFrameType(&frameType);
|
|
|
|
}
|
|
|
|
if (nsLayoutAtoms::tableRowGroupFrame == frameType) {
|
|
|
|
rgFrame = aFrame;
|
|
|
|
}
|
|
|
|
else if (nsLayoutAtoms::scrollFrame == frameType) {
|
|
|
|
nsIScrollableFrame* scrollable = nsnull;
|
|
|
|
nsresult rv = aFrame->QueryInterface(kIScrollableFrameIID, (void **)&scrollable);
|
|
|
|
if (NS_SUCCEEDED(rv) && (scrollable)) {
|
|
|
|
nsIFrame* scrolledFrame;
|
|
|
|
scrollable->GetScrolledFrame(nsnull, scrolledFrame);
|
|
|
|
if (scrolledFrame) {
|
|
|
|
nsIAtom* scrolledType;
|
|
|
|
scrolledFrame->GetFrameType(&scrolledType);
|
|
|
|
if (nsLayoutAtoms::tableRowGroupFrame == scrolledType) {
|
|
|
|
rgFrame = scrolledFrame;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(scrolledType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!aFrameTypeIn) {
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
}
|
|
|
|
return (nsTableRowGroupFrame*)rgFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
// collect the rows ancestors of aFrame
|
2000-01-13 08:29:38 +03:00
|
|
|
PRInt32
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableFrame::CollectRows(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsVoidArray& aCollection)
|
1999-12-14 01:56:31 +03:00
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
if (!aFrame) return 0;
|
|
|
|
PRInt32 numRows = 0;
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(aFrame);
|
|
|
|
if (rgFrame) {
|
|
|
|
nsIFrame* childFrame = nsnull;
|
2000-01-22 04:16:50 +03:00
|
|
|
rgFrame->FirstChild(aPresContext, nsnull, &childFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
while (childFrame) {
|
|
|
|
nsIAtom* childType;
|
|
|
|
childFrame->GetFrameType(&childType);
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == childType) {
|
|
|
|
aCollection.AppendElement(childFrame);
|
2000-01-13 08:29:38 +03:00
|
|
|
numRows++;
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
else {
|
2000-01-22 04:16:50 +03:00
|
|
|
numRows += CollectRows(aPresContext, childFrame, aCollection);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
NS_IF_RELEASE(childType);
|
|
|
|
childFrame->GetNextSibling(&childFrame);
|
|
|
|
}
|
|
|
|
}
|
2000-01-13 08:29:38 +03:00
|
|
|
return numRows;
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableFrame::InsertRowGroups(nsIPresContext& aPresContext,
|
|
|
|
nsIFrame* aFirstRowGroupFrame,
|
|
|
|
PRInt32 aRowIndex)
|
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-12-14 01:56:31 +03:00
|
|
|
if (cellMap) {
|
2000-01-13 08:29:38 +03:00
|
|
|
PRInt32 rowIndex = aRowIndex;
|
1999-12-14 01:56:31 +03:00
|
|
|
nsVoidArray rows;
|
|
|
|
for (nsIFrame* kidFrame = aFirstRowGroupFrame; kidFrame; kidFrame->GetNextSibling(&kidFrame)) {
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(kidFrame);
|
|
|
|
if (rgFrame) {
|
|
|
|
// create and add the cell map for the row group
|
|
|
|
cellMap->InsertGroupCellMap(rowIndex, *rgFrame);
|
|
|
|
// collect the new row frames in an array and add them to the table
|
2000-01-22 04:16:50 +03:00
|
|
|
PRInt32 numRows = CollectRows(&aPresContext, kidFrame, rows);
|
2000-01-13 08:29:38 +03:00
|
|
|
if (numRows > 0) {
|
|
|
|
InsertRows(aPresContext, *rgFrame, rows, rowIndex, PR_TRUE);
|
|
|
|
rowIndex += numRows;
|
|
|
|
rows.Clear();
|
|
|
|
}
|
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
/* ***** Column Layout Data methods ***** */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lists the column layout data which turns
|
|
|
|
* around and lists the cell layout data.
|
|
|
|
* This is for debugging purposes only.
|
|
|
|
*/
|
1998-11-06 00:42:46 +03:00
|
|
|
#ifdef NS_DEBUG
|
1998-07-24 20:51:16 +04:00
|
|
|
void nsTableFrame::ListColumnLayoutData(FILE* out, PRInt32 aIndent)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-07-11 04:00:31 +04:00
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
if (this!=firstInFlow)
|
|
|
|
{
|
|
|
|
firstInFlow->ListColumnLayoutData(out, aIndent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap *cellMap = GetCellMap();
|
1998-08-18 03:37:04 +04:00
|
|
|
if (nsnull!=cellMap)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
fprintf(out,"Column Layout Data \n");
|
|
|
|
|
1998-10-20 09:05:17 +04:00
|
|
|
PRInt32 numCols = cellMap->GetColCount();
|
1998-08-18 03:37:04 +04:00
|
|
|
PRInt32 numRows = cellMap->GetRowCount();
|
1998-07-11 04:00:31 +04:00
|
|
|
for (PRInt32 colIndex = 0; colIndex<numCols; colIndex++)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-07-11 04:00:31 +04:00
|
|
|
for (PRInt32 indent = aIndent; --indent >= 0; )
|
|
|
|
fputs(" ", out);
|
|
|
|
fprintf(out,"Column Data [%d] \n",colIndex);
|
|
|
|
for (PRInt32 rowIndex = 0; rowIndex < numRows; rowIndex++)
|
|
|
|
{
|
1999-10-22 18:51:41 +04:00
|
|
|
// nsTableCellFrame* cellFrame = cellMap->GetCellInfoAt(rowIndex, colIndex);
|
1998-07-11 04:00:31 +04:00
|
|
|
PRInt32 rowIndent;
|
|
|
|
for (rowIndent = aIndent+2; --rowIndent >= 0; ) fputs(" ", out);
|
|
|
|
fprintf(out,"Cell Data [%d] \n",rowIndex);
|
1999-10-20 18:18:56 +04:00
|
|
|
for (rowIndent = aIndent+2; --rowIndent >= 0; ) fputs(" ", out);
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-11-06 00:42:46 +03:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-17 10:04:42 +03:00
|
|
|
|
1998-12-03 21:01:35 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Child frame enumeration
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableFrame::FirstChild(nsIPresContext* aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame** aFirstChild) const
|
1998-12-03 21:01:35 +03:00
|
|
|
{
|
2000-01-22 04:16:50 +03:00
|
|
|
NS_PRECONDITION(nsnull != aFirstChild, "null OUT parameter pointer");
|
|
|
|
if (aListName == nsLayoutAtoms::colGroupList) {
|
1999-02-10 05:25:01 +03:00
|
|
|
*aFirstChild = mColGroups.FirstChild();
|
1998-12-03 21:01:35 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-01-22 04:16:50 +03:00
|
|
|
|
|
|
|
return nsHTMLContainerFrame::FirstChild(aPresContext, aListName, aFirstChild);
|
1998-12-03 21:01:35 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-03 21:01:35 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableFrame::GetAdditionalChildListName(PRInt32 aIndex,
|
1999-02-10 05:25:01 +03:00
|
|
|
nsIAtom** aListName) const
|
1998-12-03 21:01:35 +03:00
|
|
|
{
|
1999-02-10 05:25:01 +03:00
|
|
|
NS_PRECONDITION(nsnull != aListName, "null OUT parameter pointer");
|
1998-12-03 21:01:35 +03:00
|
|
|
if (aIndex < 0) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
1999-02-10 05:25:01 +03:00
|
|
|
*aListName = nsnull;
|
1998-12-03 21:01:35 +03:00
|
|
|
switch (aIndex) {
|
|
|
|
case NS_TABLE_FRAME_COLGROUP_LIST_INDEX:
|
1999-02-10 05:25:01 +03:00
|
|
|
*aListName = nsLayoutAtoms::colGroupList;
|
|
|
|
NS_ADDREF(*aListName);
|
1998-12-03 21:01:35 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/* SEC: TODO: adjust the rect for captions */
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableFrame::Paint(nsIPresContext* aPresContext,
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-12-21 09:38:18 +03:00
|
|
|
// table paint code is concerned primarily with borders and bg color
|
1999-03-26 03:39:35 +03:00
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsStyleDisplay* disp =
|
|
|
|
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
|
|
|
|
if (disp->mVisible) {
|
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
const nsStyleColor* color =
|
|
|
|
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
|
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
1999-06-08 01:10:25 +04:00
|
|
|
|
|
|
|
nsCompatibility mode;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetCompatibilityMode(&mode);
|
1999-06-08 01:10:25 +04:00
|
|
|
if (eCompatibility_Standard == mode) {
|
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, *color, *spacing, 0, 0);
|
|
|
|
// paint the column groups and columns
|
|
|
|
nsIFrame* colGroupFrame = mColGroups.FirstChild();
|
|
|
|
while (nsnull != colGroupFrame) {
|
|
|
|
PaintChild(aPresContext, aRenderingContext, aDirtyRect, colGroupFrame, aWhichLayer);
|
|
|
|
colGroupFrame->GetNextSibling(&colGroupFrame);
|
|
|
|
}
|
|
|
|
}
|
1998-12-18 18:54:23 +03:00
|
|
|
PRIntn skipSides = GetSkipSides();
|
1999-08-10 04:49:10 +04:00
|
|
|
if (NS_STYLE_BORDER_SEPARATE == GetBorderCollapseStyle())
|
1998-12-18 18:54:23 +03:00
|
|
|
{
|
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
1999-01-23 01:38:34 +03:00
|
|
|
aDirtyRect, rect, *spacing, mStyleContext, skipSides);
|
1998-12-18 18:54:23 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-12-31 02:23:45 +03:00
|
|
|
//printf("paint table frame\n");
|
1999-10-28 08:09:39 +04:00
|
|
|
nsBorderEdges* edges = nsnull;
|
|
|
|
if (mBorderCollapser) {
|
|
|
|
edges = mBorderCollapser->GetEdges();
|
|
|
|
}
|
1998-12-21 09:38:18 +03:00
|
|
|
nsCSSRendering::PaintBorderEdges(aPresContext, aRenderingContext, this,
|
1999-10-28 08:09:39 +04:00
|
|
|
aDirtyRect, rect, edges, mStyleContext, skipSides);
|
1998-12-18 18:54:23 +03:00
|
|
|
}
|
1998-12-18 01:59:40 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
1998-04-14 00:24:54 +04:00
|
|
|
// for debug...
|
1999-03-26 03:39:35 +03:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
|
1998-12-23 18:47:43 +03:00
|
|
|
aRenderingContext.SetColor(NS_RGB(0,255,0));
|
1998-04-14 00:24:54 +04:00
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-18 18:54:23 +03:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1999-09-18 03:33:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
/*nsFrame::Paint(aPresContext,
|
1999-05-20 04:52:00 +04:00
|
|
|
aRenderingContext,
|
|
|
|
aDirtyRect,
|
1999-09-18 03:33:39 +04:00
|
|
|
aWhichLayer);*/
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-05-20 04:52:00 +04:00
|
|
|
|
|
|
|
//null range means the whole thing
|
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsTableFrame::SetSelected(nsIPresContext* aPresContext,
|
|
|
|
nsIDOMRange *aRange,
|
|
|
|
PRBool aSelected,
|
|
|
|
nsSpread aSpread)
|
1999-05-20 04:52:00 +04:00
|
|
|
{
|
1999-09-22 02:58:14 +04:00
|
|
|
#if 0
|
1999-05-20 04:52:00 +04:00
|
|
|
//traverse through children unselect tables
|
1999-09-18 03:33:39 +04:00
|
|
|
if ((aSpread == eSpreadDown)){
|
1999-05-20 04:52:00 +04:00
|
|
|
nsIFrame* kid;
|
|
|
|
nsresult rv = FirstChild(nsnull, &kid);
|
1999-09-02 01:37:32 +04:00
|
|
|
while (NS_SUCCEEDED(rv) && nsnull != kid) {
|
1999-09-18 03:33:39 +04:00
|
|
|
kid->SetSelected(nsnull,aSelected,eSpreadDown);
|
1999-05-20 04:52:00 +04:00
|
|
|
|
1999-09-02 01:37:32 +04:00
|
|
|
rv = kid->GetNextSibling(&kid);
|
1999-05-20 04:52:00 +04:00
|
|
|
}
|
|
|
|
}
|
1999-09-22 02:58:14 +04:00
|
|
|
#endif
|
|
|
|
return NS_OK;//return nsFrame::SetSelected(aRange,aSelected,eSpreadNone);
|
|
|
|
|
1999-05-20 04:52:00 +04:00
|
|
|
}
|
|
|
|
|
1999-06-02 03:04:13 +04:00
|
|
|
PRBool nsTableFrame::ParentDisablesSelection() const //override default behavior
|
|
|
|
{
|
|
|
|
PRBool returnval;
|
|
|
|
if (NS_FAILED(GetSelected(&returnval)))
|
|
|
|
return PR_FALSE;
|
|
|
|
if (returnval)
|
|
|
|
return PR_TRUE;
|
|
|
|
return nsFrame::ParentDisablesSelection();
|
|
|
|
}
|
1999-05-20 04:52:00 +04:00
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
PRIntn
|
|
|
|
nsTableFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
1998-11-11 22:56:02 +03:00
|
|
|
// frame attribute was accounted for in nsHTMLTableElement::MapTableBorderInto
|
|
|
|
// account for pagination
|
1998-10-20 21:45:07 +04:00
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
PRBool nsTableFrame::NeedsReflow(const nsHTMLReflowState& aReflowState)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
PRBool result = PR_TRUE;
|
1999-08-03 18:26:00 +04:00
|
|
|
|
1999-10-05 03:48:05 +04:00
|
|
|
if (mBits.mIsInvariantWidth) {
|
1999-08-03 18:26:00 +04:00
|
|
|
result = PR_FALSE;
|
|
|
|
} else if ((eReflowReason_Incremental == aReflowState.reason) &&
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight)) {
|
|
|
|
// If it's an incremental reflow and we're in galley mode, then only
|
|
|
|
// do a full reflow if we need to. We need to if the cell map is invalid,
|
|
|
|
// or the column info is invalid, or if we need to do a pass-1 reflow
|
1999-12-14 01:56:31 +03:00
|
|
|
result = !(IsFirstPassValid() && IsColumnWidthsValid());
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-08-03 18:26:00 +04:00
|
|
|
// Called by IR_TargetIsChild() after an incremental reflow of
|
|
|
|
// aKidFrame. Only called if we don't need a full reflow, e.g., the
|
|
|
|
// column widths haven't changed. Not used for paginated mode, so
|
|
|
|
// we don't need to worry about split row group frames
|
|
|
|
//
|
|
|
|
// Slides all the row groups following aKidFrame by the specified
|
|
|
|
// amount
|
1999-08-19 07:51:25 +04:00
|
|
|
//
|
|
|
|
// XXX This is kind of klunky because the InnerTableReflowState::y
|
|
|
|
// data member does not include the table's border/padding...
|
1999-11-24 09:03:41 +03:00
|
|
|
nsresult nsTableFrame::AdjustSiblingsAfterReflow(nsIPresContext* aPresContext,
|
1998-10-21 00:05:44 +04:00
|
|
|
InnerTableReflowState& aReflowState,
|
1998-07-07 01:39:23 +04:00
|
|
|
nsIFrame* aKidFrame,
|
1999-08-31 02:30:32 +04:00
|
|
|
nsSize* aMaxElementSize,
|
1998-07-07 01:39:23 +04:00
|
|
|
nscoord aDeltaY)
|
|
|
|
{
|
1999-08-03 18:26:00 +04:00
|
|
|
NS_PRECONDITION(NS_UNCONSTRAINEDSIZE == aReflowState.reflowState.availableHeight,
|
1999-08-19 07:51:25 +04:00
|
|
|
"we're not in galley mode");
|
1998-07-07 01:39:23 +04:00
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// If it's the footer that was reflowed, then we don't need to adjust any of
|
|
|
|
// the frames, because the footer is the bottom most frame
|
|
|
|
if (aKidFrame != aReflowState.footerFrame) {
|
1998-07-07 01:39:23 +04:00
|
|
|
nsIFrame* kidFrame;
|
1999-08-19 07:51:25 +04:00
|
|
|
nsRect kidRect;
|
|
|
|
PRBool movedFooter = PR_FALSE;
|
|
|
|
|
|
|
|
// Move the frames that follow aKidFrame by aDeltaY, and update the running
|
|
|
|
// y-offset
|
|
|
|
for (aKidFrame->GetNextSibling(&kidFrame); kidFrame; kidFrame->GetNextSibling(&kidFrame)) {
|
2000-02-28 01:36:42 +03:00
|
|
|
nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(kidFrame);
|
|
|
|
if (!rgFrame) continue; // skip foreign frames
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// See if it's the footer we're moving
|
|
|
|
if (kidFrame == aReflowState.footerFrame) {
|
|
|
|
movedFooter = PR_TRUE;
|
|
|
|
}
|
1998-07-07 01:39:23 +04:00
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Get the frame's bounding rect
|
|
|
|
kidFrame->GetRect(kidRect);
|
1998-07-07 01:39:23 +04:00
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Adjust the running y-offset
|
|
|
|
aReflowState.y += kidRect.height;
|
1999-08-31 02:30:32 +04:00
|
|
|
|
|
|
|
// Update the max element size
|
|
|
|
//XXX: this should call into layout strategy to get the width field
|
2000-02-28 01:36:42 +03:00
|
|
|
if (aMaxElementSize) {
|
1999-08-31 02:30:32 +04:00
|
|
|
const nsStyleSpacing* tableSpacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing , ((const nsStyleStruct *&)tableSpacing));
|
|
|
|
nsMargin borderPadding;
|
|
|
|
GetTableBorder (borderPadding); // gets the max border thickness for each edge
|
2000-02-12 04:55:40 +03:00
|
|
|
borderPadding += aReflowState.reflowState.mComputedPadding;
|
1999-08-31 02:30:32 +04:00
|
|
|
nscoord cellSpacing = GetCellSpacingX();
|
|
|
|
nsSize kidMaxElementSize;
|
2000-02-28 01:36:42 +03:00
|
|
|
rgFrame->GetMaxElementSize(kidMaxElementSize);
|
1999-08-31 02:30:32 +04:00
|
|
|
nscoord kidWidth = kidMaxElementSize.width + borderPadding.left + borderPadding.right + cellSpacing*2;
|
|
|
|
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, kidWidth);
|
|
|
|
aMaxElementSize->height += kidMaxElementSize.height;
|
|
|
|
}
|
1999-08-19 07:51:25 +04:00
|
|
|
|
|
|
|
// Adjust the y-origin if its position actually changed
|
|
|
|
if (aDeltaY != 0) {
|
|
|
|
kidRect.y += aDeltaY;
|
1999-11-24 09:03:41 +03:00
|
|
|
kidFrame->MoveTo(aPresContext, kidRect.x, kidRect.y);
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We also need to move the footer if there is one and we haven't already
|
|
|
|
// moved it
|
|
|
|
if (aReflowState.footerFrame && !movedFooter) {
|
|
|
|
aReflowState.footerFrame->GetRect(kidRect);
|
|
|
|
|
|
|
|
// Adjust the running y-offset
|
|
|
|
aReflowState.y += kidRect.height;
|
|
|
|
|
|
|
|
if (aDeltaY != 0) {
|
|
|
|
kidRect.y += aDeltaY;
|
1999-11-24 09:03:41 +03:00
|
|
|
aReflowState.footerFrame->MoveTo(aPresContext, kidRect.x, kidRect.y);
|
1998-10-01 08:46:11 +04:00
|
|
|
}
|
1998-07-07 01:39:23 +04:00
|
|
|
}
|
1999-09-13 07:19:39 +04:00
|
|
|
|
|
|
|
// Invalidate the area we offset. Note that we only repaint within
|
|
|
|
// our existing frame bounds.
|
|
|
|
// XXX It would be better to bitblt the row frames and not repaint,
|
|
|
|
// but we don't have such a view manager function yet...
|
|
|
|
aKidFrame->GetRect(kidRect);
|
|
|
|
if (kidRect.YMost() < mRect.height) {
|
|
|
|
nsRect dirtyRect(0, kidRect.YMost(),
|
|
|
|
mRect.width, mRect.height - kidRect.YMost());
|
1999-11-24 09:03:41 +03:00
|
|
|
Invalidate(aPresContext, dirtyRect);
|
1999-09-13 07:19:39 +04:00
|
|
|
}
|
1998-07-07 01:39:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-12 04:55:40 +03:00
|
|
|
void
|
|
|
|
nsTableFrame::SetColumnDimensions(nsIPresContext* aPresContext,
|
|
|
|
nscoord aHeight,
|
|
|
|
const nsMargin& aBorderPadding)
|
1999-06-08 01:10:25 +04:00
|
|
|
{
|
2000-02-12 04:55:40 +03:00
|
|
|
nscoord colHeight = aHeight -= aBorderPadding.top + aBorderPadding.bottom;
|
1999-06-08 01:10:25 +04:00
|
|
|
nscoord cellSpacingX = GetCellSpacingX();
|
|
|
|
nscoord halfCellSpacingX = NSToCoordRound(((float)cellSpacingX) / (float)2);
|
|
|
|
|
|
|
|
nsIFrame* colGroupFrame = mColGroups.FirstChild();
|
|
|
|
PRInt32 colX = 0;
|
2000-02-12 04:55:40 +03:00
|
|
|
nsPoint colGroupOrigin(aBorderPadding.left, aBorderPadding.top);
|
1999-07-28 12:09:02 +04:00
|
|
|
PRInt32 numCols = GetColCount();
|
1999-06-08 01:10:25 +04:00
|
|
|
while (nsnull != colGroupFrame) {
|
|
|
|
nscoord colGroupWidth = 0;
|
|
|
|
nsIFrame* colFrame = nsnull;
|
2000-01-22 04:16:50 +03:00
|
|
|
colGroupFrame->FirstChild(aPresContext, nsnull, &colFrame);
|
1999-06-08 01:10:25 +04:00
|
|
|
nsPoint colOrigin(0, 0);
|
|
|
|
while (nsnull != colFrame) {
|
1999-08-10 06:45:18 +04:00
|
|
|
const nsStyleDisplay* colDisplay;
|
|
|
|
colFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)colDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay) {
|
|
|
|
NS_ASSERTION(colX < numCols, "invalid number of columns");
|
|
|
|
nscoord colWidth = mColumnWidths[colX];
|
|
|
|
if (numCols == 1) {
|
|
|
|
colWidth += cellSpacingX + cellSpacingX;
|
|
|
|
}
|
|
|
|
else if ((0 == colX) || (numCols - 1 == colX)) {
|
|
|
|
colWidth += cellSpacingX + halfCellSpacingX;
|
|
|
|
}
|
1999-08-26 01:49:18 +04:00
|
|
|
else if (GetNumCellsOriginatingInCol(colX) > 0) {
|
1999-08-10 06:45:18 +04:00
|
|
|
colWidth += cellSpacingX;
|
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
|
1999-08-10 06:45:18 +04:00
|
|
|
colGroupWidth += colWidth;
|
|
|
|
nsRect colRect(colOrigin.x, colOrigin.y, colWidth, colHeight);
|
1999-10-26 08:44:41 +04:00
|
|
|
colFrame->SetRect(aPresContext, colRect);
|
1999-08-10 06:45:18 +04:00
|
|
|
colOrigin.x += colWidth;
|
|
|
|
colX++;
|
|
|
|
}
|
1999-06-08 01:10:25 +04:00
|
|
|
colFrame->GetNextSibling(&colFrame);
|
|
|
|
}
|
|
|
|
nsRect colGroupRect(colGroupOrigin.x, colGroupOrigin.y, colGroupWidth, colHeight);
|
1999-10-26 08:44:41 +04:00
|
|
|
colGroupFrame->SetRect(aPresContext, colGroupRect);
|
1999-06-08 01:10:25 +04:00
|
|
|
colGroupFrame->GetNextSibling(&colGroupFrame);
|
|
|
|
colGroupOrigin.x += colGroupWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// SEC: TODO need to worry about continuing frames prev/next in flow for splitting across pages.
|
|
|
|
|
|
|
|
/* overview:
|
|
|
|
if mFirstPassValid is false, this is our first time through since content was last changed
|
|
|
|
do pass 1
|
|
|
|
get min/max info for all cells in an infinite space
|
1998-11-16 09:46:00 +03:00
|
|
|
do column balancing
|
|
|
|
do pass 2
|
|
|
|
use column widths to size table and ResizeReflow rowgroups (and therefore rows and cells)
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
|
1998-05-29 01:39:22 +04:00
|
|
|
/* Layout the entire inner table. */
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-05-25 21:31:49 +04:00
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-08-24 16:01:31 +04:00
|
|
|
if (nsDebugTable::gRflTable) nsTableFrame::DebugReflow("T::Rfl en", this, &aReflowState, nsnull);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-07-07 01:39:23 +04:00
|
|
|
// Initialize out parameter
|
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
|
|
|
}
|
1998-05-12 08:17:56 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2000-02-12 04:55:40 +03:00
|
|
|
// XXX yank this nasty code and see what happens, and then yank other
|
|
|
|
// similar calls to InvalidateFirstPassCache.
|
1999-07-30 03:19:52 +04:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth) &&
|
|
|
|
(this == (nsTableFrame *)GetFirstInFlow())) {
|
|
|
|
InvalidateFirstPassCache();
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
nsresult rv = NS_OK;
|
1999-10-15 08:09:22 +04:00
|
|
|
nsSize* pass1MaxElementSize = aDesiredSize.maxElementSize;
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
|
|
|
rv = IncrementalReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-06-23 09:43:27 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// NeedsReflow and IsFirstPassValid take into account reflow type = Initial_Reflow
|
1999-12-14 01:56:31 +03:00
|
|
|
if (NeedsReflow(aReflowState)) {
|
|
|
|
PRBool needsRecalc = PR_FALSE;
|
1999-08-04 03:20:06 +04:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth) ||
|
1999-12-14 01:56:31 +03:00
|
|
|
(PR_FALSE==IsFirstPassValid())) {
|
1998-10-30 10:57:44 +03:00
|
|
|
nsReflowReason reason = aReflowState.reason;
|
1999-12-14 01:56:31 +03:00
|
|
|
if (eReflowReason_Initial != reason)
|
1998-10-30 10:57:44 +03:00
|
|
|
reason = eReflowReason_Resize;
|
1999-10-28 08:09:39 +04:00
|
|
|
if (mBorderCollapser) {
|
|
|
|
mBorderCollapser->ComputeVerticalBorders(aPresContext, 0, -1);
|
|
|
|
}
|
1998-10-30 10:57:44 +03:00
|
|
|
rv = ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState, aStatus, nsnull, reason, PR_TRUE);
|
1998-10-11 13:18:27 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
1999-12-14 01:56:31 +03:00
|
|
|
needsRecalc = PR_TRUE;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
if (mTableLayoutStrategy && (needsRecalc || !IsColumnWidthsValid())) {
|
2000-01-03 01:55:48 +03:00
|
|
|
nscoord boxWidth = CalcBorderBoxWidth(aReflowState);
|
2000-02-12 04:55:40 +03:00
|
|
|
mTableLayoutStrategy->Initialize(aPresContext, aDesiredSize.maxElementSize,
|
|
|
|
boxWidth, aReflowState);
|
1999-12-14 01:56:31 +03:00
|
|
|
mBits.mColumnWidthsValid = PR_TRUE; //so we don't do this a second time below
|
1998-10-16 01:07:37 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
if (!mPrevInFlow) {
|
|
|
|
// only do this for a first-in-flow table frame
|
1998-08-14 20:16:43 +04:00
|
|
|
// assign column widths, and assign aMaxElementSize->width
|
2000-01-03 01:55:48 +03:00
|
|
|
BalanceColumnWidths(aPresContext, aReflowState, nsSize(aReflowState.availableWidth, aReflowState.availableHeight),
|
1998-08-14 20:16:43 +04:00
|
|
|
aDesiredSize.maxElementSize);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-08-14 20:16:43 +04:00
|
|
|
// assign table width
|
2000-02-12 04:55:40 +03:00
|
|
|
SetTableWidth(aPresContext, aReflowState);
|
1998-08-14 20:16:43 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-02-11 06:55:33 +03:00
|
|
|
if ((eReflowReason_Initial == aReflowState.reason) &&
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth)) {
|
|
|
|
// Don't bother doing a pass2 reflow. Use our pass1 width as our
|
|
|
|
// desired width
|
|
|
|
aDesiredSize.width = mRect.width;
|
1999-09-13 07:19:39 +04:00
|
|
|
|
2000-02-11 06:55:33 +03:00
|
|
|
} else {
|
|
|
|
nscoord pass1Height = aDesiredSize.height;
|
|
|
|
|
|
|
|
// Constrain our reflow width to the computed table width. Note: this is based
|
|
|
|
// on the width of the first-in-flow
|
|
|
|
nsHTMLReflowState reflowState(aReflowState);
|
|
|
|
PRInt32 pass1Width = mRect.width;
|
|
|
|
if (mPrevInFlow) {
|
|
|
|
nsTableFrame* table = (nsTableFrame*)GetFirstInFlow();
|
|
|
|
pass1Width = table->mRect.width;
|
|
|
|
}
|
|
|
|
reflowState.availableWidth = pass1Width;
|
|
|
|
if (pass1MaxElementSize) {
|
|
|
|
// we already have the max element size, so don't request it during pass2
|
|
|
|
aDesiredSize.maxElementSize = nsnull;
|
|
|
|
}
|
|
|
|
rv = ResizeReflowPass2(aPresContext, aDesiredSize, reflowState, aStatus);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
1999-09-13 07:19:39 +04:00
|
|
|
|
2000-02-11 06:55:33 +03:00
|
|
|
aDesiredSize.width = PR_MIN(aDesiredSize.width, pass1Width);
|
|
|
|
|
|
|
|
// If this is an incremental reflow and we're here that means we had to
|
|
|
|
// reflow all the rows, e.g., the column widths changed. We need to make
|
|
|
|
// sure that any damaged areas are repainted
|
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
|
|
|
nsRect damageRect;
|
|
|
|
|
|
|
|
damageRect.x = 0;
|
|
|
|
damageRect.y = 0;
|
|
|
|
damageRect.width = mRect.width;
|
|
|
|
damageRect.height = mRect.height;
|
|
|
|
Invalidate(aPresContext, damageRect);
|
|
|
|
}
|
1999-09-13 07:19:39 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
else {
|
1998-04-14 00:24:54 +04:00
|
|
|
// set aDesiredSize and aMaxElementSize
|
|
|
|
}
|
|
|
|
|
2000-02-12 04:55:40 +03:00
|
|
|
SetColumnDimensions(aPresContext, aDesiredSize.height, aReflowState.mComputedBorderPadding);
|
1999-10-15 08:09:22 +04:00
|
|
|
if (pass1MaxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize = pass1MaxElementSize;
|
|
|
|
}
|
1999-06-08 01:10:25 +04:00
|
|
|
|
2000-01-11 18:55:31 +03:00
|
|
|
// See if we are supposed to compute our maximum width
|
|
|
|
if (aDesiredSize.mFlags & NS_REFLOW_CALC_MAX_WIDTH) {
|
2000-02-12 03:58:38 +03:00
|
|
|
PRBool isAutoWidth = IsAutoLayout(&aReflowState) &&
|
2000-01-11 18:55:31 +03:00
|
|
|
(eStyleUnit_Auto == aReflowState.mStylePosition->mWidth.GetUnit());
|
|
|
|
|
|
|
|
// See if the pass1 maximum width is no longer valid because one of the
|
|
|
|
// cell maximum widths changed
|
|
|
|
if (isAutoWidth && !IsMaximumWidthValid()) {
|
|
|
|
// Initialize the strategy and have it compute the natural size of
|
|
|
|
// the table
|
2000-02-12 04:55:40 +03:00
|
|
|
mTableLayoutStrategy->Initialize(aPresContext, nsnull, NS_UNCONSTRAINEDSIZE, aReflowState);
|
2000-01-11 18:55:31 +03:00
|
|
|
|
|
|
|
// Now the maximum width is valid
|
|
|
|
mBits.mMaximumWidthValid = PR_TRUE;
|
|
|
|
|
|
|
|
// Initializing the table layout strategy assigns preliminary column
|
|
|
|
// widths. We can't leave the column widths this way, and so we need to
|
|
|
|
// balance the column widths to get them back to what we had previously.
|
|
|
|
// XXX It would be nice to have a cleaner way to calculate the updated
|
|
|
|
// maximum width
|
|
|
|
BalanceColumnWidths(aPresContext, aReflowState,
|
|
|
|
nsSize(aReflowState.availableWidth, aReflowState.availableHeight),
|
|
|
|
aDesiredSize.maxElementSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isAutoWidth) {
|
|
|
|
// Ask the strategy for the natural width of the content area
|
|
|
|
aDesiredSize.mMaximumWidth = mTableLayoutStrategy->GetTableMaxContentWidth();
|
|
|
|
|
|
|
|
// Add in space for border
|
|
|
|
nsMargin border;
|
|
|
|
GetTableBorder (border); // this gets the max border value at every edge
|
|
|
|
aDesiredSize.mMaximumWidth += border.left + border.right;
|
|
|
|
|
|
|
|
// Add in space for padding
|
|
|
|
aDesiredSize.mMaximumWidth += aReflowState.mComputedPadding.left +
|
|
|
|
aReflowState.mComputedPadding.right;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// We're not auto width so the natural width is the same as the desired width
|
|
|
|
aDesiredSize.mMaximumWidth = aDesiredSize.width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-03 01:55:48 +03:00
|
|
|
if (nsDebugTable::gRflTable) nsTableFrame::DebugReflow("T::Rfl ex", this, nsnull, &aDesiredSize, aStatus);
|
1998-10-11 13:18:27 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** the first of 2 reflow passes
|
|
|
|
* lay out the captions and row groups in an infinite space (NS_UNCONSTRAINEDSIZE)
|
|
|
|
* cache the results for each caption and cell.
|
|
|
|
* if successful, set mFirstPassValid=PR_TRUE, so we know we can skip this step
|
|
|
|
* next time. mFirstPassValid is set to PR_FALSE when content is changed.
|
|
|
|
* NOTE: should never get called on a continuing frame! All cached pass1 state
|
|
|
|
* is stored in the inner table first-in-flow.
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresContext,
|
1998-10-15 11:46:16 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsTableRowGroupFrame * aStartingFrame,
|
1998-10-20 03:43:06 +04:00
|
|
|
nsReflowReason aReason,
|
|
|
|
PRBool aDoSiblingFrames)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-30 00:36:05 +04:00
|
|
|
NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");
|
1999-01-14 08:16:23 +03:00
|
|
|
NS_PRECONDITION(aReflowState.parentReflowState->frame == mParent,
|
1998-05-30 00:36:05 +04:00
|
|
|
"bad parent reflow state");
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_ASSERTION(nsnull==mPrevInFlow, "illegal call, cannot call pass 1 on a continuing frame.");
|
1998-06-17 20:38:24 +04:00
|
|
|
NS_ASSERTION(nsnull != mContent, "null content");
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
nsresult rv=NS_OK;
|
|
|
|
// set out params
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); // availSize is the space available at any given time in the process
|
|
|
|
nsSize maxSize(0, 0); // maxSize is the size of the largest child so far in the process
|
|
|
|
nsSize kidMaxSize(0,0);
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics kidSize(&kidMaxSize);
|
1998-04-14 00:24:54 +04:00
|
|
|
nscoord y = 0;
|
|
|
|
|
|
|
|
// Compute the insets (sum of border and padding)
|
1998-12-23 18:47:43 +03:00
|
|
|
// XXX: since this is pass1 reflow and where we place the rowgroup frames is irrelevant, insets are probably a waste
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-02-12 03:58:38 +03:00
|
|
|
if (IsAutoLayout(&aReflowState))
|
1998-09-23 03:36:06 +04:00
|
|
|
{
|
1998-10-15 11:46:16 +04:00
|
|
|
nsIFrame* kidFrame = aStartingFrame;
|
|
|
|
if (nsnull==kidFrame)
|
1999-01-16 01:52:05 +03:00
|
|
|
kidFrame=mFrames.FirstChild();
|
1999-02-10 09:13:38 +03:00
|
|
|
for ( ; nsnull != kidFrame; kidFrame->GetNextSibling(&kidFrame))
|
1998-09-24 20:37:22 +04:00
|
|
|
{
|
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-09-24 20:37:22 +04:00
|
|
|
if ((NS_STYLE_DISPLAY_TABLE_HEADER_GROUP != childDisplay->mDisplay) &&
|
|
|
|
(NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP != childDisplay->mDisplay) &&
|
1998-12-03 21:01:35 +03:00
|
|
|
(NS_STYLE_DISPLAY_TABLE_ROW_GROUP != childDisplay->mDisplay) )
|
1998-10-23 21:24:57 +04:00
|
|
|
{ // it's an unknown frame type, give it a generic reflow and ignore the results
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
|
1998-10-23 21:24:57 +04:00
|
|
|
availSize, aReason);
|
1998-10-30 10:57:44 +03:00
|
|
|
// rv intentionally not set here
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, 0, 0, 0, aStatus);
|
|
|
|
kidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
1998-09-24 20:37:22 +04:00
|
|
|
continue;
|
|
|
|
}
|
2000-02-11 06:55:33 +03:00
|
|
|
|
|
|
|
// Get the row group's border padding
|
|
|
|
nsMargin borderPadding;
|
|
|
|
GetTableBorderForRowGroup(GetRowGroupFrameFor(kidFrame, childDisplay), borderPadding);
|
|
|
|
const nsStyleSpacing* tableSpacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)tableSpacing));
|
|
|
|
nsMargin padding;
|
|
|
|
tableSpacing->GetPadding(padding);
|
|
|
|
borderPadding += padding;
|
|
|
|
|
|
|
|
// Reflow the child
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
|
1998-10-15 11:46:16 +04:00
|
|
|
availSize, aReason);
|
1998-12-14 04:24:11 +03:00
|
|
|
// Note: we don't bother checking here for whether we should clear the
|
|
|
|
// isTopOfPage reflow state flag, because we're dealing with an unconstrained
|
|
|
|
// height and it isn't an issue...
|
2000-02-11 06:55:33 +03:00
|
|
|
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, borderPadding.left,
|
|
|
|
borderPadding.top + y, 0, aStatus);
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1998-10-06 04:27:22 +04:00
|
|
|
// Place the child since some of its content fit in us.
|
2000-02-11 06:55:33 +03:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, kidSize, borderPadding.left,
|
|
|
|
borderPadding.top + y, 0);
|
1998-10-06 04:27:22 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE==kidSize.height)
|
2000-02-11 06:55:33 +03:00
|
|
|
// XXX This is very suspicious. Why would a row group frame want
|
|
|
|
// such a large height?
|
1998-10-06 04:27:22 +04:00
|
|
|
y = NS_UNCONSTRAINEDSIZE;
|
|
|
|
else
|
|
|
|
y += kidSize.height;
|
|
|
|
if (kidMaxSize.width > maxSize.width) {
|
|
|
|
maxSize.width = kidMaxSize.width;
|
|
|
|
}
|
|
|
|
if (kidMaxSize.height > maxSize.height) {
|
|
|
|
maxSize.height = kidMaxSize.height;
|
|
|
|
}
|
1998-09-16 21:19:20 +04:00
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
1998-10-06 04:27:22 +04:00
|
|
|
// If the child didn't finish layout then it means that it used
|
|
|
|
// up all of our available space (or needs us to split).
|
|
|
|
break;
|
1998-09-23 03:36:06 +04:00
|
|
|
}
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_FALSE==aDoSiblingFrames)
|
|
|
|
break;
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
1998-12-03 21:01:35 +03:00
|
|
|
|
|
|
|
// if required, give the colgroups their initial reflows
|
|
|
|
if (PR_TRUE==aDoSiblingFrames)
|
|
|
|
{
|
1999-01-16 01:52:05 +03:00
|
|
|
kidFrame=mColGroups.FirstChild();
|
1999-02-10 09:13:38 +03:00
|
|
|
for ( ; nsnull != kidFrame; kidFrame->GetNextSibling(&kidFrame))
|
1998-12-03 21:01:35 +03:00
|
|
|
{
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
|
1998-12-03 21:01:35 +03:00
|
|
|
availSize, aReason);
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, 0, 0, 0, aStatus);
|
|
|
|
FinishReflowChild(kidFrame, aPresContext, kidSize, 0, 0, 0);
|
1998-12-03 21:01:35 +03:00
|
|
|
}
|
|
|
|
}
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-02-11 06:55:33 +03:00
|
|
|
// Get the table's border/padding
|
|
|
|
const nsStyleSpacing* mySpacing = (const nsStyleSpacing*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
nsMargin tableBorderPadding;
|
|
|
|
GetTableBorder (tableBorderPadding); // this gets the max border thickness at each edge
|
|
|
|
nsMargin tablePadding;
|
|
|
|
mySpacing->GetPadding(tablePadding);
|
|
|
|
tableBorderPadding += tablePadding;
|
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
aDesiredSize.width = kidSize.width;
|
2000-02-11 06:55:33 +03:00
|
|
|
nscoord defaultHeight = y + tableBorderPadding.top + tableBorderPadding.bottom;
|
|
|
|
aDesiredSize.height = ComputeDesiredHeight(aPresContext, aReflowState, defaultHeight);
|
1999-10-05 03:48:05 +04:00
|
|
|
mBits.mFirstPassValid = PR_TRUE;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-03-09 08:29:37 +03:00
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
nsTableFrame::GetFirstBodyRowGroupFrame()
|
|
|
|
{
|
|
|
|
nsIFrame* headerFrame = nsnull;
|
|
|
|
nsIFrame* footerFrame = nsnull;
|
|
|
|
|
|
|
|
for (nsIFrame* kidFrame = mFrames.FirstChild(); nsnull != kidFrame; ) {
|
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
|
|
|
|
|
|
|
// We expect the header and footer row group frames to be first, and we only
|
|
|
|
// allow one header and one footer
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == childDisplay->mDisplay) {
|
|
|
|
if (headerFrame) {
|
|
|
|
// We already have a header frame and so this header frame is treated
|
|
|
|
// like an ordinary body row group frame
|
|
|
|
return kidFrame;
|
|
|
|
}
|
|
|
|
headerFrame = kidFrame;
|
|
|
|
|
|
|
|
} else if (NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay) {
|
|
|
|
if (footerFrame) {
|
|
|
|
// We already have a footer frame and so this footer frame is treated
|
|
|
|
// like an ordinary body row group frame
|
|
|
|
return kidFrame;
|
|
|
|
}
|
|
|
|
footerFrame = kidFrame;
|
|
|
|
|
|
|
|
} else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay) {
|
|
|
|
return kidFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the next child
|
|
|
|
kidFrame->GetNextSibling(&kidFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Table specific version that takes into account repeated header and footer
|
|
|
|
// frames when continuing table frames
|
|
|
|
void
|
1999-10-21 09:11:43 +04:00
|
|
|
nsTableFrame::PushChildren(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFromChild,
|
|
|
|
nsIFrame* aPrevSibling)
|
1999-03-09 08:29:37 +03:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aFromChild, "null pointer");
|
|
|
|
NS_PRECONDITION(nsnull != aPrevSibling, "pushing first child");
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsIFrame* prevNextSibling;
|
|
|
|
aPrevSibling->GetNextSibling(&prevNextSibling);
|
|
|
|
NS_PRECONDITION(prevNextSibling == aFromChild, "bad prev sibling");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Disconnect aFromChild from its previous sibling
|
|
|
|
aPrevSibling->SetNextSibling(nsnull);
|
|
|
|
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
nsTableFrame* nextInFlow = (nsTableFrame*)mNextInFlow;
|
|
|
|
|
|
|
|
// Insert the frames after any repeated header and footer frames
|
|
|
|
nsIFrame* firstBodyFrame = nextInFlow->GetFirstBodyRowGroupFrame();
|
|
|
|
nsIFrame* prevSibling = nsnull;
|
|
|
|
if (firstBodyFrame) {
|
|
|
|
prevSibling = nextInFlow->mFrames.GetPrevSiblingFor(firstBodyFrame);
|
|
|
|
}
|
1999-04-13 06:38:09 +04:00
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
|
|
|
for (nsIFrame* f = aFromChild; f; f->GetNextSibling(&f)) {
|
1999-10-26 08:44:41 +04:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, this, nextInFlow);
|
1999-04-13 06:38:09 +04:00
|
|
|
}
|
1999-03-09 08:29:37 +03:00
|
|
|
nextInFlow->mFrames.InsertFrames(mNextInFlow, prevSibling, aFromChild);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Add the frames to our overflow list
|
1999-10-21 09:11:43 +04:00
|
|
|
SetOverflowFrames(aPresContext, aFromChild);
|
1999-03-09 08:29:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Table specific version that takes into account header and footer row group
|
|
|
|
// frames that are repeated for continuing table frames
|
|
|
|
//
|
|
|
|
// Appends the overflow frames to the end of the child list, just like the
|
|
|
|
// nsContainerFrame version does, except that there are no assertions that
|
|
|
|
// the child list is empty (it may not be empty, because there may be repeated
|
|
|
|
// header/footer frames)
|
|
|
|
PRBool
|
1999-10-21 09:11:43 +04:00
|
|
|
nsTableFrame::MoveOverflowToChildList(nsIPresContext* aPresContext)
|
1999-03-09 08:29:37 +03:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
|
|
|
// Check for an overflow list with our prev-in-flow
|
|
|
|
nsTableFrame* prevInFlow = (nsTableFrame*)mPrevInFlow;
|
|
|
|
if (nsnull != prevInFlow) {
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* prevOverflowFrames = prevInFlow->GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
if (prevOverflowFrames) {
|
1999-04-13 06:38:09 +04:00
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
1999-10-21 09:11:43 +04:00
|
|
|
for (nsIFrame* f = prevOverflowFrames; f; f->GetNextSibling(&f)) {
|
1999-10-26 08:44:41 +04:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, prevInFlow, this);
|
1999-04-13 06:38:09 +04:00
|
|
|
}
|
1999-10-21 09:11:43 +04:00
|
|
|
mFrames.InsertFrames(this, nsnull, prevOverflowFrames);
|
1999-03-09 08:29:37 +03:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* overflowFrames = GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
if (overflowFrames) {
|
|
|
|
mFrames.AppendFrames(nsnull, overflowFrames);
|
1999-03-09 08:29:37 +03:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/** the second of 2 reflow passes
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableFrame::ResizeReflowPass2(nsIPresContext* aPresContext,
|
1998-10-11 13:18:27 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-30 00:36:05 +04:00
|
|
|
NS_PRECONDITION(aReflowState.frame == this, "bad reflow state");
|
1999-01-14 08:16:23 +03:00
|
|
|
NS_PRECONDITION(aReflowState.parentReflowState->frame == mParent,
|
1998-05-30 00:36:05 +04:00
|
|
|
"bad parent reflow state");
|
1998-10-11 13:18:27 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// set out param
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
nsMargin borderPadding;
|
|
|
|
GetTableBorder (borderPadding); // this gets the max border thickness at each edge
|
2000-02-12 04:55:40 +03:00
|
|
|
borderPadding += aReflowState.mComputedPadding;
|
1998-07-07 01:39:23 +04:00
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
InnerTableReflowState state(aPresContext, aReflowState, borderPadding);
|
1998-04-14 00:24:54 +04:00
|
|
|
// now that we've computed the column width information, reflow all children
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
1998-04-23 21:29:07 +04:00
|
|
|
//PreReflowCheck();
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif
|
|
|
|
|
1999-03-03 19:33:57 +03:00
|
|
|
// Check for an overflow list, and append any row group frames being
|
|
|
|
// pushed
|
1999-11-24 09:03:41 +03:00
|
|
|
MoveOverflowToChildList(aPresContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Reflow the existing frames
|
1999-01-16 01:52:05 +03:00
|
|
|
if (mFrames.NotEmpty()) {
|
1999-08-26 01:49:18 +04:00
|
|
|
ComputePercentBasisForRows(aReflowState);
|
1998-10-21 00:05:44 +04:00
|
|
|
rv = ReflowMappedChildren(aPresContext, aDesiredSize, state, aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
// Did we successfully reflow our mapped children?
|
1998-10-21 00:05:44 +04:00
|
|
|
if (NS_FRAME_COMPLETE == aStatus) {
|
1998-04-14 00:24:54 +04:00
|
|
|
// Any space left?
|
1998-09-24 07:36:52 +04:00
|
|
|
if (state.availSize.height > 0) {
|
1998-04-14 00:24:54 +04:00
|
|
|
// Try and pull-up some children from a next-in-flow
|
1998-10-21 00:05:44 +04:00
|
|
|
rv = PullUpChildren(aPresContext, aDesiredSize, state, aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return our size and our status
|
1998-09-01 01:23:28 +04:00
|
|
|
aDesiredSize.width = ComputeDesiredWidth(aReflowState);
|
1998-12-23 18:47:43 +03:00
|
|
|
nscoord defaultHeight = state.y + borderPadding.top + borderPadding.bottom;
|
1998-11-20 04:01:25 +03:00
|
|
|
aDesiredSize.height = ComputeDesiredHeight(aPresContext, aReflowState, defaultHeight);
|
1999-02-11 09:22:33 +03:00
|
|
|
|
|
|
|
AdjustForCollapsingRows(aPresContext, aDesiredSize.height);
|
|
|
|
AdjustForCollapsingCols(aPresContext, aDesiredSize.width);
|
|
|
|
|
1998-12-30 09:48:15 +03:00
|
|
|
// once horizontal borders are computed and all row heights are set,
|
|
|
|
// we need to fix up length of vertical edges
|
|
|
|
// XXX need to figure start row and end row correctly
|
1999-10-28 08:09:39 +04:00
|
|
|
if ((NS_STYLE_BORDER_COLLAPSE == GetBorderCollapseStyle()) && mBorderCollapser) {
|
|
|
|
mBorderCollapser->DidComputeHorizontalBorders(aPresContext, 0, 10000);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
1998-10-11 13:18:27 +04:00
|
|
|
//PostReflowCheck(aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
return rv;
|
|
|
|
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1999-08-26 01:49:18 +04:00
|
|
|
void nsTableFrame::ComputePercentBasisForRows(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
2000-01-03 01:55:48 +03:00
|
|
|
nscoord height = CalcBorderBoxHeight(aReflowState, PR_TRUE);
|
|
|
|
if ((height > 0) && (height != NS_UNCONSTRAINEDSIZE)) {
|
1999-08-26 01:49:18 +04:00
|
|
|
// exclude our border and padding
|
2000-02-12 04:55:40 +03:00
|
|
|
nsMargin borderPadding = aReflowState.mComputedBorderPadding;
|
|
|
|
height -= borderPadding.top + borderPadding.bottom;
|
|
|
|
|
1999-08-26 01:49:18 +04:00
|
|
|
// exclude cell spacing for all rows
|
|
|
|
height -= (1 + GetRowCount()) * GetCellSpacingY();
|
|
|
|
height = PR_MAX(0, height);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
height = 0;
|
|
|
|
}
|
|
|
|
mPercentBasisForRows = height;
|
|
|
|
}
|
|
|
|
|
1999-12-16 04:51:06 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsTableFrame::CollapseRowGroupIfNecessary(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aRowGroupFrame,
|
|
|
|
const nscoord& aYTotalOffset,
|
|
|
|
nscoord& aYGroupOffset, PRInt32& aRowX)
|
1999-06-14 12:01:00 +04:00
|
|
|
{
|
|
|
|
const nsStyleDisplay* groupDisplay;
|
|
|
|
aRowGroupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
|
|
|
|
|
|
|
|
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
|
|
|
|
nsIFrame* rowFrame;
|
2000-01-22 04:16:50 +03:00
|
|
|
aRowGroupFrame->FirstChild(aPresContext, nsnull, &rowFrame);
|
1999-06-14 12:01:00 +04:00
|
|
|
|
|
|
|
while (nsnull != rowFrame) {
|
|
|
|
const nsStyleDisplay* rowDisplay;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
|
1999-12-16 04:51:06 +03:00
|
|
|
CollapseRowGroupIfNecessary(aPresContext, rowFrame, aYTotalOffset, aYGroupOffset, aRowX);
|
1999-06-14 12:01:00 +04:00
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
|
|
|
|
nsRect rowRect;
|
|
|
|
rowFrame->GetRect(rowRect);
|
|
|
|
if (collapseGroup || (NS_STYLE_VISIBILITY_COLLAPSE == rowDisplay->mVisible)) {
|
|
|
|
aYGroupOffset += rowRect.height;
|
|
|
|
rowRect.height = 0;
|
1999-10-26 08:44:41 +04:00
|
|
|
rowFrame->SetRect(aPresContext, rowRect);
|
1999-06-14 12:01:00 +04:00
|
|
|
nsIFrame* cellFrame;
|
2000-01-22 04:16:50 +03:00
|
|
|
rowFrame->FirstChild(aPresContext, nsnull, &cellFrame);
|
1999-06-14 12:01:00 +04:00
|
|
|
while (nsnull != cellFrame) {
|
|
|
|
const nsStyleDisplay* cellDisplay;
|
|
|
|
cellFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)cellDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == cellDisplay->mDisplay) {
|
|
|
|
nsTableCellFrame* cFrame = (nsTableCellFrame*)cellFrame;
|
|
|
|
nsRect cRect;
|
|
|
|
cFrame->GetRect(cRect);
|
|
|
|
cRect.height -= rowRect.height;
|
1999-10-22 06:06:22 +04:00
|
|
|
cFrame->SetCollapseOffsetY(aPresContext, -aYGroupOffset);
|
1999-10-26 08:44:41 +04:00
|
|
|
cFrame->SetRect(aPresContext, cRect);
|
1999-06-14 12:01:00 +04:00
|
|
|
}
|
|
|
|
cellFrame->GetNextSibling(&cellFrame);
|
|
|
|
}
|
|
|
|
// check if a cell above spans into here
|
2000-01-15 23:10:00 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
|
|
|
if (cellMap) {
|
|
|
|
PRInt32 numCols = cellMap->GetColCount();
|
1999-06-14 12:01:00 +04:00
|
|
|
nsTableCellFrame* lastCell = nsnull;
|
|
|
|
for (int colX = 0; colX < numCols; colX++) {
|
2000-01-15 23:10:00 +03:00
|
|
|
CellData* cellData = cellMap->GetCellAt(aRowX, colX);
|
2000-01-13 08:29:38 +03:00
|
|
|
if (cellData && cellData->IsSpan()) { // a cell above is spanning into here
|
1999-06-14 12:01:00 +04:00
|
|
|
// adjust the real cell's rect only once
|
1999-08-19 23:52:37 +04:00
|
|
|
nsTableCellFrame* realCell = nsnull;
|
2000-01-13 08:29:38 +03:00
|
|
|
if (cellData->IsRowSpan())
|
2000-01-15 23:10:00 +03:00
|
|
|
realCell = cellMap->GetCellFrame(aRowX, colX, *cellData, PR_TRUE);
|
1999-06-14 12:01:00 +04:00
|
|
|
if (realCell != lastCell) {
|
|
|
|
nsRect realRect;
|
|
|
|
realCell->GetRect(realRect);
|
|
|
|
realRect.height -= rowRect.height;
|
1999-10-26 08:44:41 +04:00
|
|
|
realCell->SetRect(aPresContext, realRect);
|
1999-06-14 12:01:00 +04:00
|
|
|
}
|
|
|
|
lastCell = realCell;
|
|
|
|
}
|
|
|
|
}
|
2000-01-15 23:10:00 +03:00
|
|
|
}
|
1999-06-14 12:01:00 +04:00
|
|
|
} else { // row is not collapsed but needs to be adjusted by those that are
|
|
|
|
rowRect.y -= aYGroupOffset;
|
1999-10-26 08:44:41 +04:00
|
|
|
rowFrame->SetRect(aPresContext, rowRect);
|
1999-06-14 12:01:00 +04:00
|
|
|
}
|
|
|
|
aRowX++;
|
|
|
|
}
|
|
|
|
rowFrame->GetNextSibling(&rowFrame);
|
|
|
|
} // end row frame while
|
|
|
|
|
|
|
|
nsRect groupRect;
|
|
|
|
aRowGroupFrame->GetRect(groupRect);
|
|
|
|
groupRect.height -= aYGroupOffset;
|
|
|
|
groupRect.y -= aYTotalOffset;
|
1999-10-26 08:44:41 +04:00
|
|
|
aRowGroupFrame->SetRect(aPresContext, groupRect);
|
1999-06-14 12:01:00 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-12-16 04:51:06 +03:00
|
|
|
// collapsing row groups, rows, col groups and cols are accounted for after both passes of
|
|
|
|
// reflow so that it has no effect on the calculations of reflow.
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableFrame::AdjustForCollapsingRows(nsIPresContext* aPresContext,
|
1999-02-11 09:22:33 +03:00
|
|
|
nscoord& aHeight)
|
|
|
|
{
|
|
|
|
nsIFrame* groupFrame = mFrames.FirstChild();
|
|
|
|
nscoord yGroupOffset = 0; // total offset among rows within a single row group
|
|
|
|
nscoord yTotalOffset = 0; // total offset among all rows in all row groups
|
1999-12-16 04:51:06 +03:00
|
|
|
PRInt32 rowIndex = 0;
|
|
|
|
|
|
|
|
// collapse the rows and/or row groups as necessary
|
1999-02-11 09:22:33 +03:00
|
|
|
while (nsnull != groupFrame) {
|
|
|
|
const nsStyleDisplay* groupDisplay;
|
|
|
|
groupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
|
1999-06-14 12:01:00 +04:00
|
|
|
if (IsRowGroup(groupDisplay->mDisplay)) {
|
1999-12-16 04:51:06 +03:00
|
|
|
CollapseRowGroupIfNecessary(aPresContext, groupFrame, yTotalOffset, yGroupOffset, rowIndex);
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
|
|
|
yTotalOffset += yGroupOffset;
|
|
|
|
yGroupOffset = 0;
|
|
|
|
groupFrame->GetNextSibling(&groupFrame);
|
1999-12-16 04:51:06 +03:00
|
|
|
}
|
1999-02-11 09:22:33 +03:00
|
|
|
|
|
|
|
aHeight -= yTotalOffset;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableFrame::AdjustForCollapsingCols(nsIPresContext* aPresContext,
|
1999-02-11 09:22:33 +03:00
|
|
|
nscoord& aWidth)
|
|
|
|
{
|
2000-01-15 23:10:00 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
|
|
|
if (!cellMap) return NS_OK;
|
|
|
|
|
|
|
|
PRInt32 numRows = cellMap->GetRowCount();
|
1999-05-04 23:15:56 +04:00
|
|
|
nsTableIterator groupIter(mColGroups, eTableDIR);
|
1999-04-22 07:51:58 +04:00
|
|
|
nsIFrame* groupFrame = groupIter.First();
|
1999-02-11 09:22:33 +03:00
|
|
|
nscoord cellSpacingX = GetCellSpacingX();
|
|
|
|
nscoord xOffset = 0;
|
1999-12-16 04:51:06 +03:00
|
|
|
PRInt32 colX = (groupIter.IsLeftToRight()) ? 0 : GetColCount() - 1;
|
1999-04-22 07:51:58 +04:00
|
|
|
PRInt32 direction = (groupIter.IsLeftToRight()) ? 1 : -1;
|
1999-12-16 04:51:06 +03:00
|
|
|
// iterate over the col groups
|
1999-02-11 09:22:33 +03:00
|
|
|
while (nsnull != groupFrame) {
|
|
|
|
const nsStyleDisplay* groupDisplay;
|
|
|
|
groupFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)groupDisplay));
|
|
|
|
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupDisplay->mVisible);
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableIterator colIter(aPresContext, *groupFrame, eTableDIR);
|
1999-04-22 07:51:58 +04:00
|
|
|
nsIFrame* colFrame = colIter.First();
|
1999-12-16 04:51:06 +03:00
|
|
|
// iterate over the cols in the col group
|
1999-02-11 09:22:33 +03:00
|
|
|
while (nsnull != colFrame) {
|
|
|
|
const nsStyleDisplay* colDisplay;
|
|
|
|
colFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)colDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN == colDisplay->mDisplay) {
|
|
|
|
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colDisplay->mVisible);
|
1999-12-16 04:51:06 +03:00
|
|
|
PRInt32 colWidth = GetColumnWidth(colX);
|
|
|
|
if (collapseGroup || collapseCol) {
|
|
|
|
xOffset += colWidth + cellSpacingX;
|
|
|
|
}
|
|
|
|
nsTableCellFrame* lastCell = nsnull;
|
|
|
|
nsTableCellFrame* cellFrame = nsnull;
|
|
|
|
for (PRInt32 rowX = 0; rowX < numRows; rowX++) {
|
2000-01-15 23:10:00 +03:00
|
|
|
CellData* cellData = cellMap->GetCellAt(rowX, colX);
|
1999-12-16 04:51:06 +03:00
|
|
|
nsRect cellRect;
|
|
|
|
if (cellData) {
|
2000-01-13 08:29:38 +03:00
|
|
|
if (cellData->IsOrig()) { // the cell originates at (rowX, colX)
|
|
|
|
cellFrame = cellData->GetCellFrame();
|
1999-12-16 09:29:50 +03:00
|
|
|
// reset the collapse offsets since they may have been collapsed previously
|
|
|
|
cellFrame->SetCollapseOffsetX(aPresContext, 0);
|
|
|
|
cellFrame->SetCollapseOffsetY(aPresContext, 0);
|
1999-12-16 04:51:06 +03:00
|
|
|
cellFrame->GetRect(cellRect);
|
|
|
|
if (collapseGroup || collapseCol) {
|
|
|
|
if (lastCell != cellFrame) { // do it only once if there is a row span
|
|
|
|
cellRect.width -= colWidth;
|
|
|
|
cellFrame->SetCollapseOffsetX(aPresContext, -xOffset);
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
1999-12-16 04:51:06 +03:00
|
|
|
} else { // the cell is not in a collapsed col but needs to move
|
|
|
|
cellRect.x -= xOffset;
|
|
|
|
}
|
|
|
|
cellFrame->SetRect(aPresContext, cellRect);
|
1999-02-11 09:22:33 +03:00
|
|
|
// if the cell does not originate at (rowX, colX), adjust the real cells width
|
1999-12-16 04:51:06 +03:00
|
|
|
} else if (collapseGroup || collapseCol) {
|
2000-01-13 08:29:38 +03:00
|
|
|
if (cellData->IsColSpan()) {
|
2000-01-15 23:10:00 +03:00
|
|
|
cellFrame = cellMap->GetCellFrame(rowX, colX, *cellData, PR_FALSE);
|
1999-12-16 04:51:06 +03:00
|
|
|
}
|
|
|
|
if ((cellFrame) && (lastCell != cellFrame)) {
|
|
|
|
cellFrame->GetRect(cellRect);
|
|
|
|
cellRect.width -= colWidth + cellSpacingX;
|
|
|
|
cellFrame->SetRect(aPresContext, cellRect);
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-12-16 04:51:06 +03:00
|
|
|
lastCell = cellFrame;
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
1999-12-16 04:51:06 +03:00
|
|
|
colX += direction;
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
colFrame = colIter.Next();
|
1999-02-11 09:22:33 +03:00
|
|
|
} // inner while
|
1999-04-22 07:51:58 +04:00
|
|
|
groupFrame = groupIter.Next();
|
1999-02-11 09:22:33 +03:00
|
|
|
} // outer while
|
|
|
|
|
|
|
|
aWidth -= xOffset;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Sets the starting column index for aColGroupFrame and the siblings frames that
|
|
|
|
// follow
|
|
|
|
void
|
|
|
|
nsTableFrame::SetStartingColumnIndexFor(nsTableColGroupFrame* aColGroupFrame,
|
|
|
|
PRInt32 aIndex)
|
|
|
|
{
|
|
|
|
while (aColGroupFrame) {
|
|
|
|
aIndex += aColGroupFrame->SetStartColumnIndex(aIndex);
|
|
|
|
aColGroupFrame->GetNextSibling((nsIFrame**)&aColGroupFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate the starting column index to use for the specified col group frame
|
|
|
|
PRInt32
|
|
|
|
nsTableFrame::CalculateStartingColumnIndexFor(nsTableColGroupFrame* aColGroupFrame)
|
|
|
|
{
|
|
|
|
PRInt32 index = 0;
|
|
|
|
for (nsTableColGroupFrame* colGroupFrame = (nsTableColGroupFrame*)mColGroups.FirstChild();
|
|
|
|
colGroupFrame && (colGroupFrame != aColGroupFrame);
|
|
|
|
colGroupFrame->GetNextSibling((nsIFrame**)&colGroupFrame))
|
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
index += colGroupFrame->GetColCount();
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableFrame::AppendFrames(nsIPresContext* aPresContext,
|
1999-08-19 07:51:25 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
PRInt32 startColIndex = 0;
|
1999-08-19 07:51:25 +04:00
|
|
|
// Because we actually have two child lists, one for col group frames and one
|
|
|
|
// for everything else, we need to look at each frame individually
|
|
|
|
nsIFrame* f = aFrameList;
|
1999-12-14 01:56:31 +03:00
|
|
|
nsIFrame* firstAppendedColGroup = nsnull;
|
1999-08-19 07:51:25 +04:00
|
|
|
while (f) {
|
|
|
|
nsIFrame* next;
|
|
|
|
|
|
|
|
// Get the next frame and disconnect this frame from its sibling
|
|
|
|
f->GetNextSibling(&next);
|
|
|
|
f->SetNextSibling(nsnull);
|
|
|
|
|
|
|
|
// See what kind of frame we have
|
|
|
|
const nsStyleDisplay *display;
|
|
|
|
f->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
|
|
|
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == display->mDisplay) {
|
|
|
|
// Append the new col group frame
|
|
|
|
mColGroups.AppendFrame(nsnull, f);
|
1999-12-14 01:56:31 +03:00
|
|
|
if (!firstAppendedColGroup) {
|
|
|
|
firstAppendedColGroup = f;
|
|
|
|
nsIFrame* lastChild = mFrames.LastChild();
|
|
|
|
nsTableColGroupFrame* lastColGroup =
|
2000-01-22 04:16:50 +03:00
|
|
|
(nsTableColGroupFrame*)GetFrameAtOrBefore(aPresContext, this, lastChild,
|
|
|
|
nsLayoutAtoms::tableColGroupFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
startColIndex = (lastColGroup)
|
|
|
|
? lastColGroup->GetStartColumnIndex() + lastColGroup->GetColCount() : 0;
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
|
|
|
} else if (IsRowGroup(display->mDisplay)) {
|
1999-12-14 01:56:31 +03:00
|
|
|
// insert the rows into the table
|
1999-12-17 09:52:37 +03:00
|
|
|
InsertRowGroups(*aPresContext, f, GetRowCount());
|
1999-08-19 07:51:25 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// Append the new row group frame to the sibling chain
|
|
|
|
mFrames.AppendFrame(nsnull, f);
|
1999-08-19 07:51:25 +04:00
|
|
|
} else {
|
|
|
|
// Nothing special to do, just add the frame to our child list
|
|
|
|
mFrames.AppendFrame(nsnull, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move to the next frame
|
|
|
|
f = next;
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
if (firstAppendedColGroup) {
|
|
|
|
InsertColGroups(*aPresContext, startColIndex, firstAppendedColGroup);
|
|
|
|
}
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// We'll need to do a pass-1 layout of all cells in all the rows of the
|
1999-12-14 01:56:31 +03:00
|
|
|
// rowgroup. XXX - fix this
|
1999-08-19 07:51:25 +04:00
|
|
|
InvalidateFirstPassCache();
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// Because the number of columns may have changed invalidate them
|
|
|
|
InvalidateColumnWidths();
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Mark the table as dirty and generate a reflow command targeted at the
|
|
|
|
// outer table frame
|
|
|
|
nsIReflowCommand* reflowCmd;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
mState |= NS_FRAME_IS_DIRTY;
|
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, mParent, nsIReflowCommand::ReflowDirty);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// Add the reflow command
|
|
|
|
rv = aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
return NS_OK;
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableFrame::InsertFrames(nsIPresContext* aPresContext,
|
1999-08-19 07:51:25 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
// Asssume there's only one frame being inserted. The problem is that
|
|
|
|
// row group frames and col group frames go in separate child lists and
|
|
|
|
// so if there's more than one this gets messy...
|
|
|
|
// XXX The frame construction code should be separating out child frames
|
|
|
|
// based on the type...
|
|
|
|
nsIFrame* nextSibling;
|
|
|
|
aFrameList->GetNextSibling(&nextSibling);
|
|
|
|
NS_PRECONDITION(!nextSibling, "expected only one child frame");
|
|
|
|
|
|
|
|
// See what kind of frame we have
|
|
|
|
const nsStyleDisplay *display=nsnull;
|
|
|
|
aFrameList->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
|
|
|
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == display->mDisplay) {
|
|
|
|
// Insert the column group frame
|
1999-12-14 01:56:31 +03:00
|
|
|
nsFrameList frames(aFrameList); // convience for getting last frame
|
|
|
|
nsIFrame* lastFrame = frames.LastChild();
|
1999-08-19 07:51:25 +04:00
|
|
|
mColGroups.InsertFrame(nsnull, aPrevFrame, aFrameList);
|
1999-12-14 01:56:31 +03:00
|
|
|
// find the starting col index for the first new col group
|
|
|
|
PRInt32 startColIndex = 0;
|
|
|
|
if (aPrevFrame) {
|
|
|
|
nsTableColGroupFrame* prevColGroup =
|
2000-01-22 04:16:50 +03:00
|
|
|
(nsTableColGroupFrame*)GetFrameAtOrBefore(aPresContext, this, aPrevFrame,
|
|
|
|
nsLayoutAtoms::tableColGroupFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
if (prevColGroup) {
|
|
|
|
startColIndex = prevColGroup->GetStartColumnIndex() + prevColGroup->GetColCount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
InsertColGroups(*aPresContext, startColIndex, aFrameList, lastFrame);
|
1999-08-19 07:51:25 +04:00
|
|
|
} else if (IsRowGroup(display->mDisplay)) {
|
1999-12-14 01:56:31 +03:00
|
|
|
// get the starting row index of the new rows and insert them into the table
|
|
|
|
PRInt32 rowIndex = 0;
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableRowGroupFrame* prevRowGroup = (nsTableRowGroupFrame *)nsTableFrame::GetFrameAtOrBefore(aPresContext, this, aPrevFrame, nsLayoutAtoms::tableRowGroupFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
if (prevRowGroup) {
|
|
|
|
PRInt32 numRows;
|
|
|
|
prevRowGroup->GetRowCount(numRows);
|
|
|
|
rowIndex = prevRowGroup->GetStartRowIndex() + numRows;
|
|
|
|
}
|
|
|
|
InsertRowGroups(*aPresContext, aFrameList, rowIndex);
|
1999-08-19 07:51:25 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// Insert the frames in the sibling chain
|
|
|
|
mFrames.InsertFrame(nsnull, aPrevFrame, aFrameList);
|
1999-08-19 07:51:25 +04:00
|
|
|
} else {
|
|
|
|
// Just insert the frame and don't worry about reflowing it
|
|
|
|
mFrames.InsertFrame(nsnull, aPrevFrame, aFrameList);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// Because the number of columns may have changed invalidate them
|
|
|
|
InvalidateColumnWidths();
|
1999-08-19 07:51:25 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
InvalidateFirstPassCache(); // XXX fix this
|
1999-08-19 07:51:25 +04:00
|
|
|
|
|
|
|
// Mark the table as dirty and generate a reflow command targeted at the
|
|
|
|
// outer table frame
|
|
|
|
nsIReflowCommand* reflowCmd;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
mState |= NS_FRAME_IS_DIRTY;
|
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, mParent, nsIReflowCommand::ReflowDirty);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// Add the reflow command
|
|
|
|
rv = aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
|
|
|
return rv;
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableFrame::RemoveFrame(nsIPresContext* aPresContext,
|
1999-08-19 07:51:25 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
// See what kind of frame we have
|
|
|
|
const nsStyleDisplay *display=nsnull;
|
|
|
|
aOldFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
|
|
|
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == display->mDisplay) {
|
|
|
|
nsIFrame* nextColGroupFrame;
|
|
|
|
aOldFrame->GetNextSibling(&nextColGroupFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableColGroupFrame* colGroup = (nsTableColGroupFrame*)aOldFrame;
|
|
|
|
PRInt32 firstColIndex = colGroup->GetStartColumnIndex();
|
|
|
|
PRInt32 lastColIndex = firstColIndex + colGroup->GetColCount() - 1;
|
|
|
|
// remove the col frames, the colGroup frame and reset col indices
|
|
|
|
colGroup->RemoveChildrenAtEnd(*aPresContext, colGroup->GetColCount());
|
1999-08-19 07:51:25 +04:00
|
|
|
mColGroups.DestroyFrame(aPresContext, aOldFrame);
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableColGroupFrame::ResetColIndices(aPresContext, nextColGroupFrame, firstColIndex);
|
1999-12-14 01:56:31 +03:00
|
|
|
// remove the cols from the table
|
|
|
|
PRInt32 colX;
|
|
|
|
for (colX = lastColIndex; colX >= firstColIndex; colX--) {
|
|
|
|
nsTableColFrame* colFrame = (nsTableColFrame*)mColFrames.ElementAt(colX);
|
|
|
|
if (colFrame) {
|
|
|
|
RemoveCol(*aPresContext, colGroup, colX, PR_TRUE, PR_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (colX = lastColIndex; colX >= firstColIndex; colX--) {
|
|
|
|
nsTableColFrame* colFrame = (nsTableColFrame*)mColFrames.ElementAt(colX);
|
|
|
|
if (colFrame) {
|
|
|
|
RemoveCol(*aPresContext, colGroup, colX, PR_FALSE, PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
1999-08-19 07:51:25 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
PRInt32 numAnonymousColsToAdd = GetColCount() - mColFrames.Count();
|
|
|
|
if (numAnonymousColsToAdd > 0) {
|
|
|
|
// this sets the child list, updates the col cache and cell map
|
|
|
|
CreateAnonymousColFrames(*aPresContext, numAnonymousColsToAdd,
|
|
|
|
eColAnonymousCell, PR_TRUE);
|
|
|
|
}
|
1999-08-19 07:51:25 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
InvalidateColumnWidths();
|
2000-01-13 08:29:38 +03:00
|
|
|
AddTableDirtyReflowCommand(aPresContext, this);
|
1999-08-19 07:51:25 +04:00
|
|
|
} else {
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(aOldFrame);
|
|
|
|
if (rgFrame) {
|
|
|
|
PRInt32 startRowIndex = rgFrame->GetStartRowIndex();
|
|
|
|
PRInt32 numRows;
|
2000-01-13 23:22:19 +03:00
|
|
|
rgFrame->GetRowCount(numRows, PR_TRUE);
|
2000-01-13 08:29:38 +03:00
|
|
|
// remove the row group from the cell map
|
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
|
|
|
if (cellMap) {
|
|
|
|
cellMap->RemoveGroupCellMap(rgFrame);
|
|
|
|
}
|
|
|
|
// only remove cols that are of type eTypeAnonymous cell (they are at the end)
|
|
|
|
PRInt32 numColsInMap = GetColCount(); // cell map's notion of num cols
|
|
|
|
PRInt32 numColsInCache = mColFrames.Count();
|
|
|
|
PRInt32 numColsNotRemoved = DestroyAnonymousColFrames(*aPresContext, numColsInCache - numColsInMap);
|
|
|
|
// if the cell map has fewer cols than the cache, correct it
|
|
|
|
if (numColsNotRemoved > 0) {
|
|
|
|
cellMap->AddColsAtEnd(numColsNotRemoved);
|
|
|
|
}
|
2000-01-22 04:16:50 +03:00
|
|
|
AdjustRowIndices(aPresContext, startRowIndex, -numRows);
|
2000-01-13 08:29:38 +03:00
|
|
|
// remove the row group frame from the sibling chain
|
|
|
|
mFrames.DestroyFrame(aPresContext, aOldFrame);
|
1999-08-19 07:51:25 +04:00
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
InvalidateColumnWidths();
|
|
|
|
AddTableDirtyReflowCommand(aPresContext, this);
|
|
|
|
} else {
|
|
|
|
// Just remove the frame
|
|
|
|
mFrames.DestroyFrame(aPresContext, aOldFrame);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
1998-10-11 13:18:27 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Constrain our reflow width to the computed table width. Note: this is
|
|
|
|
// based on the width of the first-in-flow
|
|
|
|
nsHTMLReflowState reflowState(aReflowState);
|
|
|
|
PRInt32 pass1Width = mRect.width;
|
|
|
|
if (mPrevInFlow) {
|
|
|
|
nsTableFrame* table = (nsTableFrame*)GetFirstInFlow();
|
|
|
|
pass1Width = table->mRect.width;
|
|
|
|
}
|
|
|
|
reflowState.availableWidth = pass1Width;
|
|
|
|
|
2000-02-12 04:55:40 +03:00
|
|
|
// get margin + border + padding
|
|
|
|
nsMargin borderMarginPadding;
|
|
|
|
GetTableBorder (borderMarginPadding);
|
|
|
|
borderMarginPadding += aReflowState.mComputedMargin + aReflowState.mComputedPadding;
|
|
|
|
|
|
|
|
InnerTableReflowState state(aPresContext, reflowState, borderMarginPadding);
|
1998-10-11 13:18:27 +04:00
|
|
|
|
|
|
|
// determine if this frame is the target or not
|
|
|
|
nsIFrame *target=nsnull;
|
1999-08-19 07:51:25 +04:00
|
|
|
rv = reflowState.reflowCommand->GetTarget(target);
|
1998-10-11 13:18:27 +04:00
|
|
|
if ((PR_TRUE==NS_SUCCEEDED(rv)) && (nsnull!=target))
|
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
// this is the target if target is either this or the outer table frame containing this inner frame
|
|
|
|
nsIFrame *outerTableFrame=nsnull;
|
1999-02-10 04:36:30 +03:00
|
|
|
GetParent(&outerTableFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
if ((this==target) || (outerTableFrame==target))
|
1998-10-11 13:18:27 +04:00
|
|
|
rv = IR_TargetIsMe(aPresContext, aDesiredSize, state, aStatus);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Get the next frame in the reflow chain
|
|
|
|
nsIFrame* nextFrame;
|
1999-08-19 07:51:25 +04:00
|
|
|
reflowState.reflowCommand->GetNext(nextFrame);
|
2000-01-27 01:11:47 +03:00
|
|
|
NS_ASSERTION(nextFrame, "next frame in reflow command is null");
|
1998-10-11 13:18:27 +04:00
|
|
|
|
|
|
|
// Recover our reflow state
|
|
|
|
rv = IR_TargetIsChild(aPresContext, aDesiredSize, state, aStatus, nextFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// this assumes the dirty children are contiguous
|
2000-01-22 04:16:50 +03:00
|
|
|
PRBool GetDirtyChildren(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIFrame** aFirstDirty,
|
|
|
|
PRInt32& aNumDirty)
|
1999-12-14 01:56:31 +03:00
|
|
|
{
|
|
|
|
*aFirstDirty = nsnull;
|
|
|
|
aNumDirty = 0;
|
|
|
|
|
|
|
|
nsIFrame* kidFrame;
|
2000-01-22 04:16:50 +03:00
|
|
|
aFrame->FirstChild(aPresContext, nsnull, &kidFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
while (kidFrame) {
|
|
|
|
nsFrameState frameState;
|
|
|
|
kidFrame->GetFrameState(&frameState);
|
|
|
|
if (frameState & NS_FRAME_IS_DIRTY) {
|
|
|
|
if (!*aFirstDirty) {
|
|
|
|
*aFirstDirty = kidFrame;
|
|
|
|
}
|
|
|
|
aNumDirty++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (aNumDirty > 0);
|
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableFrame::IR_TargetIsMe(nsIPresContext* aPresContext,
|
1998-10-11 13:18:27 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
1998-10-16 01:07:37 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-10-11 13:18:27 +04:00
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetType(type);
|
|
|
|
nsIFrame *objectFrame;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetChildFrame(objectFrame);
|
1998-10-30 10:57:44 +03:00
|
|
|
const nsStyleDisplay *childDisplay=nsnull;
|
|
|
|
if (nsnull!=objectFrame)
|
1998-12-02 19:45:20 +03:00
|
|
|
objectFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-10-11 13:18:27 +04:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case nsIReflowCommand::StyleChanged :
|
1998-10-30 10:57:44 +03:00
|
|
|
rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-11 13:18:27 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::ContentChanged :
|
|
|
|
NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
break;
|
|
|
|
|
1999-08-20 00:05:27 +04:00
|
|
|
case nsIReflowCommand::ReflowDirty:
|
1999-12-14 01:56:31 +03:00
|
|
|
{
|
|
|
|
//nsIFrame* dirtyChild;
|
|
|
|
//PRInt32 numDirty;
|
|
|
|
//if (GetDirtyChildren(this, &dirtyChild, numDirty)) {
|
|
|
|
// for (PRInt32 dirtyX = 0; dirtyX < numDirty; dirtyX++) {
|
|
|
|
// ResizeReflowPass1(aPresContext, aDesiredSize, aReflowState, aStatus,
|
|
|
|
// dirtyChild, reason, PR_FALSE);
|
|
|
|
// dirtyChild->GetNextSibling(&dirtyChild);
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//else {
|
|
|
|
// Problem is we don't know has changed, so assume the worst
|
|
|
|
InvalidateFirstPassCache();
|
|
|
|
//}
|
|
|
|
InvalidateColumnWidths();
|
|
|
|
rv = NS_OK;
|
|
|
|
break;
|
|
|
|
}
|
1999-08-20 00:05:27 +04:00
|
|
|
|
1999-03-05 07:19:09 +03:00
|
|
|
default:
|
1999-08-19 07:51:25 +04:00
|
|
|
NS_NOTYETIMPLEMENTED("unexpected reflow command type");
|
1998-10-11 13:18:27 +04:00
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableFrame::IR_StyleChanged(nsIPresContext* aPresContext,
|
1998-10-30 10:57:44 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// we presume that all the easy optimizations were done in the nsHTMLStyleSheet before we were called here
|
|
|
|
// XXX: we can optimize this when we know which style attribute changed
|
|
|
|
// if something like border changes, we need to do pass1 again
|
1998-10-31 02:08:34 +03:00
|
|
|
// but if something like width changes from 100 to 200, we just need to do pass2
|
1998-10-30 10:57:44 +03:00
|
|
|
InvalidateFirstPassCache();
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Recovers the reflow state to what it should be if aKidFrame is about
|
|
|
|
// to be reflowed. Restores the following:
|
|
|
|
// - availSize
|
|
|
|
// - y
|
|
|
|
// - footerFrame
|
|
|
|
// - firstBodySection
|
|
|
|
//
|
|
|
|
// In the case of the footer frame the y-offset is set to its current
|
|
|
|
// y-offset. Note that this is different from resize reflow when the
|
|
|
|
// footer is positioned higher up and then moves down as each row
|
|
|
|
// group frame is relowed
|
|
|
|
//
|
|
|
|
// XXX This is kind of klunky because the InnerTableReflowState::y
|
|
|
|
// data member does not include the table's border/padding...
|
|
|
|
nsresult
|
|
|
|
nsTableFrame::RecoverState(InnerTableReflowState& aReflowState,
|
1999-08-31 02:30:32 +04:00
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nsSize* aMaxElementSize)
|
1999-08-19 07:51:25 +04:00
|
|
|
{
|
|
|
|
// Walk the list of children looking for aKidFrame
|
2000-02-28 01:36:42 +03:00
|
|
|
for (nsIFrame* childFrame = mFrames.FirstChild(); childFrame; childFrame->GetNextSibling(&childFrame)) {
|
|
|
|
nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(childFrame);
|
|
|
|
if (!rgFrame) continue; // skip foreign frame types
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// If this is a footer row group, remember it
|
|
|
|
const nsStyleDisplay *display;
|
2000-02-28 01:36:42 +03:00
|
|
|
rgFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// We only allow a single footer frame, and the footer frame must occur before
|
|
|
|
// any body section row groups
|
|
|
|
if ((NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == display->mDisplay) &&
|
|
|
|
!aReflowState.footerFrame && !aReflowState.firstBodySection) {
|
2000-02-28 01:36:42 +03:00
|
|
|
aReflowState.footerFrame = childFrame;
|
1999-08-19 07:51:25 +04:00
|
|
|
|
|
|
|
} else if ((NS_STYLE_DISPLAY_TABLE_ROW_GROUP == display->mDisplay) &&
|
|
|
|
!aReflowState.firstBodySection) {
|
2000-02-28 01:36:42 +03:00
|
|
|
aReflowState.firstBodySection = childFrame;
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// See if this is the frame we're looking for
|
2000-02-28 01:36:42 +03:00
|
|
|
if (childFrame == aKidFrame) {
|
1999-08-19 07:51:25 +04:00
|
|
|
// If it's the footer, then keep going because the footer is at the
|
|
|
|
// very bottom
|
2000-02-28 01:36:42 +03:00
|
|
|
if (childFrame != aReflowState.footerFrame) {
|
1999-08-19 07:51:25 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-10-11 13:18:27 +04:00
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Get the frame's height
|
|
|
|
nsSize kidSize;
|
2000-02-28 01:36:42 +03:00
|
|
|
childFrame->GetSize(kidSize);
|
1999-08-19 07:51:25 +04:00
|
|
|
|
|
|
|
// If our height is constrained then update the available height. Do
|
|
|
|
// this for all frames including the footer frame
|
|
|
|
if (PR_FALSE == aReflowState.unconstrainedHeight) {
|
|
|
|
aReflowState.availSize.height -= kidSize.height;
|
|
|
|
}
|
1998-10-16 01:07:37 +04:00
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Update the running y-offset. Don't do this for the footer frame
|
2000-02-28 01:36:42 +03:00
|
|
|
if (childFrame != aReflowState.footerFrame) {
|
1999-08-19 07:51:25 +04:00
|
|
|
aReflowState.y += kidSize.height;
|
|
|
|
}
|
1999-08-31 02:30:32 +04:00
|
|
|
|
|
|
|
// Update the max element size
|
|
|
|
//XXX: this should call into layout strategy to get the width field
|
|
|
|
if (nsnull != aMaxElementSize)
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* tableSpacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing , ((const nsStyleStruct *&)tableSpacing));
|
|
|
|
nsMargin borderPadding;
|
|
|
|
GetTableBorder (borderPadding); // gets the max border thickness for each edge
|
2000-02-12 04:55:40 +03:00
|
|
|
borderPadding += aReflowState.reflowState.mComputedPadding;
|
1999-08-31 02:30:32 +04:00
|
|
|
nscoord cellSpacing = GetCellSpacingX();
|
|
|
|
nsSize kidMaxElementSize;
|
2000-02-28 01:36:42 +03:00
|
|
|
rgFrame->GetMaxElementSize(kidMaxElementSize);
|
1999-08-31 02:30:32 +04:00
|
|
|
nscoord kidWidth = kidMaxElementSize.width + borderPadding.left + borderPadding.right + cellSpacing*2;
|
|
|
|
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, kidWidth);
|
|
|
|
aMaxElementSize->height += kidMaxElementSize.height;
|
|
|
|
}
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
1998-10-16 01:07:37 +04:00
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
return NS_OK;
|
1998-10-11 13:18:27 +04:00
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
|
1998-10-11 13:18:27 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame * aNextFrame)
|
|
|
|
|
|
|
|
{
|
|
|
|
nsresult rv;
|
1999-08-19 07:51:25 +04:00
|
|
|
// Recover the state as if aNextFrame is about to be reflowed
|
1999-08-31 02:30:32 +04:00
|
|
|
RecoverState(aReflowState, aNextFrame, aDesiredSize.maxElementSize);
|
1998-10-11 13:18:27 +04:00
|
|
|
|
|
|
|
// Remember the old rect
|
|
|
|
nsRect oldKidRect;
|
|
|
|
aNextFrame->GetRect(oldKidRect);
|
|
|
|
|
|
|
|
// Pass along the reflow command
|
1999-08-31 02:30:32 +04:00
|
|
|
nsSize kidMaxElementSize;
|
|
|
|
nsHTMLReflowMetrics desiredSize(aDesiredSize.maxElementSize ? &kidMaxElementSize
|
|
|
|
: nsnull);
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
1999-08-19 07:51:25 +04:00
|
|
|
aNextFrame, aReflowState.availSize);
|
1998-10-11 13:18:27 +04:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
nscoord x = aReflowState.mBorderPadding.left;
|
|
|
|
nscoord y = aReflowState.mBorderPadding.top + aReflowState.y;
|
|
|
|
rv = ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState,
|
|
|
|
x, y, 0, aStatus);
|
1998-10-11 13:18:27 +04:00
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Place the row group frame. Don't use PlaceChild(), because it moves
|
|
|
|
// the footer frame as well. We'll adjust the footer frame later on in
|
|
|
|
// AdjustSiblingsAfterReflow()
|
|
|
|
nsRect kidRect(x, y, desiredSize.width, desiredSize.height);
|
1999-11-19 18:33:29 +03:00
|
|
|
FinishReflowChild(aNextFrame, aPresContext, desiredSize, x, y, 0);
|
1999-08-19 07:51:25 +04:00
|
|
|
|
|
|
|
// Adjust the running y-offset
|
1999-11-19 18:33:29 +03:00
|
|
|
aReflowState.y += desiredSize.height;
|
1999-08-19 07:51:25 +04:00
|
|
|
|
|
|
|
// If our height is constrained, then update the available height
|
|
|
|
if (PR_FALSE == aReflowState.unconstrainedHeight) {
|
1999-11-19 18:33:29 +03:00
|
|
|
aReflowState.availSize.height -= desiredSize.height;
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
1998-10-11 13:18:27 +04:00
|
|
|
|
1999-08-31 02:30:32 +04:00
|
|
|
// Update the max element size
|
|
|
|
//XXX: this should call into layout strategy to get the width field
|
|
|
|
if (nsnull != aDesiredSize.maxElementSize)
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* tableSpacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing , ((const nsStyleStruct *&)tableSpacing));
|
|
|
|
nsMargin borderPadding;
|
|
|
|
GetTableBorder (borderPadding); // gets the max border thickness for each edge
|
2000-02-12 04:55:40 +03:00
|
|
|
borderPadding += aReflowState.reflowState.mComputedPadding;
|
1999-08-31 02:30:32 +04:00
|
|
|
nscoord cellSpacing = GetCellSpacingX();
|
|
|
|
nscoord kidWidth = kidMaxElementSize.width + borderPadding.left + borderPadding.right + cellSpacing*2;
|
|
|
|
aDesiredSize.maxElementSize->width = PR_MAX(aDesiredSize.maxElementSize->width, kidWidth);
|
|
|
|
aDesiredSize.maxElementSize->height += kidMaxElementSize.height;
|
|
|
|
}
|
|
|
|
|
1999-08-03 18:26:00 +04:00
|
|
|
// If the column width info is valid, then adjust the row group frames
|
|
|
|
// that follow. Otherwise, return and we'll recompute the column widths
|
|
|
|
// and reflow all the row group frames
|
1999-08-19 07:51:25 +04:00
|
|
|
if (!NeedsReflow(aReflowState.reflowState)) {
|
1999-09-13 07:19:39 +04:00
|
|
|
// If the row group frame changed height, then damage the horizontal strip
|
|
|
|
// that was either added or went away
|
|
|
|
if (desiredSize.height != oldKidRect.height) {
|
|
|
|
nsRect dirtyRect;
|
|
|
|
|
|
|
|
dirtyRect.x = 0;
|
|
|
|
dirtyRect.y = PR_MIN(oldKidRect.YMost(), kidRect.YMost());
|
|
|
|
dirtyRect.width = mRect.width;
|
|
|
|
dirtyRect.height = PR_MAX(oldKidRect.YMost(), kidRect.YMost()) -
|
|
|
|
dirtyRect.y;
|
1999-11-24 09:03:41 +03:00
|
|
|
Invalidate(aPresContext, dirtyRect);
|
1999-09-13 07:19:39 +04:00
|
|
|
}
|
|
|
|
|
1999-08-03 18:26:00 +04:00
|
|
|
// Adjust the row groups that follow
|
1999-08-31 02:30:32 +04:00
|
|
|
AdjustSiblingsAfterReflow(aPresContext, aReflowState, aNextFrame,
|
|
|
|
aDesiredSize.maxElementSize, desiredSize.height -
|
1999-08-03 18:26:00 +04:00
|
|
|
oldKidRect.height);
|
1999-09-13 07:19:39 +04:00
|
|
|
|
1999-08-03 18:26:00 +04:00
|
|
|
// Return our size and our status
|
|
|
|
aDesiredSize.width = ComputeDesiredWidth(aReflowState.reflowState);
|
|
|
|
nscoord defaultHeight = aReflowState.y + aReflowState.mBorderPadding.top +
|
|
|
|
aReflowState.mBorderPadding.bottom;
|
|
|
|
aDesiredSize.height = ComputeDesiredHeight(aPresContext, aReflowState.reflowState,
|
|
|
|
defaultHeight);
|
|
|
|
|
|
|
|
// XXX Is this needed?
|
|
|
|
#if 0
|
|
|
|
AdjustForCollapsingRows(aPresContext, aDesiredSize.height);
|
|
|
|
AdjustForCollapsingCols(aPresContext, aDesiredSize.width);
|
|
|
|
|
|
|
|
// once horizontal borders are computed and all row heights are set,
|
|
|
|
// we need to fix up length of vertical edges
|
|
|
|
// XXX need to figure start row and end row correctly
|
1999-10-28 08:09:39 +04:00
|
|
|
if ((NS_STYLE_BORDER_COLLAPSE == GetBorderCollapseStyle()) && mBorderCollapser) {
|
|
|
|
mBorderCollapser->DidComputeHorizontalBorders(aPresContext, 0, 10000);
|
|
|
|
}
|
1998-10-11 13:18:27 +04:00
|
|
|
#endif
|
1999-08-03 18:26:00 +04:00
|
|
|
}
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-02 08:10:00 +04:00
|
|
|
nscoord nsTableFrame::ComputeDesiredWidth(const nsHTMLReflowState& aReflowState) const
|
1998-09-01 01:23:28 +04:00
|
|
|
{
|
2000-01-03 01:55:48 +03:00
|
|
|
nscoord desiredWidth = aReflowState.availableWidth;
|
1998-09-01 01:23:28 +04:00
|
|
|
// this is the biggest hack in the world. But there's no other rational way to handle nested percent tables
|
1998-12-02 19:45:20 +03:00
|
|
|
const nsStylePosition* position;
|
1998-09-01 01:23:28 +04:00
|
|
|
PRBool isNested=IsNested(aReflowState, position);
|
|
|
|
if((eReflowReason_Initial==aReflowState.reason) &&
|
|
|
|
(PR_TRUE==isNested) && (eStyleUnit_Percent==position->mWidth.GetUnit()))
|
|
|
|
{
|
1999-03-06 20:01:15 +03:00
|
|
|
nsITableLayoutStrategy* tableLayoutStrategy = mTableLayoutStrategy;
|
|
|
|
if (mPrevInFlow) {
|
|
|
|
// Get the table layout strategy from the first-in-flow
|
|
|
|
nsTableFrame* table = (nsTableFrame*)GetFirstInFlow();
|
|
|
|
tableLayoutStrategy = table->mTableLayoutStrategy;
|
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
desiredWidth = tableLayoutStrategy->GetTableMaxContentWidth();
|
1998-09-01 01:23:28 +04:00
|
|
|
}
|
|
|
|
return desiredWidth;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Position and size aKidFrame and update our reflow state. The origin of
|
1999-01-05 03:41:40 +03:00
|
|
|
// aKidRect is relative to the upper-left origin of our frame
|
1999-11-24 09:03:41 +03:00
|
|
|
void nsTableFrame::PlaceChild(nsIPresContext* aPresContext,
|
1998-10-21 00:05:44 +04:00
|
|
|
InnerTableReflowState& aReflowState,
|
1999-11-19 18:33:29 +03:00
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
nsSize* aMaxElementSize,
|
|
|
|
nsSize& aKidMaxElementSize)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
// Place and size the child
|
1999-11-19 18:33:29 +03:00
|
|
|
FinishReflowChild(aKidFrame, aPresContext, aDesiredSize, aX, aY, 0);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Adjust the running y-offset
|
1999-11-19 18:33:29 +03:00
|
|
|
aReflowState.y += aDesiredSize.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-03-05 09:00:40 +03:00
|
|
|
// If our height is constrained, then update the available height
|
1998-10-21 00:05:44 +04:00
|
|
|
if (PR_FALSE == aReflowState.unconstrainedHeight) {
|
1999-11-19 18:33:29 +03:00
|
|
|
aReflowState.availSize.height -= aDesiredSize.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-03-05 09:00:40 +03:00
|
|
|
// If this is a footer row group, remember it
|
1998-06-17 20:38:24 +04:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
aKidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1999-03-05 09:00:40 +03:00
|
|
|
|
|
|
|
// We only allow a single footer frame, and the footer frame must occur before
|
|
|
|
// any body section row groups
|
|
|
|
if ((NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == childDisplay->mDisplay) &&
|
|
|
|
!aReflowState.footerFrame && !aReflowState.firstBodySection)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
1999-03-05 09:00:40 +03:00
|
|
|
aReflowState.footerFrame = aKidFrame;
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
1999-03-05 09:00:40 +03:00
|
|
|
else if (aReflowState.footerFrame)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
1999-03-05 09:00:40 +03:00
|
|
|
// Place the row group frame
|
|
|
|
nsSize footerSize;
|
|
|
|
nsPoint origin;
|
|
|
|
aKidFrame->GetOrigin(origin);
|
|
|
|
aReflowState.footerFrame->GetSize(footerSize);
|
|
|
|
origin.y -= footerSize.height;
|
1999-11-24 09:03:41 +03:00
|
|
|
aKidFrame->MoveTo(aPresContext, origin.x, origin.y);
|
1999-03-05 09:00:40 +03:00
|
|
|
|
|
|
|
// Move the footer below the body row group frame
|
|
|
|
aReflowState.footerFrame->GetOrigin(origin);
|
1999-11-19 18:33:29 +03:00
|
|
|
origin.y += aDesiredSize.height;
|
1999-11-24 09:03:41 +03:00
|
|
|
aReflowState.footerFrame->MoveTo(aPresContext, origin.x, origin.y);
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
1999-03-05 09:00:40 +03:00
|
|
|
|
1998-10-09 23:59:45 +04:00
|
|
|
//XXX: this should call into layout strategy to get the width field
|
1998-08-07 06:11:51 +04:00
|
|
|
if (nsnull != aMaxElementSize)
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* tableSpacing;
|
1998-12-02 19:45:20 +03:00
|
|
|
GetStyleData(eStyleStruct_Spacing , ((const nsStyleStruct *&)tableSpacing));
|
1998-12-23 18:47:43 +03:00
|
|
|
nsMargin borderPadding;
|
|
|
|
GetTableBorder (borderPadding); // gets the max border thickness for each edge
|
2000-02-12 04:55:40 +03:00
|
|
|
borderPadding += aReflowState.reflowState.mComputedPadding;
|
1998-12-09 09:37:18 +03:00
|
|
|
nscoord cellSpacing = GetCellSpacingX();
|
1998-08-07 06:11:51 +04:00
|
|
|
nscoord kidWidth = aKidMaxElementSize.width + borderPadding.left + borderPadding.right + cellSpacing*2;
|
|
|
|
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, kidWidth);
|
|
|
|
aMaxElementSize->height += aKidMaxElementSize.height;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reflow the frames we've already created
|
|
|
|
*
|
|
|
|
* @param aPresContext presentation context to use
|
1998-10-21 00:05:44 +04:00
|
|
|
* @param aReflowState current inline state
|
1998-04-14 00:24:54 +04:00
|
|
|
* @return true if we successfully reflowed all the mapped children and false
|
|
|
|
* otherwise, e.g. we pushed children to the next in flow
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
1998-10-21 00:05:44 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-01-16 01:52:05 +03:00
|
|
|
NS_PRECONDITION(mFrames.NotEmpty(), "no children");
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
PRInt32 childCount = 0;
|
|
|
|
nsIFrame* prevKidFrame = nsnull;
|
1998-06-03 04:43:53 +04:00
|
|
|
nsSize kidMaxElementSize(0,0);
|
1998-10-21 00:05:44 +04:00
|
|
|
nsSize* pKidMaxElementSize = (nsnull != aDesiredSize.maxElementSize) ? &kidMaxElementSize : nsnull;
|
1998-10-23 21:24:57 +04:00
|
|
|
nsresult rv = NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-09-24 01:48:26 +04:00
|
|
|
nsReflowReason reason;
|
2000-02-12 03:58:38 +03:00
|
|
|
if (!IsAutoLayout(&aReflowState.reflowState))
|
1998-09-24 01:48:26 +04:00
|
|
|
{
|
1998-10-21 00:05:44 +04:00
|
|
|
reason = aReflowState.reflowState.reason;
|
1999-08-31 09:55:33 +04:00
|
|
|
if (eReflowReason_Incremental==reason) {
|
1998-12-08 04:00:14 +03:00
|
|
|
reason = eReflowReason_Resize;
|
1999-08-31 09:55:33 +04:00
|
|
|
if (aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
|
|
|
}
|
|
|
|
}
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
reason = eReflowReason_Resize;
|
|
|
|
|
1998-12-03 21:01:35 +03:00
|
|
|
// this never passes reflows down to colgroups
|
1999-01-16 01:52:05 +03:00
|
|
|
for (nsIFrame* kidFrame = mFrames.FirstChild(); nsnull != kidFrame; )
|
1998-09-24 20:37:22 +04:00
|
|
|
{
|
1998-10-21 00:05:44 +04:00
|
|
|
nsSize kidAvailSize(aReflowState.availSize);
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(pKidMaxElementSize);
|
1998-06-03 04:43:53 +04:00
|
|
|
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-05 04:47:37 +03:00
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-12-03 21:01:35 +03:00
|
|
|
if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
|
1998-12-14 04:24:11 +03:00
|
|
|
{
|
1999-03-05 09:00:40 +03:00
|
|
|
// Keep track of the first body section row group
|
|
|
|
if (nsnull == aReflowState.firstBodySection) {
|
1998-12-14 04:24:11 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay) {
|
1999-03-05 09:00:40 +03:00
|
|
|
aReflowState.firstBodySection = kidFrame;
|
1998-12-14 04:24:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
nsMargin borderPadding;
|
1999-01-30 18:52:19 +03:00
|
|
|
GetTableBorderForRowGroup(GetRowGroupFrameFor(kidFrame, childDisplay), borderPadding);
|
1998-12-23 18:47:43 +03:00
|
|
|
const nsStyleSpacing* tableSpacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing, ((const nsStyleStruct *&)tableSpacing));
|
2000-02-12 04:55:40 +03:00
|
|
|
borderPadding += aReflowState.reflowState.mComputedPadding;
|
1998-12-23 18:47:43 +03:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Reflow the child into the available space
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
|
|
|
kidFrame, kidAvailSize, reason);
|
1999-03-05 09:00:40 +03:00
|
|
|
if (aReflowState.firstBodySection && (kidFrame != aReflowState.firstBodySection)) {
|
1998-12-14 04:24:11 +03:00
|
|
|
// If this isn't the first row group frame or the header or footer, then
|
|
|
|
// we can't be at the top of the page anymore...
|
|
|
|
kidReflowState.isTopOfPage = PR_FALSE;
|
|
|
|
}
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1999-01-05 03:41:40 +03:00
|
|
|
nscoord x = borderPadding.left;
|
|
|
|
nscoord y = borderPadding.top + aReflowState.y;
|
1999-06-23 07:02:21 +04:00
|
|
|
|
|
|
|
if (RowGroupsShouldBeConstrained()) {
|
|
|
|
// Only applies to the tree widget.
|
2000-01-03 01:55:48 +03:00
|
|
|
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aReflowState.reflowState, PR_TRUE);
|
2000-01-17 04:10:41 +03:00
|
|
|
if ((tableSpecifiedHeight != NS_UNCONSTRAINEDSIZE)) {
|
1999-06-23 07:02:21 +04:00
|
|
|
kidReflowState.availableHeight = tableSpecifiedHeight - y;
|
|
|
|
if (kidReflowState.availableHeight < 0)
|
|
|
|
kidReflowState.availableHeight = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
|
|
|
|
x, y, 0, aStatus);
|
1998-10-06 04:27:22 +04:00
|
|
|
// Did the child fit?
|
1998-12-14 04:24:11 +03:00
|
|
|
if (desiredSize.height > kidAvailSize.height) {
|
1999-03-05 09:00:40 +03:00
|
|
|
if (aReflowState.firstBodySection && (kidFrame != aReflowState.firstBodySection)) {
|
|
|
|
// The child is too tall to fit at all in the available space, and it's
|
|
|
|
// not a header/footer or our first row group frame
|
1999-11-24 09:03:41 +03:00
|
|
|
PushChildren(aPresContext, kidFrame, prevKidFrame);
|
1998-12-14 04:24:11 +03:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
break;
|
|
|
|
}
|
1998-10-06 04:27:22 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-01-05 03:41:40 +03:00
|
|
|
// Place the child
|
1998-10-11 13:18:27 +04:00
|
|
|
if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
|
1998-10-06 04:27:22 +04:00
|
|
|
{
|
|
|
|
// we don't want to adjust the maxElementSize if this is an initial reflow
|
|
|
|
// it was set by the TableLayoutStrategy and shouldn't be changed.
|
|
|
|
nsSize *requestedMaxElementSize = nsnull;
|
1998-10-21 00:05:44 +04:00
|
|
|
if (eReflowReason_Initial != aReflowState.reflowState.reason)
|
|
|
|
requestedMaxElementSize = aDesiredSize.maxElementSize;
|
1999-11-19 18:33:29 +03:00
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame, desiredSize,
|
|
|
|
x, y, requestedMaxElementSize, kidMaxElementSize);
|
|
|
|
} else {
|
|
|
|
kidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
childCount++;
|
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Remember where we just were in case we end up pushing children
|
|
|
|
prevKidFrame = kidFrame;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Special handling for incomplete children
|
1998-10-21 00:05:44 +04:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* kidNextInFlow;
|
|
|
|
|
1999-02-24 07:48:08 +03:00
|
|
|
kidFrame->GetNextInFlow(&kidNextInFlow);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == kidNextInFlow) {
|
1998-04-17 02:21:32 +04:00
|
|
|
// The child doesn't have a next-in-flow so create a continuing
|
|
|
|
// frame. This hooks the child into the flow
|
1999-02-24 07:03:50 +03:00
|
|
|
nsIFrame* continuingFrame;
|
|
|
|
nsIPresShell* presShell;
|
|
|
|
nsIStyleSet* styleSet;
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetShell(&presShell);
|
1999-02-24 07:03:50 +03:00
|
|
|
presShell->GetStyleSet(&styleSet);
|
|
|
|
NS_RELEASE(presShell);
|
1999-11-24 09:03:41 +03:00
|
|
|
styleSet->CreateContinuingFrame(aPresContext, kidFrame, this, &continuingFrame);
|
1999-02-24 07:03:50 +03:00
|
|
|
NS_RELEASE(styleSet);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Add the continuing frame to the sibling list
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* nextSib;
|
|
|
|
|
1999-02-10 09:13:38 +03:00
|
|
|
kidFrame->GetNextSibling(&nextSib);
|
1998-04-14 00:24:54 +04:00
|
|
|
continuingFrame->SetNextSibling(nextSib);
|
|
|
|
kidFrame->SetNextSibling(continuingFrame);
|
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
// We've used up all of our available space so push the remaining
|
|
|
|
// children to the next-in-flow
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* nextSibling;
|
|
|
|
|
1999-02-10 09:13:38 +03:00
|
|
|
kidFrame->GetNextSibling(&nextSibling);
|
1998-04-17 02:21:32 +04:00
|
|
|
if (nsnull != nextSibling) {
|
1999-11-24 09:03:41 +03:00
|
|
|
PushChildren(aPresContext, nextSibling, kidFrame);
|
1998-04-17 02:21:32 +04:00
|
|
|
}
|
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-23 21:24:57 +04:00
|
|
|
else
|
|
|
|
{// it's an unknown frame type, give it a generic reflow and ignore the results
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext,
|
|
|
|
aReflowState.reflowState, kidFrame,
|
1998-10-23 21:24:57 +04:00
|
|
|
nsSize(0,0), eReflowReason_Resize);
|
1999-06-28 17:44:40 +04:00
|
|
|
nsHTMLReflowMetrics unusedDesiredSize(nsnull);
|
2000-02-01 07:30:04 +03:00
|
|
|
nsReflowStatus status;
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(kidFrame, aPresContext, unusedDesiredSize, kidReflowState,
|
2000-02-01 07:30:04 +03:00
|
|
|
0, 0, 0, status);
|
1999-11-19 18:33:29 +03:00
|
|
|
kidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
1998-10-23 21:24:57 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Get the next child
|
1999-02-10 09:13:38 +03:00
|
|
|
kidFrame->GetNextSibling(&kidFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update the child count
|
1998-10-23 21:24:57 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try and pull-up frames from our next-in-flow
|
|
|
|
*
|
|
|
|
* @param aPresContext presentation context to use
|
1998-10-21 00:05:44 +04:00
|
|
|
* @param aReflowState current inline state
|
1998-04-14 00:24:54 +04:00
|
|
|
* @return true if we successfully pulled-up all the children and false
|
|
|
|
* otherwise, e.g. child didn't fit
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableFrame::PullUpChildren(nsIPresContext* aPresContext,
|
1998-10-21 00:05:44 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-09-21 07:40:32 +04:00
|
|
|
nsTableFrame* nextInFlow = (nsTableFrame*)mNextInFlow;
|
1998-06-03 04:43:53 +04:00
|
|
|
nsSize kidMaxElementSize(0,0);
|
1998-10-21 00:05:44 +04:00
|
|
|
nsSize* pKidMaxElementSize = (nsnull != aDesiredSize.maxElementSize) ? &kidMaxElementSize : nsnull;
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* prevKidFrame = mFrames.LastChild();
|
1998-10-21 00:05:44 +04:00
|
|
|
nsresult rv = NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
while (nsnull != nextInFlow) {
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics kidSize(pKidMaxElementSize);
|
1998-06-03 04:43:53 +04:00
|
|
|
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
1998-04-17 02:21:32 +04:00
|
|
|
|
1999-01-16 01:52:05 +03:00
|
|
|
// XXX change to use nsFrameList::PullFrame
|
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Get the next child
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* kidFrame = nextInFlow->mFrames.FirstChild();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Any more child frames?
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == kidFrame) {
|
1998-04-17 02:21:32 +04:00
|
|
|
// No. Any frames on its overflow list?
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIFrame* nextOverflowFrames = nextInFlow->GetOverflowFrames(aPresContext, PR_TRUE);
|
1999-10-21 09:11:43 +04:00
|
|
|
if (nextOverflowFrames) {
|
1998-04-17 02:21:32 +04:00
|
|
|
// Move the overflow list to become the child list
|
1999-10-21 09:11:43 +04:00
|
|
|
nextInFlow->mFrames.AppendFrames(nsnull, nextOverflowFrames);
|
1999-01-16 01:52:05 +03:00
|
|
|
kidFrame = nextInFlow->mFrames.FirstChild();
|
1998-04-17 02:21:32 +04:00
|
|
|
} else {
|
|
|
|
// We've pulled up all the children, so move to the next-in-flow.
|
1999-02-24 07:48:08 +03:00
|
|
|
nextInFlow->GetNextInFlow((nsIFrame**)&nextInFlow);
|
1998-04-17 02:21:32 +04:00
|
|
|
continue;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// See if the child fits in the available space. If it fits or
|
|
|
|
// it's splittable then reflow it. The reason we can't just move
|
|
|
|
// it is that we still need ascent/descent information
|
1998-06-03 04:43:53 +04:00
|
|
|
nsSize kidFrameSize(0,0);
|
1998-05-22 08:54:11 +04:00
|
|
|
nsSplittableType kidIsSplittable;
|
1998-04-17 05:41:24 +04:00
|
|
|
|
|
|
|
kidFrame->GetSize(kidFrameSize);
|
|
|
|
kidFrame->IsSplittable(kidIsSplittable);
|
1998-10-21 00:05:44 +04:00
|
|
|
if ((kidFrameSize.height > aReflowState.availSize.height) &&
|
1998-05-22 08:54:11 +04:00
|
|
|
NS_FRAME_IS_NOT_SPLITTABLE(kidIsSplittable)) {
|
1998-10-21 00:05:44 +04:00
|
|
|
//XXX: Troy
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-04-17 02:21:32 +04:00
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
|
|
|
kidFrame, aReflowState.availSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
eReflowReason_Resize);
|
1998-04-17 02:21:32 +04:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState,
|
|
|
|
0, aReflowState.y, 0, aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-06 04:27:22 +04:00
|
|
|
// Did the child fit?
|
1999-01-16 01:52:05 +03:00
|
|
|
if ((kidSize.height > aReflowState.availSize.height) && mFrames.NotEmpty()) {
|
1998-10-06 04:27:22 +04:00
|
|
|
// The child is too wide to fit in the available space, and it's
|
|
|
|
// not our first child
|
1998-10-21 00:05:44 +04:00
|
|
|
//XXX: Troy
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-10-06 04:27:22 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1998-10-06 04:27:22 +04:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-10-11 13:18:27 +04:00
|
|
|
if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
|
1998-10-06 04:27:22 +04:00
|
|
|
{
|
1999-11-19 18:33:29 +03:00
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame, kidSize, 0,
|
|
|
|
aReflowState.y, aDesiredSize.maxElementSize, *pKidMaxElementSize);
|
|
|
|
} else {
|
|
|
|
kidFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
1998-05-29 01:39:22 +04:00
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
|
|
|
|
// Remove the frame from its current parent
|
1999-01-16 01:52:05 +03:00
|
|
|
nextInFlow->mFrames.RemoveFirstChild();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Link the frame into our list of children
|
1999-01-14 08:16:23 +03:00
|
|
|
kidFrame->SetParent(this);
|
1998-04-17 05:41:24 +04:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
if (nsnull == prevKidFrame) {
|
1999-01-16 01:52:05 +03:00
|
|
|
mFrames.SetFrames(kidFrame);
|
1998-04-17 02:21:32 +04:00
|
|
|
} else {
|
|
|
|
prevKidFrame->SetNextSibling(kidFrame);
|
|
|
|
}
|
|
|
|
kidFrame->SetNextSibling(nsnull);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Remember where we just were in case we end up pushing children
|
|
|
|
prevKidFrame = kidFrame;
|
1998-10-21 00:05:44 +04:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
1998-04-17 02:21:32 +04:00
|
|
|
// No the child isn't complete
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* kidNextInFlow;
|
|
|
|
|
1999-02-24 07:48:08 +03:00
|
|
|
kidFrame->GetNextInFlow(&kidNextInFlow);
|
1998-04-17 02:21:32 +04:00
|
|
|
if (nsnull == kidNextInFlow) {
|
|
|
|
// The child doesn't have a next-in-flow so create a
|
|
|
|
// continuing frame. The creation appends it to the flow and
|
|
|
|
// prepares it for reflow.
|
1999-02-24 07:03:50 +03:00
|
|
|
nsIFrame* continuingFrame;
|
|
|
|
nsIPresShell* presShell;
|
|
|
|
nsIStyleSet* styleSet;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetShell(&presShell);
|
1999-02-24 07:03:50 +03:00
|
|
|
presShell->GetStyleSet(&styleSet);
|
|
|
|
NS_RELEASE(presShell);
|
1999-11-24 09:03:41 +03:00
|
|
|
styleSet->CreateContinuingFrame(aPresContext, kidFrame, this, &continuingFrame);
|
1999-02-24 07:03:50 +03:00
|
|
|
NS_RELEASE(styleSet);
|
1998-04-17 02:21:32 +04:00
|
|
|
|
|
|
|
// Add the continuing frame to our sibling list and then push
|
|
|
|
// it to the next-in-flow. This ensures the next-in-flow's
|
|
|
|
// content offsets and child count are set properly. Note that
|
|
|
|
// we can safely assume that the continuation is complete so
|
1998-09-21 07:40:32 +04:00
|
|
|
// we pass PR_TRUE into PushChidren
|
1998-04-17 02:21:32 +04:00
|
|
|
kidFrame->SetNextSibling(continuingFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
PushChildren(aPresContext, continuingFrame, kidFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-21 00:05:44 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Now I've got all the cells laid out in an infinite space.
|
|
|
|
For each column, use the min size for each cell in that column
|
|
|
|
along with the attributes of the table, column group, and column
|
|
|
|
to assign widths to each column.
|
|
|
|
*/
|
|
|
|
// use the cell map to determine which cell is in which column.
|
1999-11-24 09:03:41 +03:00
|
|
|
void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-04-14 00:24:54 +04:00
|
|
|
const nsSize& aMaxSize,
|
|
|
|
nsSize* aMaxElementSize)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull==mPrevInFlow, "never ever call me on a continuing frame!");
|
2000-01-15 23:10:00 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
|
|
|
if (!cellMap) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "never ever call me until the cell map is built!");
|
|
|
|
return;
|
|
|
|
}
|
1998-07-07 04:20:21 +04:00
|
|
|
|
2000-01-15 23:10:00 +03:00
|
|
|
PRInt32 numCols = cellMap->GetColCount();
|
1998-10-10 01:53:07 +04:00
|
|
|
if (numCols>mColumnWidthsLength)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-10-10 01:53:07 +04:00
|
|
|
PRInt32 priorColumnWidthsLength=mColumnWidthsLength;
|
1999-10-05 03:48:05 +04:00
|
|
|
if (0 == priorColumnWidthsLength) {
|
|
|
|
mColumnWidthsLength = numCols;
|
|
|
|
} else {
|
|
|
|
while (numCols>mColumnWidthsLength)
|
|
|
|
mColumnWidthsLength += kColumnWidthIncrement;
|
|
|
|
}
|
1998-10-10 01:53:07 +04:00
|
|
|
PRInt32 * newColumnWidthsArray = new PRInt32[mColumnWidthsLength];
|
|
|
|
nsCRT::memset (newColumnWidthsArray, 0, mColumnWidthsLength*sizeof(PRInt32));
|
1999-10-05 03:48:05 +04:00
|
|
|
if (mColumnWidths) {
|
|
|
|
nsCRT::memcpy (newColumnWidthsArray, mColumnWidths, priorColumnWidthsLength*sizeof(PRInt32));
|
|
|
|
delete [] mColumnWidths;
|
|
|
|
}
|
1998-10-10 01:53:07 +04:00
|
|
|
mColumnWidths = newColumnWidthsArray;
|
2000-01-03 01:55:48 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// need to figure out the overall table width constraint
|
1998-04-25 22:48:48 +04:00
|
|
|
// default case, get 100% of available space
|
1998-07-11 04:00:31 +04:00
|
|
|
|
2000-01-03 01:55:48 +03:00
|
|
|
PRInt32 maxWidth = CalcBorderBoxWidth(aReflowState);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-30 21:57:09 +04:00
|
|
|
// based on the compatibility mode, create a table layout strategy
|
2000-01-03 01:55:48 +03:00
|
|
|
nscoord boxWidth = CalcBorderBoxWidth(aReflowState);
|
1999-06-03 06:42:33 +04:00
|
|
|
if (nsnull == mTableLayoutStrategy) {
|
1999-05-27 02:22:23 +04:00
|
|
|
nsCompatibility mode;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetCompatibilityMode(&mode);
|
2000-02-12 03:58:38 +03:00
|
|
|
if (!IsAutoLayout(&aReflowState))
|
1998-10-20 03:43:06 +04:00
|
|
|
mTableLayoutStrategy = new FixedTableLayoutStrategy(this);
|
1998-09-23 03:36:06 +04:00
|
|
|
else
|
1999-05-27 02:22:23 +04:00
|
|
|
mTableLayoutStrategy = new BasicTableLayoutStrategy(this, eCompatibility_NavQuirks == mode);
|
2000-02-12 04:55:40 +03:00
|
|
|
mTableLayoutStrategy->Initialize(aPresContext, aMaxElementSize, boxWidth, aReflowState);
|
1999-10-05 03:48:05 +04:00
|
|
|
mBits.mColumnWidthsValid=PR_TRUE;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-06-03 06:42:33 +04:00
|
|
|
// fixed-layout tables need to reinitialize the layout strategy. When there are scroll bars
|
|
|
|
// reflow gets called twice and the 2nd time has the correct space available.
|
2000-02-12 03:58:38 +03:00
|
|
|
else if (!IsAutoLayout(&aReflowState)) {
|
2000-02-12 04:55:40 +03:00
|
|
|
mTableLayoutStrategy->Initialize(aPresContext, aMaxElementSize, boxWidth, aReflowState);
|
1999-06-03 06:42:33 +04:00
|
|
|
}
|
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
mTableLayoutStrategy->BalanceColumnWidths(aPresContext, mStyleContext, aReflowState, maxWidth);
|
1999-07-28 12:09:02 +04:00
|
|
|
//Dump(PR_TRUE, PR_TRUE);
|
1999-10-05 03:48:05 +04:00
|
|
|
mBits.mColumnWidthsSet=PR_TRUE;
|
1998-12-23 18:47:43 +03:00
|
|
|
|
|
|
|
// if collapsing borders, compute the top and bottom edges now that we have column widths
|
1999-10-28 08:09:39 +04:00
|
|
|
if ((NS_STYLE_BORDER_COLLAPSE == GetBorderCollapseStyle()) && mBorderCollapser) {
|
2000-01-15 23:10:00 +03:00
|
|
|
mBorderCollapser->ComputeHorizontalBorders(aPresContext, 0, cellMap->GetRowCount()-1);
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
sum the width of each column
|
|
|
|
add in table insets
|
|
|
|
set rect
|
|
|
|
*/
|
2000-02-12 04:55:40 +03:00
|
|
|
void nsTableFrame::SetTableWidth(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull==mPrevInFlow, "never ever call me on a continuing frame!");
|
2000-01-15 23:10:00 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
|
|
|
if (!cellMap) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "never ever call me until the cell map is built!");
|
|
|
|
return;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-09 09:37:18 +03:00
|
|
|
nscoord cellSpacing = GetCellSpacingX();
|
1999-07-28 12:09:02 +04:00
|
|
|
PRInt32 tableWidth = 0;
|
1998-07-07 04:20:21 +04:00
|
|
|
|
1998-10-26 21:42:22 +03:00
|
|
|
PRInt32 numCols = GetColCount();
|
1999-07-28 12:09:02 +04:00
|
|
|
for (PRInt32 colIndex = 0; colIndex < numCols; colIndex++) {
|
1998-07-11 04:00:31 +04:00
|
|
|
nscoord totalColWidth = mColumnWidths[colIndex];
|
1999-08-26 01:49:18 +04:00
|
|
|
if (GetNumCellsOriginatingInCol(colIndex) > 0) { // skip degenerate cols
|
1999-07-28 12:09:02 +04:00
|
|
|
totalColWidth += cellSpacing; // add cell spacing to left of col
|
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
tableWidth += totalColWidth;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
if (numCols > 0) {
|
|
|
|
tableWidth += cellSpacing; // add last cellspacing
|
|
|
|
}
|
|
|
|
else if (0 == tableWidth) {
|
|
|
|
nsRect tableRect = mRect;
|
|
|
|
tableRect.width = 0;
|
1999-11-24 09:03:41 +03:00
|
|
|
SetRect(aPresContext, tableRect);
|
1999-07-28 12:09:02 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Compute the insets (sum of border and padding)
|
1998-06-05 10:09:09 +04:00
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
1998-05-13 02:28:01 +04:00
|
|
|
nsMargin borderPadding;
|
1998-12-23 18:47:43 +03:00
|
|
|
GetTableBorder (borderPadding); // this gets the max border value at every edge
|
2000-02-12 04:55:40 +03:00
|
|
|
borderPadding += aReflowState.mComputedPadding;
|
1998-05-13 02:28:01 +04:00
|
|
|
|
|
|
|
nscoord rightInset = borderPadding.right;
|
|
|
|
nscoord leftInset = borderPadding.left;
|
1998-04-14 00:24:54 +04:00
|
|
|
tableWidth += (leftInset + rightInset);
|
1998-04-17 05:41:24 +04:00
|
|
|
nsRect tableSize = mRect;
|
1998-04-14 00:24:54 +04:00
|
|
|
tableSize.width = tableWidth;
|
1999-11-24 09:03:41 +03:00
|
|
|
SetRect(aPresContext, tableSize);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-08-24 08:17:05 +04:00
|
|
|
// XXX percentage based margin/border/padding
|
2000-02-12 04:55:40 +03:00
|
|
|
nscoord GetVerticalMarginBorderPadding(nsIFrame* aFrame,
|
|
|
|
const nsIID& aIID)
|
1999-08-24 08:17:05 +04:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
if (!aFrame) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIContent> iContent;
|
|
|
|
nsresult rv = aFrame->GetContent(getter_AddRefs(iContent));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsIHTMLContent* htmlContent = nsnull;
|
|
|
|
rv = iContent->QueryInterface(aIID, (void **)&htmlContent);
|
|
|
|
if (htmlContent && NS_SUCCEEDED(rv)) {
|
2000-02-12 04:55:40 +03:00
|
|
|
nsCOMPtr<nsIStyleContext> styleContext;
|
|
|
|
aFrame->GetStyleContext(getter_AddRefs(styleContext));
|
1999-08-24 08:17:05 +04:00
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)styleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
nsMargin margin(0,0,0,0);
|
|
|
|
if (spacing->GetMargin(margin)) {
|
|
|
|
result += margin.top + margin.bottom;
|
|
|
|
}
|
|
|
|
if (spacing->GetBorderPadding(margin)) {
|
|
|
|
result += margin.top + margin.bottom;
|
|
|
|
}
|
|
|
|
NS_RELEASE(htmlContent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the height of the nearest ancestor of this table which has a height other than
|
|
|
|
* auto, except when there is an ancestor which is a table and that table does not have
|
|
|
|
* a coord height. It can be the case that the nearest such ancestor is a scroll frame
|
|
|
|
* or viewport frame; this provides backwards compatibility with Nav4.X and IE.
|
1998-11-20 04:01:25 +03:00
|
|
|
*/
|
|
|
|
nscoord nsTableFrame::GetEffectiveContainerHeight(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
1999-08-24 08:17:05 +04:00
|
|
|
nsIFrame* lastArea = nsnull;
|
|
|
|
nsIFrame* lastBlock = nsnull;
|
|
|
|
nsIAtom* frameType = nsnull;
|
|
|
|
nscoord result = -1;
|
1998-11-20 04:01:25 +03:00
|
|
|
const nsHTMLReflowState* rs = &aReflowState;
|
1999-08-24 08:17:05 +04:00
|
|
|
|
|
|
|
while (rs) {
|
|
|
|
const nsStyleDisplay* display;
|
1998-12-02 19:45:20 +03:00
|
|
|
rs->frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)display);
|
1999-08-24 08:17:05 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE == display->mDisplay) {
|
|
|
|
const nsStylePosition* position;
|
1998-12-02 19:45:20 +03:00
|
|
|
rs->frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)position);
|
1998-11-20 04:01:25 +03:00
|
|
|
nsStyleUnit unit = position->mHeight.GetUnit();
|
1999-08-24 08:17:05 +04:00
|
|
|
if ((eStyleUnit_Null == unit) || (eStyleUnit_Auto == unit)) {
|
1998-11-20 04:01:25 +03:00
|
|
|
result = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-08-24 08:17:05 +04:00
|
|
|
if (NS_AUTOHEIGHT != rs->mComputedHeight) {
|
1999-07-20 07:41:03 +04:00
|
|
|
result = rs->mComputedHeight;
|
1999-08-24 08:17:05 +04:00
|
|
|
// if we get to the scroll frame or viewport frame, then subtract out
|
|
|
|
// margin/border/padding for the HTML and BODY elements
|
|
|
|
rs->frame->GetFrameType(&frameType);
|
|
|
|
if ((nsLayoutAtoms::viewportFrame == frameType) ||
|
|
|
|
(nsLayoutAtoms::scrollFrame == frameType)) {
|
|
|
|
result -= GetVerticalMarginBorderPadding(lastArea, kIHTMLElementIID);
|
|
|
|
result -= GetVerticalMarginBorderPadding(lastBlock, kIBodyElementIID);
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
1998-11-20 04:01:25 +03:00
|
|
|
break;
|
|
|
|
}
|
1999-08-24 08:17:05 +04:00
|
|
|
// keep track of the area and block frame on the way up because they could
|
|
|
|
// be the HTML and BODY elements
|
|
|
|
rs->frame->GetFrameType(&frameType);
|
|
|
|
if (nsLayoutAtoms::areaFrame == frameType) {
|
|
|
|
lastArea = rs->frame;
|
|
|
|
}
|
|
|
|
else if (nsLayoutAtoms::blockFrame == frameType) {
|
|
|
|
lastBlock = rs->frame;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
|
1998-11-20 04:01:25 +03:00
|
|
|
// XXX: evil cast!
|
|
|
|
rs = (nsHTMLReflowState *)(rs->parentReflowState);
|
|
|
|
}
|
1999-08-24 08:17:05 +04:00
|
|
|
NS_ASSERTION(-1 != result, "bad state: no constrained height in reflow chain");
|
1998-11-20 04:01:25 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
get the table height attribute
|
|
|
|
if it is auto, table height = SUM(height of rowgroups)
|
|
|
|
else if (resolved table height attribute > SUM(height of rowgroups))
|
|
|
|
proportionately distribute extra height to each row
|
|
|
|
we assume we are passed in the default table height==the sum of the heights of the table's rowgroups
|
|
|
|
in aDesiredSize.height.
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
void nsTableFrame::DistributeSpaceToCells(nsIPresContext* aPresContext,
|
1999-06-15 03:42:16 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsIFrame* aRowGroupFrame)
|
|
|
|
{
|
|
|
|
// now that all of the rows have been resized, resize the cells
|
1999-06-23 13:07:59 +04:00
|
|
|
nsTableRowGroupFrame* rowGroupFrame = (nsTableRowGroupFrame*)aRowGroupFrame;
|
|
|
|
nsIFrame * rowFrame = rowGroupFrame->GetFirstFrame();
|
1999-06-15 03:42:16 +04:00
|
|
|
while (nsnull!=rowFrame) {
|
|
|
|
const nsStyleDisplay *rowDisplay;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
|
|
|
|
((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
|
|
|
|
}
|
|
|
|
// The calling function, DistributeSpaceToRows, takes care of the recursive row
|
|
|
|
// group descent, which is why there's no NS_STYLE_DISPLAY_TABLE_ROW_GROUP case
|
|
|
|
// here.
|
1999-06-23 13:07:59 +04:00
|
|
|
rowGroupFrame->GetNextFrame(rowFrame, &rowFrame);
|
1999-06-15 03:42:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
void nsTableFrame::DistributeSpaceToRows(nsIPresContext* aPresContext,
|
1999-06-15 03:42:16 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-10-28 08:09:39 +04:00
|
|
|
nsIFrame* aRowGroupFrame,
|
|
|
|
const nscoord& aSumOfRowHeights,
|
|
|
|
const nscoord& aExcess,
|
|
|
|
const nsStyleTable* aTableStyle,
|
|
|
|
nscoord& aExcessForRowGroup,
|
|
|
|
nscoord& aRowGroupYPos)
|
1999-06-15 03:42:16 +04:00
|
|
|
{
|
|
|
|
// the rows in rowGroupFrame need to be expanded by rowHeightDelta[i]
|
|
|
|
// and the rowgroup itself needs to be expanded by SUM(row height deltas)
|
1999-06-23 13:07:59 +04:00
|
|
|
nsTableRowGroupFrame* rowGroupFrame = (nsTableRowGroupFrame*)aRowGroupFrame;
|
|
|
|
nsIFrame * rowFrame = rowGroupFrame->GetFirstFrame();
|
1999-06-15 03:42:16 +04:00
|
|
|
nscoord y = 0;
|
|
|
|
while (nsnull!=rowFrame)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *rowDisplay;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
|
|
|
|
DistributeSpaceToRows(aPresContext, aReflowState, rowFrame, aSumOfRowHeights,
|
|
|
|
aExcess, aTableStyle, aExcessForRowGroup, y);
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay)
|
|
|
|
{ // the row needs to be expanded by the proportion this row contributed to the original height
|
|
|
|
nsRect rowRect;
|
|
|
|
rowFrame->GetRect(rowRect);
|
|
|
|
float percent = ((float)(rowRect.height)) / ((float)(aSumOfRowHeights));
|
|
|
|
nscoord excessForRow = NSToCoordRound((float)aExcess*percent);
|
1999-06-23 13:07:59 +04:00
|
|
|
|
|
|
|
if (rowGroupFrame->RowsDesireExcessSpace()) {
|
|
|
|
nsRect newRowRect(rowRect.x, y, rowRect.width, excessForRow+rowRect.height);
|
1999-11-24 09:03:41 +03:00
|
|
|
rowFrame->SetRect(aPresContext, newRowRect);
|
1999-10-28 08:09:39 +04:00
|
|
|
if ((NS_STYLE_BORDER_COLLAPSE == GetBorderCollapseStyle()) && mBorderCollapser) {
|
|
|
|
PRInt32 rowIndex = ((nsTableRowFrame*)rowFrame)->GetRowIndex();
|
|
|
|
mBorderCollapser->SetBorderEdgeLength(NS_SIDE_LEFT, rowIndex, newRowRect.height);
|
|
|
|
mBorderCollapser->SetBorderEdgeLength(NS_SIDE_RIGHT, rowIndex, newRowRect.height);
|
1999-06-23 13:07:59 +04:00
|
|
|
}
|
|
|
|
// better if this were part of an overloaded row::SetRect
|
|
|
|
y += excessForRow+rowRect.height;
|
1999-06-15 03:42:16 +04:00
|
|
|
}
|
1999-06-23 13:07:59 +04:00
|
|
|
|
1999-06-15 03:42:16 +04:00
|
|
|
aExcessForRowGroup += excessForRow;
|
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
nsRect rowRect;
|
|
|
|
rowFrame->GetRect(rowRect);
|
|
|
|
y += rowRect.height;
|
|
|
|
}
|
|
|
|
|
1999-06-23 13:07:59 +04:00
|
|
|
rowGroupFrame->GetNextFrame(rowFrame, &rowFrame);
|
1999-06-15 03:42:16 +04:00
|
|
|
}
|
|
|
|
|
1999-06-23 13:07:59 +04:00
|
|
|
nsRect rowGroupRect;
|
|
|
|
aRowGroupFrame->GetRect(rowGroupRect);
|
|
|
|
if (rowGroupFrame->RowGroupDesiresExcessSpace()) {
|
|
|
|
nsRect newRowGroupRect(rowGroupRect.x, aRowGroupYPos, rowGroupRect.width, aExcessForRowGroup+rowGroupRect.height);
|
1999-11-24 09:03:41 +03:00
|
|
|
aRowGroupFrame->SetRect(aPresContext, newRowGroupRect);
|
1999-06-23 13:07:59 +04:00
|
|
|
aRowGroupYPos += aExcessForRowGroup + rowGroupRect.height;
|
|
|
|
}
|
|
|
|
else aRowGroupYPos += rowGroupRect.height;
|
1999-06-15 03:42:16 +04:00
|
|
|
|
|
|
|
DistributeSpaceToCells(aPresContext, aReflowState, aRowGroupFrame);
|
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
nscoord nsTableFrame::ComputeDesiredHeight(nsIPresContext* aPresContext,
|
1998-11-20 04:01:25 +03:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-08-26 01:49:18 +04:00
|
|
|
nscoord aDefaultHeight)
|
1998-11-20 04:01:25 +03:00
|
|
|
{
|
2000-01-15 23:10:00 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
|
|
|
if (!cellMap) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "never ever call me until the cell map is built!");
|
|
|
|
return 0;
|
|
|
|
}
|
1998-11-20 04:01:25 +03:00
|
|
|
nscoord result = aDefaultHeight;
|
|
|
|
|
2000-01-03 01:55:48 +03:00
|
|
|
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aReflowState, PR_TRUE);
|
|
|
|
if ((tableSpecifiedHeight > 0) && (tableSpecifiedHeight != NS_UNCONSTRAINEDSIZE)) {
|
2000-02-11 06:55:33 +03:00
|
|
|
if (tableSpecifiedHeight > aDefaultHeight) {
|
1998-11-20 04:01:25 +03:00
|
|
|
result = tableSpecifiedHeight;
|
2000-02-11 06:55:33 +03:00
|
|
|
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) {
|
|
|
|
// proportionately distribute the excess height to each row. Note that we
|
|
|
|
// don't need to do this if it's an unconstrained reflow
|
|
|
|
nscoord excess = tableSpecifiedHeight - aDefaultHeight;
|
|
|
|
nscoord sumOfRowHeights = 0;
|
|
|
|
nscoord rowGroupYPos = 0;
|
|
|
|
nsIFrame* childFrame = mFrames.FirstChild();
|
|
|
|
nsIFrame* firstRowGroupFrame = nsnull;
|
|
|
|
while (nsnull != childFrame) {
|
|
|
|
const nsStyleDisplay* childDisplay;
|
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
|
|
|
if (IsRowGroup(childDisplay->mDisplay)) {
|
|
|
|
if (((nsTableRowGroupFrame*)childFrame)->RowGroupReceivesExcessSpace()) {
|
|
|
|
((nsTableRowGroupFrame*)childFrame)->GetHeightOfRows(aPresContext, sumOfRowHeights);
|
1999-11-02 18:41:38 +03:00
|
|
|
}
|
2000-02-11 06:55:33 +03:00
|
|
|
if (!firstRowGroupFrame) {
|
|
|
|
// the first row group's y position starts inside our padding
|
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
2000-02-12 04:55:40 +03:00
|
|
|
nsMargin borderPadding = aReflowState.mComputedBorderPadding;
|
|
|
|
rowGroupYPos = borderPadding.top;
|
2000-02-11 06:55:33 +03:00
|
|
|
firstRowGroupFrame = childFrame;
|
1999-11-02 18:41:38 +03:00
|
|
|
}
|
|
|
|
}
|
2000-02-11 06:55:33 +03:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
1999-08-21 03:27:54 +04:00
|
|
|
}
|
2000-02-11 06:55:33 +03:00
|
|
|
|
|
|
|
childFrame = mFrames.FirstChild();
|
|
|
|
while (childFrame) {
|
|
|
|
const nsStyleDisplay* childDisplay;
|
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
|
|
|
if (IsRowGroup(childDisplay->mDisplay)) {
|
|
|
|
if (((nsTableRowGroupFrame*)childFrame)->RowGroupReceivesExcessSpace()) {
|
|
|
|
nscoord excessForGroup = 0;
|
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
|
|
|
DistributeSpaceToRows(aPresContext, aReflowState, childFrame, sumOfRowHeights,
|
|
|
|
excess, tableStyle, excessForGroup, rowGroupYPos);
|
|
|
|
|
|
|
|
// Make sure child views are properly positioned
|
|
|
|
nsIView* view;
|
|
|
|
childFrame->GetView(aPresContext, &view);
|
|
|
|
if (view) {
|
|
|
|
nsContainerFrame::PositionFrameView(aPresContext, childFrame, view);
|
|
|
|
} else {
|
|
|
|
nsContainerFrame::PositionChildViews(aPresContext, childFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsRect rowGroupRect;
|
|
|
|
childFrame->GetRect(rowGroupRect);
|
|
|
|
rowGroupYPos += rowGroupRect.height;
|
2000-01-25 06:11:24 +03:00
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
}
|
2000-02-11 06:55:33 +03:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-07-26 08:23:01 +04:00
|
|
|
void nsTableFrame::AdjustColumnsForCOLSAttribute()
|
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
// XXX this is not right,
|
|
|
|
#if 0
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap *cellMap = GetCellMap();
|
1998-08-18 03:37:04 +04:00
|
|
|
NS_ASSERTION(nsnull!=cellMap, "bad cell map");
|
1998-07-26 08:23:01 +04:00
|
|
|
|
|
|
|
// any specified-width column turns off COLS attribute
|
|
|
|
nsStyleTable* tableStyle = (nsStyleTable *)mStyleContext->GetMutableStyleData(eStyleStruct_Table);
|
|
|
|
if (tableStyle->mCols != NS_STYLE_TABLE_COLS_NONE)
|
|
|
|
{
|
1998-10-20 09:05:17 +04:00
|
|
|
PRInt32 numCols = cellMap->GetColCount();
|
|
|
|
PRInt32 numRows = cellMap->GetRowCount();
|
1998-07-26 08:23:01 +04:00
|
|
|
for (PRInt32 rowIndex=0; rowIndex<numRows; rowIndex++)
|
|
|
|
{
|
|
|
|
for (PRInt32 colIndex=0; colIndex<numCols; colIndex++)
|
|
|
|
{
|
1998-08-18 03:37:04 +04:00
|
|
|
nsTableCellFrame *cellFrame = cellMap->GetCellFrameAt(rowIndex, colIndex);
|
1998-07-26 08:23:01 +04:00
|
|
|
// get the cell style info
|
|
|
|
const nsStylePosition* cellPosition;
|
|
|
|
if (nsnull!=cellFrame)
|
|
|
|
{
|
|
|
|
cellFrame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)cellPosition);
|
|
|
|
if ((eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) ||
|
|
|
|
(eStyleUnit_Percent==cellPosition->mWidth.GetUnit()))
|
|
|
|
{
|
|
|
|
tableStyle->mCols = NS_STYLE_TABLE_COLS_NONE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
#endif
|
1998-07-26 08:23:01 +04:00
|
|
|
}
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
NS_METHOD nsTableFrame::GetColumnFrame(PRInt32 aColIndex, nsTableColFrame *&aColFrame)
|
|
|
|
{
|
1999-12-16 04:51:06 +03:00
|
|
|
aColFrame = (nsTableColFrame *)mColFrames.ElementAt(aColIndex);
|
1998-06-05 06:36:25 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
PRBool nsTableFrame::IsColumnWidthsSet()
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
1999-10-05 03:48:05 +04:00
|
|
|
return (PRBool)firstInFlow->mBits.mColumnWidthsSet;
|
1998-10-11 13:18:27 +04:00
|
|
|
}
|
|
|
|
|
1999-08-19 23:52:37 +04:00
|
|
|
PRBool nsTableFrame::ColumnsCanBeInvalidatedBy(nsStyleCoord* aPrevStyleWidth,
|
1999-08-21 03:27:54 +04:00
|
|
|
const nsTableCellFrame& aCellFrame) const
|
1999-08-19 23:52:37 +04:00
|
|
|
{
|
|
|
|
if (mTableLayoutStrategy) {
|
1999-08-21 03:27:54 +04:00
|
|
|
return mTableLayoutStrategy->ColumnsCanBeInvalidatedBy(aPrevStyleWidth, aCellFrame);
|
1999-08-19 23:52:37 +04:00
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsTableFrame::ColumnsCanBeInvalidatedBy(const nsTableCellFrame& aCellFrame,
|
|
|
|
PRBool aConsiderMinWidth) const
|
|
|
|
|
|
|
|
{
|
|
|
|
if (mTableLayoutStrategy) {
|
|
|
|
return mTableLayoutStrategy->ColumnsCanBeInvalidatedBy(aCellFrame, aConsiderMinWidth);
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsTableFrame::ColumnsAreValidFor(const nsTableCellFrame& aCellFrame,
|
|
|
|
nscoord aPrevCellMin,
|
|
|
|
nscoord aPrevCellDes) const
|
|
|
|
{
|
|
|
|
if (mTableLayoutStrategy) {
|
|
|
|
return mTableLayoutStrategy->ColumnsAreValidFor(aCellFrame, aPrevCellMin, aPrevCellDes);
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
// XXX This could be more incremental
|
1998-10-16 01:07:37 +04:00
|
|
|
void nsTableFrame::InvalidateColumnWidths()
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
1999-10-05 03:48:05 +04:00
|
|
|
firstInFlow->mBits.mColumnWidthsValid=PR_FALSE;
|
1998-10-16 01:07:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsTableFrame::IsColumnWidthsValid() const
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
1999-10-05 03:48:05 +04:00
|
|
|
return (PRBool)firstInFlow->mBits.mColumnWidthsValid;
|
1998-10-16 01:07:37 +04:00
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
PRBool nsTableFrame::IsFirstPassValid() const
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
1999-10-05 03:48:05 +04:00
|
|
|
return (PRBool)firstInFlow->mBits.mFirstPassValid;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
void nsTableFrame::InvalidateFirstPassCache()
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
1999-10-05 03:48:05 +04:00
|
|
|
firstInFlow->mBits.mFirstPassValid=PR_FALSE;
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
|
2000-01-11 18:55:31 +03:00
|
|
|
PRBool nsTableFrame::IsMaximumWidthValid() const
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
return (PRBool)firstInFlow->mBits.mMaximumWidthValid;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableFrame::InvalidateMaximumWidth()
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
firstInFlow->mBits.mMaximumWidthValid=PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
PRInt32 nsTableFrame::GetColumnWidth(PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
|
|
|
PRInt32 result = 0;
|
|
|
|
if (this!=firstInFlow)
|
|
|
|
result = firstInFlow->GetColumnWidth(aColIndex);
|
|
|
|
else
|
|
|
|
{
|
1999-10-14 08:27:01 +04:00
|
|
|
// Because we lazily allocate the column widths when balancing the
|
|
|
|
// columns, it may not be allocated yet. For example, if this is
|
|
|
|
// an incremental reflow. That's okay, just return 0 for the column
|
|
|
|
// width
|
1998-09-01 01:23:28 +04:00
|
|
|
#ifdef NS_DEBUG
|
2000-01-15 23:10:00 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
|
|
|
if (!cellMap) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "no cell map");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
PRInt32 numCols = cellMap->GetColCount();
|
1998-04-17 02:21:32 +04:00
|
|
|
NS_ASSERTION (numCols > aColIndex, "bad arg, col index out of bounds");
|
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull!=mColumnWidths)
|
|
|
|
result = mColumnWidths[aColIndex];
|
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-06-05 22:11:20 +04:00
|
|
|
void nsTableFrame::SetColumnWidth(PRInt32 aColIndex, nscoord aWidth)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();
|
|
|
|
NS_ASSERTION(nsnull!=firstInFlow, "illegal state -- no first in flow");
|
1998-09-01 01:23:28 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
if (this!=firstInFlow)
|
|
|
|
firstInFlow->SetColumnWidth(aColIndex, aWidth);
|
|
|
|
else
|
|
|
|
{
|
1999-10-05 03:48:05 +04:00
|
|
|
// Note: in the case of incremental reflow sometimes the table layout
|
|
|
|
// strategy will call to set a column width before we've allocated the
|
|
|
|
// column width array
|
|
|
|
if (!mColumnWidths) {
|
2000-01-15 23:10:00 +03:00
|
|
|
mColumnWidthsLength = mCellMap->GetColCount(); // mCellMap is valid since first inflow
|
1999-10-05 03:48:05 +04:00
|
|
|
mColumnWidths = new PRInt32[mColumnWidthsLength];
|
|
|
|
nsCRT::memset (mColumnWidths, 0, mColumnWidthsLength*sizeof(PRInt32));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull!=mColumnWidths && aColIndex<mColumnWidthsLength) {
|
1998-04-14 00:24:54 +04:00
|
|
|
mColumnWidths[aColIndex] = aWidth;
|
1999-10-05 03:48:05 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-05-27 00:57:24 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Update the border style to map to the HTML border style
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void nsTableFrame::MapHTMLBorderStyle(nsStyleSpacing& aSpacingStyle, nscoord aBorderWidth)
|
|
|
|
{
|
|
|
|
nsStyleCoord width;
|
|
|
|
width.SetCoordValue(aBorderWidth);
|
|
|
|
aSpacingStyle.mBorder.SetTop(width);
|
|
|
|
aSpacingStyle.mBorder.SetLeft(width);
|
|
|
|
aSpacingStyle.mBorder.SetBottom(width);
|
|
|
|
aSpacingStyle.mBorder.SetRight(width);
|
|
|
|
|
1999-01-23 01:38:34 +03:00
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_BG_OUTSET);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_BG_OUTSET);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_BG_OUTSET);
|
|
|
|
aSpacingStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_BG_OUTSET);
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
nsIStyleContext* styleContext = mStyleContext;
|
1998-06-17 20:38:24 +04:00
|
|
|
const nsStyleColor* colorData = (const nsStyleColor*)
|
|
|
|
styleContext->GetStyleData(eStyleStruct_Color);
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
// Look until we find a style context with a NON-transparent background color
|
|
|
|
while (styleContext)
|
|
|
|
{
|
|
|
|
if ((colorData->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)!=0)
|
|
|
|
{
|
|
|
|
nsIStyleContext* temp = styleContext;
|
|
|
|
styleContext = styleContext->GetParent();
|
|
|
|
if (temp != mStyleContext)
|
|
|
|
NS_RELEASE(temp);
|
1998-06-05 10:09:09 +04:00
|
|
|
colorData = (const nsStyleColor*)styleContext->GetStyleData(eStyleStruct_Color);
|
1998-05-27 00:57:24 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Yaahoo, we found a style context which has a background color
|
|
|
|
|
|
|
|
nscolor borderColor = 0xFFC0C0C0;
|
|
|
|
|
|
|
|
if (styleContext != nsnull)
|
|
|
|
{
|
|
|
|
borderColor = colorData->mBackgroundColor;
|
|
|
|
if (styleContext != mStyleContext)
|
|
|
|
NS_RELEASE(styleContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the border color is white, then shift to grey
|
|
|
|
if (borderColor == 0xFFFFFFFF)
|
|
|
|
borderColor = 0xFFC0C0C0;
|
|
|
|
|
1998-12-07 22:07:45 +03:00
|
|
|
aSpacingStyle.SetBorderColor(NS_SIDE_TOP, borderColor);
|
|
|
|
aSpacingStyle.SetBorderColor(NS_SIDE_LEFT, borderColor);
|
|
|
|
aSpacingStyle.SetBorderColor(NS_SIDE_BOTTOM, borderColor);
|
|
|
|
aSpacingStyle.SetBorderColor(NS_SIDE_RIGHT, borderColor);
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PRBool nsTableFrame::ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult)
|
|
|
|
{
|
|
|
|
if (aValue.GetUnit() == eHTMLUnit_Pixel)
|
|
|
|
aResult = aValue.GetPixelValue();
|
|
|
|
else if (aValue.GetUnit() == eHTMLUnit_Empty)
|
|
|
|
aResult = aDefault;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NS_ERROR("Unit must be pixel or empty");
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
void nsTableFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
|
1998-05-27 00:57:24 +04:00
|
|
|
{
|
1998-09-15 21:58:24 +04:00
|
|
|
#if 0
|
1998-05-27 00:57:24 +04:00
|
|
|
// Check to see if the table has either cell padding or
|
|
|
|
// Cell spacing defined for the table. If true, then
|
|
|
|
// this setting overrides any specific border, margin or
|
|
|
|
// padding information in the cell. If these attributes
|
|
|
|
// are not defined, the the cells attributes are used
|
|
|
|
|
|
|
|
nsHTMLValue padding_value;
|
|
|
|
nsHTMLValue spacing_value;
|
|
|
|
nsHTMLValue border_value;
|
|
|
|
|
|
|
|
|
1998-08-30 00:20:38 +04:00
|
|
|
nsresult border_result;
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
nscoord padding = 0;
|
|
|
|
nscoord spacing = 0;
|
|
|
|
nscoord border = 1;
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
float p2t = aPresContext->GetPixelsToTwips();
|
1998-05-27 00:57:24 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
nsIHTMLContent* table = (nsIHTMLContent*)mContent;
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(table,"Table Must not be null");
|
|
|
|
if (!table)
|
|
|
|
return;
|
|
|
|
|
1998-06-05 10:09:09 +04:00
|
|
|
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetMutableStyleData(eStyleStruct_Spacing);
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
border_result = table->GetAttribute(nsHTMLAtoms::border,border_value);
|
1998-08-30 00:20:38 +04:00
|
|
|
if (border_result == NS_CONTENT_ATTR_HAS_VALUE)
|
1998-05-27 00:57:24 +04:00
|
|
|
{
|
|
|
|
PRInt32 intValue = 0;
|
|
|
|
|
1998-11-14 04:52:27 +03:00
|
|
|
if (ConvertToPixelValue(border_value,1,intValue)) //XXX this is busted if this code is ever used again. MMP
|
1998-08-01 03:34:45 +04:00
|
|
|
border = NSIntPixelsToTwips(intValue, p2t);
|
1998-05-27 00:57:24 +04:00
|
|
|
}
|
|
|
|
MapHTMLBorderStyle(*spacingData,border);
|
1998-09-15 21:58:24 +04:00
|
|
|
#endif
|
1998-05-27 00:57:24 +04:00
|
|
|
}
|
|
|
|
|
2000-02-12 04:55:40 +03:00
|
|
|
nscoord
|
|
|
|
CalcPercentPadding(nscoord aBasis,
|
|
|
|
nsStyleCoord aStyleCoord)
|
|
|
|
{
|
|
|
|
float percent = (NS_UNCONSTRAINEDSIZE == aBasis)
|
|
|
|
? 0 : aStyleCoord.GetPercentValue();
|
|
|
|
return NSToCoordRound(((float)aBasis) * percent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GetPaddingFor(const nsSize& aBasis,
|
|
|
|
const nsStyleSpacing& aSpacing,
|
|
|
|
nsMargin& aPadding)
|
|
|
|
{
|
|
|
|
nsStyleCoord styleCoord;
|
|
|
|
aSpacing.mPadding.GetTop(styleCoord);
|
|
|
|
if (eStyleUnit_Percent == aSpacing.mPadding.GetTopUnit()) {
|
|
|
|
aPadding.top = CalcPercentPadding(aBasis.height, styleCoord);
|
|
|
|
}
|
|
|
|
else if (eStyleUnit_Coord == aSpacing.mPadding.GetTopUnit()) {
|
|
|
|
aPadding.top = styleCoord.GetCoordValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
aSpacing.mPadding.GetRight(styleCoord);
|
|
|
|
if (eStyleUnit_Percent == aSpacing.mPadding.GetRightUnit()) {
|
|
|
|
aPadding.right = CalcPercentPadding(aBasis.width, styleCoord);
|
|
|
|
}
|
|
|
|
else if (eStyleUnit_Coord == aSpacing.mPadding.GetTopUnit()) {
|
|
|
|
aPadding.right = styleCoord.GetCoordValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
aSpacing.mPadding.GetBottom(styleCoord);
|
|
|
|
if (eStyleUnit_Percent == aSpacing.mPadding.GetBottomUnit()) {
|
|
|
|
aPadding.bottom = CalcPercentPadding(aBasis.height, styleCoord);
|
|
|
|
}
|
|
|
|
else if (eStyleUnit_Coord == aSpacing.mPadding.GetTopUnit()) {
|
|
|
|
aPadding.bottom = styleCoord.GetCoordValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
aSpacing.mPadding.GetLeft(styleCoord);
|
|
|
|
if (eStyleUnit_Percent == aSpacing.mPadding.GetLeftUnit()) {
|
|
|
|
aPadding.left = CalcPercentPadding(aBasis.width, styleCoord);
|
|
|
|
}
|
|
|
|
else if (eStyleUnit_Coord == aSpacing.mPadding.GetTopUnit()) {
|
|
|
|
aPadding.left = styleCoord.GetCoordValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsMargin
|
|
|
|
nsTableFrame::GetPadding(const nsHTMLReflowState& aReflowState,
|
|
|
|
const nsTableCellFrame* aCellFrame)
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
aCellFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct *&)spacing);
|
|
|
|
nsMargin padding(0,0,0,0);
|
|
|
|
if (!spacing->GetPadding(padding)) {
|
|
|
|
const nsHTMLReflowState* parentRS = aReflowState.parentReflowState;
|
|
|
|
while (parentRS) {
|
|
|
|
if (parentRS->frame) {
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
parentRS->frame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableFrame == frameType.get()) {
|
|
|
|
nsSize basis(parentRS->mComputedWidth, parentRS->mComputedHeight);
|
|
|
|
GetPaddingFor(basis, *spacing, padding);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parentRS = parentRS->parentReflowState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return padding;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsMargin
|
|
|
|
nsTableFrame::GetPadding(const nsSize& aBasis,
|
|
|
|
const nsTableCellFrame* aCellFrame)
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
aCellFrame->GetStyleData(eStyleStruct_Spacing,(const nsStyleStruct *&)spacing);
|
|
|
|
nsMargin padding(0,0,0,0);
|
|
|
|
if (!spacing->GetPadding(padding)) {
|
|
|
|
GetPaddingFor(aBasis, *spacing, padding);
|
|
|
|
}
|
|
|
|
return padding;
|
|
|
|
}
|
1998-05-27 00:57:24 +04:00
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
NS_METHOD nsTableFrame::GetCellMarginData(nsTableCellFrame* aKidFrame, nsMargin& aMargin)
|
1998-05-22 03:43:18 +04:00
|
|
|
{
|
|
|
|
nsresult result = NS_ERROR_NOT_INITIALIZED;
|
|
|
|
|
1999-10-20 18:18:56 +04:00
|
|
|
if (aKidFrame) {
|
|
|
|
nscoord spacingX = GetCellSpacingX();
|
|
|
|
nscoord spacingY = GetCellSpacingY();
|
|
|
|
PRInt32 rowIndex, colIndex;
|
|
|
|
aKidFrame->GetRowIndex(rowIndex);
|
|
|
|
aKidFrame->GetColIndex(colIndex);
|
|
|
|
// left/top margins only apply if the cell is a left/top border cell
|
|
|
|
// there used to be more complicated logic (rev 3.326) dealing with rowspans
|
|
|
|
// but failure to produce reasonable tests cases does not justify it.
|
|
|
|
aMargin.left = (0 == colIndex) ? spacingX : 0;
|
|
|
|
aMargin.top = (0 == rowIndex) ? spacingY : 0;
|
|
|
|
aMargin.right = spacingX;
|
|
|
|
aMargin.bottom = spacingY;
|
|
|
|
result = NS_OK;
|
1998-05-22 03:43:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-12-21 22:20:37 +03:00
|
|
|
//XXX: ok, this looks dumb now. but in a very short time this will get filled in
|
|
|
|
void nsTableFrame::GetTableBorder(nsMargin &aBorder)
|
|
|
|
{
|
1999-10-28 08:09:39 +04:00
|
|
|
if (NS_STYLE_BORDER_COLLAPSE == GetBorderCollapseStyle()) {
|
|
|
|
mBorderCollapser->GetBorder(aBorder);
|
1998-12-23 18:47:43 +03:00
|
|
|
}
|
1999-10-28 08:09:39 +04:00
|
|
|
else {
|
1998-12-21 22:20:37 +03:00
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
spacing->GetBorder(aBorder);
|
|
|
|
}
|
1998-12-23 18:47:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
now I need to actually use gettableborderat, instead of assuming that the table border is homogenous
|
|
|
|
across rows and columns. in tableFrame, LayoutStrategy, and cellFrame, maybe rowFrame
|
|
|
|
need something similar for cell (for those with spans?)
|
|
|
|
*/
|
|
|
|
|
1999-10-28 08:09:39 +04:00
|
|
|
void nsTableFrame::GetTableBorderAt(PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
nsMargin& aBorder)
|
1998-12-23 18:47:43 +03:00
|
|
|
{
|
1999-10-28 08:09:39 +04:00
|
|
|
if (NS_STYLE_BORDER_COLLAPSE==GetBorderCollapseStyle()) {
|
|
|
|
if (mBorderCollapser) {
|
|
|
|
mBorderCollapser->GetBorderAt(aRowIndex, aColIndex, aBorder);
|
|
|
|
}
|
1998-12-23 18:47:43 +03:00
|
|
|
}
|
1999-10-28 08:09:39 +04:00
|
|
|
else {
|
1998-12-21 22:20:37 +03:00
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
spacing->GetBorder(aBorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-28 08:09:39 +04:00
|
|
|
void nsTableFrame::SetBorderEdgeLength(PRUint8 aSide,
|
|
|
|
PRInt32 aIndex,
|
|
|
|
nscoord aLength)
|
|
|
|
{
|
|
|
|
if (mBorderCollapser) {
|
|
|
|
mBorderCollapser->SetBorderEdgeLength(aSide, aIndex, aLength);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableFrame::GetTableBorderForRowGroup(nsTableRowGroupFrame* aRowGroupFrame,
|
|
|
|
nsMargin& aBorder)
|
1998-12-23 18:47:43 +03:00
|
|
|
{
|
|
|
|
aBorder.SizeTo(0,0,0,0);
|
1999-10-28 08:09:39 +04:00
|
|
|
if (aRowGroupFrame) {
|
|
|
|
if (NS_STYLE_BORDER_COLLAPSE == GetBorderCollapseStyle()) {
|
|
|
|
if (mBorderCollapser) {
|
|
|
|
PRInt32 rowCount;
|
|
|
|
aRowGroupFrame->GetRowCount(rowCount);
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-12-28 22:41:57 +03:00
|
|
|
//PRInt32 colCount = cellMap->GetColCount();
|
1999-10-28 08:09:39 +04:00
|
|
|
mBorderCollapser->GetMaxBorder(aRowGroupFrame->GetStartRowIndex(), rowCount - 1,
|
|
|
|
0, cellMap->GetColCount() - 1, aBorder);
|
1998-12-23 18:47:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetTableBorder (aBorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-09 09:37:18 +03:00
|
|
|
PRUint8 nsTableFrame::GetBorderCollapseStyle()
|
|
|
|
{
|
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
|
|
|
return tableStyle->mBorderCollapse;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-05 08:27:21 +03:00
|
|
|
// XXX: could cache this. But be sure to check style changes if you do!
|
1998-12-09 09:37:18 +03:00
|
|
|
nscoord nsTableFrame::GetCellSpacingX()
|
1998-07-17 03:23:31 +04:00
|
|
|
{
|
1998-12-02 19:45:20 +03:00
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
1998-07-17 03:23:31 +04:00
|
|
|
nscoord cellSpacing = 0;
|
1998-12-09 09:37:18 +03:00
|
|
|
PRUint8 borderCollapseStyle = GetBorderCollapseStyle();
|
1999-10-28 08:09:39 +04:00
|
|
|
if (NS_STYLE_BORDER_COLLAPSE != borderCollapseStyle) {
|
1998-12-09 09:37:18 +03:00
|
|
|
if (tableStyle->mBorderSpacingX.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
cellSpacing = tableStyle->mBorderSpacingX.GetCoordValue();
|
|
|
|
}
|
1998-12-05 08:27:21 +03:00
|
|
|
}
|
1998-12-09 09:37:18 +03:00
|
|
|
return cellSpacing;
|
|
|
|
}
|
|
|
|
|
1999-05-18 09:18:16 +04:00
|
|
|
// XXX: could cache this. But be sure to check style changes if you do!
|
1998-12-09 09:37:18 +03:00
|
|
|
nscoord nsTableFrame::GetCellSpacingY()
|
|
|
|
{
|
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
|
|
|
nscoord cellSpacing = 0;
|
|
|
|
PRUint8 borderCollapseStyle = GetBorderCollapseStyle();
|
1999-10-28 08:09:39 +04:00
|
|
|
if (NS_STYLE_BORDER_COLLAPSE != borderCollapseStyle) {
|
1998-12-09 09:37:18 +03:00
|
|
|
if (tableStyle->mBorderSpacingY.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
cellSpacing = tableStyle->mBorderSpacingY.GetCoordValue();
|
|
|
|
}
|
1998-12-05 08:27:21 +03:00
|
|
|
}
|
1998-07-17 03:23:31 +04:00
|
|
|
return cellSpacing;
|
|
|
|
}
|
|
|
|
|
1999-05-18 09:18:16 +04:00
|
|
|
// Get the cellpadding defined on the table. Each cell can override this with style
|
1998-12-05 08:27:21 +03:00
|
|
|
nscoord nsTableFrame::GetCellPadding()
|
|
|
|
{
|
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
1999-05-18 09:18:16 +04:00
|
|
|
nscoord cellPadding = -1;
|
1998-12-05 08:27:21 +03:00
|
|
|
if (tableStyle->mCellPadding.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
cellPadding = tableStyle->mCellPadding.GetCoordValue();
|
|
|
|
}
|
|
|
|
return cellPadding;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewTableFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsTableFrame* it = new (aPresShell) nsTableFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_METHOD nsTableFrame::GetTableFrame(nsIFrame *aSourceFrame, nsTableFrame *& aTableFrame)
|
1998-09-24 20:37:22 +04:00
|
|
|
{
|
1998-11-16 09:46:00 +03:00
|
|
|
nsresult rv = NS_ERROR_UNEXPECTED; // the value returned
|
|
|
|
aTableFrame = nsnull; // initialize out-param
|
|
|
|
nsIFrame *parentFrame=nsnull;
|
1998-09-24 20:37:22 +04:00
|
|
|
if (nsnull!=aSourceFrame)
|
|
|
|
{
|
1998-11-16 09:46:00 +03:00
|
|
|
// "result" is the result of intermediate calls, not the result we return from this method
|
1999-02-10 04:36:30 +03:00
|
|
|
nsresult result = aSourceFrame->GetParent((nsIFrame **)&parentFrame);
|
1998-11-16 09:46:00 +03:00
|
|
|
while ((NS_OK==result) && (nsnull!=parentFrame))
|
1998-09-24 20:37:22 +04:00
|
|
|
{
|
|
|
|
const nsStyleDisplay *display;
|
1998-12-02 19:45:20 +03:00
|
|
|
parentFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)display);
|
1998-09-24 20:37:22 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE == display->mDisplay)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-11-16 09:46:00 +03:00
|
|
|
aTableFrame = (nsTableFrame *)parentFrame;
|
|
|
|
rv = NS_OK; // only set if we found the table frame
|
1998-09-24 20:37:22 +04:00
|
|
|
break;
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1999-02-10 04:36:30 +03:00
|
|
|
result = parentFrame->GetParent((nsIFrame **)&parentFrame);
|
1998-09-24 20:37:22 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_POSTCONDITION(nsnull!=aTableFrame, "unable to find table parent. aTableFrame null.");
|
1998-11-16 09:46:00 +03:00
|
|
|
NS_POSTCONDITION(NS_OK==rv, "unable to find table parent. result!=NS_OK");
|
|
|
|
return rv;
|
1998-09-24 20:37:22 +04:00
|
|
|
}
|
|
|
|
|
1998-09-01 01:23:28 +04:00
|
|
|
/* helper method for determining if this is a nested table or not */
|
1999-03-01 09:40:24 +03:00
|
|
|
// aReflowState must be the reflow state for this inner table frame, should have an assertion here for that
|
1998-12-02 19:45:20 +03:00
|
|
|
PRBool nsTableFrame::IsNested(const nsHTMLReflowState& aReflowState, const nsStylePosition *& aPosition) const
|
1998-09-01 01:23:28 +04:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
// Walk up the reflow state chain until we find a cell or the root
|
1999-10-30 06:52:11 +04:00
|
|
|
const nsHTMLReflowState* rs = aReflowState.parentReflowState; // this is for the outer frame
|
1999-03-01 09:40:24 +03:00
|
|
|
if (rs)
|
|
|
|
rs = rs->parentReflowState; // and this is the parent of the outer frame
|
1998-09-01 01:23:28 +04:00
|
|
|
while (nsnull != rs)
|
|
|
|
{
|
1998-11-06 00:42:46 +03:00
|
|
|
const nsStyleDisplay *display;
|
1998-12-02 19:45:20 +03:00
|
|
|
rs->frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)display);
|
1998-11-06 00:42:46 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE==display->mDisplay)
|
1998-09-01 01:23:28 +04:00
|
|
|
{
|
|
|
|
result = PR_TRUE;
|
1998-12-02 19:45:20 +03:00
|
|
|
rs->frame->GetStyleData(eStyleStruct_Position, ((const nsStyleStruct *&)aPosition));
|
1998-09-01 01:23:28 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
rs = rs->parentReflowState;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-01-03 01:55:48 +03:00
|
|
|
PRBool nsTableFrame::IsAutoWidth()
|
1998-06-05 06:36:25 +04:00
|
|
|
{
|
1999-08-28 01:15:21 +04:00
|
|
|
PRBool isAuto = PR_TRUE; // the default
|
1998-06-05 06:36:25 +04:00
|
|
|
|
1999-08-28 01:15:21 +04:00
|
|
|
nsStylePosition* tablePosition = (nsStylePosition*)mStyleContext->GetStyleData(eStyleStruct_Position);
|
|
|
|
switch (tablePosition->mWidth.GetUnit()) {
|
1998-06-05 06:36:25 +04:00
|
|
|
|
1999-08-28 01:15:21 +04:00
|
|
|
case eStyleUnit_Auto: // specified auto width
|
|
|
|
case eStyleUnit_Proportional: // illegal for table, so ignored
|
1999-02-12 20:45:58 +03:00
|
|
|
break;
|
1999-08-28 01:15:21 +04:00
|
|
|
case eStyleUnit_Inherit:
|
|
|
|
// get width of parent and see if it is a specified value or not
|
|
|
|
// XXX for now, just return true
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
case eStyleUnit_Percent:
|
|
|
|
isAuto = PR_FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1998-06-05 06:36:25 +04:00
|
|
|
}
|
|
|
|
|
1999-08-28 01:15:21 +04:00
|
|
|
return isAuto;
|
1998-06-05 06:36:25 +04:00
|
|
|
}
|
|
|
|
|
2000-01-03 01:55:48 +03:00
|
|
|
nscoord nsTableFrame::CalcBorderBoxWidth(const nsHTMLReflowState& aState)
|
|
|
|
{
|
|
|
|
nscoord width = aState.mComputedWidth;
|
|
|
|
|
|
|
|
if (eStyleUnit_Auto == aState.mStylePosition->mWidth.GetUnit()) {
|
|
|
|
if (0 == width) {
|
|
|
|
width = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aState.availableWidth) {
|
|
|
|
nsMargin margin(0,0,0,0);
|
|
|
|
aState.mStyleSpacing->GetMargin(margin);
|
|
|
|
width = aState.availableWidth - margin.left - margin.right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (width != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
nsMargin borderPadding(0,0,0,0);
|
|
|
|
aState.mStyleSpacing->GetBorderPadding(borderPadding);
|
|
|
|
width += borderPadding.left + borderPadding.right;
|
|
|
|
}
|
|
|
|
width = PR_MAX(width, 0);
|
|
|
|
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord nsTableFrame::CalcBorderBoxHeight(const nsHTMLReflowState& aState,
|
|
|
|
PRBool aDoNavHack)
|
|
|
|
{
|
|
|
|
nscoord height = aState.mComputedHeight;
|
|
|
|
PRBool isAutoHeight = PR_FALSE;
|
|
|
|
PRBool isPercentHack = PR_FALSE;
|
|
|
|
|
|
|
|
if (eStyleUnit_Auto == aState.mStylePosition->mHeight.GetUnit()) {
|
|
|
|
isAutoHeight = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (((0 == height) || (NS_UNCONSTRAINEDSIZE == height)) &&
|
|
|
|
aDoNavHack && (eStyleUnit_Percent == aState.mStylePosition->mHeight.GetUnit())) {
|
|
|
|
nsIAtom* frameType;
|
|
|
|
aState.frame->GetFrameType(&frameType);
|
|
|
|
if (nsLayoutAtoms::tableFrame == frameType) {
|
|
|
|
float percent = aState.mStylePosition->mHeight.GetPercentValue();
|
|
|
|
nscoord parentHeight = ((nsTableFrame*)aState.frame)->GetEffectiveContainerHeight(aState);
|
|
|
|
if ((NS_UNCONSTRAINEDSIZE != parentHeight) && (0 != parentHeight)) {
|
|
|
|
// css box-sizing not supported for this Nav hack
|
|
|
|
height = NSToCoordRound((float)parentHeight * percent);
|
|
|
|
isPercentHack = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
}
|
|
|
|
|
|
|
|
height = PR_MAX(height, 0);
|
|
|
|
|
|
|
|
if ((height != NS_UNCONSTRAINEDSIZE) && !isAutoHeight && !isPercentHack) {
|
|
|
|
nsMargin borderPadding(0,0,0,0);
|
|
|
|
aState.mStyleSpacing->GetBorderPadding(borderPadding);
|
|
|
|
height += borderPadding.top + borderPadding.bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
return height;
|
|
|
|
}
|
1999-08-28 01:15:21 +04:00
|
|
|
|
1998-09-30 03:15:01 +04:00
|
|
|
nscoord nsTableFrame::GetMinCaptionWidth()
|
|
|
|
{
|
|
|
|
nsIFrame *outerTableFrame=nsnull;
|
1999-02-10 04:36:30 +03:00
|
|
|
GetParent(&outerTableFrame);
|
1998-09-30 03:15:01 +04:00
|
|
|
return (((nsTableOuterFrame *)outerTableFrame)->GetMinCaptionWidth());
|
|
|
|
}
|
|
|
|
|
1998-10-08 19:34:48 +04:00
|
|
|
/** return the minimum width of the table. Return 0 if the min width is unknown. */
|
1999-07-28 12:09:02 +04:00
|
|
|
nscoord nsTableFrame::GetMinTableContentWidth()
|
1998-10-08 19:34:48 +04:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
if (nsnull!=mTableLayoutStrategy)
|
1999-07-28 12:09:02 +04:00
|
|
|
result = mTableLayoutStrategy->GetTableMinContentWidth();
|
1998-10-08 19:34:48 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-11-11 22:56:02 +03:00
|
|
|
/** return the maximum width of the table. Return 0 if the max width is unknown. */
|
1999-07-28 12:09:02 +04:00
|
|
|
nscoord nsTableFrame::GetMaxTableContentWidth()
|
1998-10-08 19:34:48 +04:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
if (nsnull!=mTableLayoutStrategy)
|
1999-07-28 12:09:02 +04:00
|
|
|
result = mTableLayoutStrategy->GetTableMaxContentWidth();
|
1998-10-08 19:34:48 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-02-12 04:55:40 +03:00
|
|
|
void nsTableFrame::SetMaxElementSize(nsSize* aMaxElementSize,
|
|
|
|
const nsMargin& aPadding)
|
1998-10-09 23:59:45 +04:00
|
|
|
{
|
2000-02-12 04:55:40 +03:00
|
|
|
if (nsnull!=mTableLayoutStrategy) {
|
|
|
|
mTableLayoutStrategy->SetMaxElementSize(aMaxElementSize, aPadding);
|
|
|
|
}
|
1998-10-09 23:59:45 +04:00
|
|
|
}
|
|
|
|
|
1998-09-30 03:15:01 +04:00
|
|
|
|
2000-02-12 03:58:38 +03:00
|
|
|
PRBool nsTableFrame::IsAutoLayout(const nsHTMLReflowState* aReflowState)
|
1998-10-21 00:05:44 +04:00
|
|
|
{
|
1998-12-02 19:45:20 +03:00
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
2000-02-12 03:58:38 +03:00
|
|
|
// a fixed table-layout table with an auto width is not considered as such
|
|
|
|
// for purposes of requiring pass1 reflow and assigning a layout strategy
|
|
|
|
if (NS_STYLE_TABLE_LAYOUT_FIXED == tableStyle->mLayoutStrategy) {
|
|
|
|
const nsStylePosition* position;
|
|
|
|
if (aReflowState) {
|
|
|
|
position = aReflowState->mStylePosition;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GetStyleData(eStyleStruct_Position, (const nsStyleStruct *&)position);
|
|
|
|
}
|
|
|
|
if (eStyleUnit_Auto != position->mWidth.GetUnit()) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
1998-10-21 00:05:44 +04:00
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableFrame::GetFrameName(nsString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName("Table", aResult);
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-01-18 02:35:56 +03:00
|
|
|
|
1999-01-30 18:52:19 +03:00
|
|
|
// This assumes that aFrame is a scroll frame if
|
1999-01-18 02:35:56 +03:00
|
|
|
nsTableRowGroupFrame*
|
|
|
|
nsTableFrame::GetRowGroupFrameFor(nsIFrame* aFrame, const nsStyleDisplay* aDisplay)
|
|
|
|
{
|
1999-12-07 06:36:05 +03:00
|
|
|
|
1999-01-30 18:52:19 +03:00
|
|
|
nsIFrame* result = nsnull;
|
1999-12-07 06:36:05 +03:00
|
|
|
|
|
|
|
// ok this code looks to see if it is a scrollable frame. If it is it asks it for the scrolled
|
|
|
|
// frame that should be the row group frame. -EDV
|
|
|
|
nsIScrollableFrame* scrollable = nsnull;
|
|
|
|
nsresult rv = aFrame->QueryInterface(kIScrollableFrameIID, (void **)&scrollable);
|
|
|
|
if (NS_SUCCEEDED(rv) && (nsnull != scrollable)) {
|
|
|
|
scrollable->GetScrolledFrame(nsnull, result);
|
|
|
|
} else {
|
|
|
|
result = aFrame;
|
|
|
|
}
|
1999-01-30 18:52:19 +03:00
|
|
|
|
|
|
|
return (nsTableRowGroupFrame*)result;
|
1999-01-18 02:35:56 +03:00
|
|
|
}
|
|
|
|
|
1999-02-04 02:54:32 +03:00
|
|
|
PRBool
|
1999-10-30 06:52:11 +04:00
|
|
|
nsTableFrame::IsFinalPass(const nsHTMLReflowState& aState)
|
1999-02-04 02:54:32 +03:00
|
|
|
{
|
|
|
|
return (NS_UNCONSTRAINEDSIZE != aState.availableWidth) ||
|
|
|
|
(NS_UNCONSTRAINEDSIZE != aState.availableHeight);
|
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// Find the closet sibling before aPriorChildFrame (including aPriorChildFrame) that
|
|
|
|
// is of type aChildType
|
|
|
|
nsIFrame*
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableFrame::GetFrameAtOrBefore(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aParentFrame,
|
|
|
|
nsIFrame* aPriorChildFrame,
|
|
|
|
nsIAtom* aChildType)
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
nsIFrame* result = nsnull;
|
|
|
|
if (!aPriorChildFrame) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
nsIAtom* frameType;
|
|
|
|
aPriorChildFrame->GetFrameType(&frameType);
|
|
|
|
if (aChildType == frameType) {
|
|
|
|
NS_RELEASE(frameType);
|
|
|
|
return (nsTableCellFrame*)aPriorChildFrame;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
|
|
|
|
// aPriorChildFrame is not of type aChildType, so we need start from
|
|
|
|
// the beginnng and find the closest one
|
|
|
|
nsIFrame* childFrame;
|
|
|
|
nsIFrame* lastMatchingFrame = nsnull;
|
2000-01-22 04:16:50 +03:00
|
|
|
aParentFrame->FirstChild(aPresContext, nsnull, &childFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
while (childFrame != aPriorChildFrame) {
|
|
|
|
childFrame->GetFrameType(&frameType);
|
|
|
|
if (aChildType == frameType) {
|
|
|
|
lastMatchingFrame = childFrame;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
childFrame->GetNextSibling(&childFrame);
|
|
|
|
}
|
|
|
|
return (nsTableCellFrame*)lastMatchingFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableFrame::DumpRowGroup(nsIPresContext* aPresContext, nsIFrame* aKidFrame)
|
1999-12-14 01:56:31 +03:00
|
|
|
{
|
|
|
|
nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(aKidFrame);
|
|
|
|
if (rgFrame) {
|
|
|
|
nsIFrame* rowFrame;
|
2000-01-22 04:16:50 +03:00
|
|
|
rgFrame->FirstChild(aPresContext, nsnull, &rowFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
while (rowFrame) {
|
|
|
|
nsIAtom* rowType;
|
|
|
|
rowFrame->GetFrameType(&rowType);
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == rowType) {
|
|
|
|
printf("row(%d)=%p ", ((nsTableRowFrame*)rowFrame)->GetRowIndex(), rowFrame);
|
|
|
|
nsIFrame* cellFrame;
|
2000-01-22 04:16:50 +03:00
|
|
|
rowFrame->FirstChild(aPresContext, nsnull, &cellFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
while (cellFrame) {
|
|
|
|
nsIAtom* cellType;
|
|
|
|
cellFrame->GetFrameType(&cellType);
|
|
|
|
if (nsLayoutAtoms::tableCellFrame == cellType) {
|
|
|
|
PRInt32 colIndex;
|
|
|
|
((nsTableCellFrame*)cellFrame)->GetColIndex(colIndex);
|
|
|
|
printf("cell(%d)=%p ", colIndex, cellFrame);
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(cellType);
|
|
|
|
cellFrame->GetNextSibling(&cellFrame);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
else {
|
2000-01-22 04:16:50 +03:00
|
|
|
DumpRowGroup(aPresContext, rowFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
NS_IF_RELEASE(rowType);
|
|
|
|
rowFrame->GetNextSibling(&rowFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
void nsTableFrame::Dump(nsIPresContext* aPresContext,
|
|
|
|
PRBool aDumpRows,
|
|
|
|
PRBool aDumpCols,
|
|
|
|
PRBool aDumpCellMap)
|
1999-12-14 01:56:31 +03:00
|
|
|
{
|
|
|
|
printf("***START TABLE DUMP*** \n");
|
|
|
|
// dump the columns widths array
|
|
|
|
printf("mColWidths=");
|
1999-07-28 12:09:02 +04:00
|
|
|
PRInt32 numCols = GetColCount();
|
1999-12-14 01:56:31 +03:00
|
|
|
PRInt32 colX;
|
1999-07-28 12:09:02 +04:00
|
|
|
for (colX = 0; colX < numCols; colX++) {
|
|
|
|
printf("%d ", mColumnWidths[colX]);
|
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
if (aDumpRows) {
|
|
|
|
nsIFrame* kidFrame = mFrames.FirstChild();
|
|
|
|
while (kidFrame) {
|
2000-01-22 04:16:50 +03:00
|
|
|
DumpRowGroup(aPresContext, kidFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
kidFrame->GetNextSibling(&kidFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
if (aDumpCols) {
|
1999-12-14 01:56:31 +03:00
|
|
|
// output col frame cache
|
|
|
|
printf("\n col frame cache ->");
|
|
|
|
for (colX = 0; colX < numCols; colX++) {
|
|
|
|
nsTableColFrame* colFrame = (nsTableColFrame *)mColFrames.ElementAt(colX);
|
|
|
|
if (0 == (colX % 8)) {
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
printf ("%d=%p ", colX, colFrame);
|
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
for (colX = 0; colX < numCols; colX++) {
|
|
|
|
printf("\n");
|
|
|
|
nsTableColFrame* colFrame = GetColFrame(colX);
|
|
|
|
colFrame->Dump(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aDumpCellMap) {
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-07-28 12:55:41 +04:00
|
|
|
#ifdef NS_DEBUG
|
1999-07-28 12:09:02 +04:00
|
|
|
cellMap->Dump();
|
1999-07-28 12:55:41 +04:00
|
|
|
#endif
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
|
|
|
printf(" ***END TABLE DUMP*** \n");
|
|
|
|
}
|
|
|
|
|
1999-04-22 07:51:58 +04:00
|
|
|
// nsTableIterator
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableIterator::nsTableIterator(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame& aSource,
|
1999-05-04 23:15:56 +04:00
|
|
|
nsTableIteration aType)
|
1999-04-22 07:51:58 +04:00
|
|
|
{
|
|
|
|
nsIFrame* firstChild;
|
2000-01-22 04:16:50 +03:00
|
|
|
aSource.FirstChild(aPresContext, nsnull, &firstChild);
|
1999-05-04 23:15:56 +04:00
|
|
|
Init(firstChild, aType);
|
1999-04-22 07:51:58 +04:00
|
|
|
}
|
|
|
|
|
1999-05-04 23:15:56 +04:00
|
|
|
nsTableIterator::nsTableIterator(nsFrameList& aSource,
|
|
|
|
nsTableIteration aType)
|
1999-04-22 07:51:58 +04:00
|
|
|
{
|
|
|
|
nsIFrame* firstChild = aSource.FirstChild();
|
1999-05-04 23:15:56 +04:00
|
|
|
Init(firstChild, aType);
|
1999-04-22 07:51:58 +04:00
|
|
|
}
|
|
|
|
|
1999-05-04 23:15:56 +04:00
|
|
|
void nsTableIterator::Init(nsIFrame* aFirstChild,
|
|
|
|
nsTableIteration aType)
|
1999-04-22 07:51:58 +04:00
|
|
|
{
|
|
|
|
mFirstListChild = aFirstChild;
|
|
|
|
mFirstChild = aFirstChild;
|
|
|
|
mCurrentChild = nsnull;
|
1999-05-04 23:15:56 +04:00
|
|
|
mLeftToRight = (eTableRTL == aType) ? PR_FALSE : PR_TRUE;
|
1999-04-22 07:51:58 +04:00
|
|
|
mCount = -1;
|
|
|
|
|
|
|
|
if (!mFirstChild) {
|
|
|
|
return;
|
|
|
|
}
|
1999-05-04 23:15:56 +04:00
|
|
|
if (eTableDIR == aType) {
|
1999-04-22 07:51:58 +04:00
|
|
|
nsTableFrame* table = nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(mFirstChild, table);
|
|
|
|
if (NS_SUCCEEDED(rv) && (table != nsnull)) {
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
table->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
|
|
|
mLeftToRight = (NS_STYLE_DIRECTION_LTR == display->mDirection);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(PR_FALSE, "source of table iterator is not part of a table");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!mLeftToRight) {
|
|
|
|
mCount = 0;
|
|
|
|
nsIFrame* nextChild;
|
|
|
|
mFirstChild->GetNextSibling(&nextChild);
|
|
|
|
while (nsnull != nextChild) {
|
|
|
|
mCount++;
|
|
|
|
mFirstChild = nextChild;
|
|
|
|
nextChild->GetNextSibling(&nextChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* nsTableIterator::First()
|
|
|
|
{
|
|
|
|
mCurrentChild = mFirstChild;
|
|
|
|
return mCurrentChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* nsTableIterator::Next()
|
|
|
|
{
|
|
|
|
if (!mCurrentChild) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mLeftToRight) {
|
|
|
|
mCurrentChild->GetNextSibling(&mCurrentChild);
|
|
|
|
return mCurrentChild;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsIFrame* targetChild = mCurrentChild;
|
|
|
|
mCurrentChild = nsnull;
|
|
|
|
nsIFrame* child = mFirstListChild;
|
|
|
|
while (child && (child != targetChild)) {
|
|
|
|
mCurrentChild = child;
|
|
|
|
child->GetNextSibling(&child);
|
|
|
|
}
|
|
|
|
return mCurrentChild;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsTableIterator::IsLeftToRight()
|
|
|
|
{
|
|
|
|
return mLeftToRight;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 nsTableIterator::Count()
|
|
|
|
{
|
|
|
|
if (-1 == mCount) {
|
|
|
|
mCount = 0;
|
|
|
|
nsIFrame* child = mFirstListChild;
|
|
|
|
while (nsnull != child) {
|
|
|
|
mCount++;
|
|
|
|
child->GetNextSibling(&child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mCount;
|
|
|
|
}
|
|
|
|
|
1999-08-19 23:52:37 +04:00
|
|
|
nsTableCellFrame* nsTableFrame::GetCellInfoAt(PRInt32 aRowX,
|
|
|
|
PRInt32 aColX,
|
|
|
|
PRBool* aOriginates,
|
|
|
|
PRInt32* aColSpan)
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-08-19 23:52:37 +04:00
|
|
|
return cellMap->GetCellInfoAt(aRowX, aColX, aOriginates, aColSpan);
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
|
|
|
|
1999-08-01 20:20:14 +04:00
|
|
|
/*------------------ nsITableLayout methods ------------------------------*/
|
1999-08-01 02:11:50 +04:00
|
|
|
NS_IMETHODIMP
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableFrame::GetCellDataAt(PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex,
|
1999-08-01 02:11:50 +04:00
|
|
|
nsIDOMElement* &aCell, //out params
|
2000-01-13 08:29:38 +03:00
|
|
|
PRInt32& aStartRowIndex,
|
|
|
|
PRInt32& aStartColIndex,
|
|
|
|
PRInt32& aRowSpan,
|
|
|
|
PRInt32& aColSpan,
|
2000-01-26 17:56:06 +03:00
|
|
|
PRInt32& aActualRowSpan,
|
|
|
|
PRInt32& aActualColSpan,
|
2000-01-13 08:29:38 +03:00
|
|
|
PRBool& aIsSelected)
|
1999-08-01 02:11:50 +04:00
|
|
|
{
|
|
|
|
nsresult result;
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-08-01 02:11:50 +04:00
|
|
|
// Initialize out params
|
|
|
|
aCell = nsnull;
|
|
|
|
aStartRowIndex = 0;
|
|
|
|
aStartColIndex = 0;
|
|
|
|
aRowSpan = 0;
|
|
|
|
aColSpan = 0;
|
|
|
|
aIsSelected = PR_FALSE;
|
|
|
|
|
|
|
|
if (!cellMap) { return NS_ERROR_NOT_INITIALIZED;}
|
1999-08-01 03:05:11 +04:00
|
|
|
|
|
|
|
// Return a special error value if an index is out of bounds
|
|
|
|
// This will pass the NS_SUCCEEDED() test
|
|
|
|
// Thus we can iterate indexes to get all cells in a row or col
|
1999-08-01 02:11:50 +04:00
|
|
|
// and stop when aCell is returned null.
|
1999-08-01 09:19:47 +04:00
|
|
|
PRInt32 rowCount = cellMap->GetRowCount();
|
|
|
|
PRInt32 colCount = cellMap->GetColCount();
|
|
|
|
|
|
|
|
if (aRowIndex >= rowCount || aColIndex >= colCount)
|
1999-08-01 03:05:11 +04:00
|
|
|
{
|
|
|
|
return NS_TABLELAYOUT_CELL_NOT_FOUND;
|
|
|
|
}
|
1999-08-19 23:52:37 +04:00
|
|
|
nsTableCellFrame *cellFrame = cellMap->GetCellFrameOriginatingAt(aRowIndex, aColIndex);
|
1999-08-01 09:19:47 +04:00
|
|
|
if (!cellFrame)
|
|
|
|
{
|
|
|
|
PRInt32 rowSpan, colSpan;
|
|
|
|
PRInt32 row = aStartRowIndex;
|
|
|
|
PRInt32 col = aStartColIndex;
|
|
|
|
|
|
|
|
// We didn't find a cell at requested location,
|
|
|
|
// most probably because of ROWSPAN and/or COLSPAN > 1
|
|
|
|
// Find the cell that extends into the location we requested,
|
|
|
|
// starting at the most likely indexes supplied by the caller
|
|
|
|
// in aStartRowIndex and aStartColIndex;
|
1999-08-19 23:52:37 +04:00
|
|
|
cellFrame = cellMap->GetCellFrameOriginatingAt(row, col);
|
1999-08-01 09:19:47 +04:00
|
|
|
if (cellFrame)
|
|
|
|
{
|
2000-01-26 17:56:06 +03:00
|
|
|
//The nsTableFrame version returns actual value
|
|
|
|
// when nsTableCellFrame's return values are "HTML" (i.e., may = 0)
|
2000-02-01 06:23:29 +03:00
|
|
|
rowSpan = GetEffectiveRowSpan(*cellFrame);
|
|
|
|
colSpan = GetEffectiveColSpan(*cellFrame);
|
1999-08-01 09:19:47 +04:00
|
|
|
|
|
|
|
// Check if this extends into the location we want
|
|
|
|
if( aRowIndex >= row && aRowIndex < row+rowSpan &&
|
|
|
|
aColIndex >= col && aColIndex < col+colSpan)
|
|
|
|
{
|
|
|
|
CELL_FOUND:
|
|
|
|
aStartRowIndex = row;
|
|
|
|
aStartColIndex = col;
|
2000-01-26 17:56:06 +03:00
|
|
|
aActualRowSpan = rowSpan;
|
|
|
|
aActualColSpan = colSpan;
|
|
|
|
aRowSpan = cellFrame->GetRowSpan();
|
|
|
|
aColSpan = cellFrame->GetColSpan();
|
1999-08-01 09:19:47 +04:00
|
|
|
// I know jumps aren't cool, but it's efficient!
|
|
|
|
goto TEST_IF_SELECTED;
|
|
|
|
} else {
|
|
|
|
// Suggested indexes didn't work,
|
|
|
|
// Scan through entire table to find the spanned cell
|
|
|
|
for (row = 0; row < rowCount; row++ )
|
|
|
|
{
|
|
|
|
for (col = 0; col < colCount; col++)
|
|
|
|
{
|
1999-08-19 23:52:37 +04:00
|
|
|
cellFrame = cellMap->GetCellFrameOriginatingAt(row, col);
|
1999-08-01 09:19:47 +04:00
|
|
|
if (cellFrame)
|
|
|
|
{
|
2000-02-01 06:23:29 +03:00
|
|
|
rowSpan = GetEffectiveRowSpan(*cellFrame);
|
|
|
|
colSpan = GetEffectiveColSpan(*cellFrame);
|
1999-08-01 09:19:47 +04:00
|
|
|
if( aRowIndex >= row && aRowIndex < row+rowSpan &&
|
|
|
|
aColIndex >= col && aColIndex < col+colSpan)
|
|
|
|
{
|
|
|
|
goto CELL_FOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
col = 0;
|
|
|
|
}
|
|
|
|
}
|
2000-02-02 02:39:37 +03:00
|
|
|
return NS_TABLELAYOUT_CELL_NOT_FOUND; // We didn't find a cell
|
1999-08-01 09:19:47 +04:00
|
|
|
}
|
|
|
|
}
|
1999-08-01 02:11:50 +04:00
|
|
|
|
|
|
|
result = cellFrame->GetRowIndex(aStartRowIndex);
|
|
|
|
if (NS_FAILED(result)) return result;
|
|
|
|
result = cellFrame->GetColIndex(aStartColIndex);
|
|
|
|
if (NS_FAILED(result)) return result;
|
2000-01-26 17:56:06 +03:00
|
|
|
//This returns HTML value, which may be 0
|
|
|
|
aRowSpan = cellFrame->GetRowSpan();
|
|
|
|
aColSpan = cellFrame->GetColSpan();
|
2000-02-01 06:23:29 +03:00
|
|
|
aActualRowSpan = GetEffectiveRowSpan(*cellFrame);
|
|
|
|
aActualColSpan = GetEffectiveColSpan(*cellFrame);
|
1999-08-01 02:11:50 +04:00
|
|
|
result = cellFrame->GetSelected(&aIsSelected);
|
|
|
|
if (NS_FAILED(result)) return result;
|
|
|
|
|
1999-08-01 09:19:47 +04:00
|
|
|
TEST_IF_SELECTED:
|
1999-08-01 02:11:50 +04:00
|
|
|
// do this last, because it addrefs,
|
|
|
|
// and we don't want the caller leaking it on error
|
|
|
|
nsCOMPtr<nsIContent>content;
|
|
|
|
result = cellFrame->GetContent(getter_AddRefs(content));
|
|
|
|
if (NS_SUCCEEDED(result) && content)
|
|
|
|
{
|
2000-02-03 01:24:56 +03:00
|
|
|
content->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)(&aCell));
|
1999-08-01 02:11:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-08-01 20:20:14 +04:00
|
|
|
NS_IMETHODIMP nsTableFrame::GetTableSize(PRInt32& aRowCount, PRInt32& aColCount)
|
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-08-01 20:20:14 +04:00
|
|
|
// Initialize out params
|
|
|
|
aRowCount = 0;
|
|
|
|
aColCount = 0;
|
|
|
|
if (!cellMap) { return NS_ERROR_NOT_INITIALIZED;}
|
|
|
|
|
|
|
|
aRowCount = cellMap->GetRowCount();
|
|
|
|
aColCount = cellMap->GetColCount();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------- end of nsITableLayout implementation ------------------*/
|
|
|
|
|
1999-08-26 01:49:18 +04:00
|
|
|
PRInt32 nsTableFrame::GetNumCellsOriginatingInCol(PRInt32 aColIndex) const
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-08-26 01:49:18 +04:00
|
|
|
return cellMap->GetNumCellsOriginatingInCol(aColIndex);
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
|
1999-08-19 23:52:37 +04:00
|
|
|
#define INDENT_PER_LEVEL 2
|
|
|
|
|
|
|
|
void nsTableFrame::DebugGetIndent(const nsIFrame* aFrame,
|
|
|
|
char* aBuf)
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
1999-08-19 23:52:37 +04:00
|
|
|
PRInt32 numLevels = 0;
|
|
|
|
nsIFrame* parent = nsnull;
|
|
|
|
aFrame->GetParent(&parent);
|
|
|
|
while (parent) {
|
|
|
|
nsIAtom* frameType = nsnull;
|
|
|
|
parent->GetFrameType(&frameType);
|
1999-08-27 08:29:05 +04:00
|
|
|
if ((nsDebugTable::gRflTableOuter && (nsLayoutAtoms::tableOuterFrame == frameType)) ||
|
|
|
|
(nsDebugTable::gRflTable && (nsLayoutAtoms::tableFrame == frameType)) ||
|
|
|
|
(nsDebugTable::gRflRowGrp && (nsLayoutAtoms::tableRowGroupFrame == frameType)) ||
|
|
|
|
(nsDebugTable::gRflRow && (nsLayoutAtoms::tableRowFrame == frameType)) ||
|
|
|
|
(nsDebugTable::gRflCell && (nsLayoutAtoms::tableCellFrame == frameType)) ||
|
|
|
|
(nsDebugTable::gRflArea && (nsLayoutAtoms::areaFrame == frameType))) {
|
1999-08-19 23:52:37 +04:00
|
|
|
numLevels++;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
parent->GetParent(&parent);
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
1999-08-19 23:52:37 +04:00
|
|
|
PRInt32 indent = INDENT_PER_LEVEL * numLevels;
|
|
|
|
nsCRT::memset (aBuf, ' ', indent);
|
|
|
|
aBuf[indent] = 0;
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
|
|
|
|
1999-08-19 23:52:37 +04:00
|
|
|
void PrettyUC(nscoord aSize,
|
|
|
|
char* aBuf)
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
1999-08-19 23:52:37 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aSize) {
|
|
|
|
strcpy(aBuf, "UC");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sprintf(aBuf, "%d", aSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableFrame::DebugReflow(char* aMessage,
|
|
|
|
const nsIFrame* aFrame,
|
|
|
|
const nsHTMLReflowState* aState,
|
2000-01-03 01:55:48 +03:00
|
|
|
const nsHTMLReflowMetrics* aMetrics,
|
|
|
|
const nsReflowStatus aStatus)
|
1999-08-19 23:52:37 +04:00
|
|
|
{
|
|
|
|
char indent[256];
|
|
|
|
nsTableFrame::DebugGetIndent(aFrame, indent);
|
|
|
|
printf("%s%s %p ", indent, aMessage, aFrame);
|
1999-09-02 04:07:14 +04:00
|
|
|
char width[32];
|
|
|
|
char height[32];
|
1999-08-19 23:52:37 +04:00
|
|
|
if (aState) {
|
|
|
|
PrettyUC(aState->availableWidth, width);
|
|
|
|
PrettyUC(aState->availableHeight, height);
|
|
|
|
printf("rea=%d av=(%s,%s) ", aState->reason, width, height);
|
|
|
|
PrettyUC(aState->mComputedWidth, width);
|
|
|
|
PrettyUC(aState->mComputedHeight, height);
|
2000-01-28 05:19:45 +03:00
|
|
|
printf("comp=(%s,%s) count=%d \n", width, height, gRflCount);
|
|
|
|
gRflCount++;
|
|
|
|
//if (32 == gRflCount) {
|
|
|
|
// NS_ASSERTION(PR_FALSE, "stop");
|
|
|
|
//}
|
1999-08-19 23:52:37 +04:00
|
|
|
}
|
|
|
|
if (aMetrics) {
|
|
|
|
if (aState) {
|
|
|
|
printf("%s", indent);
|
|
|
|
}
|
1999-09-02 04:07:14 +04:00
|
|
|
PrettyUC(aMetrics->width, width);
|
|
|
|
PrettyUC(aMetrics->height, height);
|
1999-09-10 17:03:32 +04:00
|
|
|
printf("des=(%s,%s) ", width, height);
|
1999-08-19 23:52:37 +04:00
|
|
|
if (aMetrics->maxElementSize) {
|
|
|
|
PrettyUC(aMetrics->maxElementSize->width, width);
|
|
|
|
PrettyUC(aMetrics->maxElementSize->height, height);
|
|
|
|
printf("maxElem=(%s,%s)", width, height);
|
|
|
|
}
|
2000-01-03 01:55:48 +03:00
|
|
|
if (NS_FRAME_COMPLETE != aStatus) {
|
|
|
|
printf("status=%d", aStatus);
|
|
|
|
}
|
1999-08-19 23:52:37 +04:00
|
|
|
printf("\n");
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-01 08:36:47 +04:00
|
|
|
PRBool nsTableFrame::RowHasSpanningCells(PRInt32 aRowIndex)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-09-01 08:36:47 +04:00
|
|
|
NS_PRECONDITION (cellMap, "bad call, cellMap not yet allocated.");
|
|
|
|
if (cellMap) {
|
|
|
|
result = cellMap->RowHasSpanningCells(aRowIndex);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-08-19 23:52:37 +04:00
|
|
|
PRBool nsTableFrame::RowIsSpannedInto(PRInt32 aRowIndex)
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap* cellMap = GetCellMap();
|
1999-08-19 23:52:37 +04:00
|
|
|
NS_PRECONDITION (cellMap, "bad call, cellMap not yet allocated.");
|
|
|
|
if (cellMap) {
|
|
|
|
result = cellMap->RowIsSpannedInto(aRowIndex);
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-08-19 23:52:37 +04:00
|
|
|
PRBool nsTableFrame::ColIsSpannedInto(PRInt32 aColIndex)
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellMap * cellMap = GetCellMap();
|
1999-08-19 23:52:37 +04:00
|
|
|
NS_PRECONDITION (cellMap, "bad call, cellMap not yet allocated.");
|
|
|
|
if (cellMap) {
|
|
|
|
result = cellMap->ColIsSpannedInto(aColIndex);
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
1999-08-10 04:49:10 +04:00
|
|
|
|
|
|
|
|
1999-09-01 05:02:16 +04:00
|
|
|
#ifdef DEBUG
|
1999-08-31 07:09:40 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
|
|
|
{
|
1999-09-01 05:02:16 +04:00
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
PRUint32 sum = sizeof(*this);
|
1999-10-02 04:02:54 +04:00
|
|
|
|
|
|
|
// Add in the amount of space for the column width array
|
|
|
|
sum += mColumnWidthsLength * sizeof(PRInt32);
|
|
|
|
|
|
|
|
// Add in size of cell map
|
|
|
|
PRUint32 cellMapSize;
|
|
|
|
mCellMap->SizeOf(aHandler, &cellMapSize);
|
|
|
|
aHandler->AddSize(nsLayoutAtoms::cellMap, cellMapSize);
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// Add in size of col cache
|
|
|
|
PRUint32 voidArraySize;
|
|
|
|
mColFrames.SizeOf(aHandler, &voidArraySize);
|
|
|
|
sum += voidArraySize - sizeof(mColFrames);
|
|
|
|
|
1999-10-02 04:02:54 +04:00
|
|
|
// Add in size of table layout strategy
|
|
|
|
PRUint32 strategySize;
|
|
|
|
mTableLayoutStrategy->SizeOf(aHandler, &strategySize);
|
|
|
|
aHandler->AddSize(nsLayoutAtoms::tableStrategy, strategySize);
|
|
|
|
|
1999-09-01 05:02:16 +04:00
|
|
|
*aResult = sum;
|
|
|
|
return NS_OK;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|