2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#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"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIContent.h"
|
1998-04-15 01:49:29 +04:00
|
|
|
#include "nsIView.h"
|
2002-05-10 22:22:41 +04:00
|
|
|
#include "nsReflowPath.h"
|
1999-01-18 02:35:56 +03:00
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
1999-02-24 07:03:50 +03:00
|
|
|
#include "nsIPresShell.h"
|
1999-02-24 08:54:31 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-06-08 01:10:25 +04:00
|
|
|
#include "nsCSSRendering.h"
|
1999-08-02 02:01:37 +04:00
|
|
|
#include "nsHTMLParts.h"
|
2004-01-22 02:05:10 +03:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-05-11 05:04:39 +04:00
|
|
|
#include "nsCellMap.h"//table cell navigation
|
|
|
|
|
2001-01-25 18:55:51 +03:00
|
|
|
nsTableRowGroupFrame::nsTableRowGroupFrame()
|
|
|
|
{
|
2001-04-09 18:21:24 +04:00
|
|
|
SetRepeatable(PR_FALSE);
|
2001-01-25 18:55:51 +03:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
mTimer = new nsReflowTimer(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableRowGroupFrame::~nsTableRowGroupFrame()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflowDone(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/* ----------- nsTableRowGroupFrame ---------- */
|
2000-05-14 04:10:25 +04:00
|
|
|
nsrefcnt nsTableRowGroupFrame::AddRef(void)
|
|
|
|
{
|
|
|
|
return 1;//implementation of nsLineIterator
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsTableRowGroupFrame::Release(void)
|
|
|
|
{
|
|
|
|
return 1;//implementation of nsLineIterator
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
|
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;
|
2000-05-11 05:04:39 +04:00
|
|
|
}
|
2004-03-09 09:48:35 +03:00
|
|
|
else if (aIID.Equals(NS_GET_IID(nsILineIteratorNavigator)))
|
2000-05-11 05:04:39 +04:00
|
|
|
{ // note there is no addref here, frames are not addref'd
|
2000-05-16 12:11:14 +04:00
|
|
|
*aInstancePtr = (void*)(nsILineIteratorNavigator*)this;
|
2000-05-11 05:04:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else {
|
1999-01-30 18:52:19 +03:00
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-12 07:40:17 +03:00
|
|
|
/* virtual */ PRBool
|
|
|
|
nsTableRowGroupFrame::IsContainingBlock() const
|
2001-11-05 03:15:51 +03:00
|
|
|
{
|
2004-03-12 07:40:17 +03:00
|
|
|
return PR_TRUE;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
PRInt32
|
|
|
|
nsTableRowGroupFrame::GetRowCount()
|
|
|
|
{
|
|
|
|
PRInt32 count = 0; // init return
|
1998-09-16 00:36:42 +04:00
|
|
|
|
|
|
|
// loop through children, adding one to aCount for every legit row
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame* childFrame = GetFirstFrame();
|
|
|
|
while (PR_TRUE) {
|
|
|
|
if (!childFrame)
|
1998-09-16 00:36:42 +04:00
|
|
|
break;
|
2003-05-15 07:42:21 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childFrame->GetStyleDisplay()->mDisplay)
|
2001-03-13 09:38:59 +03:00
|
|
|
count++;
|
1999-06-23 07:02:21 +04:00
|
|
|
GetNextFrame(childFrame, &childFrame);
|
1998-09-16 00:36:42 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
return count;
|
1998-09-16 00:36:42 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
PRInt32 nsTableRowGroupFrame::GetStartRowIndex()
|
|
|
|
{
|
|
|
|
PRInt32 result = -1;
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame* childFrame = GetFirstFrame();
|
|
|
|
while (PR_TRUE) {
|
|
|
|
if (!childFrame)
|
1998-12-23 18:47:43 +03:00
|
|
|
break;
|
2003-05-15 07:42:21 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childFrame->GetStyleDisplay()->mDisplay) {
|
1998-12-23 18:47:43 +03:00
|
|
|
result = ((nsTableRowFrame *)childFrame)->GetRowIndex();
|
|
|
|
break;
|
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
GetNextFrame(childFrame, &childFrame);
|
1998-12-23 18:47:43 +03:00
|
|
|
}
|
2000-09-14 10:49:47 +04: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 18:47:43 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-03-03 19:33:57 +03:00
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::InitRepeatedFrame(nsPresContext* aPresContext,
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableRowGroupFrame* aHeaderFooterFrame)
|
1999-03-03 19:33:57 +03:00
|
|
|
{
|
2003-06-07 12:48:24 +04:00
|
|
|
nsTableRowFrame* copyRowFrame = GetFirstRow();
|
|
|
|
nsTableRowFrame* originalRowFrame = aHeaderFooterFrame->GetFirstRow();
|
2005-02-05 07:23:52 +03:00
|
|
|
AddStateBits(NS_REPEATED_ROW_OR_ROWGROUP);
|
2003-06-07 12:48:24 +04:00
|
|
|
while (copyRowFrame && originalRowFrame) {
|
2005-02-05 07:23:52 +03:00
|
|
|
copyRowFrame->AddStateBits(NS_REPEATED_ROW_OR_ROWGROUP);
|
2003-06-07 12:48:24 +04:00
|
|
|
int rowIndex = originalRowFrame->GetRowIndex();
|
|
|
|
copyRowFrame->SetRowIndex(rowIndex);
|
1999-03-03 19:33:57 +03:00
|
|
|
|
|
|
|
// For each table cell frame set its column index
|
2003-06-07 12:48:24 +04:00
|
|
|
nsTableCellFrame* originalCellFrame = originalRowFrame->GetFirstCell();
|
|
|
|
nsTableCellFrame* copyCellFrame = copyRowFrame->GetFirstCell();
|
|
|
|
while (copyCellFrame && originalCellFrame) {
|
2003-07-07 06:01:29 +04:00
|
|
|
NS_ASSERTION(originalCellFrame->GetContent() == copyCellFrame->GetContent(),
|
|
|
|
"cell frames have different content");
|
2003-06-07 12:48:24 +04:00
|
|
|
PRInt32 colIndex;
|
|
|
|
originalCellFrame->GetColIndex(colIndex);
|
2004-04-21 19:49:29 +04:00
|
|
|
copyCellFrame->SetColIndex(colIndex);
|
2003-06-07 12:48:24 +04:00
|
|
|
|
1999-03-03 19:33:57 +03:00
|
|
|
// Move to the next cell frame
|
2003-06-07 12:48:24 +04:00
|
|
|
copyCellFrame = copyCellFrame->GetNextCell();
|
|
|
|
originalCellFrame = originalCellFrame->GetNextCell();
|
1999-03-03 19:33:57 +03:00
|
|
|
}
|
2003-06-07 12:48:24 +04:00
|
|
|
|
1999-03-03 19:33:57 +03:00
|
|
|
// Move to the next row frame
|
2003-06-07 12:48:24 +04:00
|
|
|
originalRowFrame = originalRowFrame->GetNextRow();
|
|
|
|
copyRowFrame = copyRowFrame->GetNextRow();
|
1999-03-03 19:33:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-10-22 09:27:11 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_METHOD nsTableRowGroupFrame::Paint(nsPresContext* aPresContext,
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2001-09-19 16:35:19 +04:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2001-01-27 17:09:34 +03:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-09-19 16:35:19 +04:00
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-04-14 00:24:54 +04:00
|
|
|
// for debug...
|
1999-06-08 01:10:25 +04:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0,255,0));
|
1998-04-14 00:24:54 +04:00
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
2004-03-09 09:48:35 +03:00
|
|
|
|
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
|
|
|
|
//direct (not table-called) background paint
|
|
|
|
!(aFlags & (NS_PAINT_FLAG_TABLE_BG_PAINT | NS_PAINT_FLAG_TABLE_CELL_BG_PASS))) {
|
2004-04-18 22:17:00 +04:00
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
NS_ASSERTION(tableFrame, "null table frame");
|
2004-03-09 09:48:35 +03:00
|
|
|
|
2004-04-18 22:17:00 +04:00
|
|
|
TableBackgroundPainter painter(tableFrame,
|
|
|
|
TableBackgroundPainter::eOrigin_TableRowGroup,
|
|
|
|
aPresContext, aRenderingContext,
|
|
|
|
aDirtyRect);
|
|
|
|
nsresult rv = painter.PaintRowGroup(this);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
|
2004-03-09 09:48:35 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2004-03-09 09:48:35 +03:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect,
|
|
|
|
aWhichLayer, aFlags);
|
2004-11-11 18:21:52 +03:00
|
|
|
|
|
|
|
// Paint outline
|
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
const nsStyleOutline* outlineStyle = GetStyleOutline();
|
|
|
|
const nsStyleBorder* borderStyle = GetStyleBorder();
|
|
|
|
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, *borderStyle, *outlineStyle,
|
|
|
|
mStyleContext, 0);
|
1999-09-18 03:33:39 +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;
|
|
|
|
}
|
|
|
|
|
2005-09-19 06:15:54 +04:00
|
|
|
nsIFrame*
|
2005-01-01 20:26:29 +03:00
|
|
|
nsTableRowGroupFrame::GetFrameForPoint(const nsPoint& aPoint,
|
2005-09-19 06:15:54 +04:00
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-11-07 03:36:37 +03:00
|
|
|
{
|
2000-03-22 05:43:08 +03:00
|
|
|
// this should act like a block, so we need to override
|
2005-09-19 06:15:54 +04:00
|
|
|
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, PR_FALSE);
|
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
|
2001-03-13 09:38:59 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::PlaceChild(nsPresContext* aPresContext,
|
2004-03-09 09:48:35 +03:00
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
// Place and size the child
|
2001-12-07 17:51:12 +03:00
|
|
|
FinishReflowChild(aKidFrame, aPresContext, nsnull, aDesiredSize, 0, aReflowState.y, 0);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Adjust the running y-offset
|
1999-11-19 18:33:29 +03:00
|
|
|
aReflowState.y += aDesiredSize.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// If our height is constrained then update the available height
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.availSize.height) {
|
1999-11-19 18:33:29 +03:00
|
|
|
aReflowState.availSize.height -= aDesiredSize.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::InitChildReflowState(nsPresContext& aPresContext,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool aBorderCollapse,
|
|
|
|
float aPixelsToTwips,
|
|
|
|
nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
nsMargin collapseBorder;
|
|
|
|
nsMargin padding(0,0,0,0);
|
|
|
|
nsMargin* pCollapseBorder = nsnull;
|
|
|
|
if (aBorderCollapse) {
|
|
|
|
if (aReflowState.frame) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == aReflowState.frame->GetType()) {
|
2002-02-19 18:48:28 +03:00
|
|
|
nsTableRowFrame* rowFrame = (nsTableRowFrame*)aReflowState.frame;
|
|
|
|
pCollapseBorder = rowFrame->GetBCBorderWidth(aPixelsToTwips, collapseBorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aReflowState.Init(&aPresContext, -1, -1, pCollapseBorder, &padding);
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03: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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsTableRowFrame* aStartFrame,
|
2001-08-22 08:18:48 +04:00
|
|
|
PRBool aDirtyOnly,
|
2002-03-18 00:35:08 +03:00
|
|
|
nsTableRowFrame** aFirstRowReflowed,
|
|
|
|
PRBool* aPageBreakBeforeEnd)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2002-03-18 00:35:08 +03:00
|
|
|
if (aPageBreakBeforeEnd)
|
|
|
|
*aPageBreakBeforeEnd = PR_FALSE;
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
2002-02-19 18:48:28 +03:00
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame); if (!tableFrame) ABORT1(rv);
|
|
|
|
|
|
|
|
PRBool borderCollapse = tableFrame->IsBorderCollapse();
|
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
|
1999-06-23 07:02:21 +04:00
|
|
|
|
2004-03-03 21:24:20 +03:00
|
|
|
PRBool isPaginated = aPresContext->IsPaginated();
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2001-08-22 08:18:48 +04:00
|
|
|
if (aFirstRowReflowed) {
|
|
|
|
*aFirstRowReflowed = nsnull;
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame* lastReflowedRow = nsnull;
|
|
|
|
PRBool adjustSiblings = PR_TRUE;
|
|
|
|
nsIFrame* kidFrame = (aStartFrame) ? aStartFrame : mFrames.FirstChild();
|
1999-06-23 07:02:21 +04:00
|
|
|
|
2003-07-07 06:01:29 +04:00
|
|
|
for ( ; kidFrame; kidFrame = kidFrame->GetNextSibling()) {
|
1999-08-02 02:01:37 +04:00
|
|
|
// See if we should only reflow the dirty child frames
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool doReflowChild = PR_TRUE;
|
2003-07-07 06:01:29 +04:00
|
|
|
if (aDirtyOnly && ((kidFrame->GetStateBits() & NS_FRAME_IS_DIRTY) == 0)) {
|
2001-03-13 09:38:59 +03:00
|
|
|
doReflowChild = PR_FALSE;
|
1999-06-23 07:02:21 +04:00
|
|
|
}
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom* kidType = kidFrame->GetType();
|
2001-12-07 17:51:12 +03:00
|
|
|
if (aReflowState.reflowState.mFlags.mSpecialHeightReflow) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (!isPaginated && (nsLayoutAtoms::tableRowFrame == kidType &&
|
2001-11-05 03:15:51 +03:00
|
|
|
!((nsTableRowFrame*)kidFrame)->NeedSpecialReflow())) {
|
|
|
|
doReflowChild = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Reflow the row frame
|
1999-08-02 02:01:37 +04:00
|
|
|
if (doReflowChild) {
|
|
|
|
nsSize kidAvailSize(aReflowState.availSize);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (0 >= kidAvailSize.height)
|
1999-08-02 02:01:37 +04:00
|
|
|
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
|
2004-06-07 00:45:23 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(aDesiredSize.mComputeMEW);
|
2001-03-13 09:38:59 +03:00
|
|
|
desiredSize.width = desiredSize.height = desiredSize.ascent = desiredSize.descent = 0;
|
1999-08-02 02:01:37 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// Reflow the child into the available space, giving it as much height as
|
1999-08-02 02:01:37 +04: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-11-14 14:40:03 +03:00
|
|
|
// If the incremental reflow command is a StyleChanged reflow and
|
|
|
|
// it's target is the current frame, then make sure we send
|
|
|
|
// StyleChange reflow reasons down to the children so that they
|
|
|
|
// don't over-optimize their reflow.
|
|
|
|
nsReflowReason reason = aReflowState.reason;
|
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowCommand* command = aReflowState.reflowState.path->mReflowCommand;
|
|
|
|
if (command) {
|
2001-12-18 01:39:59 +03:00
|
|
|
nsReflowType type;
|
2002-05-10 22:22:41 +04:00
|
|
|
command->GetType(type);
|
2001-12-18 01:39:59 +03:00
|
|
|
if (eReflowType_StyleChanged == type) {
|
2001-11-14 14:40:03 +03:00
|
|
|
reason = eReflowReason_StyleChange;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
if (kidFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
2001-11-14 14:40:03 +03:00
|
|
|
reason = eReflowReason_Initial;
|
|
|
|
}
|
1999-08-02 02:01:37 +04:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState, kidFrame,
|
1999-08-03 06:41:27 +04:00
|
|
|
kidAvailSize, reason);
|
2002-02-19 18:48:28 +03:00
|
|
|
InitChildReflowState(*aPresContext, borderCollapse, p2t, kidReflowState);
|
1999-08-02 02:01:37 +04:00
|
|
|
|
2002-03-27 08:50:24 +03:00
|
|
|
// If this isn't the first row, then we can't be at the top of the page
|
1999-08-03 06:41:27 +04:00
|
|
|
if (kidFrame != GetFirstFrame()) {
|
2001-12-07 17:51:12 +03:00
|
|
|
kidReflowState.mFlags.mIsTopOfPage = PR_FALSE;
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
|
|
|
|
0, aReflowState.y, 0, aStatus);
|
2001-08-22 08:18:48 +04:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Place the child
|
2001-03-13 09:38:59 +03:00
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame, desiredSize);
|
2000-04-29 01:05:31 +04:00
|
|
|
aReflowState.y += cellSpacingY;
|
2001-03-13 09:38:59 +03:00
|
|
|
lastReflowedRow = kidFrame;
|
2001-08-22 08:18:48 +04:00
|
|
|
|
|
|
|
if (aFirstRowReflowed && !*aFirstRowReflowed) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == kidType) {
|
2001-08-22 08:18:48 +04:00
|
|
|
*aFirstRowReflowed = (nsTableRowFrame*)kidFrame;
|
|
|
|
}
|
|
|
|
}
|
2002-03-18 00:35:08 +03:00
|
|
|
if (isPaginated && aPageBreakBeforeEnd && !*aPageBreakBeforeEnd &&
|
2003-10-31 23:19:18 +03:00
|
|
|
(nsLayoutAtoms::tableRowFrame == kidType)) {
|
2002-03-18 00:35:08 +03:00
|
|
|
nsTableRowFrame* nextRow = ((nsTableRowFrame*)kidFrame)->GetNextRow();
|
|
|
|
if (nextRow) {
|
|
|
|
*aPageBreakBeforeEnd = nsTableFrame::PageBreakAfter(*kidFrame, nextRow);
|
|
|
|
}
|
|
|
|
}
|
1999-08-03 06:41:27 +04:00
|
|
|
} else {
|
2001-03-13 09:38:59 +03: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
|
2003-07-07 06:01:29 +04:00
|
|
|
aReflowState.y += kidFrame->GetSize().height + cellSpacingY;
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
2004-12-27 18:05:18 +03:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowArea, kidFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// adjust the rows after the ones that were reflowed
|
|
|
|
if (lastReflowedRow && adjustSiblings) {
|
2003-07-07 06:01:29 +04:00
|
|
|
nsIFrame* nextRow = lastReflowedRow->GetNextSibling();
|
2001-03-13 09:38:59 +03:00
|
|
|
if (nextRow) {
|
2003-07-07 06:01:29 +04:00
|
|
|
nscoord deltaY = cellSpacingY + lastReflowedRow->GetRect().YMost()
|
|
|
|
- nextRow->GetPosition().y;
|
2001-03-13 09:38:59 +03:00
|
|
|
if (deltaY != 0) {
|
2004-12-27 18:05:18 +03:00
|
|
|
AdjustSiblingsAfterReflow(aReflowState, lastReflowedRow, deltaY);
|
2001-03-13 09:38:59 +03:00
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2002-03-31 21:44:57 +04:00
|
|
|
if (aReflowState.reflowState.mFlags.mSpecialHeightReflow) {
|
|
|
|
aDesiredSize.height = mRect.height;
|
|
|
|
}
|
1998-10-20 03:43:06 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableRowFrame*
|
|
|
|
nsTableRowGroupFrame::GetFirstRow()
|
1999-03-17 02:42:38 +03:00
|
|
|
{
|
2003-07-07 06:01:29 +04:00
|
|
|
for (nsIFrame* childFrame = GetFirstFrame(); childFrame;
|
|
|
|
childFrame = childFrame->GetNextSibling()) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == childFrame->GetType()) {
|
2001-11-05 03:15:51 +03:00
|
|
|
return (nsTableRowFrame*)childFrame;
|
1999-03-17 02:42:38 +03:00
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct RowInfo {
|
2001-11-14 16:44:38 +03:00
|
|
|
RowInfo() { height = pctHeight = hasStyleHeight = hasPctHeight = isSpecial = 0; }
|
|
|
|
unsigned height; // content height or fixed height, excluding pct height
|
|
|
|
unsigned pctHeight:29; // pct height
|
2001-11-05 03:15:51 +03:00
|
|
|
unsigned hasStyleHeight:1;
|
2001-11-14 16:44:38 +03:00
|
|
|
unsigned hasPctHeight:1;
|
2001-11-05 03:15:51 +03:00
|
|
|
unsigned isSpecial:1; // there is no cell originating in the row with rowspan=1 and there are at
|
|
|
|
// least 2 cells spanning the row and there is no style height on the row
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
UpdateHeights(RowInfo& aRowInfo,
|
|
|
|
nscoord aAdditionalHeight,
|
|
|
|
nscoord& aTotal,
|
|
|
|
nscoord& aUnconstrainedTotal)
|
|
|
|
{
|
|
|
|
aRowInfo.height += aAdditionalHeight;
|
|
|
|
aTotal += aAdditionalHeight;
|
|
|
|
if (!aRowInfo.hasStyleHeight) {
|
|
|
|
aUnconstrainedTotal += aAdditionalHeight;
|
1999-03-17 02:42:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-03 17:04:49 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::DidResizeRows(nsPresContext& aPresContext,
|
2001-11-05 03:15:51 +03:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2003-09-13 20:26:30 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableRowFrame* aStartRowFrameIn)
|
2000-02-03 17:04:49 +03:00
|
|
|
{
|
2001-11-05 03:15:51 +03:00
|
|
|
// update the cells spanning rows with their new heights
|
|
|
|
// this is the place where all of the cells in the row get set to the height of the row
|
|
|
|
PRInt32 rowIndex;
|
|
|
|
nsTableRowFrame* rowFrame;
|
|
|
|
nsTableRowFrame* startRowFrame = (aStartRowFrameIn) ? aStartRowFrameIn: GetFirstRow();
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!aStartRowFrameIn || startRowFrame == GetFirstRow()) {
|
|
|
|
// Reset the overflow area
|
|
|
|
aDesiredSize.mOverflowArea = nsRect(0, 0, 0, 0);
|
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
|
|
|
rowFrame->DidResize(&aPresContext, aReflowState);
|
2004-12-27 18:05:18 +03:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowArea, rowFrame);
|
2000-02-03 17:04:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-27 08:50:24 +03:00
|
|
|
static void
|
2004-08-01 03:15:21 +04:00
|
|
|
CacheRowHeightsForPrinting(nsPresContext* aPresContext,
|
2002-03-27 08:50:24 +03:00
|
|
|
nsTableRowFrame* aFirstRow)
|
|
|
|
{
|
|
|
|
for (nsTableRowFrame* row = aFirstRow; row; row = row->GetNextRow()) {
|
|
|
|
if (!row->GetPrevInFlow()) {
|
|
|
|
row->SetHasUnpaginatedHeight(PR_TRUE);
|
2003-07-07 06:01:29 +04:00
|
|
|
row->SetUnpaginatedHeight(aPresContext, row->GetSize().height);
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
// This calculates the height of rows starting at aStartRowFrameIn and takes into account
|
|
|
|
// style height on the row group, style heights on rows and cells, style heights on rowspans.
|
|
|
|
// Actual row heights will be adjusted later if the table has a style height.
|
|
|
|
// Even if rows don't change height, this method must be called to set the heights of each
|
|
|
|
// cell in the row to the height of its row.
|
2001-03-13 09:38:59 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
2001-08-22 08:18:48 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableRowFrame* aStartRowFrameIn)
|
1998-06-30 06:11:07 +04:00
|
|
|
{
|
2000-02-03 17:04:49 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
2005-04-07 22:04:38 +04:00
|
|
|
if (!tableFrame) return;
|
2000-02-03 17:04:49 +03:00
|
|
|
|
2004-03-03 21:24:20 +03:00
|
|
|
PRBool isPaginated = aPresContext->IsPaginated();
|
2002-03-27 08:50:24 +03:00
|
|
|
|
1999-05-27 02:22:23 +04:00
|
|
|
// all table cells have the same top and bottom margins, namely cellSpacingY
|
|
|
|
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
|
2001-11-05 03:15:51 +03:00
|
|
|
float p2t;
|
2004-02-11 07:57:07 +03:00
|
|
|
p2t = aPresContext->PixelsToTwips();
|
1999-05-27 02:22:23 +04:00
|
|
|
|
2002-06-14 18:17:01 +04:00
|
|
|
// find the nearest row index at or before aStartRowFrameIn that isn't spanned into.
|
2001-11-05 03:15:51 +03:00
|
|
|
// If we have a computed height, then we can't compute the heights
|
|
|
|
// incrementally from aStartRowFrameIn, and we must start at the first row.
|
2002-06-14 18:17:01 +04:00
|
|
|
PRInt32 rgStart = GetStartRowIndex();
|
|
|
|
PRInt32 startRowIndex = (aStartRowFrameIn) ? aStartRowFrameIn->GetRowIndex() : rgStart;
|
|
|
|
PRInt32 startRowIndexSave = startRowIndex;
|
|
|
|
if ((NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) && (aReflowState.mComputedHeight > 0)) {
|
|
|
|
startRowIndex = rgStart;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
while (startRowIndex > rgStart) {
|
|
|
|
if (!tableFrame->RowIsSpannedInto(startRowIndex))
|
2001-11-05 03:15:51 +03:00
|
|
|
break;
|
2002-06-14 18:17:01 +04:00
|
|
|
startRowIndex--;
|
2001-08-22 08:18:48 +04:00
|
|
|
}
|
2002-06-14 18:17:01 +04:00
|
|
|
}
|
|
|
|
// find the row corresponding to the row index we just found
|
|
|
|
nsTableRowFrame* startRowFrame = aStartRowFrameIn;
|
|
|
|
if (!startRowFrame || (startRowIndex != startRowIndexSave)) {
|
|
|
|
PRInt32 rowX = rgStart;
|
2002-06-19 17:37:18 +04:00
|
|
|
for (startRowFrame = GetFirstRow(); startRowFrame; startRowFrame = startRowFrame->GetNextRow()) {
|
2002-06-14 18:17:01 +04:00
|
|
|
if (rowX >= startRowIndex)
|
|
|
|
break;
|
|
|
|
rowX++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-22 08:18:48 +04:00
|
|
|
if (!startRowFrame) return;
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
// the current row group height is the y origin of the 1st row we are about to calculated a height for
|
2003-07-07 06:01:29 +04:00
|
|
|
nscoord startRowGroupHeight = startRowFrame->GetPosition().y;
|
2001-08-22 08:18:48 +04:00
|
|
|
|
|
|
|
PRInt32 numRows = GetRowCount() - (startRowFrame->GetRowIndex() - GetStartRowIndex());
|
2001-11-05 03:15:51 +03:00
|
|
|
// collect the current height of each row. nscoord* rowHeights = nsnull;
|
|
|
|
RowInfo* rowInfo;
|
1999-12-16 03:37:03 +03:00
|
|
|
if (numRows > 0) {
|
2001-11-05 03:15:51 +03:00
|
|
|
rowInfo = new RowInfo[numRows];
|
|
|
|
if (!rowInfo) return;
|
2002-02-05 04:41:13 +03:00
|
|
|
memset (rowInfo, 0, numRows*sizeof(RowInfo));
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
else return;
|
2001-08-08 05:13:35 +04:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
PRBool hasRowSpanningCell = PR_FALSE;
|
|
|
|
nscoord heightOfRows = 0;
|
|
|
|
nscoord heightOfUnStyledRows = 0;
|
|
|
|
// Get the height of each row without considering rowspans. This will be the max of
|
|
|
|
// the largest desired height of each cell, the largest style height of each cell,
|
|
|
|
// the style height of the row.
|
|
|
|
nscoord pctHeightBasis = GetHeightBasis(aReflowState);
|
|
|
|
PRInt32 rowIndex; // the index in rowInfo, not among the rows in the row group
|
2001-11-14 16:44:38 +03:00
|
|
|
nsTableRowFrame* rowFrame;
|
2001-11-05 03:15:51 +03:00
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
2002-03-27 08:50:24 +03:00
|
|
|
nscoord nonPctHeight = rowFrame->GetContentHeight();
|
|
|
|
if (isPaginated) {
|
2003-07-07 06:01:29 +04:00
|
|
|
nonPctHeight = PR_MAX(nonPctHeight, rowFrame->GetSize().height);
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
if (!rowFrame->GetPrevInFlow()) {
|
|
|
|
if (rowFrame->HasPctHeight()) {
|
|
|
|
rowInfo[rowIndex].hasPctHeight = PR_TRUE;
|
|
|
|
rowInfo[rowIndex].pctHeight = nsTableFrame::RoundToPixel(rowFrame->GetHeight(pctHeightBasis), p2t);
|
|
|
|
}
|
|
|
|
rowInfo[rowIndex].hasStyleHeight = rowFrame->HasStyleHeight();
|
2003-04-05 19:36:31 +04:00
|
|
|
nonPctHeight = nsTableFrame::RoundToPixel(PR_MAX(nonPctHeight, rowFrame->GetFixedHeight()), p2t);
|
2001-11-14 16:44:38 +03:00
|
|
|
}
|
|
|
|
UpdateHeights(rowInfo[rowIndex], nonPctHeight, heightOfRows, heightOfUnStyledRows);
|
2001-11-05 03:15:51 +03:00
|
|
|
|
|
|
|
if (!rowInfo[rowIndex].hasStyleHeight) {
|
2004-04-13 10:21:16 +04:00
|
|
|
if (isPaginated || tableFrame->HasMoreThanOneCell(rowIndex + startRowIndex)) {
|
2001-11-05 03:15:51 +03:00
|
|
|
rowInfo[rowIndex].isSpecial = PR_TRUE;
|
|
|
|
// iteratate the row's cell frames to see if any do not have rowspan > 1
|
|
|
|
nsTableCellFrame* cellFrame = rowFrame->GetFirstCell();
|
|
|
|
while (cellFrame) {
|
|
|
|
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(rowIndex + startRowIndex, *cellFrame);
|
|
|
|
if (1 == rowSpan) {
|
|
|
|
rowInfo[rowIndex].isSpecial = PR_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cellFrame = cellFrame->GetNextCell();
|
1999-08-21 03:27:39 +04:00
|
|
|
}
|
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
// See if a cell spans into the row. If so we'll have to do the next step
|
|
|
|
if (!hasRowSpanningCell) {
|
|
|
|
if (tableFrame->RowIsSpannedInto(rowIndex + startRowIndex)) {
|
|
|
|
hasRowSpanningCell = PR_TRUE;
|
2000-02-03 17:04:49 +03:00
|
|
|
}
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
1999-05-27 02:22:23 +04:00
|
|
|
}
|
1998-06-30 06:11:07 +04:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
if (hasRowSpanningCell) {
|
|
|
|
// Get the height of cells with rowspans and allocate any extra space to the rows they span
|
|
|
|
// iteratate the child frames and process the row frames among them
|
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
2002-03-27 08:50:24 +03:00
|
|
|
// See if the row has an originating cell with rowspan > 1. We cannot determine this for a row in a
|
|
|
|
// continued row group by calling RowHasSpanningCells, because the row's fif may not have any originating
|
|
|
|
// cells yet the row may have a continued cell which originates in it.
|
|
|
|
if (mPrevInFlow || tableFrame->RowHasSpanningCells(startRowIndex + rowIndex)) {
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableCellFrame* cellFrame = rowFrame->GetFirstCell();
|
|
|
|
// iteratate the row's cell frames
|
|
|
|
while (cellFrame) {
|
|
|
|
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(rowIndex + startRowIndex, *cellFrame);
|
|
|
|
if (rowSpan > 1) { // a cell with rowspan > 1, determine the height of the rows it spans
|
|
|
|
nscoord heightOfRowsSpanned = 0;
|
|
|
|
nscoord heightOfUnStyledRowsSpanned = 0;
|
|
|
|
nscoord numSpecialRowsSpanned = 0;
|
|
|
|
nscoord cellSpacingTotal = 0;
|
|
|
|
PRInt32 spanX;
|
|
|
|
for (spanX = 0; spanX < rowSpan; spanX++) {
|
|
|
|
heightOfRowsSpanned += rowInfo[rowIndex + spanX].height;
|
|
|
|
if (!rowInfo[rowIndex + spanX].hasStyleHeight) {
|
|
|
|
heightOfUnStyledRowsSpanned += rowInfo[rowIndex + spanX].height;
|
|
|
|
}
|
|
|
|
if (0 != spanX) {
|
|
|
|
cellSpacingTotal += cellSpacingY;
|
|
|
|
}
|
|
|
|
if (rowInfo[rowIndex + spanX].isSpecial) {
|
|
|
|
numSpecialRowsSpanned++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nscoord heightOfAreaSpanned = heightOfRowsSpanned + cellSpacingTotal;
|
|
|
|
// get the height of the cell
|
2003-07-07 06:01:29 +04:00
|
|
|
nsSize cellFrameSize = cellFrame->GetSize();
|
2001-11-05 03:15:51 +03:00
|
|
|
nsSize cellDesSize = cellFrame->GetDesiredSize();
|
|
|
|
rowFrame->CalculateCellActualSize(cellFrame, cellDesSize.width,
|
|
|
|
cellDesSize.height, cellDesSize.width);
|
|
|
|
cellFrameSize.height = cellDesSize.height;
|
|
|
|
if (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 += rowFrame->GetMaxCellAscent() - cellFrame->GetDesiredAscent();
|
|
|
|
}
|
1999-08-21 03:27:39 +04:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
if (heightOfAreaSpanned < cellFrameSize.height) {
|
|
|
|
// the cell's height is larger than the available space of the rows it
|
|
|
|
// spans so distribute the excess height to the rows affected
|
|
|
|
nscoord extra = cellFrameSize.height - heightOfAreaSpanned;
|
|
|
|
nscoord extraUsed = 0;
|
|
|
|
if (0 == numSpecialRowsSpanned) {
|
|
|
|
//NS_ASSERTION(heightOfRowsSpanned > 0, "invalid row span situation");
|
|
|
|
PRBool haveUnStyledRowsSpanned = (heightOfUnStyledRowsSpanned > 0);
|
|
|
|
nscoord divisor = (haveUnStyledRowsSpanned)
|
|
|
|
? heightOfUnStyledRowsSpanned : heightOfRowsSpanned;
|
|
|
|
if (divisor > 0) {
|
|
|
|
for (spanX = rowSpan - 1; spanX >= 0; spanX--) {
|
|
|
|
if (!haveUnStyledRowsSpanned || !rowInfo[rowIndex + spanX].hasStyleHeight) {
|
|
|
|
// The amount of additional space each row gets is proportional to its height
|
|
|
|
float percent = ((float)rowInfo[rowIndex + spanX].height) / ((float)divisor);
|
1999-08-21 03:27:39 +04:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
// give rows their percentage, except for the first row which gets the remainder
|
|
|
|
nscoord extraForRow = (0 == spanX) ? extra - extraUsed
|
|
|
|
: NSToCoordRound(((float)(extra)) * percent);
|
|
|
|
extraForRow = PR_MIN(nsTableFrame::RoundToPixel(extraForRow, p2t), extra - extraUsed);
|
2000-02-03 17:04:49 +03:00
|
|
|
// update the row height
|
2001-11-05 03:15:51 +03:00
|
|
|
UpdateHeights(rowInfo[rowIndex + spanX], extraForRow, heightOfRows, heightOfUnStyledRows);
|
|
|
|
extraUsed += extraForRow;
|
|
|
|
if (extraUsed >= extra) {
|
|
|
|
NS_ASSERTION((extraUsed == extra), "invalid row height calculation");
|
|
|
|
break;
|
|
|
|
}
|
2000-02-03 17:04:49 +03:00
|
|
|
}
|
1999-08-21 03:27:39 +04:00
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// put everything in the last row
|
|
|
|
UpdateHeights(rowInfo[rowIndex + rowSpan - 1], extra, heightOfRows, heightOfUnStyledRows);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// give the extra to the special rows
|
|
|
|
nscoord numSpecialRowsAllocated = 0;
|
|
|
|
for (spanX = rowSpan - 1; spanX >= 0; spanX--) {
|
|
|
|
if (rowInfo[rowIndex + spanX].isSpecial) {
|
|
|
|
// The amount of additional space each degenerate row gets is proportional to the number of them
|
|
|
|
float percent = 1.0f / ((float)numSpecialRowsSpanned);
|
|
|
|
|
|
|
|
// give rows their percentage, except for the first row which gets the remainder
|
|
|
|
nscoord extraForRow = (numSpecialRowsSpanned - 1 == numSpecialRowsAllocated)
|
|
|
|
? extra - extraUsed
|
|
|
|
: NSToCoordRound(((float)(extra)) * percent);
|
|
|
|
extraForRow = PR_MIN(nsTableFrame::RoundToPixel(extraForRow, p2t), extra - extraUsed);
|
|
|
|
// update the row height
|
|
|
|
UpdateHeights(rowInfo[rowIndex + spanX], extraForRow, heightOfRows, heightOfUnStyledRows);
|
|
|
|
extraUsed += extraForRow;
|
|
|
|
if (extraUsed >= extra) {
|
|
|
|
NS_ASSERTION((extraUsed == extra), "invalid row height calculation");
|
|
|
|
break;
|
2000-02-04 05:49:27 +03:00
|
|
|
}
|
|
|
|
}
|
1998-09-16 00:36:42 +04:00
|
|
|
}
|
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
} // if (rowSpan > 1)
|
|
|
|
cellFrame = cellFrame->GetNextCell();
|
|
|
|
} // while (cellFrame)
|
|
|
|
} // if (tableFrame->RowHasSpanningCells(startRowIndex + rowIndex) {
|
|
|
|
} // while (rowFrame)
|
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2001-11-14 16:44:38 +03:00
|
|
|
// pct height rows have already got their content heights. Give them their pct heights up to pctHeightBasis
|
|
|
|
nscoord extra = pctHeightBasis - heightOfRows;
|
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame && (extra > 0); rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
|
|
|
RowInfo& rInfo = rowInfo[rowIndex];
|
|
|
|
if (rInfo.hasPctHeight) {
|
2002-12-13 18:21:38 +03:00
|
|
|
nscoord rowExtra = (rInfo.pctHeight > rInfo.height)
|
|
|
|
? rInfo.pctHeight - rInfo.height: 0;
|
2001-11-14 16:44:38 +03:00
|
|
|
rowExtra = PR_MIN(rowExtra, extra);
|
|
|
|
UpdateHeights(rInfo, rowExtra, heightOfRows, heightOfUnStyledRows);
|
|
|
|
extra -= rowExtra;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-27 08:50:24 +03:00
|
|
|
PRBool styleHeightAllocation = PR_FALSE;
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord rowGroupHeight = startRowGroupHeight + heightOfRows + ((numRows - 1) * cellSpacingY);
|
|
|
|
// if we have a style height, allocate the extra height to unconstrained rows
|
|
|
|
if ((aReflowState.mComputedHeight > rowGroupHeight) &&
|
|
|
|
(NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight)) {
|
2001-11-14 16:44:38 +03:00
|
|
|
nscoord extraComputedHeight = aReflowState.mComputedHeight - rowGroupHeight;
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord extraUsed = 0;
|
|
|
|
PRBool haveUnStyledRows = (heightOfUnStyledRows > 0);
|
|
|
|
nscoord divisor = (haveUnStyledRows)
|
|
|
|
? heightOfUnStyledRows : heightOfRows;
|
|
|
|
if (divisor > 0) {
|
2002-03-27 08:50:24 +03:00
|
|
|
styleHeightAllocation = PR_TRUE;
|
2001-11-05 03:15:51 +03:00
|
|
|
for (rowIndex = 0; rowIndex < numRows; rowIndex++) {
|
|
|
|
if (!haveUnStyledRows || !rowInfo[rowIndex].hasStyleHeight) {
|
|
|
|
// The amount of additional space each row gets is based on the
|
|
|
|
// percentage of space it occupies
|
|
|
|
float percent = ((float)rowInfo[rowIndex].height) / ((float)divisor);
|
|
|
|
// give rows their percentage, except for the last row which gets the remainder
|
|
|
|
nscoord extraForRow = (numRows - 1 == rowIndex)
|
|
|
|
? extraComputedHeight - extraUsed
|
|
|
|
: NSToCoordRound(((float)extraComputedHeight) * percent);
|
|
|
|
extraForRow = PR_MIN(nsTableFrame::RoundToPixel(extraForRow, p2t), extraComputedHeight - extraUsed);
|
|
|
|
// update the row height
|
|
|
|
UpdateHeights(rowInfo[rowIndex], extraForRow, heightOfRows, heightOfUnStyledRows);
|
|
|
|
extraUsed += extraForRow;
|
|
|
|
if (extraUsed >= extraComputedHeight) {
|
|
|
|
NS_ASSERTION((extraUsed == extraComputedHeight), "invalid row height calculation");
|
|
|
|
break;
|
1999-08-21 03:27:39 +04:00
|
|
|
}
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
}
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
rowGroupHeight = aReflowState.mComputedHeight;
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord yOrigin = startRowGroupHeight;
|
|
|
|
// update the rows with their (potentially) new heights
|
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
2003-07-07 06:01:29 +04:00
|
|
|
nsRect rowBounds = rowFrame->GetRect();
|
2001-11-05 03:15:51 +03:00
|
|
|
|
|
|
|
PRBool movedFrame = (rowBounds.y != yOrigin);
|
|
|
|
nscoord rowHeight = (rowInfo[rowIndex].height > 0) ? rowInfo[rowIndex].height : 0;
|
|
|
|
|
|
|
|
if (movedFrame || (rowHeight != rowBounds.height)) {
|
|
|
|
// Resize the row to its final size and position
|
|
|
|
rowBounds.y = yOrigin;
|
|
|
|
rowBounds.height = rowHeight;
|
2003-07-07 06:01:29 +04:00
|
|
|
rowFrame->SetRect(rowBounds);
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
if (movedFrame) {
|
2004-12-27 18:05:18 +03:00
|
|
|
nsTableFrame::RePositionViews(rowFrame);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
yOrigin += rowHeight + cellSpacingY;
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
|
|
|
|
2002-03-27 08:50:24 +03:00
|
|
|
if (isPaginated && styleHeightAllocation) {
|
|
|
|
// since the row group has a style height, cache the row heights, so next in flows can honor them
|
|
|
|
CacheRowHeightsForPrinting(aPresContext, GetFirstRow());
|
|
|
|
}
|
|
|
|
|
2003-09-13 20:26:30 +04:00
|
|
|
DidResizeRows(*aPresContext, aReflowState, aDesiredSize, startRowFrame);
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2000-02-03 17:04:49 +03:00
|
|
|
aDesiredSize.height = rowGroupHeight; // Adjust our desired size
|
2001-11-05 03:15:51 +03:00
|
|
|
delete [] rowInfo; // cleanup
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
|
1999-08-19 07:51:25 +04: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
|
2004-12-27 18:05:18 +03:00
|
|
|
nsTableRowGroupFrame::AdjustSiblingsAfterReflow(nsRowGroupReflowState& aReflowState,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nscoord aDeltaY)
|
1998-07-03 03:19:31 +04:00
|
|
|
{
|
1999-08-19 07:51:25 +04:00
|
|
|
NS_PRECONDITION(NS_UNCONSTRAINEDSIZE == aReflowState.reflowState.availableHeight,
|
|
|
|
"we're not in galley mode");
|
1998-07-03 03:19:31 +04:00
|
|
|
nsIFrame* lastKidFrame = aKidFrame;
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// Move the frames that follow aKidFrame by aDeltaY
|
2003-07-07 06:01:29 +04:00
|
|
|
for (nsIFrame* kidFrame = aKidFrame->GetNextSibling(); kidFrame;
|
|
|
|
kidFrame = kidFrame->GetNextSibling()) {
|
1999-08-31 02:30:32 +04:00
|
|
|
// Move the frame if we need to
|
|
|
|
if (aDeltaY != 0) {
|
2003-07-07 06:01:29 +04:00
|
|
|
kidFrame->SetPosition(kidFrame->GetPosition() + nsPoint(0, aDeltaY));
|
2004-12-27 18:05:18 +03:00
|
|
|
nsTableFrame::RePositionViews(kidFrame);
|
1998-07-03 03:19:31 +04:00
|
|
|
}
|
|
|
|
|
1999-08-31 02:30:32 +04:00
|
|
|
// Remember the last frame
|
|
|
|
lastKidFrame = kidFrame;
|
1998-07-03 03:19:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update our running y-offset to reflect the bottommost child
|
2003-07-07 06:01:29 +04:00
|
|
|
aReflowState.y = lastKidFrame->GetRect().YMost();
|
1998-07-03 03:19:31 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
|
2001-04-16 18:51:52 +04:00
|
|
|
// Create a continuing frame, add it to the child list, and then push it
|
|
|
|
// and the frames that follow
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::CreateContinuingRowFrame(nsPresContext& aPresContext,
|
2001-04-16 18:51:52 +04:00
|
|
|
nsIFrame& aRowFrame,
|
|
|
|
nsIFrame** aContRowFrame)
|
|
|
|
{
|
2002-03-27 08:50:24 +03:00
|
|
|
// XXX what is the row index?
|
2001-04-16 18:51:52 +04:00
|
|
|
if (!aContRowFrame) {NS_ASSERTION(PR_FALSE, "bad call"); return;}
|
|
|
|
// create the continuing frame which will create continuing cell frames
|
2004-01-08 01:30:53 +03:00
|
|
|
aPresContext.PresShell()->FrameConstructor()->
|
|
|
|
CreateContinuingFrame(&aPresContext, &aRowFrame, this, aContRowFrame);
|
2001-04-16 18:51:52 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2002-10-03 18:33:23 +04:00
|
|
|
// Reflow the cells with rowspan > 1 which originate between aFirstRow
|
|
|
|
// and end on or after aLastRow. aFirstTruncatedRow is the highest row on the
|
|
|
|
// page that contains a cell which cannot split on this page
|
2002-03-27 08:50:24 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::SplitSpanningCells(nsPresContext& aPresContext,
|
2001-04-16 18:51:52 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2002-10-03 18:33:23 +04:00
|
|
|
nsTableFrame& aTable,
|
|
|
|
nsTableRowFrame& aFirstRow,
|
|
|
|
nsTableRowFrame& aLastRow,
|
|
|
|
PRBool aFirstRowIsTopOfPage,
|
|
|
|
nscoord aAvailHeight,
|
|
|
|
nsTableRowFrame*& aContRow,
|
|
|
|
nsTableRowFrame*& aFirstTruncatedRow,
|
|
|
|
nscoord& aDesiredHeight)
|
2001-04-16 18:51:52 +04:00
|
|
|
{
|
2002-10-03 18:33:23 +04:00
|
|
|
aFirstTruncatedRow = nsnull;
|
|
|
|
aDesiredHeight = 0;
|
|
|
|
|
|
|
|
PRInt32 lastRowIndex = aLastRow.GetRowIndex();
|
2003-06-06 07:22:01 +04:00
|
|
|
PRBool wasLast = PR_FALSE;
|
2002-10-03 18:33:23 +04:00
|
|
|
// Iterate the rows between aFirstRow and aLastRow
|
2003-06-06 07:22:01 +04:00
|
|
|
for (nsTableRowFrame* row = &aFirstRow; !wasLast; row = row->GetNextRow()) {
|
|
|
|
wasLast = (row == &aLastRow);
|
2002-10-03 18:33:23 +04:00
|
|
|
PRInt32 rowIndex = row->GetRowIndex();
|
2003-07-07 06:01:29 +04:00
|
|
|
nsPoint rowPos = row->GetPosition();
|
2002-10-03 18:33:23 +04:00
|
|
|
// Iterate the cells looking for those that have rowspan > 1
|
|
|
|
for (nsTableCellFrame* cell = row->GetFirstCell(); cell; cell = cell->GetNextCell()) {
|
|
|
|
PRInt32 rowSpan = aTable.GetEffectiveRowSpan(rowIndex, *cell);
|
|
|
|
// Only reflow rowspan > 1 cells which span aLastRow. Those which don't span aLastRow
|
|
|
|
// were reflowed correctly during the unconstrained height reflow.
|
|
|
|
if ((rowSpan > 1) && (rowIndex + rowSpan > lastRowIndex)) {
|
|
|
|
nsReflowStatus status;
|
|
|
|
// Ask the row to reflow the cell to the height of all the rows it spans up through aLastRow
|
|
|
|
// aAvailHeight is the space between the row group start and the end of the page
|
2003-07-07 06:01:29 +04:00
|
|
|
nscoord cellAvailHeight = aAvailHeight - rowPos.y;
|
2002-10-03 18:33:23 +04:00
|
|
|
nscoord cellHeight = row->ReflowCellFrame(&aPresContext, aReflowState, cell,
|
|
|
|
cellAvailHeight, status);
|
2003-07-07 06:01:29 +04:00
|
|
|
aDesiredHeight = PR_MAX(aDesiredHeight, rowPos.y + cellHeight);
|
2002-10-03 18:33:23 +04:00
|
|
|
if (NS_FRAME_IS_COMPLETE(status)) {
|
|
|
|
if (cellHeight > cellAvailHeight) {
|
|
|
|
aFirstTruncatedRow = row;
|
|
|
|
if ((row != &aFirstRow) || !aFirstRowIsTopOfPage) {
|
|
|
|
// return now, since we will be getting another reflow after either (1) row is
|
|
|
|
// moved to the next page or (2) the row group is moved to the next page
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!aContRow) {
|
2004-01-08 01:30:53 +03:00
|
|
|
CreateContinuingRowFrame(aPresContext, aLastRow, (nsIFrame**)&aContRow);
|
2002-10-03 18:33:23 +04:00
|
|
|
}
|
|
|
|
if (aContRow) {
|
|
|
|
if (row != &aLastRow) {
|
|
|
|
// aContRow needs a continuation for cell, since cell spanned into aLastRow
|
|
|
|
// but does not originate there
|
|
|
|
nsTableCellFrame* contCell = nsnull;
|
2004-01-08 01:30:53 +03:00
|
|
|
aPresContext.PresShell()->FrameConstructor()->
|
|
|
|
CreateContinuingFrame(&aPresContext, cell, &aLastRow,
|
|
|
|
(nsIFrame**)&contCell);
|
2002-10-03 18:33:23 +04:00
|
|
|
PRInt32 colIndex;
|
|
|
|
cell->GetColIndex(colIndex);
|
|
|
|
aContRow->InsertCellFrame(contCell, colIndex);
|
|
|
|
}
|
2001-04-16 18:51:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-03 18:33:23 +04:00
|
|
|
// Remove the next-in-flow of the row, its cells and their cell blocks. This
|
|
|
|
// is necessary in case the row doesn't need a continuation later on or needs
|
|
|
|
// a continuation which doesn't have the same number of cells that now exist.
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::UndoContinuedRow(nsPresContext* aPresContext,
|
2002-10-03 18:33:23 +04:00
|
|
|
nsTableRowFrame* aRow)
|
|
|
|
{
|
|
|
|
if (!aRow) return; // allow null aRow to avoid callers doing null checks
|
|
|
|
|
|
|
|
// rowBefore was the prev-sibling of aRow's next-sibling before aRow was created
|
|
|
|
nsTableRowFrame* rowBefore = (nsTableRowFrame*)aRow->GetPrevInFlow();
|
|
|
|
|
|
|
|
nsIFrame* firstOverflow = GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
if (!rowBefore || !firstOverflow || (firstOverflow != aRow)) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "invalid continued row");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove aRow from the sibling chain and hook its next-sibling up with rowBefore
|
2003-07-07 06:01:29 +04:00
|
|
|
rowBefore->SetNextSibling(aRow->GetNextSibling());
|
2002-10-03 18:33:23 +04:00
|
|
|
|
|
|
|
// Destroy the row, its cells, and their cell blocks. Cell blocks that have split
|
|
|
|
// will not have reflowed yet to pick up content from any overflow lines.
|
|
|
|
aRow->Destroy(aPresContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsTableRowFrame*
|
|
|
|
GetRowBefore(nsTableRowFrame& aStartRow,
|
|
|
|
nsTableRowFrame& aRow)
|
|
|
|
{
|
|
|
|
nsTableRowFrame* rowBefore = nsnull;
|
|
|
|
for (nsTableRowFrame* sib = &aStartRow; sib && (sib != &aRow); sib = sib->GetNextRow()) {
|
|
|
|
rowBefore = sib;
|
|
|
|
}
|
|
|
|
return rowBefore;
|
|
|
|
}
|
|
|
|
|
1998-12-14 04:24:11 +03:00
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
|
1998-12-14 04:24:11 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-02-22 06:28:00 +03:00
|
|
|
nsTableFrame* aTableFrame,
|
1998-12-14 04:24:11 +03:00
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2002-10-03 18:33:23 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsTableRowFrame* prevRowFrame = nsnull;
|
2001-04-17 18:39:54 +04:00
|
|
|
aDesiredSize.height = 0;
|
2001-04-16 18:51:52 +04:00
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
2004-11-11 20:27:38 +03:00
|
|
|
nscoord availWidth = (NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth) ?
|
|
|
|
NS_UNCONSTRAINEDSIZE :
|
|
|
|
nsTableFrame::RoundToPixel(aReflowState.availableWidth, p2t);
|
|
|
|
nscoord availHeight = (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) ?
|
|
|
|
NS_UNCONSTRAINEDSIZE :
|
|
|
|
nsTableFrame::RoundToPixel(aReflowState.availableHeight, p2t);
|
2003-04-05 19:36:31 +04:00
|
|
|
|
2002-10-03 18:33:23 +04:00
|
|
|
PRBool borderCollapse = ((nsTableFrame*)aTableFrame->GetFirstInFlow())->IsBorderCollapse();
|
|
|
|
nscoord cellSpacingY = aTableFrame->GetCellSpacingY();
|
2004-11-11 20:27:38 +03:00
|
|
|
|
|
|
|
NS_ASSERTION(aPresContext->IsPaginated(), "SplitRowGroup currently supports only paged media");
|
|
|
|
if (!aPresContext->IsPaginated())
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2002-03-27 08:50:24 +03:00
|
|
|
// get the page height
|
|
|
|
nsRect actualRect;
|
|
|
|
nsRect adjRect;
|
|
|
|
aPresContext->GetPageDim(&actualRect, &adjRect);
|
|
|
|
nscoord pageHeight = actualRect.height;
|
|
|
|
|
|
|
|
PRBool isTopOfPage = aReflowState.mFlags.mIsTopOfPage;
|
2002-10-03 18:33:23 +04:00
|
|
|
nsTableRowFrame* firstRowThisPage = GetFirstRow();
|
|
|
|
|
|
|
|
// Walk each of the row frames looking for the first row frame that doesn't fit
|
|
|
|
// in the available space
|
|
|
|
for (nsTableRowFrame* rowFrame = firstRowThisPage; rowFrame; rowFrame = rowFrame->GetNextRow()) {
|
|
|
|
PRBool rowIsOnPage = PR_TRUE;
|
2003-07-07 06:01:29 +04:00
|
|
|
nsRect rowRect = rowFrame->GetRect();
|
2002-10-03 18:33:23 +04:00
|
|
|
// See if the row fits on this page
|
|
|
|
if (rowRect.YMost() > availHeight) {
|
|
|
|
nsTableRowFrame* contRow = nsnull;
|
|
|
|
// Reflow the row in the availabe space and have it split if it is the 1st
|
|
|
|
// row (on the page) or there is at least 5% of the current page available
|
|
|
|
// XXX this 5% should be made a preference
|
2001-11-21 17:42:00 +03:00
|
|
|
if (!prevRowFrame || (availHeight - aDesiredSize.height > pageHeight / 20)) {
|
2002-10-03 18:33:23 +04:00
|
|
|
nsSize availSize(availWidth, PR_MAX(availHeight - rowRect.y, 0));
|
2002-03-27 08:50:24 +03:00
|
|
|
// don't let the available height exceed what CalculateRowHeights set for it
|
2002-10-03 18:33:23 +04:00
|
|
|
availSize.height = PR_MIN(availSize.height, rowRect.height);
|
2002-03-27 08:50:24 +03:00
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
nsHTMLReflowState rowReflowState(aPresContext, aReflowState, rowFrame, availSize,
|
|
|
|
eReflowReason_Resize);
|
|
|
|
InitChildReflowState(*aPresContext, borderCollapse, p2t, rowReflowState);
|
2002-03-27 08:50:24 +03:00
|
|
|
rowReflowState.mFlags.mIsTopOfPage = isTopOfPage; // set top of page
|
2003-09-13 20:26:30 +04:00
|
|
|
nsHTMLReflowMetrics rowMetrics(PR_FALSE);
|
2002-02-19 18:48:28 +03:00
|
|
|
|
2002-10-03 18:33:23 +04:00
|
|
|
// Reflow the cell with the constrained height. A cell with rowspan >1 will get this
|
|
|
|
// reflow later during SplitSpanningCells.
|
|
|
|
rv = ReflowChild(rowFrame, aPresContext, rowMetrics, rowReflowState,
|
1999-11-19 18:33:29 +03:00
|
|
|
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
2002-10-03 18:33:23 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2003-07-07 06:01:29 +04:00
|
|
|
rowFrame->SetSize(nsSize(rowMetrics.width, rowMetrics.height));
|
2001-12-07 17:51:12 +03:00
|
|
|
rowFrame->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
|
2001-11-05 03:15:51 +03:00
|
|
|
rowFrame->DidResize(aPresContext, aReflowState);
|
1998-12-14 04:24:11 +03:00
|
|
|
|
1998-12-16 00:26:05 +03:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
2002-10-03 18:33:23 +04:00
|
|
|
// The row frame is incomplete and all of the rowspan 1 cells' block frames split
|
|
|
|
if ((rowMetrics.height <= rowReflowState.availableHeight) || isTopOfPage) {
|
|
|
|
// The row stays on this page because either it split ok or we're on the top of page.
|
|
|
|
// If top of page and the height exceeded the avail height, then there will be data loss
|
|
|
|
NS_WARN_IF_FALSE(rowMetrics.height <= rowReflowState.availableHeight,
|
2002-03-27 08:50:24 +03:00
|
|
|
"data loss - incomplete row needed more height than available, on top of page");
|
2004-01-08 01:30:53 +03:00
|
|
|
CreateContinuingRowFrame(*aPresContext, *rowFrame, (nsIFrame**)&contRow);
|
2002-10-03 18:33:23 +04:00
|
|
|
if (contRow) {
|
|
|
|
aDesiredSize.height += rowMetrics.height;
|
|
|
|
if (prevRowFrame)
|
|
|
|
aDesiredSize.height += cellSpacingY;
|
|
|
|
}
|
|
|
|
else return NS_ERROR_NULL_POINTER;
|
2001-11-01 18:31:13 +03:00
|
|
|
}
|
2002-03-27 08:50:24 +03:00
|
|
|
else {
|
2002-10-03 18:33:23 +04:00
|
|
|
// Put the row on the next page to give it more height
|
|
|
|
rowIsOnPage = PR_FALSE;
|
2001-04-02 07:21:58 +04:00
|
|
|
}
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
else {
|
2002-10-03 18:33:23 +04:00
|
|
|
// The row frame is complete because either (1) it's minimum height is greater than the
|
|
|
|
// available height we gave it, or (2) it may have been given a larger height through
|
|
|
|
// style than it's content, or (3) it contains a rowspan >1 cell which hasn't been
|
|
|
|
// reflowed with a constrained height yet (we will find out when SplitSpanningCells is
|
|
|
|
// called below)
|
|
|
|
if (rowMetrics.height >= availSize.height) {
|
|
|
|
// cases (1) and (2)
|
|
|
|
if (isTopOfPage) {
|
|
|
|
// We're on top of the page, so keep the row on this page. There will be data loss.
|
|
|
|
// Push the row frame that follows
|
|
|
|
nsTableRowFrame* nextRowFrame = rowFrame->GetNextRow();
|
|
|
|
if (nextRowFrame) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
aDesiredSize.height += rowMetrics.height;
|
|
|
|
if (prevRowFrame)
|
|
|
|
aDesiredSize.height += cellSpacingY;
|
|
|
|
NS_WARNING("data loss - complete row needed more height than available, on top of page");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// We're not on top of the page, so put the row on the next page to give it more height
|
|
|
|
rowIsOnPage = PR_FALSE;
|
2001-04-02 07:21:58 +04:00
|
|
|
}
|
1999-03-09 18:35:43 +03:00
|
|
|
}
|
1998-12-16 00:26:05 +03:00
|
|
|
}
|
2004-04-14 00:47:52 +04:00
|
|
|
} //if (!prevRowFrame || (availHeight - aDesiredSize.height > pageHeight / 20))
|
2002-10-03 18:33:23 +04:00
|
|
|
else {
|
2002-03-27 08:50:24 +03:00
|
|
|
// put the row on the next page to give it more height
|
2002-10-03 18:33:23 +04:00
|
|
|
rowIsOnPage = PR_FALSE;
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
1998-12-16 00:26:05 +03:00
|
|
|
|
2002-10-03 18:33:23 +04:00
|
|
|
nsTableRowFrame* lastRowThisPage = rowFrame;
|
|
|
|
if (!rowIsOnPage) {
|
2002-03-27 08:50:24 +03:00
|
|
|
if (prevRowFrame) {
|
2004-04-14 00:47:52 +04:00
|
|
|
availHeight -= prevRowFrame->GetRect().YMost();
|
2002-10-03 18:33:23 +04:00
|
|
|
lastRowThisPage = prevRowFrame;
|
|
|
|
isTopOfPage = (lastRowThisPage == firstRowThisPage) && aReflowState.mFlags.mIsTopOfPage;
|
2002-03-27 08:50:24 +03:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// We can't push children, so let our parent reflow us again with more space
|
2002-10-03 18:33:23 +04:00
|
|
|
aDesiredSize.height = rowRect.YMost();
|
|
|
|
break;
|
2001-04-16 18:51:52 +04:00
|
|
|
}
|
|
|
|
}
|
2002-10-03 18:33:23 +04:00
|
|
|
// reflow the cells with rowspan >1 that occur on the page
|
|
|
|
|
|
|
|
nsTableRowFrame* firstTruncatedRow;
|
|
|
|
nscoord yMost;
|
2004-01-08 01:30:53 +03:00
|
|
|
SplitSpanningCells(*aPresContext, aReflowState, *aTableFrame, *firstRowThisPage,
|
2002-10-03 18:33:23 +04:00
|
|
|
*lastRowThisPage, aReflowState.mFlags.mIsTopOfPage, availHeight, contRow,
|
|
|
|
firstTruncatedRow, yMost);
|
|
|
|
if (firstTruncatedRow) {
|
|
|
|
// A rowspan >1 cell did not fit (and could not split) in the space we gave it
|
|
|
|
if (firstTruncatedRow == firstRowThisPage) {
|
|
|
|
if (aReflowState.mFlags.mIsTopOfPage) {
|
|
|
|
NS_WARNING("data loss in a row spanned cell");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// We can't push children, so let our parent reflow us again with more space
|
|
|
|
aDesiredSize.height = rowRect.YMost();
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
UndoContinuedRow(aPresContext, contRow);
|
2004-10-13 09:49:39 +04:00
|
|
|
contRow = nsnull;
|
2002-10-03 18:33:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // (firstTruncatedRow != firstRowThisPage)
|
|
|
|
// Try to put firstTruncateRow on the next page
|
|
|
|
nsTableRowFrame* rowBefore = ::GetRowBefore(*firstRowThisPage, *firstTruncatedRow);
|
2004-04-14 00:47:52 +04:00
|
|
|
availHeight -= rowBefore->GetRect().YMost();
|
2002-10-03 18:33:23 +04:00
|
|
|
|
|
|
|
UndoContinuedRow(aPresContext, contRow);
|
2004-10-13 09:49:39 +04:00
|
|
|
contRow = nsnull;
|
2002-10-03 18:33:23 +04:00
|
|
|
nsTableRowFrame* oldLastRowThisPage = lastRowThisPage;
|
|
|
|
lastRowThisPage = firstTruncatedRow;
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
2002-03-27 08:50:24 +03:00
|
|
|
|
2002-10-03 18:33:23 +04:00
|
|
|
// Call SplitSpanningCells again with rowBefore as the last row on the page
|
2004-01-08 01:30:53 +03:00
|
|
|
SplitSpanningCells(*aPresContext, aReflowState, *aTableFrame,
|
2002-10-03 18:33:23 +04:00
|
|
|
*firstRowThisPage, *rowBefore, aReflowState.mFlags.mIsTopOfPage,
|
|
|
|
availHeight, contRow, firstTruncatedRow, aDesiredSize.height);
|
|
|
|
if (firstTruncatedRow) {
|
|
|
|
if (aReflowState.mFlags.mIsTopOfPage) {
|
|
|
|
// We were better off with the 1st call to SplitSpanningCells, do it again
|
|
|
|
UndoContinuedRow(aPresContext, contRow);
|
2004-10-13 09:49:39 +04:00
|
|
|
contRow = nsnull;
|
2002-10-03 18:33:23 +04:00
|
|
|
lastRowThisPage = oldLastRowThisPage;
|
2004-01-08 01:30:53 +03:00
|
|
|
SplitSpanningCells(*aPresContext, aReflowState, *aTableFrame, *firstRowThisPage,
|
2002-10-03 18:33:23 +04:00
|
|
|
*lastRowThisPage, aReflowState.mFlags.mIsTopOfPage, availHeight, contRow,
|
|
|
|
firstTruncatedRow, aDesiredSize.height);
|
|
|
|
NS_WARNING("data loss in a row spanned cell");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Let our parent reflow us again with more space
|
|
|
|
aDesiredSize.height = rowRect.YMost();
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
UndoContinuedRow(aPresContext, contRow);
|
2004-10-13 09:49:39 +04:00
|
|
|
contRow = nsnull;
|
2002-10-03 18:33:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // if (firstTruncatedRow == firstRowThisPage)
|
2004-04-14 00:47:52 +04:00
|
|
|
} // if (firstTruncatedRow)
|
2002-10-03 18:33:23 +04:00
|
|
|
else {
|
|
|
|
aDesiredSize.height = PR_MAX(aDesiredSize.height, yMost);
|
|
|
|
if (contRow) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus) && !contRow) {
|
|
|
|
nsTableRowFrame* nextRow = lastRowThisPage->GetNextRow();
|
|
|
|
if (nextRow) {
|
|
|
|
PushChildren(aPresContext, nextRow, lastRowThisPage);
|
|
|
|
}
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
1998-12-14 04:24:11 +03:00
|
|
|
break;
|
2002-10-03 18:33:23 +04:00
|
|
|
} // if (rowRect.YMost() > availHeight)
|
|
|
|
else {
|
|
|
|
aDesiredSize.height = rowRect.YMost();
|
2001-04-17 18:39:54 +04:00
|
|
|
prevRowFrame = rowFrame;
|
2002-03-18 00:35:08 +03:00
|
|
|
// see if there is a page break after the row
|
|
|
|
nsTableRowFrame* nextRow = rowFrame->GetNextRow();
|
|
|
|
if (nextRow && nsTableFrame::PageBreakAfter(*rowFrame, nextRow)) {
|
|
|
|
PushChildren(aPresContext, nextRow, rowFrame);
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
break;
|
|
|
|
}
|
2001-04-17 18:39:54 +04:00
|
|
|
}
|
2002-03-27 08:50:24 +03:00
|
|
|
isTopOfPage = PR_FALSE; // after the 1st row, we can't be on top of the page any more.
|
1998-12-14 04:24:11 +03:00
|
|
|
}
|
2002-12-13 18:21:38 +03:00
|
|
|
return NS_OK;
|
1998-12-14 04:24:11 +03:00
|
|
|
}
|
|
|
|
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2000-04-22 01:36:33 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableRowGroupFrame", aReflowState.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2001-10-29 04:43:59 +03:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 18:55:51 +03:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState);
|
|
|
|
#endif
|
2001-09-24 18:48:38 +04:00
|
|
|
|
2002-04-01 10:46:17 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2004-03-03 21:24:20 +03:00
|
|
|
PRBool isPaginated = aPresContext->IsPaginated();
|
2002-04-01 10:46:17 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
1998-11-04 23:09:19 +03:00
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2005-04-07 22:04:38 +04:00
|
|
|
if (!tableFrame) return NS_ERROR_NULL_POINTER;
|
1998-11-04 23:09:19 +03:00
|
|
|
|
2002-04-11 01:32:41 +04:00
|
|
|
// see if a special height reflow needs to occur due to having a pct height
|
|
|
|
if (!NeedSpecialReflow())
|
|
|
|
nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState);
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nsRowGroupReflowState state(aReflowState, tableFrame);
|
|
|
|
PRBool haveDesiredHeight = PR_FALSE;
|
2004-04-28 20:42:59 +04:00
|
|
|
const nsStyleVisibility* groupVis = GetStyleVisibility();
|
|
|
|
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
|
|
|
|
if (collapseGroup) {
|
|
|
|
tableFrame->SetNeedToCollapseRows(PR_TRUE);
|
|
|
|
}
|
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);
|
2001-03-13 09:38:59 +03:00
|
|
|
}
|
2001-03-29 01:26:58 +04:00
|
|
|
else {
|
1998-06-23 09:43:27 +04:00
|
|
|
// Check for an overflow list
|
1999-11-24 09:03:41 +03:00
|
|
|
MoveOverflowToChildList(aPresContext);
|
1998-06-23 09:43:27 +04:00
|
|
|
|
2001-09-24 18:48:38 +04:00
|
|
|
// Reflow the existing frames.
|
2002-03-18 00:35:08 +03:00
|
|
|
PRBool splitDueToPageBreak = PR_FALSE;
|
2001-03-13 09:38:59 +03:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, state, aStatus,
|
2002-03-18 00:35:08 +03:00
|
|
|
nsnull, PR_FALSE, nsnull, &splitDueToPageBreak);
|
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;
|
|
|
|
|
|
|
|
// shrink wrap rows to height of tallest cell in that row
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool isTableUnconstrainedReflow =
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aReflowState.parentReflowState->availableWidth);
|
2000-02-11 06:55:33 +03:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// Avoid calling CalculateRowHeights. We can avoid it if the table is going to be
|
2000-02-11 06:55:33 +03: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-12-07 17:51:12 +03:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
2003-09-13 20:26:30 +04:00
|
|
|
DidResizeRows(*aPresContext, aReflowState, aDesiredSize);
|
2002-03-27 08:50:24 +03:00
|
|
|
if (isPaginated) {
|
|
|
|
CacheRowHeightsForPrinting(aPresContext, GetFirstRow());
|
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
else if ((eReflowReason_Initial != aReflowState.reason) ||
|
|
|
|
isTableUnconstrainedReflow ||
|
|
|
|
isPaginated) {
|
1998-11-20 04:01:25 +03:00
|
|
|
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState);
|
2001-03-13 09:38:59 +03:00
|
|
|
haveDesiredHeight = PR_TRUE;
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
1998-12-14 04:24:11 +03:00
|
|
|
|
|
|
|
// See if all the frames fit
|
2002-03-18 00:35:08 +03:00
|
|
|
if ((NS_FRAME_NOT_COMPLETE == aStatus) || splitDueToPageBreak ||
|
|
|
|
(aDesiredSize.height > aReflowState.availableHeight)) {
|
2001-11-29 18:41:07 +03:00
|
|
|
// Nope, find a place to split the row group
|
2001-12-07 17:51:12 +03:00
|
|
|
PRBool specialReflow = (PRBool)aReflowState.mFlags.mSpecialHeightReflow;
|
|
|
|
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = PR_FALSE;
|
2001-11-29 18:41:07 +03:00
|
|
|
|
1999-02-22 06:28:00 +03:00
|
|
|
SplitRowGroup(aPresContext, aDesiredSize, aReflowState, tableFrame, aStatus);
|
2001-11-29 18:41:07 +03:00
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = specialReflow;
|
2002-03-17 00:46:29 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
SetHasStyleHeight((NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight) &&
|
|
|
|
(aReflowState.mComputedHeight > 0));
|
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
2001-11-05 03:15:51 +03:00
|
|
|
SetNeedSpecialReflow(PR_FALSE);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// just set our width to what was available. The table will calculate the width and not use our value.
|
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
if (!haveDesiredHeight) {
|
|
|
|
// calculate the height based on the rect of the last row
|
2004-01-18 13:28:40 +03:00
|
|
|
aDesiredSize.height = GetHeightOfRows();
|
1999-08-31 02:30:32 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
|
2003-09-13 20:26:30 +04:00
|
|
|
aDesiredSize.mOverflowArea.UnionRect(aDesiredSize.mOverflowArea, nsRect(0, 0, aDesiredSize.width,
|
|
|
|
aDesiredSize.height));
|
2004-07-16 20:56:21 +04:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
2001-10-29 04:43:59 +03:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 18:55:51 +03:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState, &aDesiredSize, aStatus);
|
|
|
|
#endif
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::IncrementalReflow(nsPresContext* aPresContext,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
2002-05-10 22:22:41 +04:00
|
|
|
// the row group is a target if its path has a reflow command
|
|
|
|
nsHTMLReflowCommand* command = aReflowState.reflowState.path->mReflowCommand;
|
|
|
|
if (command)
|
|
|
|
IR_TargetIsMe(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
|
|
|
|
// see if the chidren are targets as well
|
|
|
|
// XXXwaterson Note that this will cause us to RecoverState (which
|
|
|
|
// is O(n) in the number of child rows) once for each reflow
|
|
|
|
// target. It'd probably be better to invert the loops; i.e., walk
|
|
|
|
// the rows, checking each to see if it's an IR target (which could
|
|
|
|
// be done in O(1) if we do hashing in the reflow path).
|
|
|
|
nsReflowPath::iterator iter = aReflowState.reflowState.path->FirstChild();
|
|
|
|
nsReflowPath::iterator end = aReflowState.reflowState.path->EndChildren();
|
|
|
|
for (; iter != end; ++iter)
|
|
|
|
IR_TargetIsChild(aPresContext, aDesiredSize, aReflowState, aStatus, *iter);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
2002-05-10 22:22:41 +04:00
|
|
|
return NS_OK;
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
|
1999-08-02 02:01:37 +04:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableRowGroupFrame::AppendFrames(nsIAtom* aListName,
|
1999-08-02 02:01:37 +04:00
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
// collect the new row frames in an array
|
2001-09-07 01:11:44 +04:00
|
|
|
nsAutoVoidArray rows;
|
2003-07-07 06:01:29 +04:00
|
|
|
for (nsIFrame* rowFrame = aFrameList; rowFrame;
|
|
|
|
rowFrame = rowFrame->GetNextSibling()) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == rowFrame->GetType()) {
|
1999-12-14 01:56:31 +03:00
|
|
|
rows.AppendElement(rowFrame);
|
|
|
|
}
|
|
|
|
}
|
1999-08-02 02:01:37 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
PRInt32 rowIndex = GetRowCount();
|
1999-12-14 01:56:31 +03:00
|
|
|
// Append the frames to the sibling chain
|
1999-08-02 02:01:37 +04:00
|
|
|
mFrames.AppendFrames(nsnull, aFrameList);
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
if (rows.Count() > 0) {
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (tableFrame) {
|
2005-02-07 04:58:25 +03:00
|
|
|
tableFrame->AppendRows(*this, rowIndex, rows);
|
1999-10-30 00:25:13 +04:00
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableFrame::AppendDirtyReflowCommand(this);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (tableFrame->RowIsSpannedInto(rowIndex)) {
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-10-30 00:25:13 +04:00
|
|
|
}
|
2003-06-05 21:44:28 +04:00
|
|
|
else if (!tableFrame->IsAutoHeight()) {
|
|
|
|
// The table isn't auto height, so any previously reflowed rows
|
|
|
|
// it contains were already adjusted so that they take up all of
|
|
|
|
// the table's height. We need to trigger a strategy balance to
|
|
|
|
// ensure that all rows are resized properly during the dirty reflow we
|
|
|
|
// generated above.
|
|
|
|
|
|
|
|
tableFrame->SetNeedStrategyBalance(PR_TRUE);
|
|
|
|
}
|
1999-08-02 02:01:37 +04:00
|
|
|
}
|
1999-08-02 06:18:33 +04:00
|
|
|
}
|
1999-08-02 02:01:37 +04:00
|
|
|
|
1999-08-02 06:18:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-02 02:01:37 +04:00
|
|
|
|
1999-08-02 06:18:33 +04:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableRowGroupFrame::InsertFrames(nsIAtom* aListName,
|
1999-08-02 06:18:33 +04:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2001-08-06 18:48:09 +04:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (!tableFrame) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "no table frame");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
// collect the new row frames in an array
|
|
|
|
nsVoidArray rows;
|
2001-08-06 18:48:09 +04:00
|
|
|
PRBool gotFirstRow = PR_FALSE;
|
2003-07-07 06:01:29 +04:00
|
|
|
for (nsIFrame* rowFrame = aFrameList; rowFrame;
|
|
|
|
rowFrame = rowFrame->GetNextSibling()) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == rowFrame->GetType()) {
|
1999-12-14 01:56:31 +03:00
|
|
|
rows.AppendElement(rowFrame);
|
2001-08-06 18:48:09 +04:00
|
|
|
if (!gotFirstRow) {
|
|
|
|
((nsTableRowFrame*)rowFrame)->SetFirstInserted(PR_TRUE);
|
|
|
|
gotFirstRow = PR_TRUE;
|
|
|
|
tableFrame->SetRowInserted(PR_TRUE);
|
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
}
|
1999-08-02 06:18:33 +04:00
|
|
|
|
2001-11-20 03:58:53 +03:00
|
|
|
PRInt32 startRowIndex = GetStartRowIndex();
|
1999-12-14 01:56:31 +03:00
|
|
|
// Insert the frames in the sibling chain
|
1999-08-02 06:18:33 +04:00
|
|
|
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
PRInt32 numRows = rows.Count();
|
|
|
|
if (numRows > 0) {
|
2004-01-18 13:28:40 +03:00
|
|
|
nsTableRowFrame* prevRow = (nsTableRowFrame *)nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame, nsLayoutAtoms::tableRowFrame);
|
2001-11-20 03:58:53 +03:00
|
|
|
PRInt32 rowIndex = (prevRow) ? prevRow->GetRowIndex() + 1 : startRowIndex;
|
2005-02-07 04:58:25 +03:00
|
|
|
tableFrame->InsertRows(*this, rows, rowIndex, PR_TRUE);
|
2001-08-06 18:48:09 +04:00
|
|
|
|
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableFrame::AppendDirtyReflowCommand(this);
|
2001-08-06 18:48:09 +04:00
|
|
|
if (tableFrame->RowIsSpannedInto(rowIndex) ||
|
|
|
|
tableFrame->RowHasSpanningCells(rowIndex + numRows - 1)) {
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
2003-06-05 21:44:28 +04:00
|
|
|
else if (!tableFrame->IsAutoHeight()) {
|
|
|
|
// The table isn't auto height, so any previously reflowed rows
|
|
|
|
// it contains were already adjusted so that they take up all of
|
|
|
|
// the table's height. We need to trigger a strategy balance to
|
|
|
|
// ensure that all rows are resized properly during the dirty reflow we
|
|
|
|
// generated above.
|
|
|
|
|
|
|
|
tableFrame->SetNeedStrategyBalance(PR_TRUE);
|
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
1999-08-02 06:18:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableRowGroupFrame::RemoveFrame(nsIAtom* aListName,
|
1999-08-02 06:18:33 +04:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (tableFrame) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == aOldFrame->GetType()) {
|
2001-03-13 09:38:59 +03:00
|
|
|
// remove the rows from the table (and flag a rebalance)
|
2005-02-07 04:58:25 +03:00
|
|
|
tableFrame->RemoveRows((nsTableRowFrame &)*aOldFrame, 1, PR_TRUE);
|
1999-08-02 06:18:33 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// XXX this could be optimized (see nsTableFrame::RemoveRows)
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-08-02 06:18:33 +04:00
|
|
|
// Because we haven't added any new frames we don't need to do a pass1
|
2001-03-13 09:38:59 +03:00
|
|
|
// reflow. Just generate a reflow command so we reflow the table
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableFrame::AppendDirtyReflowCommand(this);
|
1999-08-02 02:01:37 +04:00
|
|
|
}
|
|
|
|
}
|
2005-02-07 04:58:25 +03:00
|
|
|
mFrames.DestroyFrame(GetPresContext(), aOldFrame);
|
1999-08-02 02:01:37 +04:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
return NS_OK;
|
1999-08-02 02:01:37 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::IR_TargetIsMe(nsPresContext* aPresContext,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_FRAME_COMPLETE;
|
2001-12-18 01:39:59 +03:00
|
|
|
nsReflowType type;
|
2002-05-10 22:22:41 +04:00
|
|
|
aReflowState.reflowState.path->mReflowCommand->GetType(type);
|
2001-03-13 09:38:59 +03:00
|
|
|
|
|
|
|
switch (type) {
|
2001-12-18 01:39:59 +03:00
|
|
|
case eReflowType_ReflowDirty: {
|
2001-03-13 09:38:59 +03:00
|
|
|
nsRowGroupReflowState state(aReflowState);
|
|
|
|
state.reason = eReflowReason_Resize;
|
|
|
|
// Reflow the dirty child frames. Typically this is newly added frames.
|
2001-08-22 08:18:48 +04:00
|
|
|
nsTableRowFrame* firstRowReflowed;
|
2001-03-13 09:38:59 +03:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, state, aStatus,
|
2001-08-22 08:18:48 +04:00
|
|
|
nsnull, PR_TRUE, &firstRowReflowed);
|
|
|
|
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState.reflowState, firstRowReflowed);
|
2001-03-13 09:38:59 +03:00
|
|
|
break;
|
|
|
|
}
|
2001-12-18 01:39:59 +03:00
|
|
|
case eReflowType_StyleChanged :
|
2001-03-13 09:38:59 +03:00
|
|
|
rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
break;
|
2001-12-18 01:39:59 +03:00
|
|
|
case eReflowType_ContentChanged :
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTYETIMPLEMENTED("unexpected reflow command type");
|
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
|
1999-03-09 08:28:44 +03:00
|
|
|
// XXX If we have a next-in-flow, then we're not complete
|
|
|
|
if (mNextInFlow) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord
|
|
|
|
nsTableRowGroupFrame::GetHeightBasis(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
nscoord result = 0;
|
2001-11-05 18:15:24 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame((nsIFrame*)this, tableFrame);
|
|
|
|
if (tableFrame) {
|
|
|
|
if ((aReflowState.mComputedHeight > 0) && (aReflowState.mComputedHeight < NS_UNCONSTRAINEDSIZE)) {
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord cellSpacing = PR_MAX(0, GetRowCount() - 1) * tableFrame->GetCellSpacingY();
|
2001-11-05 18:15:24 +03:00
|
|
|
result = aReflowState.mComputedHeight - cellSpacing;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const nsHTMLReflowState* parentRS = aReflowState.parentReflowState;
|
|
|
|
if (parentRS && (tableFrame != parentRS->frame)) {
|
|
|
|
parentRS = parentRS->parentReflowState;
|
|
|
|
}
|
|
|
|
if (parentRS && (tableFrame == parentRS->frame) &&
|
|
|
|
(parentRS->mComputedHeight > 0) && (parentRS->mComputedHeight < NS_UNCONSTRAINEDSIZE)) {
|
2001-11-20 04:21:18 +03:00
|
|
|
nscoord cellSpacing = PR_MAX(0, tableFrame->GetRowCount() + 1) * tableFrame->GetCellSpacingY();
|
2001-11-05 18:15:24 +03:00
|
|
|
result = parentRS->mComputedHeight - cellSpacing;
|
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
}
|
2001-11-05 18:15:24 +03:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord
|
2004-01-18 13:28:40 +03:00
|
|
|
nsTableRowGroupFrame::GetHeightOfRows()
|
1999-06-14 12:22:47 +04:00
|
|
|
{
|
2000-04-29 01:05:31 +04:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
2005-03-24 22:02:59 +03:00
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (!tableFrame) return 0;
|
2000-04-29 01:05:31 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord height = 0;
|
2000-04-29 01:05:31 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// enumerate the rows and total their heights
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame* rowFrame = GetFirstChild(nsnull);
|
2001-03-13 09:38:59 +03:00
|
|
|
PRInt32 numRows = 0;
|
2004-01-09 17:20:53 +03:00
|
|
|
while (rowFrame) {
|
2003-05-15 07:42:21 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == rowFrame->GetStyleDisplay()->mDisplay) {
|
2003-07-07 06:01:29 +04:00
|
|
|
height += rowFrame->GetSize().height;
|
2001-03-13 09:38:59 +03:00
|
|
|
numRows++;
|
1999-06-14 12:22:47 +04:00
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
GetNextFrame(rowFrame, &rowFrame);
|
1999-06-14 12:22:47 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
if (numRows > 1) {
|
|
|
|
height += (numRows - 1) * tableFrame->GetCellSpacingY(); // add in cell spacing
|
|
|
|
}
|
|
|
|
|
|
|
|
return height;
|
1999-06-14 12:22:47 +04:00
|
|
|
}
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Recovers the reflow state to what it should be if aKidFrame is about
|
2001-03-13 09:38:59 +03:00
|
|
|
// to be reflowed. Restores availSize, y
|
1999-08-19 07:51:25 +04:00
|
|
|
nsresult
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowGroupFrame::RecoverState(nsRowGroupReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame)
|
1999-08-19 07:51:25 +04:00
|
|
|
{
|
2000-05-10 04:54:00 +04:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
|
|
|
|
|
2002-05-10 22:22:41 +04:00
|
|
|
aReflowState.y = 0;
|
|
|
|
|
2001-10-22 18:37:03 +04:00
|
|
|
// Walk the list of children up to aKidFrame
|
2003-07-07 06:01:29 +04:00
|
|
|
for (nsIFrame* frame = mFrames.FirstChild(); frame && (frame != aKidFrame);
|
|
|
|
frame = frame->GetNextSibling()) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (frame->GetType() == nsLayoutAtoms::tableRowFrame) {
|
2001-10-22 18:37:03 +04:00
|
|
|
// Update the running y-offset
|
2003-07-07 06:01:29 +04:00
|
|
|
nsSize kidSize = frame->GetSize();
|
2001-10-22 18:37:03 +04:00
|
|
|
aReflowState.y += kidSize.height + cellSpacingY;
|
1999-08-19 07:51:25 +04:00
|
|
|
|
2001-10-22 18:37:03 +04:00
|
|
|
// If our height is constrained then update the available height
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.availSize.height) {
|
|
|
|
aReflowState.availSize.height -= kidSize.height;
|
|
|
|
}
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-01 09:16:12 +04:00
|
|
|
PRBool
|
|
|
|
nsTableRowGroupFrame::IsSimpleRowFrame(nsTableFrame* aTableFrame,
|
|
|
|
nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
// Make sure it's a row frame and not a row group frame
|
2003-10-31 23:19:18 +03:00
|
|
|
if (aFrame->GetType() == nsLayoutAtoms::tableRowFrame) {
|
1999-09-01 09:16:12 +04:00
|
|
|
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-09-15 10:11:29 +04:00
|
|
|
nsIFrame*
|
|
|
|
GetLastRowSibling(nsIFrame* aRowFrame)
|
|
|
|
{
|
|
|
|
nsIFrame* lastRowFrame = nsnull;
|
2003-07-07 06:01:29 +04:00
|
|
|
for (nsIFrame* lastFrame = aRowFrame; lastFrame;
|
|
|
|
lastFrame = lastFrame->GetNextSibling()) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == lastFrame->GetType()) {
|
2000-09-15 10:11:29 +04:00
|
|
|
lastRowFrame = lastFrame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return lastRowFrame;
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::IR_TargetIsChild(nsPresContext* aPresContext,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame* aNextFrame)
|
1998-10-14 20:32:45 +04:00
|
|
|
|
|
|
|
{
|
|
|
|
nsresult rv;
|
2000-01-17 20:45:17 +03:00
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame); if (!tableFrame) ABORT1(NS_ERROR_NULL_POINTER);
|
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Recover the state as if aNextFrame is about to be reflowed
|
2001-03-13 09:38:59 +03:00
|
|
|
RecoverState(aReflowState, aNextFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
|
|
|
// Remember the old rect
|
2003-07-07 06:01:29 +04:00
|
|
|
nsSize oldKidSize = aNextFrame->GetSize();
|
1998-10-14 20:32:45 +04:00
|
|
|
|
2000-01-17 20:45:17 +03: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...
|
2002-02-19 18:48:28 +03:00
|
|
|
nsSize kidAvailSize(aReflowState.availSize.width, NS_UNCONSTRAINEDSIZE);
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState, aNextFrame,
|
|
|
|
kidAvailSize, aReflowState.reason);
|
|
|
|
InitChildReflowState(*aPresContext, tableFrame->IsBorderCollapse(), p2t, kidReflowState);
|
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
nsHTMLReflowMetrics desiredSize(aDesiredSize.mComputeMEW,
|
2000-03-09 11:45:26 +03:00
|
|
|
aDesiredSize.mFlags);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
2000-01-17 20:45:17 +03:00
|
|
|
// Pass along the reflow command
|
1999-11-19 18:33:29 +03:00
|
|
|
rv = ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState,
|
|
|
|
0, aReflowState.y, 0, aStatus);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Place the row frame
|
|
|
|
nsRect kidRect(0, aReflowState.y, desiredSize.width, desiredSize.height);
|
2001-03-13 09:38:59 +03:00
|
|
|
PlaceChild(aPresContext, aReflowState, aNextFrame, desiredSize);
|
1999-08-19 07:51:25 +04: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 18:28:00 +04:00
|
|
|
// Only call CalculateRowHeights() if necessary since it can be expensive
|
|
|
|
PRBool needToCalcRowHeights = PR_FALSE;
|
1999-09-01 09:16:12 +04:00
|
|
|
if (IsSimpleRowFrame(aReflowState.tableFrame, aNextFrame)) {
|
1999-09-13 07:19:39 +04:00
|
|
|
// See if the row changed height
|
2003-07-07 06:01:29 +04:00
|
|
|
if (oldKidSize.height == desiredSize.height) {
|
1999-09-13 07:19:39 +04:00
|
|
|
// 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
|
2003-07-07 06:01:29 +04:00
|
|
|
aDesiredSize.height = GetLastRowSibling(mFrames.FirstChild())->GetRect().YMost();
|
1999-09-13 07:19:39 +04:00
|
|
|
} else {
|
|
|
|
// Inform the row of its new height.
|
|
|
|
((nsTableRowFrame*)aNextFrame)->DidResize(aPresContext, aReflowState.reflowState);
|
2003-09-13 20:26:30 +04:00
|
|
|
// the overflow area may have changed inflate the overflow area
|
2001-05-14 18:28:00 +04: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...
|
2004-03-10 06:09:05 +03:00
|
|
|
Invalidate(kidRect);
|
2001-11-06 04:44:20 +03:00
|
|
|
|
2001-05-14 18:28:00 +04:00
|
|
|
// 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());
|
2004-03-10 06:09:05 +03:00
|
|
|
Invalidate(dirtyRect);
|
2001-05-14 18:28:00 +04:00
|
|
|
}
|
1999-09-13 07:19:39 +04:00
|
|
|
|
2001-05-14 18:28:00 +04:00
|
|
|
// Adjust the frames that follow
|
2004-12-27 18:05:18 +03:00
|
|
|
AdjustSiblingsAfterReflow(aReflowState, aNextFrame,
|
2003-07-07 06:01:29 +04:00
|
|
|
desiredSize.height - oldKidSize.height);
|
2001-05-14 18:28:00 +04:00
|
|
|
aDesiredSize.height = aReflowState.y;
|
1999-09-13 07:19:39 +04:00
|
|
|
}
|
2001-05-14 18:28:00 +04:00
|
|
|
else needToCalcRowHeights = PR_TRUE;
|
1999-09-13 07:19:39 +04:00
|
|
|
}
|
1999-08-19 07:51:25 +04:00
|
|
|
} else {
|
2000-05-26 02:40:21 +04: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
|
2003-07-07 06:01:29 +04:00
|
|
|
aDesiredSize.height = GetLastRowSibling(mFrames.FirstChild())->GetRect().YMost();
|
2001-05-14 18:28:00 +04: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,
|
2003-07-07 06:01:29 +04:00
|
|
|
// desiredSize.height - oldKidSize.height);
|
1999-12-16 03:37:03 +03:00
|
|
|
|
2001-05-14 18:28:00 +04:00
|
|
|
// Now recalculate the row heights
|
|
|
|
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState.reflowState);
|
1999-12-16 03:37:03 +03:00
|
|
|
|
2001-05-14 18:28:00 +04: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);
|
2004-03-10 06:09:05 +03:00
|
|
|
Invalidate(dirtyRect);
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
2004-01-28 21:44:41 +03:00
|
|
|
else {
|
|
|
|
// need to recover the OverflowArea
|
|
|
|
for (nsTableRowFrame* rowFrame = GetFirstRow(); rowFrame; rowFrame = rowFrame->GetNextRow()) {
|
2004-12-27 18:05:18 +03:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowArea, rowFrame);
|
2004-01-28 21:44:41 +03:00
|
|
|
}
|
2004-07-16 20:56:21 +04:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
2004-01-28 21:44:41 +03:00
|
|
|
}
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return our desired width
|
2001-03-13 09:38:59 +03:00
|
|
|
//aDesiredSize.width = aReflowState.reflowState.availableWidth;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-03-09 08:28:44 +03:00
|
|
|
if (mNextInFlow) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::IR_StyleChanged(nsPresContext* aPresContext,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-30 10:57:44 +03:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// we presume that all the easy optimizations were done in the nsHTMLStyleSheet before we were called here
|
|
|
|
// XXX: we can optimize this when we know which style attribute changed
|
2001-03-13 09:38:59 +03:00
|
|
|
aReflowState.tableFrame->SetNeedStrategyInit(PR_TRUE);
|
2001-11-14 14:40:03 +03:00
|
|
|
nsRowGroupReflowState state(aReflowState);
|
|
|
|
nsTableRowFrame* firstRowReflowed;
|
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, state, aStatus,
|
|
|
|
nsnull, PR_FALSE, &firstRowReflowed);
|
|
|
|
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState.reflowState, firstRowReflowed);
|
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsTableRowGroupFrame::GetType() const
|
1999-02-24 08:54:31 +03:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::tableRowGroupFrame;
|
1999-02-24 08:54:31 +03: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
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewTableRowGroupFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsTableRowGroupFrame* it = new (aPresShell) nsTableRowGroupFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-23 15:35:34 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::Init(nsPresContext* aPresContext,
|
2001-02-23 15:35:34 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-02-23 15:35:34 +03:00
|
|
|
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-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsTableRowGroupFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 20:22:29 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableRowGroup"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|
2000-05-11 05:04:39 +04:00
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
nsMargin*
|
|
|
|
nsTableRowGroupFrame::GetBCBorderWidth(float aPixelsToTwips,
|
|
|
|
nsMargin& aBorder)
|
|
|
|
{
|
|
|
|
aBorder.left = aBorder.right = 0;
|
|
|
|
|
|
|
|
nsTableRowFrame* firstRowFrame = nsnull;
|
|
|
|
nsTableRowFrame* lastRowFrame = nsnull;
|
|
|
|
for (nsTableRowFrame* rowFrame = GetFirstRow(); rowFrame; rowFrame = rowFrame->GetNextRow()) {
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!firstRowFrame) {
|
2002-02-19 18:48:28 +03:00
|
|
|
firstRowFrame = rowFrame;
|
|
|
|
}
|
|
|
|
lastRowFrame = rowFrame;
|
|
|
|
}
|
|
|
|
if (firstRowFrame) {
|
|
|
|
aBorder.top = firstRowFrame->GetTopBCBorderWidth(&aPixelsToTwips);
|
|
|
|
aBorder.bottom = lastRowFrame->GetBottomBCBorderWidth(&aPixelsToTwips);
|
|
|
|
}
|
|
|
|
|
|
|
|
return &aBorder;
|
|
|
|
}
|
|
|
|
|
2004-03-09 09:48:35 +03:00
|
|
|
void nsTableRowGroupFrame::SetContinuousBCBorderWidth(PRUint8 aForSide,
|
|
|
|
BCPixelSize aPixelValue)
|
|
|
|
{
|
|
|
|
switch (aForSide) {
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
mRightContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
mBottomContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
mLeftContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
NS_ERROR("invalid NS_SIDE argument");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-11 05:04:39 +04:00
|
|
|
//nsILineIterator methods for nsTableFrame
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetNumLines(PRInt32* aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
2001-03-13 09:38:59 +03:00
|
|
|
*aResult = GetRowCount();
|
|
|
|
return *aResult; // XXX should return NS_OK
|
2000-05-11 05:04:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetDirection(PRBool* aIsRightToLeft)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsRightToLeft);
|
|
|
|
*aIsRightToLeft = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowGroupFrame::GetLine(PRInt32 aLineNumber,
|
|
|
|
nsIFrame** aFirstFrameOnLine,
|
|
|
|
PRInt32* aNumFramesOnLine,
|
|
|
|
nsRect& aLineBounds,
|
|
|
|
PRUint32* aLineFlags)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFirstFrameOnLine);
|
|
|
|
NS_ENSURE_ARG_POINTER(aNumFramesOnLine);
|
|
|
|
NS_ENSURE_ARG_POINTER(aLineFlags);
|
|
|
|
|
2000-05-13 13:02:27 +04:00
|
|
|
nsTableFrame* parentFrame = nsnull;
|
|
|
|
if (NS_FAILED(nsTableFrame::GetTableFrame(this, parentFrame)))
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-05-11 05:04:39 +04:00
|
|
|
|
|
|
|
nsTableCellMap* cellMap = parentFrame->GetCellMap();
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!cellMap)
|
2000-05-11 05:04:39 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2003-09-13 20:26:30 +04:00
|
|
|
if (aLineNumber >= cellMap->GetRowCount())
|
2000-05-11 05:04:39 +04:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
*aLineFlags = 0;/// should we fill these in later?
|
|
|
|
// not gonna touch aLineBounds right now
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
CellData* firstCellData = cellMap->GetDataAt(aLineNumber, 0);
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!firstCellData)
|
2001-01-27 02:40:36 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2000-05-11 05:04:39 +04:00
|
|
|
*aFirstFrameOnLine = (nsIFrame*)firstCellData->GetCellFrame();
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!(*aFirstFrameOnLine))
|
2000-05-14 04:10:25 +04:00
|
|
|
{
|
|
|
|
while((aLineNumber > 0)&&(!(*aFirstFrameOnLine)))
|
|
|
|
{
|
|
|
|
aLineNumber--;
|
2002-02-19 18:48:28 +03:00
|
|
|
firstCellData = cellMap->GetDataAt(aLineNumber, 0);
|
2000-05-14 04:10:25 +04:00
|
|
|
*aFirstFrameOnLine = (nsIFrame*)firstCellData->GetCellFrame();
|
|
|
|
}
|
|
|
|
}
|
2000-05-11 05:04:39 +04:00
|
|
|
*aNumFramesOnLine = cellMap->GetNumCellsOriginatingInRow(aLineNumber);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowGroupFrame::FindLineContaining(nsIFrame* aFrame,
|
|
|
|
PRInt32* aLineNumberResult)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFrame);
|
|
|
|
NS_ENSURE_ARG_POINTER(aLineNumberResult);
|
|
|
|
|
2001-07-18 00:27:01 +04:00
|
|
|
// make sure it is a rowFrame in the RowGroup
|
|
|
|
// - it should be, but we do not validate in every case (see bug 88849)
|
2003-10-31 23:19:18 +03:00
|
|
|
if (aFrame->GetType() != nsLayoutAtoms::tableRowFrame) {
|
2001-07-18 00:27:01 +04:00
|
|
|
NS_WARNING("RowGroup contains a frame that is not a row");
|
|
|
|
*aLineNumberResult = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2000-05-11 05:04:39 +04:00
|
|
|
nsTableRowFrame* rowFrame = (nsTableRowFrame*)aFrame;
|
|
|
|
*aLineNumberResult = rowFrame->GetRowIndex();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowGroupFrame::FindLineAt(nscoord aY,
|
|
|
|
PRInt32* aLineNumberResult)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2001-03-13 01:25:55 +03: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 05:04:39 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowGroupFrame::FindFrameAt(PRInt32 aLineNumber,
|
|
|
|
nscoord aX,
|
|
|
|
nsIFrame** aFrameFound,
|
|
|
|
PRBool* aXIsBeforeFirstFrame,
|
|
|
|
PRBool* aXIsAfterLastFrame)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
2003-01-18 17:05:50 +03:00
|
|
|
PRInt32 colCount = 0;
|
2000-05-11 05:04:39 +04:00
|
|
|
CellData* cellData;
|
2002-01-04 13:52:48 +03:00
|
|
|
nsIFrame* tempFrame = nsnull;
|
2000-05-11 05:04:39 +04:00
|
|
|
|
2000-05-13 13:02:27 +04:00
|
|
|
nsTableFrame* parentFrame = nsnull;
|
2003-07-07 06:01:29 +04:00
|
|
|
nsTableFrame::GetTableFrame(this, parentFrame);
|
2000-05-11 05:04:39 +04:00
|
|
|
nsTableCellMap* cellMap = parentFrame->GetCellMap();
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!cellMap)
|
2000-05-11 05:04:39 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2003-01-18 17:05:50 +03:00
|
|
|
colCount = cellMap->GetColCount();
|
2000-05-11 05:04:39 +04:00
|
|
|
|
|
|
|
*aXIsBeforeFirstFrame = PR_FALSE;
|
|
|
|
*aXIsAfterLastFrame = PR_FALSE;
|
|
|
|
|
2000-05-14 04:10:25 +04:00
|
|
|
PRBool gotParentRect = PR_FALSE;
|
2003-01-18 17:05:50 +03:00
|
|
|
for (PRInt32 i = 0; i < colCount; i++)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
2002-02-19 18:48:28 +03:00
|
|
|
cellData = cellMap->GetDataAt(aLineNumber, i);
|
2003-02-17 09:17:09 +03:00
|
|
|
if (!cellData)
|
|
|
|
continue; // we hit a cellmap hole
|
2003-01-18 17:05:50 +03:00
|
|
|
if (!cellData->IsOrig())
|
|
|
|
continue;
|
2000-05-11 05:04:39 +04:00
|
|
|
tempFrame = (nsIFrame*)cellData->GetCellFrame();
|
2000-05-14 04:10:25 +04:00
|
|
|
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!tempFrame)
|
2000-05-14 04:10:25 +04:00
|
|
|
continue;
|
2000-05-11 05:04:39 +04:00
|
|
|
|
2003-07-07 06:01:29 +04:00
|
|
|
nsRect tempRect = tempFrame->GetRect();//offsetting x to be in row coordinates
|
2000-05-14 04:10:25 +04:00
|
|
|
if(!gotParentRect)
|
2000-05-11 05:04:39 +04:00
|
|
|
{//only do this once
|
2003-07-07 06:01:29 +04:00
|
|
|
nsIFrame* tempParentFrame = tempFrame->GetParent();
|
2001-10-13 13:27:46 +04:00
|
|
|
if(!tempParentFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-05-11 05:04:39 +04:00
|
|
|
|
2003-07-07 06:01:29 +04:00
|
|
|
aX -= tempParentFrame->GetPosition().x;
|
2000-05-14 04:10:25 +04:00
|
|
|
gotParentRect = PR_TRUE;
|
2000-05-11 05:04:39 +04:00
|
|
|
}
|
|
|
|
|
2003-09-13 20:26:30 +04:00
|
|
|
if (i==0 &&(aX <= 0))//short circuit for negative x coords
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
|
|
|
*aXIsBeforeFirstFrame = PR_TRUE;
|
|
|
|
*aFrameFound = tempFrame;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2003-09-13 20:26:30 +04:00
|
|
|
if (aX < tempRect.x)
|
2000-05-14 04:10:25 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
if(aX < tempRect.XMost())
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
|
|
|
*aFrameFound = tempFrame;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//x coord not found in frame, return last frame
|
|
|
|
*aXIsAfterLastFrame = PR_TRUE;
|
|
|
|
*aFrameFound = tempFrame;
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!(*aFrameFound))
|
2000-05-14 04:10:25 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
2000-05-11 05:04:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowGroupFrame::GetNextSiblingOnLine(nsIFrame*& aFrame,
|
|
|
|
PRInt32 aLineNumber)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFrame);
|
|
|
|
|
|
|
|
nsITableCellLayout* cellFrame;
|
2002-12-13 18:21:38 +03:00
|
|
|
nsresult result = CallQueryInterface(aFrame, &cellFrame);
|
2003-09-13 20:26:30 +04:00
|
|
|
if (NS_FAILED(result))
|
2002-12-13 18:21:38 +03:00
|
|
|
return result;
|
|
|
|
|
2000-05-13 13:02:27 +04:00
|
|
|
nsTableFrame* parentFrame = nsnull;
|
|
|
|
result = nsTableFrame::GetTableFrame(this, parentFrame);
|
2000-05-11 05:04:39 +04:00
|
|
|
nsTableCellMap* cellMap = parentFrame->GetCellMap();
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!cellMap)
|
2000-05-11 05:04:39 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
|
|
|
|
PRInt32 colIndex;
|
|
|
|
PRInt32& colIndexRef = colIndex;
|
|
|
|
cellFrame->GetColIndex(colIndexRef);
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
CellData* cellData = cellMap->GetDataAt(aLineNumber, colIndex + 1);
|
2000-05-11 05:04:39 +04:00
|
|
|
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!cellData)// if this isnt a valid cell, drop down and check the next line
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
2002-02-19 18:48:28 +03:00
|
|
|
cellData = cellMap->GetDataAt(aLineNumber + 1, 0);
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!cellData)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
|
|
|
//*aFrame = nsnull;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!aFrame)
|
2000-05-14 04:10:25 +04:00
|
|
|
{
|
|
|
|
//PRInt32 numCellsInRow = cellMap->GetNumCellsOriginatingInRow(aLineNumber) - 1;
|
|
|
|
PRInt32 tempCol = colIndex + 1;
|
|
|
|
PRInt32 tempRow = aLineNumber;
|
2003-09-13 20:26:30 +04:00
|
|
|
while ((tempCol > 0) && (!aFrame))
|
2000-05-14 04:10:25 +04:00
|
|
|
{
|
|
|
|
tempCol--;
|
2002-02-19 18:48:28 +03:00
|
|
|
cellData = cellMap->GetDataAt(aLineNumber, tempCol);
|
2000-05-14 04:10:25 +04:00
|
|
|
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!aFrame && (tempCol==0))
|
2000-05-14 04:10:25 +04:00
|
|
|
{
|
2003-09-13 20:26:30 +04:00
|
|
|
while ((tempRow > 0) && (!aFrame))
|
2000-05-14 04:10:25 +04:00
|
|
|
{
|
|
|
|
tempRow--;
|
2002-02-19 18:48:28 +03:00
|
|
|
cellData = cellMap->GetDataAt(tempRow, 0);
|
2000-05-14 04:10:25 +04:00
|
|
|
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-05-11 05:04:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-11 18:56:29 +04:00
|
|
|
//end nsLineIterator methods
|
|
|
|
|