1998-04-13 20:24:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:40:37 +00: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-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-13 20:24:54 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:40:37 +00:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-04-13 20:24:54 +00:00
|
|
|
*/
|
1999-02-12 17:45:58 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsTableRowGroupFrame.h"
|
|
|
|
#include "nsTableRowFrame.h"
|
1998-11-11 19:56:02 +00:00
|
|
|
#include "nsTableFrame.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsTableCellFrame.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIContent.h"
|
1998-04-14 21:49:29 +00:00
|
|
|
#include "nsIView.h"
|
1998-06-23 05:43:27 +00:00
|
|
|
#include "nsIReflowCommand.h"
|
1998-10-01 04:46:11 +00:00
|
|
|
#include "nsHTMLIIDs.h"
|
1999-01-17 23:35:56 +00:00
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
1999-02-24 04:03:50 +00:00
|
|
|
#include "nsIStyleSet.h"
|
|
|
|
#include "nsIPresShell.h"
|
1999-02-24 05:54:31 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-06-07 21:10:25 +00:00
|
|
|
#include "nsCSSRendering.h"
|
1999-08-01 22:01:37 +00:00
|
|
|
#include "nsHTMLParts.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2000-05-11 01:04:39 +00:00
|
|
|
#include "nsCellMap.h"//table cell navigation
|
|
|
|
|
2001-01-25 15:55:51 +00:00
|
|
|
nsTableRowGroupFrame::nsTableRowGroupFrame()
|
|
|
|
{
|
2001-04-09 14:21:24 +00:00
|
|
|
SetRepeatable(PR_FALSE);
|
2001-01-25 15:55:51 +00:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
mTimer = new nsReflowTimer(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableRowGroupFrame::~nsTableRowGroupFrame()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflowDone(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
/* ----------- nsTableRowGroupFrame ---------- */
|
2000-05-14 00:10:25 +00:00
|
|
|
nsrefcnt nsTableRowGroupFrame::AddRef(void)
|
|
|
|
{
|
|
|
|
return 1;//implementation of nsLineIterator
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsTableRowGroupFrame::Release(void)
|
|
|
|
{
|
|
|
|
return 1;//implementation of nsLineIterator
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-01-30 15:52:19 +00: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;
|
2000-05-11 01:04:39 +00:00
|
|
|
}
|
2000-05-16 08:11:14 +00:00
|
|
|
else if (aIID.Equals(NS_GET_IID(nsILineIteratorNavigator)))
|
2000-05-11 01:04:39 +00:00
|
|
|
{ // note there is no addref here, frames are not addref'd
|
2000-05-16 08:11:14 +00:00
|
|
|
*aInstancePtr = (void*)(nsILineIteratorNavigator*)this;
|
2000-05-11 01:04:39 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else {
|
1999-01-30 15:52:19 +00:00
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
PRInt32
|
|
|
|
nsTableRowGroupFrame::GetRowCount()
|
|
|
|
{
|
|
|
|
PRInt32 count = 0; // init return
|
1998-09-15 20:36:42 +00:00
|
|
|
|
|
|
|
// loop through children, adding one to aCount for every legit row
|
2001-03-13 06:38:59 +00:00
|
|
|
nsIFrame* childFrame = GetFirstFrame();
|
|
|
|
while (PR_TRUE) {
|
|
|
|
if (!childFrame)
|
1998-09-15 20:36:42 +00:00
|
|
|
break;
|
2001-03-13 06:38:59 +00:00
|
|
|
const nsStyleDisplay* childDisplay;
|
1998-12-02 16:45:20 +00:00
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-09-15 20:36:42 +00:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
2001-03-13 06:38:59 +00:00
|
|
|
count++;
|
1999-06-23 03:02:21 +00:00
|
|
|
GetNextFrame(childFrame, &childFrame);
|
1998-09-15 20:36:42 +00:00
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
return count;
|
1998-09-15 20:36:42 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-12-23 15:47:43 +00:00
|
|
|
PRInt32 nsTableRowGroupFrame::GetStartRowIndex()
|
|
|
|
{
|
|
|
|
PRInt32 result = -1;
|
2001-03-13 06:38:59 +00:00
|
|
|
nsIFrame* childFrame = GetFirstFrame();
|
|
|
|
while (PR_TRUE) {
|
|
|
|
if (!childFrame)
|
1998-12-23 15:47:43 +00:00
|
|
|
break;
|
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
2001-03-13 06:38:59 +00:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay) {
|
1998-12-23 15:47:43 +00:00
|
|
|
result = ((nsTableRowFrame *)childFrame)->GetRowIndex();
|
|
|
|
break;
|
|
|
|
}
|
1999-06-23 03:02:21 +00:00
|
|
|
GetNextFrame(childFrame, &childFrame);
|
1998-12-23 15:47:43 +00:00
|
|
|
}
|
2000-09-14 06:49:47 +00:00
|
|
|
// if the row group doesn't have any children, get it the hard way
|
|
|
|
if (-1 == result) {
|
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (tableFrame) {
|
|
|
|
return tableFrame->GetStartRowIndex(*this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-23 15:47:43 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-03-03 16:33:57 +00:00
|
|
|
nsresult
|
2000-01-22 01:16:50 +00:00
|
|
|
nsTableRowGroupFrame::InitRepeatedFrame(nsIPresContext* aPresContext,
|
|
|
|
nsTableRowGroupFrame* aHeaderFooterFrame)
|
1999-03-03 16:33:57 +00:00
|
|
|
{
|
|
|
|
nsIFrame* originalRowFrame;
|
1999-06-23 03:02:21 +00:00
|
|
|
nsIFrame* copyRowFrame = GetFirstFrame();
|
1999-03-03 16:33:57 +00:00
|
|
|
|
2000-01-22 01:16:50 +00:00
|
|
|
aHeaderFooterFrame->FirstChild(aPresContext, nsnull, &originalRowFrame);
|
1999-03-03 16:33:57 +00:00
|
|
|
while (copyRowFrame) {
|
|
|
|
// Set the row frame index
|
|
|
|
int rowIndex = ((nsTableRowFrame*)originalRowFrame)->GetRowIndex();
|
|
|
|
((nsTableRowFrame*)copyRowFrame)->SetRowIndex(rowIndex);
|
|
|
|
|
|
|
|
// For each table cell frame set its column index
|
|
|
|
nsIFrame* originalCellFrame;
|
|
|
|
nsIFrame* copyCellFrame;
|
2000-01-22 01:16:50 +00:00
|
|
|
originalRowFrame->FirstChild(aPresContext, nsnull, &originalCellFrame);
|
|
|
|
copyRowFrame->FirstChild(aPresContext, nsnull, ©CellFrame);
|
1999-03-03 16:33:57 +00:00
|
|
|
while (copyCellFrame) {
|
|
|
|
nsIAtom* frameType;
|
|
|
|
copyCellFrame->GetFrameType(&frameType);
|
|
|
|
|
|
|
|
if (nsLayoutAtoms::tableCellFrame == frameType) {
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsIContent* content1;
|
|
|
|
nsIContent* content2;
|
|
|
|
originalCellFrame->GetContent(&content1);
|
|
|
|
copyCellFrame->GetContent(&content2);
|
|
|
|
NS_ASSERTION(content1 == content2, "cell frames have different content");
|
|
|
|
NS_IF_RELEASE(content1);
|
|
|
|
NS_IF_RELEASE(content2);
|
|
|
|
#endif
|
|
|
|
PRInt32 colIndex;
|
|
|
|
((nsTableCellFrame*)originalCellFrame)->GetColIndex(colIndex);
|
|
|
|
((nsTableCellFrame*)copyCellFrame)->InitCellFrame(colIndex);
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
|
|
|
|
// Move to the next cell frame
|
|
|
|
copyCellFrame->GetNextSibling(©CellFrame);
|
|
|
|
originalCellFrame->GetNextSibling(&originalCellFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move to the next row frame
|
1999-06-23 03:02:21 +00:00
|
|
|
GetNextFrame(originalRowFrame, &originalRowFrame);
|
|
|
|
GetNextFrame(copyRowFrame, ©RowFrame);
|
1999-03-03 16:33:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-10-22 05:27:11 +00:00
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext* aPresContext,
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
const nsRect& aDirtyRect,
|
1999-06-07 21:10:25 +00:00
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2001-01-27 14:09:34 +00:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-06-07 21:10:25 +00:00
|
|
|
nsresult rv;
|
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
|
|
|
nsCompatibility mode;
|
1999-11-24 06:03:41 +00:00
|
|
|
aPresContext->GetCompatibilityMode(&mode);
|
1999-06-07 21:10:25 +00:00
|
|
|
if (eCompatibility_Standard == mode) {
|
2001-05-31 22:19:43 +00:00
|
|
|
const nsStyleVisibility* vis =
|
|
|
|
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
|
|
|
|
if (vis->IsVisibleOrCollapsed()) {
|
2001-02-07 09:57:26 +00:00
|
|
|
const nsStyleBorder* border =
|
|
|
|
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
|
2001-05-31 22:19:43 +00:00
|
|
|
const nsStyleBackground* color =
|
|
|
|
(const nsStyleBackground*)mStyleContext->GetStyleData(eStyleStruct_Background);
|
1999-06-07 21:10:25 +00:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv) || (nsnull == tableFrame)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2000-04-28 21:05:31 +00:00
|
|
|
nsRect rect(0,0,mRect.width, mRect.height);
|
1999-06-07 21:10:25 +00:00
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
2001-02-07 09:57:26 +00:00
|
|
|
aDirtyRect, rect, *color, *border, 0, 0);
|
1999-06-07 21:10:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
1998-04-13 20:24:54 +00:00
|
|
|
// for debug...
|
1999-06-07 21:10:25 +00:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0,255,0));
|
1998-04-13 20:24:54 +00:00
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-12-18 15:54:23 +00:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1999-09-17 23:33:39 +00:00
|
|
|
return NS_OK;
|
|
|
|
/*nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);*/
|
1999-06-07 21:10:25 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-20 17:45:07 +00: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-13 20:24:54 +00:00
|
|
|
// aDirtyRect is in our coordinate system
|
|
|
|
// child rect's are also in our coordinate system
|
2001-03-13 06:38:59 +00:00
|
|
|
// overloaded method from nsContainerFrame. The difference is that
|
|
|
|
// we don't want to clip our children, so a cell can do a rowspan
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
void nsTableRowGroupFrame::PaintChildren(nsIPresContext* aPresContext,
|
1998-04-13 20:24:54 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-06-23 03:02:21 +00:00
|
|
|
nsIFrame* kid = GetFirstFrame();
|
1998-04-13 20:24:54 +00:00
|
|
|
while (nsnull != kid) {
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIView *pView;
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
kid->GetView(aPresContext, &pView);
|
1998-04-14 21:49:29 +00:00
|
|
|
if (nsnull == pView) {
|
1998-10-30 02:08:25 +00:00
|
|
|
PRBool clipState;
|
1998-04-14 21:49:29 +00: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 15:54:23 +00:00
|
|
|
kid->Paint(aPresContext, aRenderingContext, kidDamageArea, aWhichLayer);
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1999-03-26 00:39:35 +00:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) &&
|
|
|
|
GetShowFrameBorders()) {
|
1998-04-14 21:49:29 +00:00
|
|
|
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
|
|
|
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
|
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-10-30 02:08:25 +00:00
|
|
|
aRenderingContext.PopState(clipState);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1999-06-23 03:02:21 +00:00
|
|
|
GetNextFrame(kid, &kid);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-18 05:25:26 +00:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 04:44:41 +00:00
|
|
|
nsTableRowGroupFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
2000-03-22 02:43:08 +00:00
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
nsIFrame** aFrame)
|
1998-11-07 00:36:37 +00:00
|
|
|
{
|
2000-03-22 02:43:08 +00:00
|
|
|
// this should act like a block, so we need to override
|
|
|
|
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
|
1998-11-07 00:36:37 +00:00
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Position and size aKidFrame and update our reflow state. The origin of
|
1999-01-05 00:41:40 +00:00
|
|
|
// aKidRect is relative to the upper-left origin of our frame
|
2001-03-13 06:38:59 +00:00
|
|
|
void
|
|
|
|
nsTableRowGroupFrame::PlaceChild(nsIPresContext* aPresContext,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
// Place and size the child
|
2001-03-13 06:38:59 +00:00
|
|
|
FinishReflowChild(aKidFrame, aPresContext, aDesiredSize, 0, aReflowState.y, 0);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
// Adjust the running y-offset
|
1999-11-19 15:33:29 +00:00
|
|
|
aReflowState.y += aDesiredSize.height;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
// If our height is constrained then update the available height
|
2001-03-13 06:38:59 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.availSize.height) {
|
1999-11-19 15:33:29 +00:00
|
|
|
aReflowState.availSize.height -= aDesiredSize.height;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// Reflow the frames we've already created. If aDirtyOnly is set then only
|
|
|
|
// reflow dirty frames. This assumes that all of the dirty frames are contiguous.
|
|
|
|
NS_METHOD
|
|
|
|
nsTableRowGroupFrame::ReflowChildren(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsTableRowFrame* aStartFrame,
|
|
|
|
PRBool aDirtyOnly)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-04-28 21:05:31 +00:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv) || !tableFrame) return rv;
|
|
|
|
|
|
|
|
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
|
1999-06-23 03:02:21 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
nsIFrame* lastReflowedRow = nsnull;
|
|
|
|
PRBool adjustSiblings = PR_TRUE;
|
|
|
|
nsIFrame* kidFrame = (aStartFrame) ? aStartFrame : mFrames.FirstChild();
|
1999-06-23 03:02:21 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
for ( ; kidFrame; ) {
|
1999-08-01 22:01:37 +00:00
|
|
|
// Get the frame state bits
|
|
|
|
nsFrameState frameState;
|
|
|
|
kidFrame->GetFrameState(&frameState);
|
|
|
|
|
|
|
|
// See if we should only reflow the dirty child frames
|
2001-03-13 06:38:59 +00:00
|
|
|
PRBool doReflowChild = PR_TRUE;
|
|
|
|
if (aDirtyOnly && ((frameState & NS_FRAME_IS_DIRTY) == 0)) {
|
|
|
|
doReflowChild = PR_FALSE;
|
1999-06-23 03:02:21 +00:00
|
|
|
}
|
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
// Reflow the row frame
|
1999-08-01 22:01:37 +00:00
|
|
|
if (doReflowChild) {
|
|
|
|
nsSize kidAvailSize(aReflowState.availSize);
|
2001-03-13 06:38:59 +00:00
|
|
|
if (0 >= kidAvailSize.height)
|
1999-08-01 22:01:37 +00:00
|
|
|
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
|
2001-03-13 06:38:59 +00:00
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
|
|
|
desiredSize.width = desiredSize.height = desiredSize.ascent = desiredSize.descent = 0;
|
1999-08-01 22:01:37 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// Reflow the child into the available space, giving it as much height as
|
1999-08-01 22:01:37 +00:00
|
|
|
// 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;
|
2001-03-13 06:38:59 +00:00
|
|
|
nsReflowReason reason = (frameState & NS_FRAME_FIRST_REFLOW)
|
|
|
|
? eReflowReason_Initial : aReflowState.reason;
|
1999-08-01 22:01:37 +00:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState, kidFrame,
|
1999-08-03 02:41:27 +00:00
|
|
|
kidAvailSize, reason);
|
1999-08-01 22:01:37 +00:00
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
// If this isn't the first row frame, then we can't be at the top of
|
|
|
|
// the page anymore...
|
|
|
|
if (kidFrame != GetFirstFrame()) {
|
|
|
|
kidReflowState.isTopOfPage = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-11-19 15:33:29 +00:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
|
|
|
|
0, aReflowState.y, 0, aStatus);
|
1999-08-01 22:01:37 +00:00
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
// Place the child
|
1999-08-01 22:01:37 +00:00
|
|
|
nsRect kidRect (0, aReflowState.y, desiredSize.width, desiredSize.height);
|
2001-03-13 06:38:59 +00:00
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame, desiredSize);
|
2000-04-28 21:05:31 +00:00
|
|
|
aReflowState.y += cellSpacingY;
|
2001-03-13 06:38:59 +00:00
|
|
|
lastReflowedRow = kidFrame;
|
1999-08-03 02:41:27 +00:00
|
|
|
} else {
|
2001-03-13 06:38:59 +00:00
|
|
|
// were done reflowing, so see if we need to reposition the rows that follow
|
|
|
|
if (lastReflowedRow) {
|
|
|
|
if (tableFrame->NeedsReflow(aReflowState.reflowState)) {
|
|
|
|
adjustSiblings = PR_FALSE;
|
|
|
|
break; // don't bother if the table will reflow everything.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Adjust the running y-offset so we know where the next row should be placed
|
|
|
|
nsSize kidSize;
|
1999-08-03 02:41:27 +00:00
|
|
|
kidFrame->GetSize(kidSize);
|
2000-04-28 21:05:31 +00:00
|
|
|
aReflowState.y += kidSize.height + cellSpacingY;
|
1998-12-21 06:38:18 +00:00
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
kidFrame->GetNextSibling(&kidFrame); // Get the next child
|
|
|
|
}
|
1999-06-23 03:02:21 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// adjust the rows after the ones that were reflowed
|
|
|
|
if (lastReflowedRow && adjustSiblings) {
|
|
|
|
nsIFrame* nextRow = nsnull;
|
|
|
|
lastReflowedRow->GetNextSibling(&nextRow);
|
|
|
|
if (nextRow) {
|
|
|
|
nsRect lastReflowedRect, nextRect;
|
|
|
|
lastReflowedRow->GetRect(lastReflowedRect);
|
|
|
|
nextRow->GetRect(nextRect);
|
|
|
|
nscoord deltaY = cellSpacingY + lastReflowedRect.YMost() - nextRect.y;
|
|
|
|
if (deltaY != 0) {
|
|
|
|
AdjustSiblingsAfterReflow(aPresContext, aReflowState, lastReflowedRow, deltaY);
|
|
|
|
}
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-19 23:43:06 +00:00
|
|
|
return rv;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
1999-02-20 03:15:03 +00:00
|
|
|
* Pull-up all the row frames from our next-in-flow
|
1998-04-13 20:24:54 +00:00
|
|
|
*/
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowGroupFrame::PullUpAllRowFrames(nsIPresContext* aPresContext)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-02-20 03:15:03 +00:00
|
|
|
if (mNextInFlow) {
|
|
|
|
nsTableRowGroupFrame* nextInFlow = (nsTableRowGroupFrame*)mNextInFlow;
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
while (nextInFlow) {
|
1999-03-05 06:00:40 +00:00
|
|
|
// Any frames on the next-in-flow's overflow list?
|
1999-11-24 06:03:41 +00:00
|
|
|
nsIFrame* nextOverflowFrames = nextInFlow->GetOverflowFrames(aPresContext,
|
1999-10-21 05:11:43 +00:00
|
|
|
PR_TRUE);
|
|
|
|
if (nextOverflowFrames) {
|
1999-03-05 06:00:40 +00:00
|
|
|
// Yes, append them to its child list
|
1999-10-21 05:11:43 +00:00
|
|
|
nextInFlow->mFrames.AppendFrames(nextInFlow, nextOverflowFrames);
|
1998-04-16 22:21:32 +00:00
|
|
|
}
|
1999-03-05 06:00:40 +00:00
|
|
|
|
|
|
|
// Any row frames?
|
|
|
|
if (nextInFlow->mFrames.NotEmpty()) {
|
1999-04-13 02:38:09 +00:00
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
1999-06-23 03:02:21 +00:00
|
|
|
for (nsIFrame* f = nextInFlow->GetFirstFrame(); f; GetNextFrame(f, &f)) {
|
1999-11-24 06:03:41 +00:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, nextInFlow, this);
|
1999-04-13 02:38:09 +00:00
|
|
|
}
|
1999-03-05 06:00:40 +00:00
|
|
|
// Append them to our child list
|
1999-04-13 00:06:17 +00:00
|
|
|
mFrames.AppendFrames(this, nextInFlow->mFrames);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-03-05 06:00:40 +00:00
|
|
|
// Move to the next-in-flow
|
|
|
|
nextInFlow->GetNextInFlow((nsIFrame**)&nextInFlow);
|
1998-04-16 22:21:32 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-02-20 03:15:03 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
void
|
|
|
|
nsTableRowGroupFrame::GetNextRowSibling(nsIFrame** aRowFrame)
|
1999-03-16 23:42:38 +00:00
|
|
|
{
|
1999-12-13 22:56:31 +00:00
|
|
|
if (!*aRowFrame) return;
|
1999-06-23 03:02:21 +00:00
|
|
|
GetNextFrame(*aRowFrame, aRowFrame);
|
|
|
|
while(*aRowFrame) {
|
1999-03-16 23:42:38 +00:00
|
|
|
const nsStyleDisplay *display;
|
|
|
|
(*aRowFrame)->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == display->mDisplay) {
|
|
|
|
return;
|
|
|
|
}
|
1999-06-23 03:02:21 +00:00
|
|
|
GetNextFrame(*aRowFrame, aRowFrame);
|
1999-03-16 23:42:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-03 14:04:49 +00:00
|
|
|
// allocate the height of rows which have no cells originating in them
|
|
|
|
// except with cells with rowspan > 1. Store the height as negative
|
|
|
|
// to distinguish them from regular rows.
|
|
|
|
void
|
|
|
|
AllocateSpecialHeight(nsIPresContext* aPresContext,
|
|
|
|
nsTableFrame* aTableFrame,
|
|
|
|
nsIFrame* aRowFrame,
|
|
|
|
nscoord& aHeight)
|
|
|
|
{
|
|
|
|
nsIFrame* cellFrame;
|
|
|
|
aRowFrame->FirstChild(aPresContext, nsnull, &cellFrame);
|
|
|
|
while (cellFrame) {
|
|
|
|
nsCOMPtr<nsIAtom> cellType;
|
|
|
|
cellFrame->GetFrameType(getter_AddRefs(cellType));
|
2000-02-03 15:41:04 +00:00
|
|
|
if (nsLayoutAtoms::tableCellFrame == cellType.get()) {
|
2000-02-03 14:04:49 +00:00
|
|
|
PRInt32 rowSpan = aTableFrame->GetEffectiveRowSpan((nsTableCellFrame&)*cellFrame);
|
|
|
|
if (rowSpan > 1) {
|
|
|
|
// use a simple average to allocate the special row. This is not exact,
|
|
|
|
// but much better than nothing.
|
2000-02-04 02:49:27 +00:00
|
|
|
nsSize cellDesSize = ((nsTableCellFrame*)cellFrame)->GetDesiredSize();
|
2000-02-03 14:04:49 +00:00
|
|
|
((nsTableRowFrame*)aRowFrame)->CalculateCellActualSize(cellFrame, cellDesSize.width,
|
2000-02-04 02:49:27 +00:00
|
|
|
cellDesSize.height, cellDesSize.width);
|
2000-02-03 14:04:49 +00:00
|
|
|
PRInt32 propHeight = NSToCoordRound((float)cellDesSize.height / (float)rowSpan);
|
|
|
|
// special rows store the largest negative value
|
|
|
|
aHeight = PR_MIN(aHeight, -propHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cellFrame->GetNextSibling(&cellFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-20 01:01:25 +00: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.
|
|
|
|
*/
|
2001-03-13 06:38:59 +00:00
|
|
|
void
|
|
|
|
nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState)
|
1998-06-30 02:11:07 +00:00
|
|
|
{
|
2000-02-03 14:04:49 +00:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
1999-05-26 22:22:23 +00:00
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2000-02-03 14:04:49 +00:00
|
|
|
if (NS_FAILED(rv) || nsnull==tableFrame) return;
|
|
|
|
|
1999-05-26 22:22:23 +00:00
|
|
|
// all table cells have the same top and bottom margins, namely cellSpacingY
|
|
|
|
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
|
|
|
|
|
1999-08-20 23:27:39 +00:00
|
|
|
PRBool hasRowSpanningCell = PR_FALSE;
|
2001-03-13 06:38:59 +00:00
|
|
|
PRInt32 numRows = GetRowCount();
|
2000-02-03 14:04:49 +00:00
|
|
|
// collect the current height of each row. rows which have 0 height because
|
|
|
|
// they have no cells originating in them without rowspans > 1, are referred to as
|
|
|
|
// special rows. The current height of a special row will be a negative number until
|
|
|
|
// it comes time to actually resize frames.
|
1999-12-16 00:37:03 +00:00
|
|
|
nscoord* rowHeights = nsnull;
|
|
|
|
if (numRows > 0) {
|
|
|
|
rowHeights = new nscoord[numRows];
|
|
|
|
if (!rowHeights) return;
|
|
|
|
nsCRT::memset (rowHeights, 0, numRows*sizeof(nscoord));
|
1999-12-16 01:51:06 +00:00
|
|
|
} // else - tree row groups need not have rows directly beneath them
|
1998-06-30 02:11:07 +00:00
|
|
|
|
2000-02-03 14:04:49 +00:00
|
|
|
// Step 1: get the height of the tallest cell in the row and save it for
|
|
|
|
// pass 2. This height is for table cells that originate in this
|
|
|
|
// row and that don't span into the rows that follow
|
1999-06-23 03:02:21 +00:00
|
|
|
nsIFrame* rowFrame = GetFirstFrame();
|
1998-09-15 20:36:42 +00:00
|
|
|
PRInt32 rowIndex = 0;
|
1999-02-22 03:28:00 +00:00
|
|
|
|
|
|
|
// For row groups that are split across pages, the first row frame won't
|
|
|
|
// necessarily be index 0
|
1999-06-14 08:01:00 +00:00
|
|
|
PRInt32 startRowIndex = -1;
|
2000-02-03 14:04:49 +00:00
|
|
|
while (rowFrame) {
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
rowFrame->GetFrameType(getter_AddRefs(frameType));
|
2000-02-03 15:41:04 +00:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType.get()) {
|
1999-06-14 08:01:00 +00:00
|
|
|
if (startRowIndex == -1) {
|
|
|
|
startRowIndex = ((nsTableRowFrame*)rowFrame)->GetRowIndex();
|
|
|
|
}
|
1998-09-15 20:36:42 +00:00
|
|
|
// get the height of the tallest cell in the row (excluding cells that span rows)
|
2000-05-25 22:40:21 +00:00
|
|
|
rowHeights[rowIndex] = ((nsTableRowFrame*)rowFrame)->GetTallestCell();
|
1999-08-20 23:27:39 +00:00
|
|
|
// See if a cell spans into the row. If so we'll have to do step 2
|
|
|
|
if (!hasRowSpanningCell) {
|
|
|
|
if (tableFrame->RowIsSpannedInto(rowIndex + startRowIndex)) {
|
|
|
|
hasRowSpanningCell = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
2000-02-03 14:04:49 +00:00
|
|
|
// special rows need to have some values, so they will get allocations
|
|
|
|
// later. If left at 0, they would get nothing.
|
|
|
|
if (0 == rowHeights[rowIndex]) {
|
|
|
|
AllocateSpecialHeight(aPresContext, tableFrame, rowFrame, rowHeights[rowIndex]);
|
|
|
|
}
|
1998-09-15 20:36:42 +00:00
|
|
|
rowIndex++;
|
1998-06-30 02:11:07 +00:00
|
|
|
}
|
2000-02-03 14:04:49 +00:00
|
|
|
GetNextFrame(rowFrame, &rowFrame); // Get the next row
|
1999-05-26 22:22:23 +00:00
|
|
|
}
|
1998-06-30 02:11:07 +00:00
|
|
|
|
2001-05-14 14:28:00 +00:00
|
|
|
// Step 2: Now account for cells that span rows. A spanning cell's height is the sum of the heights of the
|
2000-02-03 14:04:49 +00:00
|
|
|
// rows it spans, 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.
|
|
|
|
// We go through this loop twice. The first time, we are adjusting cell heights
|
|
|
|
// 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.
|
2001-08-06 14:26:36 +00:00
|
|
|
nscoord yOrigin = 0;
|
2001-05-14 14:28:00 +00:00
|
|
|
nscoord lastCount = (hasRowSpanningCell) ? 2 : 1;
|
|
|
|
for (PRInt32 counter = 0; counter <= lastCount; counter++) {
|
|
|
|
rowFrame = GetFirstFrame();
|
|
|
|
rowIndex = 0;
|
|
|
|
while (rowFrame) {
|
|
|
|
nsCOMPtr<nsIAtom> rowType;
|
|
|
|
rowFrame->GetFrameType(getter_AddRefs(rowType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == rowType.get()) {
|
|
|
|
if (hasRowSpanningCell) {
|
1999-08-20 23:27:39 +00:00
|
|
|
// check this row for a cell with rowspans
|
2000-02-03 14:04:49 +00:00
|
|
|
nsIFrame* cellFrame;
|
2000-01-22 01:16:50 +00:00
|
|
|
rowFrame->FirstChild(aPresContext, nsnull, &cellFrame);
|
2000-02-03 14:04:49 +00:00
|
|
|
while (cellFrame) {
|
|
|
|
nsCOMPtr<nsIAtom> cellType;
|
|
|
|
cellFrame->GetFrameType(getter_AddRefs(cellType));
|
2000-02-03 15:41:04 +00:00
|
|
|
if (nsLayoutAtoms::tableCellFrame == cellType.get()) {
|
1999-08-20 23:27:39 +00:00
|
|
|
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(rowIndex + startRowIndex,
|
2000-02-01 03:23:29 +00:00
|
|
|
(nsTableCellFrame&)*cellFrame);
|
2000-02-03 14:04:49 +00:00
|
|
|
if (rowSpan > 1) { // found a cell with rowspan > 1, determine the height
|
|
|
|
// of the rows it spans
|
1999-08-20 23:27:39 +00:00
|
|
|
nscoord heightOfRowsSpanned = 0;
|
2000-04-28 21:05:31 +00:00
|
|
|
nscoord cellSpacingOfRowsSpanned = 0;
|
2000-02-03 14:04:49 +00:00
|
|
|
PRInt32 spanX;
|
2000-02-04 02:49:27 +00:00
|
|
|
PRBool cellsOrigInSpan = PR_FALSE; // do any cells originate in the spanned rows
|
2000-02-03 14:04:49 +00:00
|
|
|
for (spanX = 0; spanX < rowSpan; spanX++) {
|
2000-02-04 02:49:27 +00:00
|
|
|
PRInt32 rIndex = rowIndex + spanX;
|
|
|
|
if (rowHeights[rIndex] > 0) {
|
2000-02-03 14:04:49 +00:00
|
|
|
// don't consider negative values of special rows
|
2000-02-04 02:49:27 +00:00
|
|
|
heightOfRowsSpanned += rowHeights[rowIndex + spanX];
|
|
|
|
cellsOrigInSpan = PR_TRUE;
|
2000-02-03 14:04:49 +00:00
|
|
|
}
|
2000-04-28 21:05:31 +00:00
|
|
|
if (0 != spanX) {
|
|
|
|
cellSpacingOfRowsSpanned += cellSpacingY;
|
|
|
|
}
|
1999-08-20 23:27:39 +00:00
|
|
|
}
|
2000-04-28 21:05:31 +00:00
|
|
|
nscoord availHeightOfRowsSpanned = heightOfRowsSpanned + cellSpacingOfRowsSpanned;
|
1999-08-20 23:27:39 +00:00
|
|
|
|
|
|
|
// see if the cell's height fits within the rows it spans. If this is
|
|
|
|
// pass 1 then use the cell's desired height and not the current height
|
|
|
|
// of its frame. That way this works for incremental reflow, too
|
|
|
|
nsSize cellFrameSize;
|
|
|
|
cellFrame->GetSize(cellFrameSize);
|
|
|
|
if (0 == counter) {
|
2000-02-03 14:04:49 +00:00
|
|
|
nsSize cellDesSize = ((nsTableCellFrame*)cellFrame)->GetDesiredSize();
|
|
|
|
((nsTableRowFrame*)rowFrame)->CalculateCellActualSize(cellFrame, cellDesSize.width,
|
|
|
|
cellDesSize.height, cellDesSize.width);
|
|
|
|
cellFrameSize.height = cellDesSize.height;
|
2000-06-05 08:25:11 +00:00
|
|
|
// see if the cell has 'vertical-align: baseline'
|
|
|
|
if (((nsTableCellFrame*)cellFrame)->HasVerticalAlignBaseline()) {
|
|
|
|
// to ensure that a spanning cell with a long descender doesn't
|
|
|
|
// collide with the next row, we need to take into account the shift
|
|
|
|
// that will be done to align the cell on the baseline of the row.
|
|
|
|
cellFrameSize.height += ((nsTableRowFrame*)rowFrame)->GetMaxCellAscent()
|
|
|
|
- ((nsTableCellFrame*)cellFrame)->GetDesiredAscent();
|
2000-07-28 09:19:26 +00:00
|
|
|
}
|
1999-08-20 23:27:39 +00:00
|
|
|
}
|
|
|
|
|
2000-02-03 14:04:49 +00:00
|
|
|
if (availHeightOfRowsSpanned >= cellFrameSize.height) {
|
2000-04-28 21:05:31 +00:00
|
|
|
// the cell's height fits with the available space of the rows it
|
1999-08-20 23:27:39 +00:00
|
|
|
// spans. Set the cell frame's height
|
1999-11-24 06:03:41 +00:00
|
|
|
cellFrame->SizeTo(aPresContext, cellFrameSize.width, availHeightOfRowsSpanned);
|
1999-08-20 23:27:39 +00:00
|
|
|
// Realign cell content based on new height
|
2000-06-05 08:25:11 +00:00
|
|
|
((nsTableCellFrame*)cellFrame)->VerticallyAlignChild(aPresContext, aReflowState, ((nsTableRowFrame*)rowFrame)->GetMaxCellAscent());
|
1999-08-20 23:27:39 +00:00
|
|
|
}
|
2000-02-03 14:04:49 +00:00
|
|
|
else {
|
1999-08-20 23:27:39 +00:00
|
|
|
// the cell's height is larger than the available space of the rows it
|
|
|
|
// spans so distribute the excess height to the rows affected
|
2000-02-04 02:49:27 +00:00
|
|
|
nscoord excessAvail = cellFrameSize.height - availHeightOfRowsSpanned;
|
|
|
|
nscoord excessBasis = excessAvail;
|
1999-08-20 23:27:39 +00:00
|
|
|
|
2000-02-03 14:04:49 +00:00
|
|
|
nsTableRowFrame* rowFrameToBeResized = (nsTableRowFrame *)rowFrame;
|
|
|
|
// iterate every row starting at last row spanned and up to the row with
|
|
|
|
// the spanning cell. do this bottom up so that special rows can get a full
|
|
|
|
// allocation before other rows.
|
2001-03-26 05:16:32 +00:00
|
|
|
PRInt32 beginRowIndex = rowIndex + rowSpan - 1;
|
|
|
|
for (PRInt32 rowX = beginRowIndex; (rowX >= rowIndex) && (excessAvail > 0); rowX--) {
|
2000-02-04 02:49:27 +00:00
|
|
|
nscoord excessForRow = 0;
|
|
|
|
// special rows gets as much as they can
|
|
|
|
if (rowHeights[rowX] <= 0) {
|
2001-03-26 05:16:32 +00:00
|
|
|
if ((rowX == beginRowIndex) || (!cellsOrigInSpan)) {
|
2000-02-04 02:49:27 +00:00
|
|
|
if (0 == rowHeights[rowX]) {
|
|
|
|
// give it all since no cell originates in the row
|
|
|
|
excessForRow = excessBasis;
|
|
|
|
}
|
|
|
|
else { // don't let the allocation excced what it needs
|
|
|
|
excessForRow = (excessBasis > -rowHeights[rowX]) ? -rowHeights[rowX] : excessBasis;
|
|
|
|
}
|
2000-02-03 14:04:49 +00:00
|
|
|
rowHeights[rowX] = excessForRow;
|
2000-02-04 02:49:27 +00:00
|
|
|
excessBasis -= excessForRow;
|
|
|
|
excessAvail -= excessForRow;
|
2000-02-03 14:04:49 +00:00
|
|
|
}
|
|
|
|
}
|
2000-02-04 02:49:27 +00:00
|
|
|
else if (cellsOrigInSpan) { // normal rows
|
2000-02-03 14:04:49 +00:00
|
|
|
// The amount of additional space each normal row gets is based on the
|
|
|
|
// percentage of space it occupies, i.e. they don't all get the
|
|
|
|
// same amount of available space
|
|
|
|
float percent = ((float)rowHeights[rowX]) / ((float)heightOfRowsSpanned);
|
1999-08-20 23:27:39 +00:00
|
|
|
|
2000-02-03 14:04:49 +00:00
|
|
|
// give rows their percentage, except for the first row which gets
|
|
|
|
// the remainder
|
|
|
|
excessForRow = (rowX == rowIndex)
|
2000-02-04 02:49:27 +00:00
|
|
|
? excessAvail
|
|
|
|
: NSToCoordRound(((float)(excessBasis)) * percent);
|
2000-02-03 14:04:49 +00:00
|
|
|
// update the row height
|
|
|
|
rowHeights[rowX] += excessForRow;
|
2000-02-04 02:49:27 +00:00
|
|
|
excessAvail -= excessForRow;
|
2000-02-03 14:04:49 +00:00
|
|
|
}
|
1999-08-20 23:27:39 +00:00
|
|
|
// Get the next row frame
|
|
|
|
GetNextRowSibling((nsIFrame**)&rowFrameToBeResized);
|
|
|
|
}
|
2000-02-04 02:49:27 +00:00
|
|
|
// if excessAvail is > 0 it is because !cellsOrigInSpan and the
|
|
|
|
// allocation involving special rows couldn't allocate everything.
|
|
|
|
// just give the remainder to the last row spanned.
|
|
|
|
if (excessAvail > 0) {
|
2001-03-26 05:16:32 +00:00
|
|
|
if (rowHeights[beginRowIndex] >= 0) {
|
|
|
|
rowHeights[beginRowIndex] += excessAvail;
|
2000-02-04 02:49:27 +00:00
|
|
|
}
|
|
|
|
else {
|
2001-03-26 05:16:32 +00:00
|
|
|
rowHeights[beginRowIndex] = excessAvail;
|
2000-02-04 02:49:27 +00:00
|
|
|
}
|
|
|
|
}
|
1998-09-15 20:36:42 +00:00
|
|
|
}
|
|
|
|
}
|
1998-06-30 02:11:07 +00:00
|
|
|
}
|
2000-02-03 14:04:49 +00:00
|
|
|
cellFrame->GetNextSibling(&cellFrame); // Get the next row child (cell frame)
|
1998-06-30 02:11:07 +00:00
|
|
|
}
|
2001-05-14 14:28:00 +00:00
|
|
|
}
|
1999-08-20 23:27:39 +00:00
|
|
|
|
2001-05-14 14:28:00 +00:00
|
|
|
// If this is the last pass then resize the row to its final size and move the
|
|
|
|
// row's position if the previous rows have caused a shift
|
|
|
|
if (lastCount == counter) {
|
|
|
|
nsRect rowBounds;
|
2001-08-06 14:26:36 +00:00
|
|
|
rowFrame->GetRect(rowBounds);
|
|
|
|
|
|
|
|
PRBool movedFrame = (rowBounds.y != yOrigin);
|
2001-05-14 14:28:00 +00:00
|
|
|
nscoord rowHeight = (rowHeights[rowIndex] > 0) ? rowHeights[rowIndex] : 0;
|
1999-08-20 23:27:39 +00:00
|
|
|
|
2001-05-14 14:28:00 +00:00
|
|
|
// Resize the row to its final size and position
|
2001-08-06 14:26:36 +00:00
|
|
|
rowBounds.y = yOrigin;
|
2001-05-14 14:28:00 +00:00
|
|
|
rowBounds.height = rowHeight;
|
|
|
|
rowFrame->SetRect(aPresContext, rowBounds);
|
1999-12-13 22:56:31 +00:00
|
|
|
|
2001-05-14 14:28:00 +00:00
|
|
|
if (movedFrame) {
|
|
|
|
nsTableFrame::RePositionViews(aPresContext, rowFrame);
|
1999-08-20 23:27:39 +00:00
|
|
|
}
|
2001-08-06 14:26:36 +00:00
|
|
|
// set the origin of the next row.
|
|
|
|
yOrigin += rowHeight + cellSpacingY;
|
1999-08-19 03:51:25 +00:00
|
|
|
}
|
2001-05-14 14:28:00 +00:00
|
|
|
|
|
|
|
rowIndex++;
|
1999-06-23 03:02:21 +00:00
|
|
|
}
|
2001-05-14 14:28:00 +00:00
|
|
|
GetNextFrame(rowFrame, &rowFrame); // Get the next rowgroup child (row frame)
|
1998-06-30 02:11:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-19 03:51:25 +00:00
|
|
|
// step 3: notify the rows of their new heights
|
1999-08-20 23:27:39 +00:00
|
|
|
nscoord rowGroupHeight = 0;
|
1999-06-23 03:02:21 +00:00
|
|
|
rowFrame = GetFirstFrame();
|
1999-08-19 03:51:25 +00:00
|
|
|
rowIndex = 0;
|
2000-02-03 14:04:49 +00:00
|
|
|
while (rowFrame) {
|
2000-02-11 03:55:33 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) {
|
|
|
|
nsCOMPtr<nsIAtom> rowType;
|
|
|
|
rowFrame->GetFrameType(getter_AddRefs(rowType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == rowType.get()) {
|
|
|
|
// Notify the row of the new size
|
|
|
|
((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
|
|
|
|
}
|
1998-11-20 01:01:25 +00:00
|
|
|
}
|
1999-08-20 23:27:39 +00:00
|
|
|
|
|
|
|
// Update the running row group height. The height includes frames that
|
|
|
|
// aren't rows as well
|
2000-02-03 14:04:49 +00:00
|
|
|
nsSize rowSize;
|
1999-08-20 23:27:39 +00:00
|
|
|
rowFrame->GetSize(rowSize);
|
|
|
|
rowGroupHeight += rowSize.height;
|
2000-04-28 21:05:31 +00:00
|
|
|
if (0 != rowIndex) {
|
|
|
|
rowGroupHeight += cellSpacingY;
|
|
|
|
}
|
1999-08-20 23:27:39 +00:00
|
|
|
|
2000-02-03 14:04:49 +00:00
|
|
|
GetNextFrame(rowFrame, &rowFrame); // Get the next row
|
1999-08-19 03:51:25 +00:00
|
|
|
rowIndex++;
|
1998-11-20 01:01:25 +00:00
|
|
|
}
|
|
|
|
|
2000-02-03 14:04:49 +00:00
|
|
|
aDesiredSize.height = rowGroupHeight; // Adjust our desired size
|
|
|
|
delete [] rowHeights; // cleanup
|
1998-06-30 02:11:07 +00:00
|
|
|
}
|
|
|
|
|
1999-08-19 03:51:25 +00:00
|
|
|
// Called by IR_TargetIsChild() to adjust the sibling frames that follow
|
|
|
|
// after an incremental reflow of aKidFrame.
|
|
|
|
// This function is not used for paginated mode so we don't need to deal
|
|
|
|
// with continuing frames, and it's only called if aKidFrame has no
|
|
|
|
// cells that span into it and no cells that span across it. That way
|
|
|
|
// we don't have to deal with rowspans
|
|
|
|
nsresult
|
2001-03-13 06:38:59 +00:00
|
|
|
nsTableRowGroupFrame::AdjustSiblingsAfterReflow(nsIPresContext* aPresContext,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nscoord aDeltaY)
|
1998-07-02 23:19:31 +00:00
|
|
|
{
|
1999-08-19 03:51:25 +00:00
|
|
|
NS_PRECONDITION(NS_UNCONSTRAINEDSIZE == aReflowState.reflowState.availableHeight,
|
|
|
|
"we're not in galley mode");
|
1998-07-02 23:19:31 +00:00
|
|
|
nsIFrame* lastKidFrame = aKidFrame;
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// Move the frames that follow aKidFrame by aDeltaY
|
1999-08-30 22:30:32 +00:00
|
|
|
nsIFrame* kidFrame;
|
|
|
|
for (aKidFrame->GetNextSibling(&kidFrame); kidFrame; kidFrame->GetNextSibling(&kidFrame)) {
|
|
|
|
// Move the frame if we need to
|
|
|
|
if (aDeltaY != 0) {
|
1998-07-02 23:19:31 +00:00
|
|
|
nsPoint origin;
|
|
|
|
|
1999-08-19 03:51:25 +00:00
|
|
|
// Adjust the y-origin
|
1998-07-02 23:19:31 +00:00
|
|
|
kidFrame->GetOrigin(origin);
|
|
|
|
origin.y += aDeltaY;
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
kidFrame->MoveTo(aPresContext, origin.x, origin.y);
|
2001-03-13 06:38:59 +00:00
|
|
|
nsTableFrame::RePositionViews(aPresContext, kidFrame);
|
1998-07-02 23:19:31 +00:00
|
|
|
}
|
|
|
|
|
1999-08-30 22:30:32 +00:00
|
|
|
// Remember the last frame
|
|
|
|
lastKidFrame = kidFrame;
|
1998-07-02 23:19:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update our running y-offset to reflect the bottommost child
|
|
|
|
nsRect rect;
|
|
|
|
lastKidFrame->GetRect(rect);
|
1998-10-19 23:43:06 +00:00
|
|
|
aReflowState.y = rect.YMost();
|
1998-07-02 23:19:31 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-16 22:21:32 +00:00
|
|
|
|
2001-04-16 14:51:52 +00:00
|
|
|
// Create a continuing frame, add it to the child list, and then push it
|
|
|
|
// and the frames that follow
|
|
|
|
void
|
|
|
|
nsTableRowGroupFrame::CreateContinuingRowFrame(nsIPresContext& aPresContext,
|
|
|
|
nsIStyleSet& aStyleSet,
|
|
|
|
nsIFrame& aRowFrame,
|
|
|
|
nsIFrame** aContRowFrame)
|
|
|
|
{
|
|
|
|
if (!aContRowFrame) {NS_ASSERTION(PR_FALSE, "bad call"); return;}
|
|
|
|
// create the continuing frame which will create continuing cell frames
|
|
|
|
aStyleSet.CreateContinuingFrame(&aPresContext, &aRowFrame, this, aContRowFrame);
|
|
|
|
if (!*aContRowFrame) return;
|
|
|
|
|
|
|
|
// Add the continuing row frame to the child list
|
|
|
|
nsIFrame* nextRow;
|
|
|
|
GetNextFrame(&aRowFrame, &nextRow);
|
|
|
|
(*aContRowFrame)->SetNextSibling(nextRow);
|
|
|
|
aRowFrame.SetNextSibling(*aContRowFrame);
|
|
|
|
|
|
|
|
// Push the continuing row frame and the frames that follow
|
|
|
|
PushChildren(&aPresContext, *aContRowFrame, &aRowFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsTableRowGroupFrame::SplitSpanningCells(nsIPresContext& aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsIStyleSet& aStyleSet,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsTableRowFrame& aRowFrame,
|
|
|
|
nscoord aRowEndY,
|
|
|
|
nsTableRowFrame* aContRowFrame)
|
|
|
|
{
|
|
|
|
PRInt32 rowIndex = aRowFrame.GetRowIndex();
|
|
|
|
PRInt32 colCount = aTableFrame.GetColCount();
|
|
|
|
nsTableCellFrame* prevCellFrame = nsnull;
|
|
|
|
|
|
|
|
nscoord tallestCell = 0;
|
|
|
|
|
|
|
|
for (PRInt32 colX = 0; colX < colCount; colX++) {
|
|
|
|
nsTableCellFrame* cellFrame = aTableFrame.GetCellInfoAt(rowIndex, colX);
|
|
|
|
if (!cellFrame) continue;
|
|
|
|
// use the last in flow since a cell with a row span may have already split.
|
|
|
|
cellFrame = (nsTableCellFrame*)cellFrame->GetLastInFlow();
|
|
|
|
|
|
|
|
// See if the cell frame is really in this row, or whether it's a cell spanning from a previous row
|
|
|
|
PRInt32 realRowIndex;
|
|
|
|
cellFrame->GetRowIndex(realRowIndex);
|
|
|
|
if (realRowIndex == rowIndex) {
|
|
|
|
prevCellFrame = cellFrame;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsTableRowFrame* parentFrame;
|
|
|
|
nsPoint cellOrigin;
|
|
|
|
nsReflowStatus status;
|
|
|
|
|
|
|
|
// Ask the cell frame's parent to reflow it to the height of all the
|
|
|
|
// rows it spans between its origin and aRowEndY
|
|
|
|
cellFrame->GetParent((nsIFrame**)&parentFrame);
|
|
|
|
if (!parentFrame) {NS_ASSERTION(PR_FALSE, "bad parent"); return 0;}
|
|
|
|
parentFrame->GetOrigin(cellOrigin);
|
|
|
|
nscoord cellAvailHeight = aRowEndY - cellOrigin.y;
|
|
|
|
nscoord cellHeight = parentFrame->ReflowCellFrame(&aPresContext, aReflowState, cellFrame,
|
|
|
|
cellAvailHeight, status);
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(status)) {
|
|
|
|
// Create a continuing cell frame since the cell's block split
|
|
|
|
nsTableCellFrame* contCellFrame = nsnull;
|
|
|
|
aStyleSet.CreateContinuingFrame(&aPresContext, cellFrame, &aRowFrame, (nsIFrame**)&contCellFrame);
|
|
|
|
// Add the continuing cell frame to the appropriate row's child list
|
|
|
|
if (contCellFrame) {
|
|
|
|
if (aContRowFrame) {
|
|
|
|
aContRowFrame->InsertCellFrame(contCellFrame, colX);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aRowFrame.InsertCellFrame(contCellFrame, prevCellFrame);
|
|
|
|
}
|
|
|
|
prevCellFrame = contCellFrame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((cellHeight > cellAvailHeight) && aContRowFrame) {
|
|
|
|
// put the cell on the continuing row frame to give it more space
|
|
|
|
aRowFrame.RemoveCellFrame(cellFrame);
|
|
|
|
aContRowFrame->InsertCellFrame(cellFrame, colX);
|
|
|
|
prevCellFrame = cellFrame;
|
|
|
|
}
|
|
|
|
tallestCell = PR_MAX(tallestCell, cellHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tallestCell;
|
|
|
|
}
|
|
|
|
|
1998-12-14 01:24:11 +00:00
|
|
|
nsresult
|
1999-11-24 06:03:41 +00:00
|
|
|
nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* aPresContext,
|
1998-12-14 01:24:11 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-02-22 03:28:00 +00:00
|
|
|
nsTableFrame* aTableFrame,
|
1998-12-14 01:24:11 +00:00
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
1999-02-22 03:28:00 +00:00
|
|
|
nsIFrame* prevRowFrame = nsnull;
|
2001-04-17 14:39:54 +00:00
|
|
|
aDesiredSize.height = 0;
|
1998-12-15 16:39:09 +00:00
|
|
|
nsresult rv = NS_OK;
|
2001-04-16 14:51:52 +00:00
|
|
|
|
|
|
|
// get the style set
|
|
|
|
nsCOMPtr<nsIStyleSet> styleSet;
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
if (!presShell) {NS_ASSERTION(PR_FALSE, "no pres shell"); return NS_ERROR_NULL_POINTER;}
|
|
|
|
presShell->GetStyleSet(getter_AddRefs(styleSet));
|
|
|
|
if (!styleSet) {NS_ASSERTION(PR_FALSE, "no style set"); return NS_ERROR_NULL_POINTER;}
|
|
|
|
|
2001-04-02 03:21:58 +00:00
|
|
|
float p2t;
|
|
|
|
aPresContext->GetPixelsToTwips(&p2t);
|
|
|
|
|
|
|
|
nscoord availWidth = nsTableFrame::RoundToPixel(aReflowState.availableWidth, p2t);
|
|
|
|
nscoord availHeight = nsTableFrame::RoundToPixel(aReflowState.availableHeight, p2t);
|
2001-04-17 14:39:54 +00:00
|
|
|
nscoord lastDesiredHeight = 0;
|
1998-12-14 01:24:11 +00:00
|
|
|
|
|
|
|
// Walk each of the row frames looking for the first row frame that
|
|
|
|
// doesn't fit in the available space
|
1999-06-23 03:02:21 +00:00
|
|
|
for (nsIFrame* rowFrame = GetFirstFrame(); rowFrame; GetNextFrame(rowFrame, &rowFrame)) {
|
2001-04-02 03:21:58 +00:00
|
|
|
PRBool rowIsOnCurrentPage = PR_TRUE;
|
2001-04-16 15:53:23 +00:00
|
|
|
PRBool degenerateRow = PR_FALSE;
|
2001-04-02 03:21:58 +00:00
|
|
|
nsRect bounds;
|
1999-02-22 03:28:00 +00:00
|
|
|
rowFrame->GetRect(bounds);
|
2001-04-02 03:21:58 +00:00
|
|
|
if (bounds.YMost() > availHeight) {
|
2001-04-12 13:04:29 +00:00
|
|
|
nsRect actualRect;
|
|
|
|
nsRect adjRect;
|
|
|
|
aPresContext->GetPageDim(&actualRect, &adjRect);
|
2001-04-16 15:53:23 +00:00
|
|
|
nsIFrame* contRowFrame = nsnull;
|
2001-04-12 13:04:29 +00:00
|
|
|
nscoord pageHeight = actualRect.height;
|
2001-04-02 03:21:58 +00:00
|
|
|
// reflow the row in the availabe space and have it split if it is the 1st
|
|
|
|
// row or there is at least 20% of the current page available
|
2001-04-17 14:39:54 +00:00
|
|
|
if (!prevRowFrame || (availHeight - aDesiredSize.height > pageHeight / 5)) {
|
1998-12-14 01:24:11 +00:00
|
|
|
// Reflow the row in the available space and have it split
|
2001-04-02 03:21:58 +00:00
|
|
|
nsSize availSize(availWidth, availHeight - bounds.y);
|
1999-03-05 04:19:09 +00:00
|
|
|
nsHTMLReflowState rowReflowState(aPresContext, aReflowState, rowFrame,
|
1999-02-22 03:28:00 +00:00
|
|
|
availSize, eReflowReason_Resize);
|
1998-12-15 16:39:09 +00:00
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
1998-12-14 01:24:11 +00:00
|
|
|
|
1999-11-19 15:33:29 +00:00
|
|
|
rv = ReflowChild(rowFrame, aPresContext, desiredSize, rowReflowState,
|
|
|
|
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
1999-11-24 06:03:41 +00:00
|
|
|
rowFrame->SizeTo(aPresContext, desiredSize.width, desiredSize.height);
|
1999-11-19 15:33:29 +00:00
|
|
|
rowFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
1999-02-22 03:28:00 +00:00
|
|
|
((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
|
1998-12-14 01:24:11 +00:00
|
|
|
|
1998-12-15 21:26:05 +00:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
2001-04-16 14:51:52 +00:00
|
|
|
// the row frame is incomplete and all of the cells' block frames have split
|
|
|
|
CreateContinuingRowFrame(*aPresContext, *styleSet.get(), *rowFrame, &contRowFrame);
|
2001-04-17 14:39:54 +00:00
|
|
|
aDesiredSize.height += aTableFrame->GetCellSpacingY() + desiredSize.height;
|
2001-04-16 14:51:52 +00:00
|
|
|
}
|
|
|
|
else if (0 == desiredSize.height) {
|
|
|
|
// the row frame is complete because it had no cells originating in it.
|
|
|
|
CreateContinuingRowFrame(*aPresContext, *styleSet.get(), *rowFrame, &contRowFrame);
|
1999-03-09 15:35:43 +00:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
2001-04-17 14:39:54 +00:00
|
|
|
aDesiredSize.height = availHeight;
|
2001-04-16 14:51:52 +00:00
|
|
|
degenerateRow = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// the row frame is complete because it's minimum height was greater than the
|
|
|
|
// the available height we gave it
|
2001-04-17 14:39:54 +00:00
|
|
|
if (aDesiredSize.height > 0) {
|
2001-04-02 03:21:58 +00:00
|
|
|
// put the row on the next page since it needs more height than it was given
|
|
|
|
rowIsOnCurrentPage = PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsIFrame* nextRowFrame;
|
1999-03-09 15:35:43 +00:00
|
|
|
|
2001-04-16 14:51:52 +00:00
|
|
|
// Push the row frame that follows
|
2001-04-02 03:21:58 +00:00
|
|
|
GetNextFrame(rowFrame, &nextRowFrame);
|
1999-06-23 03:02:21 +00:00
|
|
|
|
2001-04-02 03:21:58 +00:00
|
|
|
if (nextRowFrame) {
|
|
|
|
PushChildren(aPresContext, nextRowFrame, rowFrame);
|
|
|
|
}
|
|
|
|
aStatus = nextRowFrame ? NS_FRAME_NOT_COMPLETE : NS_FRAME_COMPLETE;
|
2001-04-17 14:39:54 +00:00
|
|
|
aDesiredSize.height = bounds.YMost();
|
1999-03-09 15:35:43 +00:00
|
|
|
}
|
1998-12-15 21:26:05 +00:00
|
|
|
}
|
2001-04-02 03:21:58 +00:00
|
|
|
}
|
|
|
|
else rowIsOnCurrentPage = PR_FALSE;
|
1998-12-15 21:26:05 +00:00
|
|
|
|
2001-04-02 03:21:58 +00:00
|
|
|
if (!rowIsOnCurrentPage) {
|
1999-02-22 03:28:00 +00:00
|
|
|
// Push this row frame and those that follow to the next-in-flow
|
1999-11-24 06:03:41 +00:00
|
|
|
PushChildren(aPresContext, rowFrame, prevRowFrame);
|
1999-03-09 15:35:43 +00:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-12-14 01:24:11 +00:00
|
|
|
}
|
2001-04-16 14:51:52 +00:00
|
|
|
if (prevRowFrame) {
|
|
|
|
nscoord tallestCell =
|
|
|
|
SplitSpanningCells(*aPresContext, aReflowState, *styleSet, *aTableFrame,
|
2001-04-17 14:39:54 +00:00
|
|
|
*(nsTableRowFrame*)rowFrame, aDesiredSize.height, (nsTableRowFrame*)contRowFrame);
|
2001-04-16 14:51:52 +00:00
|
|
|
if (degenerateRow) {
|
2001-04-17 14:39:54 +00:00
|
|
|
aDesiredSize.height = lastDesiredHeight + aTableFrame->GetCellSpacingY() + tallestCell;
|
2001-04-16 14:51:52 +00:00
|
|
|
}
|
|
|
|
}
|
1998-12-14 01:24:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-04-17 14:39:54 +00:00
|
|
|
else {
|
|
|
|
aDesiredSize.height = bounds.YMost();
|
|
|
|
lastDesiredHeight = aDesiredSize.height;
|
|
|
|
prevRowFrame = rowFrame;
|
|
|
|
}
|
1998-12-14 01:24:11 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00: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 01:41:24 +00:00
|
|
|
NS_METHOD
|
1999-11-24 06:03:41 +00:00
|
|
|
nsTableRowGroupFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-02 04:10:00 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-04-21 21:36:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableRowGroupFrame", aReflowState.reason);
|
2001-01-25 15:55:51 +00:00
|
|
|
#if defined DEBUG_TABLE_REFLOW | DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState);
|
|
|
|
#endif
|
1998-10-14 16:32:45 +00:00
|
|
|
nsresult rv=NS_OK;
|
2001-03-28 21:26:58 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
1998-11-04 20:09:19 +00:00
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 06:38:59 +00:00
|
|
|
if (!tableFrame) return NS_ERROR_NULL_POINTER;
|
1998-11-04 20:09:19 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
nsRowGroupReflowState state(aReflowState, tableFrame);
|
|
|
|
PRBool haveDesiredHeight = PR_FALSE;
|
1998-07-02 23:19:31 +00:00
|
|
|
|
1998-06-23 05:43:27 +00:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
1998-11-04 20:09:19 +00:00
|
|
|
rv = IncrementalReflow(aPresContext, aDesiredSize, state, aStatus);
|
2001-03-13 06:38:59 +00:00
|
|
|
}
|
2001-03-28 21:26:58 +00:00
|
|
|
else {
|
1998-06-23 05:43:27 +00:00
|
|
|
// Check for an overflow list
|
1999-11-24 06:03:41 +00:00
|
|
|
MoveOverflowToChildList(aPresContext);
|
1998-06-23 05:43:27 +00:00
|
|
|
|
1999-02-20 03:15:03 +00:00
|
|
|
// Reflow the existing frames. Before we do, pull-up any row frames from
|
|
|
|
// our next-in-flow.
|
|
|
|
// XXX It would be more efficient to do this if we have room left after
|
|
|
|
// reflowing the frames we have, the problem is we don't know if we have
|
|
|
|
// room left until after we call CalculateRowHeights()...
|
|
|
|
PullUpAllRowFrames(aPresContext);
|
2001-03-13 06:38:59 +00:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, state, aStatus,
|
|
|
|
nsnull, PR_FALSE);
|
1998-06-23 05:43:27 +00:00
|
|
|
|
|
|
|
// Return our desired rect
|
1999-01-05 23:31:18 +00:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
1998-06-30 02:11:07 +00:00
|
|
|
aDesiredSize.height = state.y;
|
|
|
|
|
|
|
|
// shrink wrap rows to height of tallest cell in that row
|
2001-03-13 06:38:59 +00:00
|
|
|
PRBool isTableUnconstrainedReflow =
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aReflowState.parentReflowState->availableWidth);
|
2000-02-11 03:55:33 +00:00
|
|
|
|
2001-04-09 14:21:24 +00:00
|
|
|
PRBool isPaginated;
|
|
|
|
aPresContext->IsPaginated(&isPaginated);
|
2001-03-13 06:38:59 +00:00
|
|
|
// Avoid calling CalculateRowHeights. We can avoid it if the table is going to be
|
2000-02-11 03:55:33 +00:00
|
|
|
// doing a pass 2 reflow. In the case where the table is getting an unconstrained
|
|
|
|
// reflow, then we need to do this because the table will skip the pass 2 reflow,
|
|
|
|
// but we need to correctly calculate the row group height and we can't if there
|
|
|
|
// are row spans unless we do this step
|
2001-04-02 03:21:58 +00:00
|
|
|
if ((eReflowReason_Initial != aReflowState.reason) ||
|
|
|
|
isTableUnconstrainedReflow ||
|
|
|
|
isPaginated) {
|
1998-11-20 01:01:25 +00:00
|
|
|
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState);
|
2001-03-13 06:38:59 +00:00
|
|
|
haveDesiredHeight = PR_TRUE;
|
1998-11-20 01:01:25 +00:00
|
|
|
}
|
1998-12-14 01:24:11 +00:00
|
|
|
|
|
|
|
// See if all the frames fit
|
2001-03-13 06:38:59 +00:00
|
|
|
if (aDesiredSize.height > aReflowState.availableHeight) {
|
1998-12-14 01:24:11 +00:00
|
|
|
// Nope, find a place to split the row group
|
1999-02-22 03:28:00 +00:00
|
|
|
SplitRowGroup(aPresContext, aDesiredSize, aReflowState, tableFrame, aStatus);
|
1998-12-14 01:24:11 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// just set our width to what was available. The table will calculate the width and not use our value.
|
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
if (!haveDesiredHeight) {
|
|
|
|
// calculate the height based on the rect of the last row
|
|
|
|
aDesiredSize.height = GetHeightOfRows(aPresContext);
|
1999-08-30 22:30:32 +00:00
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
|
2001-01-25 15:55:51 +00:00
|
|
|
#if defined DEBUG_TABLE_REFLOW | DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState, &aDesiredSize, aStatus);
|
|
|
|
#endif
|
1998-10-14 16:32:45 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowGroupFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-14 16:32:45 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// determine if this frame is the target or not
|
2001-03-13 06:38:59 +00:00
|
|
|
nsIFrame* target = nsnull;
|
1998-11-04 20:09:19 +00:00
|
|
|
rv = aReflowState.reflowState.reflowCommand->GetTarget(target);
|
2001-03-13 06:38:59 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && target) {
|
|
|
|
if (this == target)
|
1998-11-04 20:09:19 +00:00
|
|
|
rv = IR_TargetIsMe(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2001-03-13 06:38:59 +00:00
|
|
|
else {
|
1998-10-14 16:32:45 +00:00
|
|
|
// Get the next frame in the reflow chain
|
|
|
|
nsIFrame* nextFrame;
|
1998-11-04 20:09:19 +00:00
|
|
|
aReflowState.reflowState.reflowCommand->GetNext(nextFrame);
|
1998-10-14 16:32:45 +00:00
|
|
|
|
1998-11-04 20:09:19 +00:00
|
|
|
rv = IR_TargetIsChild(aPresContext, aDesiredSize, aReflowState, aStatus, nextFrame);
|
1998-10-14 16:32:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-08-01 22:01:37 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsTableRowGroupFrame::AppendFrames(nsIPresContext* aPresContext,
|
1999-08-01 22:01:37 +00:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
1999-12-13 22:56:31 +00:00
|
|
|
// collect the new row frames in an array
|
|
|
|
nsVoidArray rows;
|
|
|
|
for (nsIFrame* rowFrame = aFrameList; rowFrame; rowFrame->GetNextSibling(&rowFrame)) {
|
2001-03-13 06:38:59 +00:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
rowFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType.get()) {
|
1999-12-13 22:56:31 +00:00
|
|
|
rows.AppendElement(rowFrame);
|
|
|
|
}
|
|
|
|
}
|
1999-08-01 22:01:37 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
PRInt32 rowIndex = GetRowCount();
|
1999-12-13 22:56:31 +00:00
|
|
|
// Append the frames to the sibling chain
|
1999-08-01 22:01:37 +00:00
|
|
|
mFrames.AppendFrames(nsnull, aFrameList);
|
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
if (rows.Count() > 0) {
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (tableFrame) {
|
2000-09-14 06:49:47 +00:00
|
|
|
tableFrame->AppendRows(*aPresContext, *this, rowIndex, rows);
|
1999-10-29 20:25:13 +00:00
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
2001-03-13 06:38:59 +00:00
|
|
|
nsTableFrame::AppendDirtyReflowCommand(&aPresShell, this);
|
|
|
|
if (tableFrame->RowIsSpannedInto(rowIndex)) {
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-10-29 20:25:13 +00:00
|
|
|
}
|
1999-08-01 22:01:37 +00:00
|
|
|
}
|
1999-08-02 02:18:33 +00:00
|
|
|
}
|
1999-08-01 22:01:37 +00:00
|
|
|
|
1999-08-02 02:18:33 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-01 22:01:37 +00:00
|
|
|
|
1999-08-02 02:18:33 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsTableRowGroupFrame::InsertFrames(nsIPresContext* aPresContext,
|
1999-08-02 02:18:33 +00:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2001-08-06 14:48:09 +00:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (!tableFrame) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "no table frame");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-13 22:56:31 +00:00
|
|
|
// collect the new row frames in an array
|
|
|
|
nsVoidArray rows;
|
2001-08-06 14:48:09 +00:00
|
|
|
PRBool gotFirstRow = PR_FALSE;
|
1999-12-13 22:56:31 +00:00
|
|
|
for (nsIFrame* rowFrame = aFrameList; rowFrame; rowFrame->GetNextSibling(&rowFrame)) {
|
2001-03-13 06:38:59 +00:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
rowFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType.get()) {
|
1999-12-13 22:56:31 +00:00
|
|
|
rows.AppendElement(rowFrame);
|
2001-08-06 14:48:09 +00:00
|
|
|
if (!gotFirstRow) {
|
|
|
|
((nsTableRowFrame*)rowFrame)->SetFirstInserted(PR_TRUE);
|
|
|
|
gotFirstRow = PR_TRUE;
|
|
|
|
tableFrame->SetRowInserted(PR_TRUE);
|
|
|
|
}
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
|
|
|
}
|
1999-08-02 02:18:33 +00:00
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
// Insert the frames in the sibling chain
|
1999-08-02 02:18:33 +00:00
|
|
|
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
PRInt32 numRows = rows.Count();
|
|
|
|
if (numRows > 0) {
|
2001-08-06 14:48:09 +00:00
|
|
|
nsTableRowFrame* prevRow = (nsTableRowFrame *)nsTableFrame::GetFrameAtOrBefore(aPresContext, this, aPrevFrame, nsLayoutAtoms::tableRowFrame);
|
|
|
|
PRInt32 rowIndex = (prevRow) ? prevRow->GetRowIndex() + 1 : 0;
|
|
|
|
tableFrame->InsertRows(*aPresContext, *this, rows, rowIndex, PR_TRUE);
|
|
|
|
|
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
|
|
|
nsTableFrame::AppendDirtyReflowCommand(&aPresShell, this);
|
|
|
|
if (tableFrame->RowIsSpannedInto(rowIndex) ||
|
|
|
|
tableFrame->RowHasSpanningCells(rowIndex + numRows - 1)) {
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
|
|
|
}
|
1999-08-02 02:18:33 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsTableRowGroupFrame::RemoveFrame(nsIPresContext* aPresContext,
|
1999-08-02 02:18:33 +00:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
1999-12-13 22:56:31 +00:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (tableFrame) {
|
2001-03-13 06:38:59 +00:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
aOldFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType.get()) {
|
|
|
|
// remove the rows from the table (and flag a rebalance)
|
|
|
|
tableFrame->RemoveRows(*aPresContext, (nsTableRowFrame &)*aOldFrame, 1, PR_TRUE);
|
1999-08-02 02:18:33 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// XXX this could be optimized (see nsTableFrame::RemoveRows)
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-08-02 02:18:33 +00:00
|
|
|
// Because we haven't added any new frames we don't need to do a pass1
|
2001-03-13 06:38:59 +00:00
|
|
|
// reflow. Just generate a reflow command so we reflow the table
|
|
|
|
nsTableFrame::AppendDirtyReflowCommand(&aPresShell, this);
|
1999-08-01 22:01:37 +00:00
|
|
|
}
|
|
|
|
}
|
1999-12-13 22:56:31 +00:00
|
|
|
mFrames.DestroyFrame(aPresContext, aOldFrame);
|
1999-08-01 22:01:37 +00:00
|
|
|
|
1999-08-03 02:41:27 +00:00
|
|
|
return NS_OK;
|
1999-08-01 22:01:37 +00:00
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-14 16:32:45 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_FRAME_COMPLETE;
|
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetType(type);
|
2001-03-13 06:38:59 +00:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case nsIReflowCommand::ReflowDirty: {
|
|
|
|
nsRowGroupReflowState state(aReflowState);
|
|
|
|
state.reason = eReflowReason_Resize;
|
|
|
|
// Reflow the dirty child frames. Typically this is newly added frames.
|
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, state, aStatus,
|
|
|
|
nsnull, PR_TRUE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case nsIReflowCommand::StyleChanged :
|
|
|
|
rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
break;
|
|
|
|
case nsIReflowCommand::ContentChanged :
|
|
|
|
NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTYETIMPLEMENTED("unexpected reflow command type");
|
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
1998-10-14 16:32:45 +00:00
|
|
|
}
|
|
|
|
|
1999-03-09 05:28:44 +00:00
|
|
|
// XXX If we have a next-in-flow, then we're not complete
|
|
|
|
if (mNextInFlow) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
1998-10-14 16:32:45 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
nscoord
|
|
|
|
nsTableRowGroupFrame::GetHeightOfRows(nsIPresContext* aPresContext)
|
1999-06-14 08:22:47 +00:00
|
|
|
{
|
2000-04-28 21:05:31 +00:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 06:38:59 +00:00
|
|
|
if (!tableFrame) return 0;
|
2000-04-28 21:05:31 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
nscoord height = 0;
|
2000-04-28 21:05:31 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// enumerate the rows and total their heights
|
2000-04-28 21:05:31 +00:00
|
|
|
nsIFrame* rowFrame = nsnull;
|
|
|
|
rv = FirstChild(aPresContext, nsnull, &rowFrame);
|
2001-03-13 06:38:59 +00:00
|
|
|
PRInt32 numRows = 0;
|
|
|
|
while ((NS_SUCCEEDED(rv)) && rowFrame) {
|
2000-04-28 21:05:31 +00:00
|
|
|
const nsStyleDisplay* rowDisplay;
|
1999-06-14 08:22:47 +00:00
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
|
2000-04-28 21:05:31 +00:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
|
1999-06-14 08:22:47 +00:00
|
|
|
nsRect rowRect;
|
|
|
|
rowFrame->GetRect(rowRect);
|
2001-03-13 06:38:59 +00:00
|
|
|
height += rowRect.height;
|
|
|
|
numRows++;
|
1999-06-14 08:22:47 +00:00
|
|
|
}
|
1999-06-23 03:02:21 +00:00
|
|
|
GetNextFrame(rowFrame, &rowFrame);
|
1999-06-14 08:22:47 +00:00
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
if (numRows > 1) {
|
|
|
|
height += (numRows - 1) * tableFrame->GetCellSpacingY(); // add in cell spacing
|
|
|
|
}
|
|
|
|
|
|
|
|
return height;
|
1999-06-14 08:22:47 +00:00
|
|
|
}
|
|
|
|
|
1999-08-19 03:51:25 +00:00
|
|
|
// Recovers the reflow state to what it should be if aKidFrame is about
|
2001-03-13 06:38:59 +00:00
|
|
|
// to be reflowed. Restores availSize, y
|
1999-08-19 03:51:25 +00:00
|
|
|
nsresult
|
2001-03-13 06:38:59 +00:00
|
|
|
nsTableRowGroupFrame::RecoverState(nsRowGroupReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame)
|
1999-08-19 03:51:25 +00:00
|
|
|
{
|
2000-05-10 00:54:00 +00:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
|
|
|
|
|
1999-08-19 03:51:25 +00:00
|
|
|
// Walk the list of children looking for aKidFrame
|
|
|
|
for (nsIFrame* frame = mFrames.FirstChild(); frame; frame->GetNextSibling(&frame)) {
|
|
|
|
if (frame == aKidFrame) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the running y-offset
|
|
|
|
nsSize kidSize;
|
|
|
|
frame->GetSize(kidSize);
|
2000-05-10 00:54:00 +00:00
|
|
|
aReflowState.y += cellSpacingY + kidSize.height;
|
1999-08-19 03:51:25 +00:00
|
|
|
|
|
|
|
// If our height is constrained then update the available height
|
2001-03-13 06:38:59 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.availSize.height) {
|
1999-08-19 03:51:25 +00:00
|
|
|
aReflowState.availSize.height -= kidSize.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-01 05:16:12 +00:00
|
|
|
PRBool
|
|
|
|
nsTableRowGroupFrame::IsSimpleRowFrame(nsTableFrame* aTableFrame,
|
|
|
|
nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
// Make sure it's a row frame and not a row group frame
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
|
|
|
|
aFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (frameType.get() == nsLayoutAtoms::tableRowFrame) {
|
|
|
|
PRInt32 rowIndex = ((nsTableRowFrame*)aFrame)->GetRowIndex();
|
|
|
|
|
|
|
|
// It's a simple row frame if there are no cells that span into or
|
|
|
|
// across the row
|
|
|
|
if (!aTableFrame->RowIsSpannedInto(rowIndex) &&
|
|
|
|
!aTableFrame->RowHasSpanningCells(rowIndex)) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-25 22:40:21 +00:00
|
|
|
nscoord
|
|
|
|
GetFrameYMost(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
aFrame->GetRect(rect);
|
|
|
|
return rect.YMost();
|
|
|
|
}
|
|
|
|
|
2000-09-15 06:11:29 +00:00
|
|
|
nsIFrame*
|
|
|
|
GetLastRowSibling(nsIFrame* aRowFrame)
|
|
|
|
{
|
|
|
|
nsIFrame* lastRowFrame = nsnull;
|
|
|
|
nsIFrame* lastFrame = aRowFrame;
|
|
|
|
while (lastFrame) {
|
|
|
|
nsCOMPtr<nsIAtom> fType;
|
|
|
|
lastFrame->GetFrameType(getter_AddRefs(fType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == fType.get()) {
|
|
|
|
lastRowFrame = lastFrame;
|
|
|
|
}
|
|
|
|
lastFrame->GetNextSibling(&lastFrame);
|
|
|
|
}
|
|
|
|
return lastRowFrame;
|
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowGroupFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame* aNextFrame)
|
1998-10-14 16:32:45 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
nsresult rv;
|
2000-01-17 17:45:17 +00:00
|
|
|
|
1999-08-19 03:51:25 +00:00
|
|
|
// Recover the state as if aNextFrame is about to be reflowed
|
2001-03-13 06:38:59 +00:00
|
|
|
RecoverState(aReflowState, aNextFrame);
|
1998-10-14 16:32:45 +00:00
|
|
|
|
|
|
|
// Remember the old rect
|
|
|
|
nsRect oldKidRect;
|
|
|
|
aNextFrame->GetRect(oldKidRect);
|
|
|
|
|
2000-01-17 17:45:17 +00:00
|
|
|
// Reflow the child giving it as much room as it wants. We'll deal with
|
|
|
|
// splitting later after final determination of rows heights taking into
|
|
|
|
// account cells with row spans...
|
|
|
|
nsSize kidAvailSize(aReflowState.availSize.width, NS_UNCONSTRAINEDSIZE);
|
1999-08-19 03:51:25 +00:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
2000-01-17 17:45:17 +00:00
|
|
|
aNextFrame, kidAvailSize);
|
1999-08-30 22:30:32 +00:00
|
|
|
nsSize kidMaxElementSize;
|
2000-03-09 08:45:26 +00:00
|
|
|
nsHTMLReflowMetrics desiredSize(aDesiredSize.maxElementSize ? &kidMaxElementSize : nsnull,
|
|
|
|
aDesiredSize.mFlags);
|
1998-10-14 16:32:45 +00:00
|
|
|
|
2000-01-17 17:45:17 +00:00
|
|
|
// Pass along the reflow command
|
1999-11-19 15:33:29 +00:00
|
|
|
rv = ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState,
|
|
|
|
0, aReflowState.y, 0, aStatus);
|
1998-10-14 16:32:45 +00:00
|
|
|
|
1999-08-19 03:51:25 +00:00
|
|
|
// Place the row frame
|
|
|
|
nsRect kidRect(0, aReflowState.y, desiredSize.width, desiredSize.height);
|
2001-03-13 06:38:59 +00:00
|
|
|
PlaceChild(aPresContext, aReflowState, aNextFrame, desiredSize);
|
1999-08-19 03:51:25 +00:00
|
|
|
|
|
|
|
// See if the table needs a reflow (e.g., if the column widths have
|
|
|
|
// changed). If so, just return and don't bother adjusting the rows
|
|
|
|
// that follow
|
|
|
|
if (!aReflowState.tableFrame->NeedsReflow(aReflowState.reflowState)) {
|
2001-05-14 14:28:00 +00:00
|
|
|
// Only call CalculateRowHeights() if necessary since it can be expensive
|
|
|
|
PRBool needToCalcRowHeights = PR_FALSE;
|
1999-09-01 05:16:12 +00:00
|
|
|
if (IsSimpleRowFrame(aReflowState.tableFrame, aNextFrame)) {
|
1999-09-13 03:19:39 +00:00
|
|
|
// See if the row changed height
|
|
|
|
if (oldKidRect.height == desiredSize.height) {
|
|
|
|
// We don't need to do any painting. The row frame has made sure that
|
|
|
|
// the cell is properly positioned, and done any necessary repainting.
|
|
|
|
// Just calculate our desired height
|
2000-09-15 06:11:29 +00:00
|
|
|
aDesiredSize.height = GetFrameYMost(GetLastRowSibling(mFrames.FirstChild()));
|
1999-09-13 03:19:39 +00:00
|
|
|
} else {
|
|
|
|
// Inform the row of its new height.
|
|
|
|
((nsTableRowFrame*)aNextFrame)->DidResize(aPresContext, aReflowState.reflowState);
|
2001-05-14 14:28:00 +00:00
|
|
|
if (aReflowState.tableFrame->IsAutoHeight()) {
|
|
|
|
// Because other cells in the row may need to be be aligned differently,
|
|
|
|
// repaint the entire row
|
|
|
|
// XXX Improve this so the row knows it should bitblt (or repaint) those
|
|
|
|
// cells that change position...
|
|
|
|
Invalidate(aPresContext, kidRect);
|
|
|
|
|
|
|
|
// Invalidate the area we're offseting. 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...
|
|
|
|
if (kidRect.YMost() < mRect.height) {
|
|
|
|
nsRect dirtyRect(0, kidRect.YMost(),
|
|
|
|
mRect.width, mRect.height - kidRect.YMost());
|
|
|
|
Invalidate(aPresContext, dirtyRect);
|
|
|
|
}
|
1999-09-13 03:19:39 +00:00
|
|
|
|
2001-05-14 14:28:00 +00:00
|
|
|
// Adjust the frames that follow
|
|
|
|
AdjustSiblingsAfterReflow(aPresContext, aReflowState, aNextFrame,
|
|
|
|
desiredSize.height - oldKidRect.height);
|
|
|
|
aDesiredSize.height = aReflowState.y;
|
1999-09-13 03:19:39 +00:00
|
|
|
}
|
2001-05-14 14:28:00 +00:00
|
|
|
else needToCalcRowHeights = PR_TRUE;
|
1999-09-13 03:19:39 +00:00
|
|
|
}
|
1999-08-19 03:51:25 +00:00
|
|
|
} else {
|
2000-05-25 22:40:21 +00:00
|
|
|
if (desiredSize.mNothingChanged) { // mNothingChanges currently only works when a cell is the target
|
|
|
|
// the cell frame did not change size. Just calculate our desired height
|
2000-09-15 06:11:29 +00:00
|
|
|
aDesiredSize.height = GetFrameYMost(GetLastRowSibling(mFrames.FirstChild()));
|
2001-05-14 14:28:00 +00:00
|
|
|
}
|
|
|
|
else needToCalcRowHeights = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (needToCalcRowHeights) {
|
|
|
|
// Adjust the frames that follow...
|
|
|
|
// XXX is this needed since CalculateRowHeights will be called?
|
|
|
|
//AdjustSiblingsAfterReflow(aPresContext, aReflowState, aNextFrame,
|
|
|
|
// desiredSize.height - oldKidRect.height);
|
1999-12-16 00:37:03 +00:00
|
|
|
|
2001-05-14 14:28:00 +00:00
|
|
|
// Now recalculate the row heights
|
|
|
|
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState.reflowState);
|
1999-12-16 00:37:03 +00:00
|
|
|
|
2001-05-14 14:28:00 +00:00
|
|
|
// Because we don't know what changed repaint everything.
|
|
|
|
// XXX We should change CalculateRowHeights() to return the bounding
|
|
|
|
// rect of what changed. Or whether anything moved or changed size...
|
|
|
|
nsRect dirtyRect(0, 0, mRect.width, mRect.height);
|
|
|
|
Invalidate(aPresContext, dirtyRect);
|
1999-08-19 03:51:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return our desired width
|
2001-03-13 06:38:59 +00:00
|
|
|
//aDesiredSize.width = aReflowState.reflowState.availableWidth;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-03-09 05:28:44 +00:00
|
|
|
if (mNextInFlow) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
|
1998-10-14 16:32:45 +00:00
|
|
|
return rv;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowGroupFrame::IR_StyleChanged(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-30 07:57:44 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// we presume that all the easy optimizations were done in the nsHTMLStyleSheet before we were called here
|
|
|
|
// XXX: we can optimize this when we know which style attribute changed
|
2001-03-13 06:38:59 +00:00
|
|
|
aReflowState.tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1998-10-30 07:57:44 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-02-24 05:54:31 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::tableRowGroupFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-15 17:58:24 +00:00
|
|
|
/* ----- global methods ----- */
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-09-15 17:58:24 +00:00
|
|
|
nsresult
|
1999-12-04 23:49:50 +00:00
|
|
|
NS_NewTableRowGroupFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-05-11 22:03:29 +00:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-04 23:49:50 +00:00
|
|
|
nsTableRowGroupFrame* it = new (aPresShell) nsTableRowGroupFrame;
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-11 22:03:29 +00:00
|
|
|
*aNewFrame = it;
|
1998-04-13 20:24:54 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-23 12:35:34 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::Init(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Let the base class do its processing
|
|
|
|
rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext,
|
|
|
|
aPrevInFlow);
|
|
|
|
|
|
|
|
// record that children that are ignorable whitespace should be excluded
|
|
|
|
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetFrameName(nsString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName("TableRowGroup", aResult);
|
|
|
|
}
|
1998-11-20 01:01:25 +00:00
|
|
|
|
1999-08-31 03:09:40 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
|
|
|
{
|
1999-09-01 01:02:16 +00:00
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-31 03:09:40 +00:00
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
PRUint32 sum = sizeof(*this);
|
|
|
|
*aResult = sum;
|
|
|
|
return NS_OK;
|
1999-08-31 03:09:40 +00:00
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|
2000-05-11 01:04:39 +00:00
|
|
|
|
|
|
|
//nsILineIterator methods for nsTableFrame
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetNumLines(PRInt32* aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
2001-03-13 06:38:59 +00:00
|
|
|
*aResult = GetRowCount();
|
|
|
|
return *aResult; // XXX should return NS_OK
|
2000-05-11 01:04:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetDirection(PRBool* aIsRightToLeft)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsRightToLeft);
|
|
|
|
*aIsRightToLeft = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 06:38:59 +00:00
|
|
|
nsTableRowGroupFrame::GetLine(PRInt32 aLineNumber,
|
|
|
|
nsIFrame** aFirstFrameOnLine,
|
|
|
|
PRInt32* aNumFramesOnLine,
|
|
|
|
nsRect& aLineBounds,
|
|
|
|
PRUint32* aLineFlags)
|
2000-05-11 01:04:39 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFirstFrameOnLine);
|
|
|
|
NS_ENSURE_ARG_POINTER(aNumFramesOnLine);
|
|
|
|
NS_ENSURE_ARG_POINTER(aLineFlags);
|
|
|
|
|
2000-05-13 09:02:27 +00:00
|
|
|
nsTableFrame* parentFrame = nsnull;
|
|
|
|
if (NS_FAILED(nsTableFrame::GetTableFrame(this, parentFrame)))
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-05-11 01:04:39 +00:00
|
|
|
|
|
|
|
nsTableCellMap* cellMap = parentFrame->GetCellMap();
|
|
|
|
if(!cellMap)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
if(aLineNumber >= cellMap->GetRowCount())
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
*aLineFlags = 0;/// should we fill these in later?
|
|
|
|
// not gonna touch aLineBounds right now
|
|
|
|
|
|
|
|
CellData* firstCellData = cellMap->GetCellAt(aLineNumber, 0);
|
2001-01-26 23:40:36 +00:00
|
|
|
if(!firstCellData)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2000-05-11 01:04:39 +00:00
|
|
|
*aFirstFrameOnLine = (nsIFrame*)firstCellData->GetCellFrame();
|
2000-05-14 00:10:25 +00:00
|
|
|
if(!(*aFirstFrameOnLine))
|
|
|
|
{
|
|
|
|
while((aLineNumber > 0)&&(!(*aFirstFrameOnLine)))
|
|
|
|
{
|
|
|
|
aLineNumber--;
|
|
|
|
firstCellData = cellMap->GetCellAt(aLineNumber, 0);
|
|
|
|
*aFirstFrameOnLine = (nsIFrame*)firstCellData->GetCellFrame();
|
|
|
|
}
|
|
|
|
}
|
2000-05-11 01:04:39 +00:00
|
|
|
*aNumFramesOnLine = cellMap->GetNumCellsOriginatingInRow(aLineNumber);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 06:38:59 +00:00
|
|
|
nsTableRowGroupFrame::FindLineContaining(nsIFrame* aFrame,
|
|
|
|
PRInt32* aLineNumberResult)
|
2000-05-11 01:04:39 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFrame);
|
|
|
|
NS_ENSURE_ARG_POINTER(aLineNumberResult);
|
|
|
|
|
2001-07-17 20:27:01 +00:00
|
|
|
// make sure it is a rowFrame in the RowGroup
|
|
|
|
// - it should be, but we do not validate in every case (see bug 88849)
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
aFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (frameType.get() != nsLayoutAtoms::tableRowFrame) {
|
|
|
|
NS_WARNING("RowGroup contains a frame that is not a row");
|
|
|
|
*aLineNumberResult = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2000-05-11 01:04:39 +00:00
|
|
|
nsTableRowFrame* rowFrame = (nsTableRowFrame*)aFrame;
|
|
|
|
*aLineNumberResult = rowFrame->GetRowIndex();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 06:38:59 +00:00
|
|
|
nsTableRowGroupFrame::FindLineAt(nscoord aY,
|
|
|
|
PRInt32* aLineNumberResult)
|
2000-05-11 01:04:39 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2001-03-12 22:25:55 +00:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::CheckLineOrder(PRInt32 aLine,
|
|
|
|
PRBool *aIsReordered,
|
|
|
|
nsIFrame **aFirstVisual,
|
|
|
|
nsIFrame **aLastVisual)
|
|
|
|
{
|
|
|
|
*aIsReordered = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
2000-05-11 01:04:39 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 06:38:59 +00:00
|
|
|
nsTableRowGroupFrame::FindFrameAt(PRInt32 aLineNumber,
|
|
|
|
nscoord aX,
|
2001-03-12 22:25:55 +00:00
|
|
|
#ifdef IBMBIDI
|
2001-03-13 06:38:59 +00:00
|
|
|
PRBool aCouldBeReordered,
|
2001-03-12 22:25:55 +00:00
|
|
|
#endif // IBMBIDI
|
2001-03-13 06:38:59 +00:00
|
|
|
nsIFrame** aFrameFound,
|
|
|
|
PRBool* aXIsBeforeFirstFrame,
|
|
|
|
PRBool* aXIsAfterLastFrame)
|
2000-05-11 01:04:39 +00:00
|
|
|
{
|
|
|
|
PRInt32 cellCount = 0;
|
|
|
|
CellData* cellData;
|
|
|
|
nsIFrame* tempFrame;
|
|
|
|
nsRect tempRect;
|
|
|
|
nsRect& tempRectRef = tempRect;
|
|
|
|
nsresult rv;
|
|
|
|
|
2000-05-13 09:02:27 +00:00
|
|
|
nsTableFrame* parentFrame = nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, parentFrame);
|
2000-05-11 01:04:39 +00:00
|
|
|
nsTableCellMap* cellMap = parentFrame->GetCellMap();
|
|
|
|
if(!cellMap)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
cellCount = cellMap->GetNumCellsOriginatingInRow(aLineNumber);
|
|
|
|
|
|
|
|
*aXIsBeforeFirstFrame = PR_FALSE;
|
|
|
|
*aXIsAfterLastFrame = PR_FALSE;
|
|
|
|
|
2000-05-14 00:10:25 +00:00
|
|
|
PRBool gotParentRect = PR_FALSE;
|
2000-05-11 01:04:39 +00:00
|
|
|
for(int i =0;i < cellCount; i++)
|
|
|
|
{
|
|
|
|
cellData = cellMap->GetCellAt(aLineNumber, i);
|
|
|
|
tempFrame = (nsIFrame*)cellData->GetCellFrame();
|
2000-05-14 00:10:25 +00:00
|
|
|
|
|
|
|
if(!tempFrame)
|
|
|
|
continue;
|
2000-05-11 01:04:39 +00:00
|
|
|
|
|
|
|
tempFrame->GetRect(tempRectRef);//offsetting x to be in row coordinates
|
2000-05-14 00:10:25 +00:00
|
|
|
if(!gotParentRect)
|
2000-05-11 01:04:39 +00:00
|
|
|
{//only do this once
|
|
|
|
nsRect parentRect;
|
|
|
|
nsRect& parentRectRef = parentRect;
|
2000-06-08 02:51:58 +00:00
|
|
|
nsIFrame* tempParentFrame;
|
2000-05-11 01:04:39 +00:00
|
|
|
|
2000-06-08 02:51:58 +00:00
|
|
|
rv = tempFrame->GetParent(&tempParentFrame);
|
2000-05-11 01:04:39 +00:00
|
|
|
|
2000-06-08 02:51:58 +00:00
|
|
|
if(NS_FAILED(rv) || !tempParentFrame)
|
2000-05-11 01:04:39 +00:00
|
|
|
return rv?rv:NS_ERROR_FAILURE;
|
|
|
|
|
2000-06-08 02:51:58 +00:00
|
|
|
tempParentFrame->GetRect(parentRectRef);
|
2000-05-11 01:04:39 +00:00
|
|
|
aX -= parentRect.x;
|
2000-05-14 00:10:25 +00:00
|
|
|
gotParentRect = PR_TRUE;
|
2000-05-11 01:04:39 +00:00
|
|
|
}
|
|
|
|
|
2000-05-14 00:10:25 +00:00
|
|
|
if(i==0 &&(aX <= 0))//short circuit for negative x coords
|
2000-05-11 01:04:39 +00:00
|
|
|
{
|
|
|
|
*aXIsBeforeFirstFrame = PR_TRUE;
|
|
|
|
*aFrameFound = tempFrame;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-05-14 00:10:25 +00:00
|
|
|
if(aX < tempRect.x)
|
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2000-05-11 01:04:39 +00:00
|
|
|
if(aX < (tempRect.x + tempRect.width))
|
|
|
|
{
|
|
|
|
*aFrameFound = tempFrame;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//x coord not found in frame, return last frame
|
|
|
|
*aXIsAfterLastFrame = PR_TRUE;
|
|
|
|
*aFrameFound = tempFrame;
|
2000-05-14 00:10:25 +00:00
|
|
|
if(!(*aFrameFound))
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-05-11 01:04:39 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 06:38:59 +00:00
|
|
|
nsTableRowGroupFrame::GetNextSiblingOnLine(nsIFrame*& aFrame,
|
|
|
|
PRInt32 aLineNumber)
|
2000-05-11 01:04:39 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFrame);
|
|
|
|
|
|
|
|
nsITableCellLayout* cellFrame;
|
|
|
|
nsresult result = aFrame->QueryInterface(NS_GET_IID(nsITableCellLayout),(void**)&cellFrame);
|
|
|
|
|
|
|
|
if(NS_FAILED(result) || !cellFrame)
|
|
|
|
return result?result:NS_ERROR_FAILURE;
|
|
|
|
|
2000-05-13 09:02:27 +00:00
|
|
|
nsTableFrame* parentFrame = nsnull;
|
|
|
|
result = nsTableFrame::GetTableFrame(this, parentFrame);
|
2000-05-11 01:04:39 +00:00
|
|
|
nsTableCellMap* cellMap = parentFrame->GetCellMap();
|
|
|
|
if(!cellMap)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
|
|
|
|
PRInt32 colIndex;
|
|
|
|
PRInt32& colIndexRef = colIndex;
|
|
|
|
cellFrame->GetColIndex(colIndexRef);
|
|
|
|
|
|
|
|
CellData* cellData = cellMap->GetCellAt(aLineNumber, colIndex + 1);
|
|
|
|
|
|
|
|
if(!cellData)// if this isnt a valid cell, drop down and check the next line
|
|
|
|
{
|
|
|
|
cellData = cellMap->GetCellAt(aLineNumber + 1, 0);
|
|
|
|
if(!cellData)
|
|
|
|
{
|
|
|
|
//*aFrame = nsnull;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
2000-05-14 00:10:25 +00:00
|
|
|
if(!aFrame)
|
|
|
|
{
|
|
|
|
//PRInt32 numCellsInRow = cellMap->GetNumCellsOriginatingInRow(aLineNumber) - 1;
|
|
|
|
PRInt32 tempCol = colIndex + 1;
|
|
|
|
PRInt32 tempRow = aLineNumber;
|
|
|
|
while((tempCol > 0) && (!aFrame))
|
|
|
|
{
|
|
|
|
tempCol--;
|
|
|
|
cellData = cellMap->GetCellAt(aLineNumber, tempCol);
|
|
|
|
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
|
|
|
if(!aFrame && (tempCol==0))
|
|
|
|
{
|
|
|
|
while((tempRow > 0) && (!aFrame))
|
|
|
|
{
|
|
|
|
tempRow--;
|
|
|
|
cellData = cellMap->GetCellAt(tempRow, 0);
|
|
|
|
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-05-11 01:04:39 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-11 14:56:29 +00:00
|
|
|
//end nsLineIterator methods
|
|
|
|
|