1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#include "nsTableRowGroupFrame.h"
|
|
|
|
#include "nsTableRowFrame.h"
|
1998-11-11 22:56:02 +03:00
|
|
|
#include "nsTableFrame.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsTableCellFrame.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIContent.h"
|
1998-04-15 01:49:29 +04:00
|
|
|
#include "nsIView.h"
|
1998-04-22 10:37:57 +04:00
|
|
|
#include "nsIPtr.h"
|
1998-06-23 09:43:27 +04:00
|
|
|
#include "nsIReflowCommand.h"
|
1998-10-01 08:46:11 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1999-01-18 02:35:56 +03:00
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
1998-07-11 04:00:31 +04:00
|
|
|
static PRBool gsDebug = PR_FALSE;
|
1998-10-14 20:32:45 +04:00
|
|
|
static PRBool gsDebugIR = PR_FALSE;
|
1998-04-14 00:24:54 +04:00
|
|
|
#else
|
1998-07-11 04:00:31 +04:00
|
|
|
static const PRBool gsDebug = PR_FALSE;
|
1998-10-14 20:32:45 +04:00
|
|
|
static const PRBool gsDebugIR = PR_FALSE;
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif
|
|
|
|
|
1998-04-22 10:37:57 +04:00
|
|
|
NS_DEF_PTR(nsIStyleContext);
|
|
|
|
NS_DEF_PTR(nsIContent);
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/* ----------- RowGroupReflowState ---------- */
|
|
|
|
|
|
|
|
struct RowGroupReflowState {
|
1998-10-14 20:32:45 +04:00
|
|
|
nsIPresContext& mPresContext; // Our pres context
|
|
|
|
const nsHTMLReflowState& reflowState; // Our reflow state
|
1998-05-30 00:36:05 +04:00
|
|
|
|
1999-01-05 03:41:40 +03:00
|
|
|
// The available size (computed from the parent)
|
1998-04-14 00:24:54 +04:00
|
|
|
nsSize availSize;
|
|
|
|
|
|
|
|
// Flags for whether the max size is unconstrained
|
|
|
|
PRBool unconstrainedWidth;
|
|
|
|
PRBool unconstrainedHeight;
|
|
|
|
|
|
|
|
// Running y-offset
|
|
|
|
nscoord y;
|
|
|
|
|
1998-10-20 03:43:06 +04:00
|
|
|
// Flag used to set maxElementSize to my first row
|
1998-04-14 00:24:54 +04:00
|
|
|
PRBool firstRow;
|
|
|
|
|
|
|
|
// Remember the height of the first row, because it's our maxElementHeight (plus header/footers)
|
|
|
|
nscoord firstRowHeight;
|
|
|
|
|
1998-11-04 23:09:19 +03:00
|
|
|
nsTableFrame *tableFrame;
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
RowGroupReflowState(nsIPresContext& aPresContext,
|
1998-11-04 23:09:19 +03:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame * aTableFrame)
|
1998-10-14 20:32:45 +04:00
|
|
|
: mPresContext(aPresContext),
|
|
|
|
reflowState(aReflowState)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-01-06 02:31:18 +03:00
|
|
|
availSize.width = reflowState.availableWidth;
|
|
|
|
availSize.height = reflowState.availableHeight;
|
1999-01-05 03:41:40 +03:00
|
|
|
y=0; // border/padding???
|
1999-01-06 02:31:18 +03:00
|
|
|
unconstrainedWidth = PRBool(reflowState.availableWidth == NS_UNCONSTRAINEDSIZE);
|
|
|
|
unconstrainedHeight = PRBool(reflowState.availableHeight == NS_UNCONSTRAINEDSIZE);
|
1998-04-14 00:24:54 +04:00
|
|
|
firstRow = PR_TRUE;
|
|
|
|
firstRowHeight=0;
|
1998-11-04 23:09:19 +03:00
|
|
|
tableFrame = aTableFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
~RowGroupReflowState() {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------- nsTableRowGroupFrame ---------- */
|
|
|
|
|
1999-01-30 18:52:19 +03:00
|
|
|
nsresult
|
|
|
|
nsTableRowGroupFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
static NS_DEFINE_IID(kITableRowGroupIID, NS_ITABLEROWGROUPFRAME_IID);
|
|
|
|
if (aIID.Equals(kITableRowGroupIID)) {
|
|
|
|
*aInstancePtr = (void*)this;
|
|
|
|
return NS_OK;
|
|
|
|
} else {
|
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-16 00:36:42 +04:00
|
|
|
NS_METHOD nsTableRowGroupFrame::GetRowCount(PRInt32 &aCount)
|
|
|
|
{
|
|
|
|
// init out-param
|
|
|
|
aCount=0;
|
|
|
|
|
|
|
|
// loop through children, adding one to aCount for every legit row
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame *childFrame = mFrames.FirstChild();
|
1998-09-16 00:36:42 +04:00
|
|
|
while (PR_TRUE)
|
|
|
|
{
|
|
|
|
if (nsnull==childFrame)
|
|
|
|
break;
|
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-09-16 00:36:42 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
|
|
|
aCount++;
|
|
|
|
childFrame->GetNextSibling(childFrame);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
PRInt32 nsTableRowGroupFrame::GetStartRowIndex()
|
|
|
|
{
|
|
|
|
PRInt32 result = -1;
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame *childFrame = mFrames.FirstChild();
|
1998-12-23 18:47:43 +03:00
|
|
|
while (PR_TRUE)
|
|
|
|
{
|
|
|
|
if (nsnull==childFrame)
|
|
|
|
break;
|
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
result = ((nsTableRowFrame *)childFrame)->GetRowIndex();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
childFrame->GetNextSibling(childFrame);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-10-22 09:27:11 +04:00
|
|
|
NS_METHOD nsTableRowGroupFrame::GetMaxColumns(PRInt32 &aMaxColumns) const
|
|
|
|
{
|
|
|
|
aMaxColumns=0;
|
|
|
|
// loop through children, remembering the max of the columns in each row
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame *childFrame = mFrames.FirstChild();
|
1998-10-22 09:27:11 +04:00
|
|
|
while (PR_TRUE)
|
|
|
|
{
|
|
|
|
if (nsnull==childFrame)
|
|
|
|
break;
|
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-10-22 09:27:11 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
PRInt32 colCount = ((nsTableRowFrame *)childFrame)->GetMaxColumns();
|
|
|
|
aMaxColumns = PR_MAX(aMaxColumns, colCount);
|
|
|
|
}
|
|
|
|
childFrame->GetNextSibling(childFrame);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-16 21:19:20 +04:00
|
|
|
NS_IMETHODIMP
|
1998-11-10 09:05:32 +03:00
|
|
|
nsTableRowGroupFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-09-16 21:19:20 +04:00
|
|
|
{
|
1999-01-16 01:52:05 +03:00
|
|
|
mFrames.SetFrames(aChildList);
|
1998-09-16 21:19:20 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
// for debug...
|
1998-04-30 04:27:59 +04:00
|
|
|
/*
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsIFrame::GetShowFrameBorders()) {
|
|
|
|
aRenderingContext.SetColor(NS_RGB(128,0,0));
|
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
1998-04-30 04:27:59 +04:00
|
|
|
*/
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-18 18:54:23 +03:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
PRIntn
|
|
|
|
nsTableRowGroupFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// aDirtyRect is in our coordinate system
|
|
|
|
// child rect's are also in our coordinate system
|
|
|
|
/** overloaded method from nsContainerFrame. The difference is that
|
|
|
|
* we don't want to clip our children, so a cell can do a rowspan
|
|
|
|
*/
|
|
|
|
void nsTableRowGroupFrame::PaintChildren(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
1998-04-14 00:24:54 +04:00
|
|
|
while (nsnull != kid) {
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIView *pView;
|
|
|
|
|
|
|
|
kid->GetView(pView);
|
1998-04-15 01:49:29 +04:00
|
|
|
if (nsnull == pView) {
|
1998-10-30 05:08:25 +03:00
|
|
|
PRBool clipState;
|
1998-04-15 01:49:29 +04:00
|
|
|
nsRect kidRect;
|
|
|
|
kid->GetRect(kidRect);
|
|
|
|
nsRect damageArea(aDirtyRect);
|
|
|
|
// Translate damage area into kid's coordinate system
|
|
|
|
nsRect kidDamageArea(damageArea.x - kidRect.x, damageArea.y - kidRect.y,
|
|
|
|
damageArea.width, damageArea.height);
|
|
|
|
aRenderingContext.PushState();
|
|
|
|
aRenderingContext.Translate(kidRect.x, kidRect.y);
|
1998-12-18 18:54:23 +03:00
|
|
|
kid->Paint(aPresContext, aRenderingContext, kidDamageArea, aWhichLayer);
|
|
|
|
if ((eFramePaintLayer_Overlay == aWhichLayer) && GetShowFrameBorders()) {
|
1998-04-15 01:49:29 +04:00
|
|
|
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
|
|
|
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
|
|
|
|
}
|
1998-10-30 05:08:25 +03:00
|
|
|
aRenderingContext.PopState(clipState);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
kid->GetNextSibling(kid);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-07 03:36:37 +03:00
|
|
|
/* we overload this here because rows have children that can span outside of themselves.
|
|
|
|
* so the default "get the child rect, see if it contains the event point" action isn't
|
|
|
|
* sufficient. We have to ask the row if it has a child that contains the point.
|
|
|
|
*/
|
1998-11-18 08:25:26 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame)
|
1998-11-07 03:36:37 +03:00
|
|
|
{
|
|
|
|
nsIFrame* kid;
|
1998-11-18 08:25:26 +03:00
|
|
|
nsRect kidRect;
|
|
|
|
nsPoint tmp;
|
|
|
|
|
1998-11-09 22:40:27 +03:00
|
|
|
FirstChild(nsnull, kid);
|
1998-11-07 03:36:37 +03:00
|
|
|
while (nsnull != kid) {
|
|
|
|
kid->GetRect(kidRect);
|
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
kid->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-11-07 03:36:37 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay) {
|
1998-11-18 08:25:26 +03:00
|
|
|
if (((nsTableRowFrame*)(kid))->Contains(aPoint)) {
|
|
|
|
tmp.MoveTo(aPoint.x - kidRect.x, aPoint.y - kidRect.y);
|
|
|
|
return kid->GetFrameForPoint(tmp, aFrame);
|
1998-11-07 03:36:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
kid->GetNextSibling(kid);
|
|
|
|
}
|
1998-11-18 08:25:26 +03:00
|
|
|
*aFrame = this;
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-11-07 03:36:37 +03:00
|
|
|
}
|
|
|
|
|
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
|
1998-10-20 03:43:06 +04:00
|
|
|
void nsTableRowGroupFrame::PlaceChild(nsIPresContext& aPresContext,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
const nsRect& aKidRect,
|
|
|
|
nsSize* aMaxElementSize,
|
|
|
|
nsSize& aKidMaxElementSize)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-07-11 04:00:31 +04:00
|
|
|
if (PR_TRUE==gsDebug)
|
1998-08-07 06:11:51 +04:00
|
|
|
printf ("rowgroup %p: placing row at %d, %d, %d, %d\n",
|
|
|
|
this, aKidRect.x, aKidRect.y, aKidRect.width, aKidRect.height);
|
1998-04-21 02:49:15 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Place and size the child
|
|
|
|
aKidFrame->SetRect(aKidRect);
|
|
|
|
|
|
|
|
// Adjust the running y-offset
|
1998-10-20 03:43:06 +04:00
|
|
|
aReflowState.y += aKidRect.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// If our height is constrained then update the available height
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_FALSE == aReflowState.unconstrainedHeight) {
|
|
|
|
aReflowState.availSize.height -= aKidRect.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update the maximum element size
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==aReflowState.firstRow)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
aReflowState.firstRow = PR_FALSE;
|
|
|
|
aReflowState.firstRowHeight = aKidRect.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull != aMaxElementSize) {
|
|
|
|
aMaxElementSize->width = aKidMaxElementSize.width;
|
|
|
|
aMaxElementSize->height = aKidMaxElementSize.height;
|
|
|
|
}
|
|
|
|
}
|
1998-08-07 06:11:51 +04:00
|
|
|
else if (nsnull != aMaxElementSize) {
|
|
|
|
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, aKidMaxElementSize.width);
|
|
|
|
}
|
|
|
|
if (gsDebug && nsnull != aMaxElementSize)
|
|
|
|
printf ("rowgroup %p: placing row %p with width = %d and MES= %d\n",
|
|
|
|
this, aKidFrame, aKidRect.width, aMaxElementSize->width);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reflow the frames we've already created
|
|
|
|
*
|
|
|
|
* @param aPresContext presentation context to use
|
1998-10-20 03:43:06 +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
|
|
|
|
*/
|
1998-10-20 03:43:06 +04:00
|
|
|
NS_METHOD nsTableRowGroupFrame::ReflowMappedChildren(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsTableRowFrame * aStartFrame,
|
|
|
|
nsReflowReason aReason,
|
|
|
|
PRBool aDoSiblings)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: ReflowMappedChildren\n");
|
1998-04-14 00:24:54 +04:00
|
|
|
nsIFrame* prevKidFrame = nsnull;
|
|
|
|
nsSize kidMaxElementSize;
|
1998-10-20 03:43:06 +04:00
|
|
|
nsSize* pKidMaxElementSize = (nsnull != aDesiredSize.maxElementSize) ? &kidMaxElementSize : nsnull;
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsIFrame* kidFrame;
|
|
|
|
if (nsnull==aStartFrame)
|
1999-01-16 01:52:05 +03:00
|
|
|
kidFrame = mFrames.FirstChild();
|
1998-10-20 03:43:06 +04:00
|
|
|
else
|
|
|
|
kidFrame = aStartFrame;
|
1998-12-21 09:38:18 +03:00
|
|
|
|
|
|
|
PRUint8 borderStyle = aReflowState.tableFrame->GetBorderCollapseStyle();
|
|
|
|
|
1998-10-20 03:43:06 +04:00
|
|
|
for ( ; nsnull != kidFrame; )
|
|
|
|
{
|
|
|
|
nsSize kidAvailSize(aReflowState.availSize);
|
1998-04-23 21:29:07 +04:00
|
|
|
if (0>=kidAvailSize.height)
|
|
|
|
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
|
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-04-17 02:21:32 +04:00
|
|
|
// Reflow the child into the available space
|
1998-12-14 04:24:11 +03:00
|
|
|
#if 1
|
|
|
|
// XXX Give it as much room as it wants. We'll deal with splitting later
|
|
|
|
// after we've computed the row heights taking into account cells with
|
|
|
|
// row spans...
|
|
|
|
kidAvailSize.height = NS_UNCONSTRAINEDSIZE;
|
|
|
|
#endif
|
1998-10-20 03:43:06 +04:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState.reflowState,
|
|
|
|
kidAvailSize, aReason);
|
1999-01-16 01:52:05 +03:00
|
|
|
if (kidFrame != mFrames.FirstChild()) {
|
1998-12-14 04:24:11 +03:00
|
|
|
// If this isn't the first row frame, then we can't be at the top of
|
|
|
|
// the page anymore...
|
|
|
|
kidReflowState.isTopOfPage = PR_FALSE;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-20 03:43:06 +04:00
|
|
|
if ((PR_TRUE==gsDebug) || (PR_TRUE==gsDebugIR))
|
|
|
|
printf("%p RG reflowing child %p with avail width = %d, reason = %d\n",
|
|
|
|
this, kidFrame, kidAvailSize.width, aReason);
|
|
|
|
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
|
|
|
if (gsDebug) printf("%p RG child %p returned desired width = %d\n",
|
|
|
|
this, kidFrame, desiredSize.width);
|
1998-10-06 04:27:22 +04:00
|
|
|
|
1998-12-14 04:24:11 +03:00
|
|
|
#if 0
|
1998-10-06 04:27:22 +04:00
|
|
|
// Did the child fit?
|
1999-01-16 01:52:05 +03:00
|
|
|
if ((kidFrame != mFrames.FirstChild()) &&
|
1998-10-06 04:27:22 +04:00
|
|
|
((kidAvailSize.height <= 0) ||
|
|
|
|
(desiredSize.height > kidAvailSize.height)))
|
|
|
|
{
|
|
|
|
// The child's height is too big to fit at all in our remaining space,
|
|
|
|
// and it's not our first child.
|
|
|
|
//
|
|
|
|
// Note that if the width is too big that's okay and we allow the
|
|
|
|
// child to extend horizontally outside of the reflow area
|
|
|
|
PushChildren(kidFrame, prevKidFrame);
|
1998-12-08 20:57:45 +03:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-10-06 04:27:22 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-12-14 04:24:11 +03:00
|
|
|
#endif
|
1998-10-06 04:27:22 +04:00
|
|
|
|
1999-01-05 03:41:40 +03:00
|
|
|
nsRect kidRect (0, aReflowState.y, desiredSize.width, desiredSize.height);
|
1998-10-20 03:43:06 +04:00
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame, kidRect, aDesiredSize.maxElementSize,
|
1998-10-06 04:27:22 +04:00
|
|
|
kidMaxElementSize);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
/* if the table has collapsing borders, we need to reset the length of the shared vertical borders
|
|
|
|
* for the table and the cells that overlap this row
|
|
|
|
*/
|
|
|
|
if ((eReflowReason_Initial != aReflowState.reflowState.reason) && (NS_STYLE_BORDER_COLLAPSE==borderStyle))
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
PRInt32 rowIndex = ((nsTableRowFrame*)kidFrame)->GetRowIndex();
|
|
|
|
aReflowState.tableFrame->SetBorderEdgeLength(NS_SIDE_LEFT,
|
|
|
|
rowIndex,
|
|
|
|
kidRect.height);
|
|
|
|
aReflowState.tableFrame->SetBorderEdgeLength(NS_SIDE_RIGHT,
|
|
|
|
rowIndex,
|
|
|
|
kidRect.height);
|
1998-12-30 09:48:15 +03:00
|
|
|
PRInt32 colCount = aReflowState.tableFrame->GetColCount();
|
|
|
|
PRInt32 colIndex = 0;
|
|
|
|
nsIFrame *cellFrame = aReflowState.tableFrame->GetCellFrameAt(rowIndex, colIndex);
|
|
|
|
while (colIndex<colCount)
|
1998-12-21 09:38:18 +03:00
|
|
|
{
|
1998-12-30 09:48:15 +03:00
|
|
|
if (nsnull!=cellFrame)
|
1998-12-21 09:38:18 +03:00
|
|
|
{
|
1998-12-30 09:48:15 +03:00
|
|
|
const nsStyleDisplay *cellDisplay;
|
|
|
|
cellFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)cellDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == cellDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_LEFT,
|
|
|
|
rowIndex,
|
|
|
|
kidRect.height);
|
|
|
|
((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_RIGHT,
|
|
|
|
rowIndex,
|
|
|
|
kidRect.height);
|
|
|
|
}
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
1998-12-30 09:48:15 +03:00
|
|
|
colIndex++;
|
|
|
|
cellFrame = aReflowState.tableFrame->GetCellFrameAt(rowIndex, colIndex);
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Remember where we just were in case we end up pushing children
|
|
|
|
prevKidFrame = kidFrame;
|
|
|
|
|
1998-12-14 04:24:11 +03:00
|
|
|
#if 0
|
1998-04-15 01:45:28 +04:00
|
|
|
/* Row groups should not create continuing frames for rows
|
|
|
|
* unless they absolutely have to!
|
|
|
|
* check to see if this is absolutely necessary (with new params from troy)
|
|
|
|
* otherwise PushChildren and bail.
|
|
|
|
*/
|
1998-04-14 00:24:54 +04:00
|
|
|
// Special handling for incomplete children
|
1998-10-20 03:43:06 +04:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
1998-04-14 00:24:54 +04:00
|
|
|
// XXX It's good to assume that we might still have room
|
|
|
|
// even if the child didn't complete (floaters will want this)
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* kidNextInFlow;
|
|
|
|
|
|
|
|
kidFrame->GetNextInFlow(kidNextInFlow);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == kidNextInFlow) {
|
|
|
|
// No the child isn't complete, and it doesn't have a next in flow so
|
|
|
|
// create a continuing frame. This hooks the child into the flow.
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* continuingFrame;
|
1998-05-07 04:08:20 +04:00
|
|
|
nsIStyleContext* kidSC;
|
1998-11-03 23:33:43 +03:00
|
|
|
kidFrame->GetStyleContext(kidSC);
|
1998-10-20 03:43:06 +04:00
|
|
|
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
|
1998-05-07 04:08:20 +04:00
|
|
|
continuingFrame);
|
|
|
|
NS_RELEASE(kidSC);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Insert the frame. We'll reflow it next pass through the loop
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* nextSib;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
kidFrame->GetNextSibling(nextSibling);
|
1998-04-17 02:21:32 +04:00
|
|
|
if (nsnull != nextSibling) {
|
1998-09-24 08:18:58 +04:00
|
|
|
PushChildren(nextSibling, kidFrame);
|
1998-04-17 02:21:32 +04:00
|
|
|
}
|
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-12-14 04:24:11 +03:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_FALSE==aDoSiblings)
|
|
|
|
break;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Get the next child
|
1998-04-17 05:41:24 +04:00
|
|
|
kidFrame->GetNextSibling(kidFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-20 03:43:06 +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-20 03:43:06 +04:00
|
|
|
* @param aReflowState current inline state
|
1998-12-09 07:26:42 +03:00
|
|
|
* @return NS_FRAME_COMPLETE if there are no frames to pull-up or if we pulled
|
|
|
|
* up all the next-in-flow frames, and NS_FRAME_NOT_COMPLETE otherwise
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1998-10-20 03:43:06 +04:00
|
|
|
NS_METHOD nsTableRowGroupFrame::PullUpChildren(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-01-18 02:35:56 +03:00
|
|
|
// XXX if this code is activated then fix the nsRowGroupFrame cast, it might be an nsScrollFrame
|
1998-04-17 02:21:32 +04:00
|
|
|
nsTableRowGroupFrame* nextInFlow = (nsTableRowGroupFrame*)mNextInFlow;
|
|
|
|
nsSize kidMaxElementSize;
|
1998-10-20 03:43:06 +04:00
|
|
|
nsSize* pKidMaxElementSize = (nsnull != aDesiredSize.maxElementSize) ? &kidMaxElementSize : nsnull;
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* prevKidFrame = mFrames.LastChild();
|
1998-10-20 03:43:06 +04:00
|
|
|
nsresult rv = NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-09 07:26:42 +03:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
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
|
|
|
|
|
|
|
// 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-12-09 07:26:42 +03:00
|
|
|
// Any more row 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-01-16 01:52:05 +03:00
|
|
|
if (nextInFlow->mOverflowFrames.NotEmpty()) {
|
1998-04-17 02:21:32 +04:00
|
|
|
// Move the overflow list to become the child list
|
1999-01-16 01:52:05 +03:00
|
|
|
nextInFlow->AppendChildren(nextInFlow->mOverflowFrames.FirstChild(), PR_TRUE);
|
|
|
|
nextInFlow->mOverflowFrames.SetFrames(nsnull);
|
|
|
|
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.
|
1998-04-17 05:41:24 +04: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
|
1998-12-09 07:26:42 +03:00
|
|
|
// it's splittable then reflow it
|
1998-05-22 08:54:11 +04:00
|
|
|
nsSize kidFrameSize;
|
|
|
|
nsSplittableType kidIsSplittable;
|
1998-04-17 05:41:24 +04:00
|
|
|
|
|
|
|
kidFrame->GetSize(kidFrameSize);
|
|
|
|
kidFrame->IsSplittable(kidIsSplittable);
|
1998-10-20 03:43:06 +04:00
|
|
|
if ((kidFrameSize.height > aReflowState.availSize.height) &&
|
1998-05-22 08:54:11 +04:00
|
|
|
NS_FRAME_IS_NOT_SPLITTABLE(kidIsSplittable)) {
|
1998-12-09 07:26:42 +03:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-04-17 02:21:32 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-10-20 03:43:06 +04:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, kidFrame,
|
|
|
|
aReflowState.reflowState, aReflowState.availSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
eReflowReason_Resize);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-20 03:43:06 +04:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, aStatus);
|
1998-10-06 04:27:22 +04:00
|
|
|
|
|
|
|
// Did the child fit?
|
1998-12-09 07:26:42 +03:00
|
|
|
if (kidSize.height > aReflowState.availSize.height) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE; // the child doesn't fit
|
1998-10-06 04:27:22 +04:00
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
|
1998-10-06 04:27:22 +04:00
|
|
|
// Place the child
|
|
|
|
nsRect kidRect (0, 0, kidSize.width, kidSize.height);
|
1998-10-20 03:43:06 +04:00
|
|
|
kidRect.y += aReflowState.y;
|
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame, kidRect, aDesiredSize.maxElementSize, *pKidMaxElementSize);
|
1998-10-06 04:27:22 +04:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Remove the frame from its current parent
|
1998-12-09 07:26:42 +03:00
|
|
|
// XXX We need to do this BEFORE we reflow the child; otherwise we're reflowing
|
|
|
|
// it without its geometric parent set properly...
|
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-04-14 00:24:54 +04:00
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Is the child we just pulled up complete?
|
1998-10-20 03:43:06 +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;
|
|
|
|
|
|
|
|
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.
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* continuingFrame;
|
1998-05-07 04:08:20 +04:00
|
|
|
nsIStyleContext* kidSC;
|
1999-02-10 03:42:56 +03:00
|
|
|
kidFrame->GetStyleContext(&kidSC);
|
1998-10-20 03:43:06 +04:00
|
|
|
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC,
|
1998-05-07 04:08:20 +04:00
|
|
|
continuingFrame);
|
|
|
|
NS_RELEASE(kidSC);
|
1998-04-17 02:21:32 +04:00
|
|
|
NS_ASSERTION(nsnull != continuingFrame, "frame creation failed");
|
|
|
|
|
|
|
|
// 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
|
|
|
|
1998-09-24 08:18:58 +04:00
|
|
|
PushChildren(continuingFrame, kidFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// If the child isn't complete then it means that we've used up
|
|
|
|
// all of our available space.
|
1998-12-09 07:26:42 +03:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-04-17 02:21:32 +04:00
|
|
|
break;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-20 03:43:06 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-11-20 04:01:25 +03:00
|
|
|
/* CalculateRowHeights provides default heights for all rows in the rowgroup.
|
|
|
|
* Actual row heights are ultimately determined by the table, when the table
|
|
|
|
* height attribute is factored in.
|
|
|
|
*/
|
|
|
|
void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState)
|
1998-06-30 06:11:07 +04:00
|
|
|
{
|
1998-11-20 04:01:25 +03:00
|
|
|
if (gsDebug) printf("TRGF CalculateRowHeights begin\n");
|
1998-07-07 07:48:21 +04:00
|
|
|
// iterate children and for each row get its height
|
1998-06-30 06:11:07 +04:00
|
|
|
PRBool atLeastOneRowSpanningCell = PR_FALSE;
|
|
|
|
PRInt32 numRows;
|
1998-09-16 00:36:42 +04:00
|
|
|
GetRowCount(numRows);
|
1998-06-30 06:11:07 +04:00
|
|
|
PRInt32 *rowHeights = new PRInt32[numRows];
|
|
|
|
nsCRT::memset (rowHeights, 0, numRows*sizeof(PRInt32));
|
|
|
|
|
1998-07-07 07:48:21 +04:00
|
|
|
/* Step 1: get the height of the tallest cell in the row and save it for
|
|
|
|
* pass 2
|
1998-06-30 06:11:07 +04:00
|
|
|
*/
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* rowFrame = mFrames.FirstChild();
|
1998-09-16 00:36:42 +04:00
|
|
|
PRInt32 rowIndex = 0;
|
1998-06-30 06:11:07 +04:00
|
|
|
while (nsnull != rowFrame)
|
|
|
|
{
|
1998-09-16 00:36:42 +04:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1999-02-04 02:54:32 +03:00
|
|
|
if ((NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay) &&
|
|
|
|
(NS_STYLE_VISIBILITY_COLLAPSE != childDisplay->mVisible))
|
1998-09-16 00:36:42 +04:00
|
|
|
{
|
|
|
|
// get the height of the tallest cell in the row (excluding cells that span rows)
|
|
|
|
nscoord maxCellHeight = ((nsTableRowFrame*)rowFrame)->GetTallestChild();
|
|
|
|
nscoord maxCellTopMargin = ((nsTableRowFrame*)rowFrame)->GetChildMaxTopMargin();
|
|
|
|
nscoord maxCellBottomMargin = ((nsTableRowFrame*)rowFrame)->GetChildMaxBottomMargin();
|
|
|
|
nscoord maxRowHeight = maxCellHeight + maxCellTopMargin + maxCellBottomMargin;
|
1998-11-24 22:41:33 +03:00
|
|
|
if (gsDebug) printf("TRGF CalcRowH: for row %d(%p), maxCellH=%d, maxCTopMargin=%d, maxCBM=%d\n",
|
|
|
|
rowIndex, rowFrame, maxCellHeight, maxCellTopMargin, maxCellBottomMargin);
|
|
|
|
if (gsDebug) printf(" rowHeight=%d\n", maxRowHeight);
|
1998-09-16 00:36:42 +04:00
|
|
|
|
|
|
|
// save the row height for pass 2 below
|
|
|
|
rowHeights[rowIndex] = maxRowHeight;
|
|
|
|
// Update top and bottom inner margin if applicable
|
|
|
|
rowIndex++;
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
|
|
|
// Get the next row
|
1998-09-16 00:36:42 +04:00
|
|
|
rowFrame->GetNextSibling(rowFrame);
|
1999-02-04 02:54:32 +03:00
|
|
|
}
|
1998-06-30 06:11:07 +04:00
|
|
|
|
1998-11-02 21:32:14 +03:00
|
|
|
/* Step 2: Now account for cells that span rows.
|
|
|
|
* A spanning cell's height is the sum of the heights of the rows it spans,
|
1998-06-30 06:11:07 +04:00
|
|
|
* or it's own desired height, whichever is greater.
|
|
|
|
* If the cell's desired height is the larger value, resize the rows and contained
|
|
|
|
* cells by an equal percentage of the additional space.
|
1998-11-02 21:32:14 +03:00
|
|
|
* We go through this loop twice. The first time, we are adjusting cell heights
|
|
|
|
* and row y-offsets on the fly.
|
|
|
|
* The second time through the loop, we're ensuring that subsequent row-spanning cells
|
|
|
|
* didn't change prior calculations.
|
|
|
|
* Since we are guaranteed to have found the max height spanners the first time through,
|
|
|
|
* we know we only need two passes, not an arbitrary number.
|
1998-06-30 06:11:07 +04:00
|
|
|
*/
|
|
|
|
/* TODO
|
|
|
|
* 1. optimization, if (PR_TRUE==atLeastOneRowSpanningCell) ... otherwise skip this step entirely
|
1998-11-24 22:41:33 +03:00
|
|
|
* we can get this info trivially from the cell map
|
1998-06-30 06:11:07 +04:00
|
|
|
*/
|
1998-11-24 22:41:33 +03:00
|
|
|
nsTableFrame *tableFrame=nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv) || nsnull==tableFrame)
|
|
|
|
return;
|
1998-11-02 21:32:14 +03:00
|
|
|
PRInt32 rowGroupHeight;
|
1998-11-06 00:42:46 +03:00
|
|
|
for (PRInt32 counter=0; counter<2; counter++)
|
1998-06-30 06:11:07 +04:00
|
|
|
{
|
1998-11-02 21:32:14 +03:00
|
|
|
rowGroupHeight = 0;
|
1999-01-16 01:52:05 +03:00
|
|
|
rowFrame = mFrames.FirstChild();
|
1998-11-02 21:32:14 +03:00
|
|
|
rowIndex = 0;
|
|
|
|
while (nsnull != rowFrame)
|
1998-06-30 06:11:07 +04:00
|
|
|
{
|
1998-11-02 21:32:14 +03:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-11-02 21:32:14 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
1998-09-16 00:36:42 +04:00
|
|
|
{
|
1998-11-24 22:41:33 +03:00
|
|
|
if (gsDebug) printf("TRGF CalcRowH: Step 2 for row %d (%p)...\n", rowIndex, rowFrame);
|
1998-11-02 21:32:14 +03:00
|
|
|
// check this row for a cell with rowspans
|
|
|
|
nsIFrame *cellFrame;
|
1998-11-09 22:40:27 +03:00
|
|
|
rowFrame->FirstChild(nsnull, cellFrame);
|
1998-11-02 21:32:14 +03:00
|
|
|
while (nsnull != cellFrame)
|
1998-09-16 00:36:42 +04:00
|
|
|
{
|
1998-11-02 21:32:14 +03:00
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
cellFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-11-02 21:32:14 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == childDisplay->mDisplay)
|
|
|
|
{
|
1998-11-24 22:41:33 +03:00
|
|
|
if (gsDebug) printf("TRGF CalcRowH: for cell %p...\n", cellFrame);
|
1998-11-02 21:32:14 +03:00
|
|
|
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(rowIndex,(nsTableCellFrame*)cellFrame);
|
|
|
|
if (rowSpan > 1)
|
|
|
|
{ // found a cell with rowspan > 1, determine its height
|
1998-11-24 22:41:33 +03:00
|
|
|
if (gsDebug) printf("TRGF CalcRowH: cell %p has rowspan=%d\n", cellFrame, rowSpan);
|
1998-11-02 21:32:14 +03:00
|
|
|
nscoord heightOfRowsSpanned = 0;
|
|
|
|
PRInt32 i;
|
|
|
|
for ( i = 0; i < rowSpan; i++)
|
|
|
|
heightOfRowsSpanned += rowHeights[rowIndex + i];
|
1998-11-24 22:41:33 +03:00
|
|
|
if (gsDebug) printf("TRGF CalcRowH: heightOfRowsSpanned=%d\n", heightOfRowsSpanned);
|
1998-06-30 06:11:07 +04:00
|
|
|
|
1998-11-02 21:32:14 +03:00
|
|
|
/* if the cell height fits in the rows, expand the spanning cell's height and slap it in */
|
|
|
|
nsSize cellFrameSize;
|
|
|
|
cellFrame->GetSize(cellFrameSize);
|
|
|
|
if (heightOfRowsSpanned > cellFrameSize.height)
|
|
|
|
{
|
1998-11-24 22:41:33 +03:00
|
|
|
if (gsDebug) printf("TRGF CalcRowH: spanning cell fits in rows spanned, had h=%d, expanded to %d\n",
|
1998-11-02 21:32:14 +03:00
|
|
|
cellFrameSize.height, heightOfRowsSpanned);
|
|
|
|
cellFrame->SizeTo(cellFrameSize.width, heightOfRowsSpanned);
|
|
|
|
// Realign cell content based on new height
|
1998-11-20 04:01:25 +03:00
|
|
|
((nsTableCellFrame*)cellFrame)->VerticallyAlignChild();
|
1998-11-02 21:32:14 +03:00
|
|
|
}
|
|
|
|
/* otherwise, distribute the excess height to the rows effected.
|
|
|
|
* push all subsequent rows down by the total change in height of all the rows above it
|
|
|
|
*/
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PRInt32 excessHeight = cellFrameSize.height - heightOfRowsSpanned;
|
1998-11-24 22:41:33 +03:00
|
|
|
if (gsDebug) printf("TRGF CalcRowH: excessHeight=%d\n", excessHeight);
|
1998-11-02 21:32:14 +03:00
|
|
|
// for every row starting at the row with the spanning cell...
|
|
|
|
nsTableRowFrame *rowFrameToBeResized = (nsTableRowFrame *)rowFrame;
|
1998-11-24 22:41:33 +03:00
|
|
|
PRInt32 *excessForRow = new PRInt32[numRows];
|
|
|
|
nsCRT::memset (excessForRow, 0, numRows*sizeof(PRInt32));
|
1998-11-02 21:32:14 +03:00
|
|
|
for (i = rowIndex; i < numRows; i++)
|
1998-09-16 00:36:42 +04:00
|
|
|
{
|
1998-11-24 22:41:33 +03:00
|
|
|
if (gsDebug) printf("TRGF CalcRowH: for row index=%d\n", i);
|
1998-11-02 21:32:14 +03:00
|
|
|
// if the row is within the spanned range, resize the row
|
|
|
|
if (i < (rowIndex + rowSpan))
|
|
|
|
{
|
1998-11-24 22:41:33 +03:00
|
|
|
float percent = ((float)rowHeights[i]) / ((float)heightOfRowsSpanned);
|
|
|
|
excessForRow[i] = NSToCoordRound(((float)(excessHeight)) * percent);
|
|
|
|
if (gsDebug) printf("TRGF CalcRowH: for row %d, excessHeight=%d from percent %f\n",
|
|
|
|
i, excessForRow[i], percent);
|
1998-11-02 21:32:14 +03:00
|
|
|
// update the row height
|
1998-11-24 22:41:33 +03:00
|
|
|
rowHeights[i] += excessForRow[i];
|
1998-11-02 21:32:14 +03:00
|
|
|
|
|
|
|
// adjust the height of the row
|
|
|
|
nsSize rowFrameSize;
|
|
|
|
rowFrameToBeResized->GetSize(rowFrameSize);
|
|
|
|
rowFrameToBeResized->SizeTo(rowFrameSize.width, rowHeights[i]);
|
1998-11-24 22:41:33 +03:00
|
|
|
if (gsDebug) printf("TRGF CalcRowH: row %d (%p) sized to %d\n",
|
|
|
|
i, rowFrameToBeResized, rowHeights[i]);
|
1998-11-02 21:32:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// if we're dealing with a row below the row containing the spanning cell,
|
|
|
|
// push that row down by the amount we've expanded the cell heights by
|
|
|
|
if ((i >= rowIndex) && (i != 0))
|
|
|
|
{
|
|
|
|
nsRect rowRect;
|
1998-06-30 06:11:07 +04:00
|
|
|
|
1998-11-02 21:32:14 +03:00
|
|
|
rowFrameToBeResized->GetRect(rowRect);
|
1998-11-24 22:41:33 +03:00
|
|
|
nscoord delta=0;
|
|
|
|
for (PRInt32 j=0; j<i; j++)
|
|
|
|
delta += excessForRow[j];
|
1998-11-02 21:32:14 +03:00
|
|
|
if (delta > excessHeight)
|
|
|
|
delta = excessHeight;
|
|
|
|
rowFrameToBeResized->MoveTo(rowRect.x, rowRect.y + delta);
|
1998-11-24 22:41:33 +03:00
|
|
|
if (gsDebug) printf("TRGF CalcRowH: row %d (%p) moved to %d after delta %d\n",
|
|
|
|
i, rowFrameToBeResized, rowRect.y + delta, delta);
|
1998-11-02 21:32:14 +03:00
|
|
|
}
|
|
|
|
// Get the next row frame
|
|
|
|
rowFrameToBeResized->GetNextSibling((nsIFrame*&)rowFrameToBeResized);
|
1998-09-16 00:36:42 +04:00
|
|
|
}
|
1998-11-24 22:41:33 +03:00
|
|
|
delete []excessForRow;
|
1998-09-16 00:36:42 +04:00
|
|
|
}
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
|
|
|
}
|
1998-11-02 21:32:14 +03:00
|
|
|
// Get the next row child (cell frame)
|
|
|
|
cellFrame->GetNextSibling(cellFrame);
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
1998-11-02 21:32:14 +03:00
|
|
|
// Update the running row group height
|
|
|
|
rowGroupHeight += rowHeights[rowIndex];
|
|
|
|
rowIndex++;
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
1998-11-02 21:32:14 +03:00
|
|
|
// Get the next rowgroup child (row frame)
|
|
|
|
rowFrame->GetNextSibling(rowFrame);
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-24 22:41:33 +03:00
|
|
|
/* step 3: finally, notify the rows of their new heights */
|
1999-01-16 01:52:05 +03:00
|
|
|
rowFrame = mFrames.FirstChild();
|
1998-11-20 04:01:25 +03:00
|
|
|
while (nsnull != rowFrame)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-11-20 04:01:25 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
|
|
|
|
}
|
|
|
|
// Get the next row
|
|
|
|
rowFrame->GetNextSibling(rowFrame);
|
|
|
|
}
|
|
|
|
|
1998-06-30 06:11:07 +04:00
|
|
|
// Adjust our desired size
|
|
|
|
aDesiredSize.height = rowGroupHeight;
|
|
|
|
|
|
|
|
// cleanup
|
|
|
|
delete []rowHeights;
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
nsresult nsTableRowGroupFrame::AdjustSiblingsAfterReflow(nsIPresContext& aPresContext,
|
1998-10-20 03:43:06 +04:00
|
|
|
RowGroupReflowState& aReflowState,
|
1998-07-03 03:19:31 +04:00
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nscoord aDeltaY)
|
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: AdjustSiblingsAfterReflow\n");
|
1998-07-03 03:19:31 +04:00
|
|
|
nsIFrame* lastKidFrame = aKidFrame;
|
|
|
|
|
|
|
|
if (aDeltaY != 0) {
|
|
|
|
// Move the frames that follow aKidFrame by aDeltaY
|
|
|
|
nsIFrame* kidFrame;
|
|
|
|
|
|
|
|
aKidFrame->GetNextSibling(kidFrame);
|
|
|
|
while (nsnull != kidFrame) {
|
|
|
|
nsPoint origin;
|
|
|
|
|
|
|
|
// XXX We can't just slide the child if it has a next-in-flow
|
|
|
|
kidFrame->GetOrigin(origin);
|
|
|
|
origin.y += aDeltaY;
|
|
|
|
|
|
|
|
// XXX We need to send move notifications to the frame...
|
1998-10-01 08:46:11 +04:00
|
|
|
nsIHTMLReflow* htmlReflow;
|
|
|
|
if (NS_OK == kidFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
1998-10-14 20:32:45 +04:00
|
|
|
htmlReflow->WillReflow(aPresContext);
|
1998-10-01 08:46:11 +04:00
|
|
|
}
|
1998-07-03 03:19:31 +04:00
|
|
|
kidFrame->MoveTo(origin.x, origin.y);
|
|
|
|
|
|
|
|
// Get the next frame
|
|
|
|
lastKidFrame = kidFrame;
|
|
|
|
kidFrame->GetNextSibling(kidFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// Get the last frame
|
1999-01-16 01:52:05 +03:00
|
|
|
lastKidFrame = mFrames.LastChild();
|
1998-07-03 03:19:31 +04:00
|
|
|
}
|
|
|
|
|
1998-07-07 04:49:07 +04:00
|
|
|
// XXX Deal with cells that have rowspans.
|
|
|
|
|
1998-07-03 03:19:31 +04:00
|
|
|
// Update our running y-offset to reflect the bottommost child
|
|
|
|
nsRect rect;
|
|
|
|
lastKidFrame->GetRect(rect);
|
1998-10-20 03:43:06 +04:00
|
|
|
aReflowState.y = rect.YMost();
|
1998-07-03 03:19:31 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
|
1998-12-14 04:24:11 +03:00
|
|
|
nsresult
|
|
|
|
nsTableRowGroupFrame::SplitRowGroup(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsIFrame* prevKidFrame = nsnull;
|
1998-12-15 19:39:09 +03:00
|
|
|
nsresult rv = NS_OK;
|
1998-12-14 04:24:11 +03:00
|
|
|
|
|
|
|
// Walk each of the row frames looking for the first row frame that
|
|
|
|
// doesn't fit in the available space
|
1999-01-16 01:52:05 +03:00
|
|
|
for (nsIFrame* kidFrame = mFrames.FirstChild(); nsnull != kidFrame; kidFrame->GetNextSibling(kidFrame)) {
|
1998-12-14 04:24:11 +03:00
|
|
|
nsRect bounds;
|
|
|
|
|
|
|
|
kidFrame->GetRect(bounds);
|
1998-12-15 19:39:09 +03:00
|
|
|
// XXX This check isn't correct if there's a footer...
|
1999-01-06 02:31:18 +03:00
|
|
|
if (bounds.YMost() > aReflowState.availableHeight) {
|
1998-12-14 04:24:11 +03:00
|
|
|
// If this is the first row frame then we need to split it
|
|
|
|
if (nsnull == prevKidFrame) {
|
|
|
|
// Reflow the row in the available space and have it split
|
1999-01-06 02:31:18 +03:00
|
|
|
nsSize kidAvailSize(aReflowState.availableWidth,
|
|
|
|
aReflowState.availableHeight - bounds.y);
|
1998-12-15 19:39:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState,
|
|
|
|
kidAvailSize, eReflowReason_Resize);
|
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
1998-12-14 04:24:11 +03:00
|
|
|
|
|
|
|
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
|
|
|
kidFrame->SizeTo(desiredSize.width, desiredSize.height);
|
1998-12-15 19:39:09 +03:00
|
|
|
((nsTableRowFrame *)kidFrame)->DidResize(aPresContext, aReflowState);
|
|
|
|
aDesiredSize.height = desiredSize.height;
|
1998-12-14 04:24:11 +03:00
|
|
|
|
1998-12-16 00:26:05 +03:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
|
|
|
// Create a continuing frame, add it to the child list, and then push it
|
|
|
|
// and the frames that follow
|
|
|
|
// XXX Check whether it already has a next-in-flow
|
|
|
|
nsIFrame* continuingFrame;
|
|
|
|
nsIStyleContext* kidSC;
|
|
|
|
|
1999-02-10 03:42:56 +03:00
|
|
|
kidFrame->GetStyleContext(&kidSC);
|
1998-12-16 00:26:05 +03:00
|
|
|
kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame);
|
|
|
|
NS_RELEASE(kidSC);
|
|
|
|
|
|
|
|
// Add it to the child list
|
|
|
|
nsIFrame* nextSibling;
|
|
|
|
|
|
|
|
kidFrame->GetNextSibling(nextSibling);
|
|
|
|
continuingFrame->SetNextSibling(nextSibling);
|
|
|
|
kidFrame->SetNextSibling(continuingFrame);
|
|
|
|
|
|
|
|
// Push it and the frames that follow
|
|
|
|
PushChildren(continuingFrame, kidFrame);
|
|
|
|
}
|
|
|
|
|
1998-12-14 04:24:11 +03:00
|
|
|
} else {
|
|
|
|
// See whether the row frame has cells that span into it or across it
|
|
|
|
PushChildren(kidFrame, prevKidFrame);
|
|
|
|
aDesiredSize.height = bounds.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
prevKidFrame = kidFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/** Layout the entire row group.
|
|
|
|
* This method stacks rows vertically according to HTML 4.0 rules.
|
|
|
|
* Rows are responsible for layout of their children.
|
|
|
|
*/
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD
|
1998-10-02 08:10:00 +04:00
|
|
|
nsTableRowGroupFrame::Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-10-14 20:32:45 +04:00
|
|
|
nsresult rv=NS_OK;
|
1998-07-11 04:00:31 +04:00
|
|
|
if (gsDebug==PR_TRUE)
|
1998-05-25 21:31:49 +04:00
|
|
|
printf("nsTableRowGroupFrame::Reflow - aMaxSize = %d, %d\n",
|
1999-01-06 02:31:18 +03:00
|
|
|
aReflowState.availableWidth, aReflowState.availableHeight);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-07-03 03:19:31 +04:00
|
|
|
// Initialize out parameter
|
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
|
|
|
}
|
|
|
|
|
1998-11-04 23:09:19 +03:00
|
|
|
nsTableFrame *tableFrame=nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
else if (tableFrame == nsnull)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
RowGroupReflowState state(aPresContext, aReflowState, tableFrame);
|
1998-07-03 03:19:31 +04:00
|
|
|
|
1998-06-23 09:43:27 +04:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
1998-11-04 23:09:19 +03:00
|
|
|
rv = IncrementalReflow(aPresContext, aDesiredSize, state, aStatus);
|
1998-06-23 09:43:27 +04:00
|
|
|
} else {
|
|
|
|
PRBool reflowMappedOK = PR_TRUE;
|
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
|
|
|
// Check for an overflow list
|
|
|
|
MoveOverflowToChildList();
|
|
|
|
|
|
|
|
// Reflow the existing frames
|
1999-01-16 01:52:05 +03:00
|
|
|
if (nsnull != mFrames.FirstChild()) {
|
1998-10-20 03:43:06 +04:00
|
|
|
rv = ReflowMappedChildren(aPresContext, aDesiredSize, state, aStatus,
|
|
|
|
nsnull, aReflowState.reason, PR_TRUE);
|
1998-06-23 09:43:27 +04:00
|
|
|
}
|
|
|
|
|
1998-12-14 04:24:11 +03:00
|
|
|
// XXX We need to figure out what to do about this...
|
|
|
|
#if 0
|
1999-01-18 02:35:56 +03:00
|
|
|
// XXX if this code is activated then fix PullUpChildren to not case nsRowGroupFrame, it might be an nsScrollFrame
|
1998-06-23 09:43:27 +04:00
|
|
|
// Did we successfully reflow our mapped children?
|
1998-10-20 03:43:06 +04:00
|
|
|
if (NS_FRAME_COMPLETE==aStatus) {
|
1998-12-09 07:26:42 +03:00
|
|
|
// Try and pull-up some children from a next-in-flow
|
|
|
|
rv = PullUpChildren(aPresContext, aDesiredSize, state, aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-12-14 04:24:11 +03:00
|
|
|
#endif
|
1998-06-23 09:43:27 +04:00
|
|
|
|
|
|
|
// Return our desired rect
|
1999-01-06 02:31:18 +03:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
1998-06-30 06:11:07 +04:00
|
|
|
aDesiredSize.height = state.y;
|
|
|
|
|
1999-01-18 02:35:56 +03:00
|
|
|
// account for scroll bars. XXX needs optimization/caching
|
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
nsIAtom* pseudoTag;
|
|
|
|
|
|
|
|
mStyleContext->GetPseudoType(pseudoTag);
|
|
|
|
if (pseudoTag == nsHTMLAtoms::scrolledContentPseudo) {
|
|
|
|
nsIFrame* scrollFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
GetParent(&scrollFrame);
|
1999-01-18 02:35:56 +03:00
|
|
|
const nsStyleDisplay *display;
|
|
|
|
scrollFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
|
|
|
if ((NS_STYLE_OVERFLOW_SCROLL == display->mOverflow) ||
|
|
|
|
(NS_STYLE_OVERFLOW_AUTO == display->mOverflow)) {
|
|
|
|
float sbWidth, sbHeight;
|
|
|
|
nsIDeviceContext* dc = aPresContext.GetDeviceContext();
|
|
|
|
|
|
|
|
dc->GetScrollBarDimensions(sbWidth, sbHeight);
|
|
|
|
NS_RELEASE(dc);
|
|
|
|
aDesiredSize.maxElementSize->width += NSToCoordRound(sbWidth);
|
|
|
|
// If scrollbars are always visible then add in the hor sb height
|
|
|
|
if (NS_STYLE_OVERFLOW_SCROLL == display->mOverflow) {
|
|
|
|
aDesiredSize.maxElementSize->height += NSToCoordRound(sbHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(pseudoTag);
|
|
|
|
}
|
|
|
|
|
1998-06-30 06:11:07 +04:00
|
|
|
// shrink wrap rows to height of tallest cell in that row
|
1998-11-20 04:01:25 +03:00
|
|
|
if (eReflowReason_Initial != aReflowState.reason) {
|
|
|
|
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState);
|
|
|
|
}
|
1998-12-14 04:24:11 +03:00
|
|
|
|
|
|
|
// See if all the frames fit
|
1999-01-06 02:31:18 +03:00
|
|
|
if (aDesiredSize.height > aReflowState.availableHeight) {
|
1998-12-14 04:24:11 +03:00
|
|
|
// Nope, find a place to split the row group
|
|
|
|
SplitRowGroup(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-04 02:54:32 +03:00
|
|
|
// check the visibility in the final pass. If it is collapse, set our desired size to 0
|
|
|
|
if (nsTableFrame::IsFinalPass(aReflowState)) {
|
|
|
|
const nsStyleDisplay *display;
|
|
|
|
GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
|
|
|
if (NS_STYLE_VISIBILITY_COLLAPSE == display->mVisible) {
|
|
|
|
aDesiredSize.width = 0;
|
|
|
|
aDesiredSize.height = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
if (gsDebug==PR_TRUE)
|
1998-04-15 01:45:28 +04:00
|
|
|
{
|
1998-05-25 21:31:49 +04:00
|
|
|
if (nsnull!=aDesiredSize.maxElementSize)
|
1998-08-07 06:11:51 +04:00
|
|
|
printf("nsTableRowGroupFrame %p returning: %s with aDesiredSize=%d,%d, aMES=%d,%d\n",
|
|
|
|
this, NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
|
1998-04-15 01:45:28 +04:00
|
|
|
aDesiredSize.width, aDesiredSize.height,
|
1998-05-25 21:31:49 +04:00
|
|
|
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
|
1998-04-15 01:45:28 +04:00
|
|
|
else
|
1998-08-07 06:11:51 +04:00
|
|
|
printf("nsTableRowGroupFrame %p returning: %s with aDesiredSize=%d,%d, aMES=NSNULL\n",
|
|
|
|
this, NS_FRAME_IS_COMPLETE(aStatus)?"Complete":"Not Complete",
|
1998-04-15 01:45:28 +04:00
|
|
|
aDesiredSize.width, aDesiredSize.height);
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_METHOD nsTableRowGroupFrame::IncrementalReflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-11-04 23:09:19 +03:00
|
|
|
RowGroupReflowState& aReflowState,
|
1998-10-14 20:32:45 +04:00
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IncrementalReflow\n");
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// determine if this frame is the target or not
|
|
|
|
nsIFrame *target=nsnull;
|
1998-11-04 23:09:19 +03:00
|
|
|
rv = aReflowState.reflowState.reflowCommand->GetTarget(target);
|
1998-10-14 20:32:45 +04:00
|
|
|
if ((PR_TRUE==NS_SUCCEEDED(rv)) && (nsnull!=target))
|
|
|
|
{
|
|
|
|
if (this==target)
|
1998-11-04 23:09:19 +03:00
|
|
|
rv = IR_TargetIsMe(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-14 20:32:45 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Get the next frame in the reflow chain
|
|
|
|
nsIFrame* nextFrame;
|
1998-11-04 23:09:19 +03:00
|
|
|
aReflowState.reflowState.reflowCommand->GetNext(nextFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
|
|
|
// Recover our reflow state
|
|
|
|
//RecoverState(state, nextFrame);
|
1998-11-04 23:09:19 +03:00
|
|
|
rv = IR_TargetIsChild(aPresContext, aDesiredSize, aReflowState, aStatus, nextFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_FRAME_COMPLETE;
|
|
|
|
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-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("TRGF IR: TargetIsMe with type=%d\n", type);
|
1998-10-14 20:32:45 +04:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case nsIReflowCommand::FrameInserted :
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_ASSERTION(nsnull!=objectFrame, "bad objectFrame");
|
|
|
|
NS_ASSERTION(nsnull!=childDisplay, "bad childDisplay");
|
1998-10-14 20:32:45 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
rv = IR_RowInserted(aPresContext, aDesiredSize, aReflowState, aStatus,
|
1998-10-20 03:43:06 +04:00
|
|
|
(nsTableRowFrame *)objectFrame, PR_FALSE);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-10-20 21:45:07 +04:00
|
|
|
rv = AddFrame(aReflowState.reflowState, objectFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::FrameAppended :
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_ASSERTION(nsnull!=objectFrame, "bad objectFrame");
|
|
|
|
NS_ASSERTION(nsnull!=childDisplay, "bad childDisplay");
|
1998-10-14 20:32:45 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
rv = IR_RowAppended(aPresContext, aDesiredSize, aReflowState, aStatus,
|
|
|
|
(nsTableRowFrame *)objectFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // no optimization to be done for Unknown frame types, so just reuse the Inserted method
|
1998-10-20 21:45:07 +04:00
|
|
|
rv = AddFrame(aReflowState.reflowState, objectFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
case nsIReflowCommand::FrameReplaced :
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
case nsIReflowCommand::FrameRemoved :
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_ASSERTION(nsnull!=objectFrame, "bad objectFrame");
|
|
|
|
NS_ASSERTION(nsnull!=childDisplay, "bad childDisplay");
|
1998-10-14 20:32:45 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
rv = IR_RowRemoved(aPresContext, aDesiredSize, aReflowState, aStatus,
|
1998-10-20 03:43:06 +04:00
|
|
|
(nsTableRowFrame *)objectFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-02-04 19:27:18 +03:00
|
|
|
rv = RemoveAFrame(objectFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::StyleChanged :
|
1998-10-30 10:57:44 +03:00
|
|
|
rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-14 20:32:45 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::ContentChanged :
|
|
|
|
NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::PullupReflow:
|
|
|
|
case nsIReflowCommand::PushReflow:
|
|
|
|
case nsIReflowCommand::CheckPullupReflow :
|
|
|
|
case nsIReflowCommand::UserDefined :
|
|
|
|
NS_NOTYETIMPLEMENTED("unimplemented reflow command type");
|
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("TRGF IR: reflow command not implemented.\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsTableRowGroupFrame::IR_RowInserted(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-20 03:43:06 +04:00
|
|
|
nsTableRowFrame * aInsertedFrame,
|
1998-10-14 20:32:45 +04:00
|
|
|
PRBool aReplace)
|
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_RowInserted\n");
|
1998-10-20 21:45:07 +04:00
|
|
|
nsresult rv = AddFrame(aReflowState.reflowState, (nsIFrame*)aInsertedFrame);
|
1998-10-20 03:43:06 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
1998-11-04 23:09:19 +03:00
|
|
|
if (PR_TRUE==aReflowState.tableFrame->RequiresPass1Layout())
|
1998-10-21 00:05:44 +04:00
|
|
|
{
|
|
|
|
// do a pass-1 layout of all the cells in the inserted row
|
|
|
|
//XXX: check the table frame to see if we can skip this
|
|
|
|
rv = ReflowMappedChildren(aPresContext, aDesiredSize, aReflowState, aStatus,
|
|
|
|
aInsertedFrame, eReflowReason_Initial, PR_FALSE);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-11-04 23:09:19 +03:00
|
|
|
aReflowState.tableFrame->InvalidateCellMap();
|
|
|
|
aReflowState.tableFrame->InvalidateColumnCache();
|
1998-10-20 03:43:06 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-20 03:43:06 +04:00
|
|
|
NS_METHOD nsTableRowGroupFrame::DidAppendRow(nsTableRowFrame *aRowFrame)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: DidAppendRow\n");
|
1998-10-14 20:32:45 +04:00
|
|
|
nsresult rv=NS_OK;
|
|
|
|
/* need to make space in the cell map. Remeber that row spans can't cross row groups
|
|
|
|
once the space is made, tell the row to initizalize its children.
|
|
|
|
it will automatically find the row to initialize into.
|
|
|
|
but this is tough because a cell in aInsertedFrame could have a rowspan
|
|
|
|
which must be respected if a subsequent row is appended.
|
|
|
|
*/
|
|
|
|
rv = aRowFrame->InitChildren();
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-20 03:43:06 +04:00
|
|
|
// support method that tells us if there are any rows in the table after our rows
|
|
|
|
// returns PR_TRUE if there are no rows after ours
|
|
|
|
PRBool nsTableRowGroupFrame::NoRowsFollow()
|
|
|
|
{
|
|
|
|
PRBool result = PR_TRUE;
|
|
|
|
nsIFrame *nextSib=nsnull;
|
|
|
|
GetNextSibling(nextSib);
|
|
|
|
while (nsnull!=nextSib)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *sibDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
nextSib->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)sibDisplay));
|
1998-10-20 03:43:06 +04:00
|
|
|
if ((NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == sibDisplay->mDisplay) ||
|
|
|
|
(NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == sibDisplay->mDisplay) ||
|
|
|
|
(NS_STYLE_DISPLAY_TABLE_ROW_GROUP == sibDisplay->mDisplay))
|
|
|
|
{
|
|
|
|
nsIFrame *childFrame=nsnull;
|
1998-11-09 22:40:27 +03:00
|
|
|
nextSib->FirstChild(nsnull, childFrame);
|
1998-10-20 03:43:06 +04:00
|
|
|
while (nsnull!=childFrame)
|
|
|
|
{
|
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-10-20 03:43:06 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
|
|
|
{ // found a row
|
|
|
|
result = PR_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nextSib->GetNextSibling(nextSib);
|
|
|
|
}
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: NoRowsFollow returning %d\n", result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
// since we know we're doing an append here, we can optimize
|
|
|
|
NS_METHOD nsTableRowGroupFrame::IR_RowAppended(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-20 03:43:06 +04:00
|
|
|
nsTableRowFrame * aAppendedFrame)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_RowAppended\n");
|
1998-10-14 20:32:45 +04:00
|
|
|
// hook aAppendedFrame into the child list
|
1998-10-20 21:45:07 +04:00
|
|
|
nsresult rv = AddFrame(aReflowState.reflowState, (nsIFrame*)aAppendedFrame);
|
1998-10-20 03:43:06 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
/* we have 2 paths to choose from. If we know that aAppendedFrame is
|
|
|
|
* the last row in the table, we can optimize. Otherwise, we have to
|
|
|
|
* treat it like an insert
|
|
|
|
*/
|
|
|
|
if (PR_TRUE==NoRowsFollow())
|
|
|
|
{ // aAppendedRow is the last row, so do the optimized route
|
|
|
|
// account for the cells in the row aAppendedFrame
|
|
|
|
// this will add the content of the rowgroup to the cell map
|
|
|
|
rv = DidAppendRow(aAppendedFrame);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
1998-11-04 23:09:19 +03:00
|
|
|
if (PR_TRUE==aReflowState.tableFrame->RequiresPass1Layout())
|
1998-10-21 00:05:44 +04:00
|
|
|
{
|
|
|
|
// do a pass1 reflow of the new row
|
|
|
|
//XXX: check the table frame to see if we can skip this
|
|
|
|
rv = ReflowMappedChildren(aPresContext, aDesiredSize, aReflowState, aStatus,
|
|
|
|
aAppendedFrame, eReflowReason_Initial, PR_FALSE);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if any column widths have to change due to this, rebalance column widths
|
|
|
|
//XXX need to calculate this, but for now just do it
|
1998-11-04 23:09:19 +03:00
|
|
|
aReflowState.tableFrame->InvalidateColumnWidths();
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
// do a pass1 reflow of the new row
|
|
|
|
//XXX: check the table frame to see if we can skip this
|
|
|
|
rv = ReflowMappedChildren(aPresContext, aDesiredSize, aReflowState, aStatus,
|
|
|
|
aAppendedFrame, eReflowReason_Initial, PR_FALSE);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
1998-11-04 23:09:19 +03:00
|
|
|
aReflowState.tableFrame->InvalidateCellMap();
|
|
|
|
aReflowState.tableFrame->InvalidateColumnCache();
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsTableRowGroupFrame::IR_RowRemoved(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-20 03:43:06 +04:00
|
|
|
nsTableRowFrame * aDeletedFrame)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_RowRemoved\n");
|
1999-02-04 19:27:18 +03:00
|
|
|
nsresult rv = RemoveAFrame((nsIFrame *)aDeletedFrame);
|
1998-10-20 03:43:06 +04:00
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
{
|
1998-11-04 23:09:19 +03:00
|
|
|
aReflowState.tableFrame->InvalidateCellMap();
|
|
|
|
aReflowState.tableFrame->InvalidateColumnCache();
|
1998-10-20 03:43:06 +04:00
|
|
|
|
|
|
|
// if any column widths have to change due to this, rebalance column widths
|
|
|
|
//XXX need to calculate this, but for now just do it
|
1998-11-04 23:09:19 +03:00
|
|
|
aReflowState.tableFrame->InvalidateColumnWidths();
|
1998-10-20 03:43:06 +04:00
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsTableRowGroupFrame::IR_TargetIsChild(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame * aNextFrame)
|
|
|
|
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_TargetIsChild\n");
|
|
|
|
// XXX Recover state
|
|
|
|
|
|
|
|
// Remember the old rect
|
|
|
|
nsRect oldKidRect;
|
|
|
|
aNextFrame->GetRect(oldKidRect);
|
|
|
|
|
|
|
|
// Pass along the reflow command
|
|
|
|
// XXX Correctly compute the available space...
|
1999-01-06 02:31:18 +03:00
|
|
|
nsSize availSpace(aReflowState.reflowState.availableWidth, aReflowState.reflowState.availableHeight);
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aNextFrame, aReflowState.reflowState, availSpace);
|
1998-10-14 20:32:45 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
|
|
|
|
|
|
|
rv = ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState, aStatus);
|
|
|
|
|
|
|
|
// Resize the row frame
|
|
|
|
nsRect kidRect;
|
|
|
|
aNextFrame->GetRect(kidRect);
|
|
|
|
aNextFrame->SizeTo(desiredSize.width, desiredSize.height);
|
|
|
|
|
|
|
|
// Adjust the frames that follow...
|
|
|
|
AdjustSiblingsAfterReflow(aPresContext, aReflowState, aNextFrame, desiredSize.height -
|
|
|
|
oldKidRect.height);
|
|
|
|
|
|
|
|
// Return of desired size
|
1999-01-06 02:31:18 +03:00
|
|
|
aDesiredSize.width = aReflowState.reflowState.availableWidth;
|
1998-10-14 20:32:45 +04:00
|
|
|
aDesiredSize.height = aReflowState.y;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_METHOD nsTableRowGroupFrame::IR_StyleChanged(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("TRGF: IR_StyleChanged for frame %p\n", this);
|
|
|
|
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
|
1998-11-04 23:09:19 +03:00
|
|
|
aReflowState.tableFrame->InvalidateFirstPassCache();
|
1998-10-30 10:57:44 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-01-18 02:35:56 +03:00
|
|
|
// XXX this doesn't handle scrolling, it that is even possible in this context
|
1998-05-07 04:08:20 +04:00
|
|
|
NS_METHOD
|
1998-07-15 07:23:23 +04:00
|
|
|
nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext& aPresContext,
|
1998-05-07 04:08:20 +04:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aStyleContext,
|
|
|
|
nsIFrame*& aContinuingFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-12-03 09:31:43 +03:00
|
|
|
nsTableRowGroupFrame* cf = new nsTableRowGroupFrame;
|
1998-05-07 04:08:20 +04:00
|
|
|
if (nsnull == cf) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-01-14 08:16:23 +03:00
|
|
|
cf->Init(aPresContext, mContent, aParent, aStyleContext);
|
1998-12-03 09:31:43 +03:00
|
|
|
cf->AppendToFlow(this);
|
1998-07-11 04:00:31 +04:00
|
|
|
if (PR_TRUE==gsDebug) printf("nsTableRowGroupFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf);
|
1998-04-17 05:41:24 +04:00
|
|
|
aContinuingFrame = cf;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
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
|
1998-12-03 09:31:43 +03:00
|
|
|
NS_NewTableRowGroupFrame(nsIFrame*& aResult)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-12-03 09:31:43 +03:00
|
|
|
nsIFrame* it = new nsTableRowGroupFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1998-09-15 21:58:24 +04:00
|
|
|
aResult = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetFrameName(nsString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName("TableRowGroup", aResult);
|
|
|
|
}
|
1998-11-20 04:01:25 +03:00
|
|
|
|