2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
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.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* 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
|
|
|
|
* either 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"),
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** 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"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIContent.h"
|
1998-04-15 01:49:29 +04:00
|
|
|
#include "nsIView.h"
|
2001-12-18 01:39:59 +03:00
|
|
|
#include "nsHTMLReflowCommand.h"
|
1998-10-01 08:46:11 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1999-01-18 02:35:56 +03:00
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
1999-02-24 07:03:50 +03:00
|
|
|
#include "nsIStyleSet.h"
|
|
|
|
#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"
|
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
|
|
|
}
|
2000-05-16 12:11:14 +04: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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::IsPercentageBase(PRBool& aBase) const
|
|
|
|
{
|
|
|
|
aBase = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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;
|
2001-03-13 09:38:59 +03:00
|
|
|
const nsStyleDisplay* childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-09-16 00:36:42 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
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;
|
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->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
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableRowGroupFrame::InitRepeatedFrame(nsIPresContext* aPresContext,
|
|
|
|
nsTableRowGroupFrame* aHeaderFooterFrame)
|
1999-03-03 19:33:57 +03:00
|
|
|
{
|
|
|
|
nsIFrame* originalRowFrame;
|
1999-06-23 07:02:21 +04:00
|
|
|
nsIFrame* copyRowFrame = GetFirstFrame();
|
1999-03-03 19:33:57 +03:00
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
aHeaderFooterFrame->FirstChild(aPresContext, nsnull, &originalRowFrame);
|
1999-03-03 19:33:57 +03:00
|
|
|
while (copyRowFrame) {
|
|
|
|
// Set the row frame index
|
|
|
|
int rowIndex = ((nsTableRowFrame*)originalRowFrame)->GetRowIndex();
|
|
|
|
((nsTableRowFrame*)copyRowFrame)->SetRowIndex(rowIndex);
|
|
|
|
|
|
|
|
// For each table cell frame set its column index
|
|
|
|
nsIFrame* originalCellFrame;
|
|
|
|
nsIFrame* copyCellFrame;
|
2000-01-22 04:16:50 +03:00
|
|
|
originalRowFrame->FirstChild(aPresContext, nsnull, &originalCellFrame);
|
|
|
|
copyRowFrame->FirstChild(aPresContext, nsnull, ©CellFrame);
|
1999-03-03 19:33:57 +03:00
|
|
|
while (copyCellFrame) {
|
|
|
|
nsIAtom* frameType;
|
|
|
|
copyCellFrame->GetFrameType(&frameType);
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
if (IS_TABLE_CELL(frameType)) {
|
1999-03-03 19:33:57 +03:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsIContent* content1;
|
|
|
|
nsIContent* content2;
|
|
|
|
originalCellFrame->GetContent(&content1);
|
|
|
|
copyCellFrame->GetContent(&content2);
|
|
|
|
NS_ASSERTION(content1 == content2, "cell frames have different content");
|
|
|
|
NS_IF_RELEASE(content1);
|
|
|
|
NS_IF_RELEASE(content2);
|
|
|
|
#endif
|
|
|
|
PRInt32 colIndex;
|
|
|
|
((nsTableCellFrame*)originalCellFrame)->GetColIndex(colIndex);
|
|
|
|
((nsTableCellFrame*)copyCellFrame)->InitCellFrame(colIndex);
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
|
|
|
|
// Move to the next cell frame
|
|
|
|
copyCellFrame->GetNextSibling(©CellFrame);
|
|
|
|
originalCellFrame->GetNextSibling(&originalCellFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move to the next row frame
|
1999-06-23 07:02:21 +04:00
|
|
|
GetNextFrame(originalRowFrame, &originalRowFrame);
|
|
|
|
GetNextFrame(copyRowFrame, ©RowFrame);
|
1999-03-03 19:33:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-10-22 09:27:11 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext* 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
|
2002-02-21 08:36:16 +03:00
|
|
|
// Standards mode background painting removed. See bug 4510
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2002-02-21 08:36:16 +03:00
|
|
|
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Display);
|
|
|
|
if (disp && (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow)) {
|
|
|
|
aRenderingContext.PushState();
|
|
|
|
SetOverflowClipRect(aRenderingContext);
|
2001-09-19 16:35:19 +04:00
|
|
|
}
|
2002-02-26 03:27:42 +03:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
|
2002-02-21 08:36:16 +03:00
|
|
|
if (disp && (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow)) {
|
|
|
|
PRBool clipState;
|
|
|
|
aRenderingContext.PopState(clipState);
|
2001-09-19 16:35:19 +04:00
|
|
|
}
|
1999-09-18 03:33:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
/*nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);*/
|
1999-06-08 01:10:25 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
PRIntn
|
|
|
|
nsTableRowGroupFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// aDirtyRect is in our coordinate system
|
|
|
|
// child rect's are also in our coordinate system
|
2001-03-13 09:38:59 +03:00
|
|
|
// overloaded method from nsContainerFrame. The difference is that
|
|
|
|
// we don't want to clip our children, so a cell can do a rowspan
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
void nsTableRowGroupFrame::PaintChildren(nsIPresContext* aPresContext,
|
1998-04-14 00:24:54 +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
|
|
|
{
|
1999-06-23 07:02:21 +04:00
|
|
|
nsIFrame* kid = GetFirstFrame();
|
1998-04-14 00:24:54 +04:00
|
|
|
while (nsnull != kid) {
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIView *pView;
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
kid->GetView(aPresContext, &pView);
|
1998-04-15 01:49:29 +04:00
|
|
|
if (nsnull == pView) {
|
1998-10-30 05:08:25 +03:00
|
|
|
PRBool clipState;
|
1998-04-15 01:49:29 +04:00
|
|
|
nsRect kidRect;
|
|
|
|
kid->GetRect(kidRect);
|
|
|
|
nsRect damageArea(aDirtyRect);
|
|
|
|
// Translate damage area into kid's coordinate system
|
|
|
|
nsRect kidDamageArea(damageArea.x - kidRect.x, damageArea.y - kidRect.y,
|
|
|
|
damageArea.width, damageArea.height);
|
|
|
|
aRenderingContext.PushState();
|
|
|
|
aRenderingContext.Translate(kidRect.x, kidRect.y);
|
2002-02-26 03:27:42 +03:00
|
|
|
kid->Paint(aPresContext, aRenderingContext, kidDamageArea, aWhichLayer, aFlags);
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1999-03-26 03:39:35 +03:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) &&
|
|
|
|
GetShowFrameBorders()) {
|
1998-04-15 01:49:29 +04:00
|
|
|
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
|
|
|
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-10-30 05:08:25 +03:00
|
|
|
aRenderingContext.PopState(clipState);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
GetNextFrame(kid, &kid);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsTableRowGroupFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
2000-03-22 05:43:08 +03:00
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
nsIFrame** aFrame)
|
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
|
|
|
|
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
|
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
|
|
|
|
nsTableRowGroupFrame::PlaceChild(nsIPresContext* aPresContext,
|
|
|
|
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
|
|
|
|
nsTableRowGroupFrame::InitChildReflowState(nsIPresContext& aPresContext,
|
|
|
|
PRBool aBorderCollapse,
|
|
|
|
float aPixelsToTwips,
|
|
|
|
nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
nsMargin collapseBorder;
|
|
|
|
nsMargin padding(0,0,0,0);
|
|
|
|
nsMargin* pCollapseBorder = nsnull;
|
|
|
|
if (aBorderCollapse) {
|
|
|
|
if (aReflowState.frame) {
|
|
|
|
nsCOMPtr<nsIAtom> fType;
|
|
|
|
aReflowState.frame->GetFrameType(getter_AddRefs(fType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == fType.get()) {
|
|
|
|
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
|
|
|
|
nsTableRowGroupFrame::ReflowChildren(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsTableRowFrame* aStartFrame,
|
2001-08-22 08:18:48 +04:00
|
|
|
PRBool aDirtyOnly,
|
|
|
|
nsTableRowFrame** aFirstRowReflowed)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
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
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
PRBool isPaginated;
|
|
|
|
aPresContext->IsPaginated(&isPaginated);
|
|
|
|
|
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
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
for ( ; kidFrame; kidFrame->GetNextSibling(&kidFrame)) {
|
1999-08-02 02:01:37 +04:00
|
|
|
// Get the frame state bits
|
2001-11-05 03:15:51 +03:00
|
|
|
nsCOMPtr<nsIAtom> kidType;
|
|
|
|
kidFrame->GetFrameType(getter_AddRefs(kidType));
|
1999-08-02 02:01:37 +04:00
|
|
|
nsFrameState frameState;
|
|
|
|
kidFrame->GetFrameState(&frameState);
|
|
|
|
|
|
|
|
// See if we should only reflow the dirty child frames
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool doReflowChild = PR_TRUE;
|
|
|
|
if (aDirtyOnly && ((frameState & NS_FRAME_IS_DIRTY) == 0)) {
|
|
|
|
doReflowChild = PR_FALSE;
|
1999-06-23 07:02:21 +04:00
|
|
|
}
|
2001-12-07 17:51:12 +03:00
|
|
|
if (aReflowState.reflowState.mFlags.mSpecialHeightReflow) {
|
2001-11-05 03:15:51 +03:00
|
|
|
if (!isPaginated && (nsLayoutAtoms::tableRowFrame == kidType.get() &&
|
|
|
|
!((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
|
2001-03-13 09:38:59 +03:00
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
|
|
|
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.
|
|
|
|
nsIFrame* target = nsnull;
|
|
|
|
nsReflowReason reason = aReflowState.reason;
|
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
|
|
|
aReflowState.reflowState.reflowCommand->GetTarget(target);
|
|
|
|
if (this == target) {
|
2001-12-18 01:39:59 +03:00
|
|
|
nsReflowType type;
|
2001-11-14 14:40:03 +03:00
|
|
|
aReflowState.reflowState.reflowCommand->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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (frameState & NS_FRAME_FIRST_REFLOW) {
|
|
|
|
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
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// If this isn't the first row frame, then we can't be at the top of
|
|
|
|
// the page anymore...
|
|
|
|
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) {
|
2001-11-05 03:15:51 +03:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == kidType.get()) {
|
2001-08-22 08:18:48 +04:00
|
|
|
*aFirstRowReflowed = (nsTableRowFrame*)kidFrame;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
nsSize kidSize;
|
1999-08-03 06:41:27 +04:00
|
|
|
kidFrame->GetSize(kidSize);
|
2000-04-29 01:05:31 +04:00
|
|
|
aReflowState.y += kidSize.height + cellSpacingY;
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
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) {
|
|
|
|
nsIFrame* nextRow = nsnull;
|
|
|
|
lastReflowedRow->GetNextSibling(&nextRow);
|
|
|
|
if (nextRow) {
|
|
|
|
nsRect lastReflowedRect, nextRect;
|
|
|
|
lastReflowedRow->GetRect(lastReflowedRect);
|
|
|
|
nextRow->GetRect(nextRect);
|
|
|
|
nscoord deltaY = cellSpacingY + lastReflowedRect.YMost() - nextRect.y;
|
|
|
|
if (deltaY != 0) {
|
|
|
|
AdjustSiblingsAfterReflow(aPresContext, aReflowState, lastReflowedRow, deltaY);
|
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2001-11-05 03:15:51 +03:00
|
|
|
nsIFrame* childFrame = GetFirstFrame();
|
|
|
|
while (childFrame) {
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
childFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType.get()) {
|
|
|
|
return (nsTableRowFrame*)childFrame;
|
1999-03-17 02:42:38 +03:00
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
childFrame->GetNextSibling(&childFrame);
|
|
|
|
}
|
|
|
|
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
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableRowGroupFrame::DidResizeRows(nsIPresContext& aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
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();
|
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
|
|
|
rowFrame->DidResize(&aPresContext, aReflowState);
|
2000-02-03 17:04:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
static PRBool
|
|
|
|
HasMoreThanOneCell(nsTableCellMap* aCellMap,
|
|
|
|
PRInt32 aRowIndex)
|
|
|
|
{
|
|
|
|
if (aCellMap) {
|
|
|
|
CellData* cellData;
|
|
|
|
PRInt32 colIndex = 0;
|
|
|
|
PRInt32 count = 0;
|
|
|
|
do {
|
2002-02-19 18:48:28 +03:00
|
|
|
cellData = aCellMap->GetDataAt(aRowIndex, colIndex);
|
2001-11-05 03:15:51 +03:00
|
|
|
if (cellData && (cellData->GetCellFrame() || cellData->IsRowSpan()))
|
|
|
|
count++;
|
|
|
|
if (count > 1)
|
|
|
|
return PR_TRUE;
|
|
|
|
colIndex++;
|
|
|
|
} while(cellData);
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext* aPresContext,
|
|
|
|
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);
|
|
|
|
if (!aPresContext || !tableFrame) return;
|
2000-02-03 17:04:49 +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;
|
|
|
|
aPresContext->GetPixelsToTwips(&p2t);
|
1999-05-27 02:22:23 +04:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
// find the nearest row at or before aStartRowFrameIn that isn't spanned into.
|
|
|
|
// If we have a computed height, then we can't compute the heights
|
|
|
|
// incrementally from aStartRowFrameIn, and we must start at the first row.
|
|
|
|
nsTableRowFrame* startRowFrame = GetFirstRow();
|
|
|
|
if (aStartRowFrameIn && (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedHeight)
|
|
|
|
&& (aReflowState.mComputedHeight > 0)) {
|
|
|
|
nsTableRowFrame* rowFrame = startRowFrame;
|
|
|
|
while (rowFrame) {
|
|
|
|
PRInt32 rowIndex = rowFrame->GetRowIndex();
|
|
|
|
if (!tableFrame->RowIsSpannedInto(rowIndex)) {
|
|
|
|
startRowFrame = rowFrame;
|
|
|
|
if (aStartRowFrameIn == startRowFrame)
|
|
|
|
break;
|
2001-08-22 08:18:48 +04:00
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
else if (aStartRowFrameIn == rowFrame)
|
|
|
|
break;
|
|
|
|
rowFrame = rowFrame->GetNextRow();
|
2001-08-22 08:18:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!startRowFrame) return;
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
PRInt32 startRowIndex = startRowFrame->GetRowIndex();
|
|
|
|
|
2001-08-22 08:18:48 +04:00
|
|
|
nsRect startRowRect;
|
|
|
|
startRowFrame->GetRect(startRowRect);
|
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
|
|
|
|
nscoord startRowGroupHeight = startRowRect.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++) {
|
2001-11-14 16:44:38 +03:00
|
|
|
if (rowFrame->HasPctHeight()) {
|
|
|
|
rowInfo[rowIndex].hasPctHeight = PR_TRUE;
|
|
|
|
rowInfo[rowIndex].pctHeight = nsTableFrame::RoundToPixel(rowFrame->GetHeight(pctHeightBasis), p2t);
|
|
|
|
}
|
|
|
|
nscoord nonPctHeight = PR_MAX(rowFrame->GetContentHeight(), rowFrame->GetFixedHeight());
|
|
|
|
UpdateHeights(rowInfo[rowIndex], nonPctHeight, heightOfRows, heightOfUnStyledRows);
|
2001-11-05 03:15:51 +03:00
|
|
|
rowInfo[rowIndex].hasStyleHeight = rowFrame->HasStyleHeight();
|
|
|
|
|
|
|
|
if (!rowInfo[rowIndex].hasStyleHeight) {
|
|
|
|
if (HasMoreThanOneCell(tableFrame->GetCellMap(), rowIndex)) {
|
|
|
|
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++) {
|
|
|
|
if (tableFrame->RowHasSpanningCells(startRowIndex + rowIndex)) {
|
|
|
|
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
|
|
|
|
nsSize cellFrameSize;
|
|
|
|
cellFrame->GetSize(cellFrameSize);
|
|
|
|
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) {
|
|
|
|
nscoord rowExtra = PR_MAX(0, rInfo.pctHeight - rInfo.height);
|
|
|
|
rowExtra = PR_MIN(rowExtra, extra);
|
|
|
|
UpdateHeights(rInfo, rowExtra, heightOfRows, heightOfUnStyledRows);
|
|
|
|
extra -= rowExtra;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
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++) {
|
|
|
|
nsRect rowBounds;
|
|
|
|
rowFrame->GetRect(rowBounds);
|
|
|
|
|
|
|
|
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;
|
|
|
|
rowFrame->SetRect(aPresContext, rowBounds);
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
if (movedFrame) {
|
|
|
|
nsTableFrame::RePositionViews(aPresContext, 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
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
DidResizeRows(*aPresContext, aReflowState, startRowFrame);
|
|
|
|
|
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
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowGroupFrame::AdjustSiblingsAfterReflow(nsIPresContext* aPresContext,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
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
|
1999-08-31 02:30:32 +04:00
|
|
|
nsIFrame* kidFrame;
|
|
|
|
for (aKidFrame->GetNextSibling(&kidFrame); kidFrame; kidFrame->GetNextSibling(&kidFrame)) {
|
|
|
|
// Move the frame if we need to
|
|
|
|
if (aDeltaY != 0) {
|
1998-07-03 03:19:31 +04:00
|
|
|
nsPoint origin;
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Adjust the y-origin
|
1998-07-03 03:19:31 +04:00
|
|
|
kidFrame->GetOrigin(origin);
|
|
|
|
origin.y += aDeltaY;
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
kidFrame->MoveTo(aPresContext, origin.x, origin.y);
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableFrame::RePositionViews(aPresContext, 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
|
|
|
|
nsRect rect;
|
|
|
|
lastKidFrame->GetRect(rect);
|
1998-10-20 03:43:06 +04:00
|
|
|
aReflowState.y = rect.YMost();
|
1998-07-03 03:19:31 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
|
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
|
|
|
|
nsTableRowGroupFrame::CreateContinuingRowFrame(nsIPresContext& aPresContext,
|
|
|
|
nsIStyleSet& aStyleSet,
|
|
|
|
nsIFrame& aRowFrame,
|
|
|
|
nsIFrame** aContRowFrame)
|
|
|
|
{
|
|
|
|
if (!aContRowFrame) {NS_ASSERTION(PR_FALSE, "bad call"); return;}
|
|
|
|
// create the continuing frame which will create continuing cell frames
|
|
|
|
aStyleSet.CreateContinuingFrame(&aPresContext, &aRowFrame, this, aContRowFrame);
|
|
|
|
if (!*aContRowFrame) return;
|
|
|
|
|
|
|
|
// Add the continuing row frame to the child list
|
|
|
|
nsIFrame* nextRow;
|
|
|
|
GetNextFrame(&aRowFrame, &nextRow);
|
|
|
|
(*aContRowFrame)->SetNextSibling(nextRow);
|
|
|
|
aRowFrame.SetNextSibling(*aContRowFrame);
|
|
|
|
|
|
|
|
// Push the continuing row frame and the frames that follow
|
|
|
|
PushChildren(&aPresContext, *aContRowFrame, &aRowFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsTableRowGroupFrame::SplitSpanningCells(nsIPresContext& aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsIStyleSet& aStyleSet,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsTableRowFrame& aRowFrame,
|
|
|
|
nscoord aRowEndY,
|
|
|
|
nsTableRowFrame* aContRowFrame)
|
|
|
|
{
|
|
|
|
PRInt32 rowIndex = aRowFrame.GetRowIndex();
|
|
|
|
PRInt32 colCount = aTableFrame.GetColCount();
|
|
|
|
nsTableCellFrame* prevCellFrame = nsnull;
|
|
|
|
|
|
|
|
nscoord tallestCell = 0;
|
|
|
|
|
|
|
|
for (PRInt32 colX = 0; colX < colCount; colX++) {
|
|
|
|
nsTableCellFrame* cellFrame = aTableFrame.GetCellInfoAt(rowIndex, colX);
|
|
|
|
if (!cellFrame) continue;
|
|
|
|
// use the last in flow since a cell with a row span may have already split.
|
|
|
|
cellFrame = (nsTableCellFrame*)cellFrame->GetLastInFlow();
|
|
|
|
|
|
|
|
// See if the cell frame is really in this row, or whether it's a cell spanning from a previous row
|
|
|
|
PRInt32 realRowIndex;
|
|
|
|
cellFrame->GetRowIndex(realRowIndex);
|
|
|
|
if (realRowIndex == rowIndex) {
|
|
|
|
prevCellFrame = cellFrame;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsTableRowFrame* parentFrame;
|
|
|
|
nsPoint cellOrigin;
|
|
|
|
nsReflowStatus status;
|
|
|
|
|
|
|
|
// Ask the cell frame's parent to reflow it to the height of all the
|
|
|
|
// rows it spans between its origin and aRowEndY
|
|
|
|
cellFrame->GetParent((nsIFrame**)&parentFrame);
|
|
|
|
if (!parentFrame) {NS_ASSERTION(PR_FALSE, "bad parent"); return 0;}
|
|
|
|
parentFrame->GetOrigin(cellOrigin);
|
|
|
|
nscoord cellAvailHeight = aRowEndY - cellOrigin.y;
|
|
|
|
nscoord cellHeight = parentFrame->ReflowCellFrame(&aPresContext, aReflowState, cellFrame,
|
|
|
|
cellAvailHeight, status);
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(status)) {
|
|
|
|
// Create a continuing cell frame since the cell's block split
|
|
|
|
nsTableCellFrame* contCellFrame = nsnull;
|
|
|
|
aStyleSet.CreateContinuingFrame(&aPresContext, cellFrame, &aRowFrame, (nsIFrame**)&contCellFrame);
|
|
|
|
// Add the continuing cell frame to the appropriate row's child list
|
|
|
|
if (contCellFrame) {
|
|
|
|
if (aContRowFrame) {
|
|
|
|
aContRowFrame->InsertCellFrame(contCellFrame, colX);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aRowFrame.InsertCellFrame(contCellFrame, prevCellFrame);
|
|
|
|
}
|
|
|
|
prevCellFrame = contCellFrame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((cellHeight > cellAvailHeight) && aContRowFrame) {
|
|
|
|
// put the cell on the continuing row frame to give it more space
|
2001-09-24 18:48:38 +04:00
|
|
|
parentFrame->RemoveCellFrame(cellFrame);
|
2001-04-16 18:51:52 +04:00
|
|
|
aContRowFrame->InsertCellFrame(cellFrame, colX);
|
|
|
|
prevCellFrame = cellFrame;
|
|
|
|
}
|
|
|
|
tallestCell = PR_MAX(tallestCell, cellHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tallestCell;
|
|
|
|
}
|
|
|
|
|
1998-12-14 04:24:11 +03:00
|
|
|
nsresult
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowGroupFrame::SplitRowGroup(nsIPresContext* 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)
|
|
|
|
{
|
1999-02-22 06:28:00 +03:00
|
|
|
nsIFrame* prevRowFrame = nsnull;
|
2001-04-17 18:39:54 +04:00
|
|
|
aDesiredSize.height = 0;
|
1998-12-15 19:39:09 +03:00
|
|
|
nsresult rv = NS_OK;
|
2001-04-16 18:51:52 +04:00
|
|
|
|
|
|
|
// get the style set
|
|
|
|
nsCOMPtr<nsIStyleSet> styleSet;
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
if (!presShell) {NS_ASSERTION(PR_FALSE, "no pres shell"); return NS_ERROR_NULL_POINTER;}
|
|
|
|
presShell->GetStyleSet(getter_AddRefs(styleSet));
|
|
|
|
if (!styleSet) {NS_ASSERTION(PR_FALSE, "no style set"); return NS_ERROR_NULL_POINTER;}
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
|
|
|
PRBool borderCollapse = ((nsTableFrame*)aTableFrame->GetFirstInFlow())->IsBorderCollapse();
|
2001-04-02 07:21:58 +04:00
|
|
|
|
|
|
|
nscoord availWidth = nsTableFrame::RoundToPixel(aReflowState.availableWidth, p2t);
|
|
|
|
nscoord availHeight = nsTableFrame::RoundToPixel(aReflowState.availableHeight, p2t);
|
2001-04-17 18:39:54 +04:00
|
|
|
nscoord lastDesiredHeight = 0;
|
1998-12-14 04:24:11 +03:00
|
|
|
|
|
|
|
// Walk each of the row frames looking for the first row frame that
|
|
|
|
// doesn't fit in the available space
|
2001-11-05 03:15:51 +03:00
|
|
|
for (nsTableRowFrame* rowFrame = GetFirstRow(); rowFrame; rowFrame = rowFrame->GetNextRow()) {
|
2001-04-02 07:21:58 +04:00
|
|
|
PRBool rowIsOnCurrentPage = PR_TRUE;
|
2001-04-16 19:53:23 +04:00
|
|
|
PRBool degenerateRow = PR_FALSE;
|
2001-04-02 07:21:58 +04:00
|
|
|
nsRect bounds;
|
1999-02-22 06:28:00 +03:00
|
|
|
rowFrame->GetRect(bounds);
|
2001-04-02 07:21:58 +04:00
|
|
|
if (bounds.YMost() > availHeight) {
|
2001-04-12 17:04:29 +04:00
|
|
|
nsRect actualRect;
|
|
|
|
nsRect adjRect;
|
|
|
|
aPresContext->GetPageDim(&actualRect, &adjRect);
|
2001-04-16 19:53:23 +04:00
|
|
|
nsIFrame* contRowFrame = nsnull;
|
2001-04-12 17:04:29 +04:00
|
|
|
nscoord pageHeight = actualRect.height;
|
2001-04-02 07:21:58 +04:00
|
|
|
// reflow the row in the availabe space and have it split if it is the 1st
|
2001-11-21 17:42:00 +03:00
|
|
|
// row or there is at least 5% of the current page available
|
|
|
|
if (!prevRowFrame || (availHeight - aDesiredSize.height > pageHeight / 20)) {
|
1998-12-14 04:24:11 +03:00
|
|
|
// Reflow the row in the available space and have it split
|
2002-02-19 18:48:28 +03:00
|
|
|
nsSize availSize(availWidth, availHeight - bounds.y);
|
|
|
|
nsHTMLReflowState rowReflowState(aPresContext, aReflowState, rowFrame, availSize,
|
|
|
|
eReflowReason_Resize);
|
|
|
|
InitChildReflowState(*aPresContext, borderCollapse, p2t, rowReflowState);
|
|
|
|
|
1998-12-15 19:39:09 +03:00
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
1998-12-14 04:24:11 +03:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
rv = ReflowChild(rowFrame, aPresContext, desiredSize, rowReflowState,
|
|
|
|
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
1999-11-24 09:03:41 +03:00
|
|
|
rowFrame->SizeTo(aPresContext, desiredSize.width, desiredSize.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)) {
|
2001-04-16 18:51:52 +04:00
|
|
|
// the row frame is incomplete and all of the cells' block frames have split
|
|
|
|
CreateContinuingRowFrame(*aPresContext, *styleSet.get(), *rowFrame, &contRowFrame);
|
2001-11-01 18:31:13 +03:00
|
|
|
aDesiredSize.height += desiredSize.height;
|
|
|
|
if (prevRowFrame) {
|
|
|
|
aDesiredSize.height += aTableFrame->GetCellSpacingY();
|
|
|
|
}
|
2001-04-16 18:51:52 +04:00
|
|
|
}
|
|
|
|
else if (0 == desiredSize.height) {
|
|
|
|
// the row frame is complete because it had no cells originating in it.
|
|
|
|
CreateContinuingRowFrame(*aPresContext, *styleSet.get(), *rowFrame, &contRowFrame);
|
1999-03-09 18:35:43 +03:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
2001-04-17 18:39:54 +04:00
|
|
|
aDesiredSize.height = availHeight;
|
2001-04-16 18:51:52 +04:00
|
|
|
degenerateRow = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// the row frame is complete because it's minimum height was greater than the
|
|
|
|
// the available height we gave it
|
2001-04-17 18:39:54 +04:00
|
|
|
if (aDesiredSize.height > 0) {
|
2001-04-02 07:21:58 +04:00
|
|
|
// put the row on the next page since it needs more height than it was given
|
|
|
|
rowIsOnCurrentPage = PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsIFrame* nextRowFrame;
|
1999-03-09 18:35:43 +03:00
|
|
|
|
2001-04-16 18:51:52 +04:00
|
|
|
// Push the row frame that follows
|
2001-04-02 07:21:58 +04:00
|
|
|
GetNextFrame(rowFrame, &nextRowFrame);
|
1999-06-23 07:02:21 +04:00
|
|
|
|
2001-04-02 07:21:58 +04:00
|
|
|
if (nextRowFrame) {
|
|
|
|
PushChildren(aPresContext, nextRowFrame, rowFrame);
|
|
|
|
}
|
|
|
|
aStatus = nextRowFrame ? NS_FRAME_NOT_COMPLETE : NS_FRAME_COMPLETE;
|
2001-04-17 18:39:54 +04:00
|
|
|
aDesiredSize.height = bounds.YMost();
|
1999-03-09 18:35:43 +03:00
|
|
|
}
|
1998-12-16 00:26:05 +03:00
|
|
|
}
|
2001-04-02 07:21:58 +04:00
|
|
|
}
|
|
|
|
else rowIsOnCurrentPage = PR_FALSE;
|
1998-12-16 00:26:05 +03:00
|
|
|
|
2001-04-02 07:21:58 +04:00
|
|
|
if (!rowIsOnCurrentPage) {
|
1999-02-22 06:28:00 +03:00
|
|
|
// Push this row frame and those that follow to the next-in-flow
|
1999-11-24 09:03:41 +03:00
|
|
|
PushChildren(aPresContext, rowFrame, prevRowFrame);
|
1999-03-09 18:35:43 +03:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-12-14 04:24:11 +03:00
|
|
|
}
|
2001-04-16 18:51:52 +04:00
|
|
|
if (prevRowFrame) {
|
|
|
|
nscoord tallestCell =
|
|
|
|
SplitSpanningCells(*aPresContext, aReflowState, *styleSet, *aTableFrame,
|
2001-11-05 03:15:51 +03:00
|
|
|
*rowFrame, aDesiredSize.height, (nsTableRowFrame*)contRowFrame);
|
2001-04-16 18:51:52 +04:00
|
|
|
if (degenerateRow) {
|
2001-04-17 18:39:54 +04:00
|
|
|
aDesiredSize.height = lastDesiredHeight + aTableFrame->GetCellSpacingY() + tallestCell;
|
2001-04-16 18:51:52 +04:00
|
|
|
}
|
|
|
|
}
|
1998-12-14 04:24:11 +03:00
|
|
|
break;
|
|
|
|
}
|
2001-04-17 18:39:54 +04:00
|
|
|
else {
|
|
|
|
aDesiredSize.height = bounds.YMost();
|
|
|
|
lastDesiredHeight = aDesiredSize.height;
|
|
|
|
prevRowFrame = rowFrame;
|
|
|
|
}
|
1998-12-14 04:24:11 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-11-29 18:41:07 +03:00
|
|
|
static void
|
|
|
|
CacheRowHeightsForPrinting(nsIPresContext* aPresContext,
|
|
|
|
nsTableRowFrame* aFirstRow)
|
|
|
|
{
|
|
|
|
for (nsTableRowFrame* row = aFirstRow; row; row = row->GetNextRow()) {
|
|
|
|
nsRect rect;
|
|
|
|
row->GetRect(rect);
|
|
|
|
row->SetHasUnpaginatedHeight(PR_TRUE);
|
|
|
|
row->SetUnpaginatedHeight(aPresContext, rect.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowGroupFrame::Reflow(nsIPresContext* 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
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
nsresult rv=NS_OK;
|
2001-03-29 01:26:58 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2001-11-05 03:15:51 +03: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);
|
2001-11-05 03:15:51 +03:00
|
|
|
if (!aPresContext || !tableFrame) return NS_ERROR_NULL_POINTER;
|
1998-11-04 23:09:19 +03:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nsRowGroupReflowState state(aReflowState, tableFrame);
|
|
|
|
PRBool haveDesiredHeight = PR_FALSE;
|
1998-07-03 03:19:31 +04:00
|
|
|
|
2001-11-29 18:41:07 +03:00
|
|
|
PRBool isPaginated;
|
|
|
|
aPresContext->IsPaginated(&isPaginated);
|
|
|
|
|
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-12-07 17:51:12 +03:00
|
|
|
if (isPaginated && aReflowState.mFlags.mSpecialHeightReflow) {
|
2001-11-29 18:41:07 +03:00
|
|
|
// cache row height info for printing, now that row heights are known.
|
|
|
|
CacheRowHeightsForPrinting(aPresContext, GetFirstRow());
|
|
|
|
}
|
2001-09-24 18:48:38 +04:00
|
|
|
// Reflow the existing frames.
|
2001-03-13 09:38:59 +03:00
|
|
|
rv = ReflowChildren(aPresContext, aDesiredSize, state, aStatus,
|
|
|
|
nsnull, PR_FALSE);
|
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) {
|
2001-11-05 03:15:51 +03:00
|
|
|
DidResizeRows(*aPresContext, aReflowState);
|
|
|
|
}
|
|
|
|
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
|
2001-03-13 09:38:59 +03:00
|
|
|
if (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;
|
2001-11-29 18:41:07 +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
|
|
|
|
aDesiredSize.height = GetHeightOfRows(aPresContext);
|
1999-08-31 02:30:32 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
|
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
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowGroupFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-14 20:32:45 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// determine if this frame is the target or not
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame* target = nsnull;
|
1998-11-04 23:09:19 +03:00
|
|
|
rv = aReflowState.reflowState.reflowCommand->GetTarget(target);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && target) {
|
|
|
|
if (this == target)
|
1998-11-04 23:09:19 +03:00
|
|
|
rv = IR_TargetIsMe(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2001-03-13 09:38:59 +03:00
|
|
|
else {
|
1998-10-14 20:32:45 +04:00
|
|
|
// Get the next frame in the reflow chain
|
|
|
|
nsIFrame* nextFrame;
|
1998-11-04 23:09:19 +03:00
|
|
|
aReflowState.reflowState.reflowCommand->GetNext(nextFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1998-11-04 23:09:19 +03:00
|
|
|
rv = IR_TargetIsChild(aPresContext, aDesiredSize, aReflowState, aStatus, nextFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-08-02 02:01:37 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowGroupFrame::AppendFrames(nsIPresContext* aPresContext,
|
1999-08-02 02:01:37 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
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;
|
1999-12-14 01:56:31 +03:00
|
|
|
for (nsIFrame* rowFrame = aFrameList; rowFrame; rowFrame->GetNextSibling(&rowFrame)) {
|
2001-03-13 09:38:59 +03:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
rowFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType.get()) {
|
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) {
|
2000-09-14 10:49:47 +04:00
|
|
|
tableFrame->AppendRows(*aPresContext, *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
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableFrame::AppendDirtyReflowCommand(&aPresShell, this);
|
|
|
|
if (tableFrame->RowIsSpannedInto(rowIndex)) {
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-10-30 00:25:13 +04:00
|
|
|
}
|
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
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowGroupFrame::InsertFrames(nsIPresContext* aPresContext,
|
1999-08-02 06:18:33 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
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;
|
1999-12-14 01:56:31 +03:00
|
|
|
for (nsIFrame* rowFrame = aFrameList; rowFrame; rowFrame->GetNextSibling(&rowFrame)) {
|
2001-03-13 09:38:59 +03:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
rowFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType.get()) {
|
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) {
|
2001-08-06 18:48:09 +04:00
|
|
|
nsTableRowFrame* prevRow = (nsTableRowFrame *)nsTableFrame::GetFrameAtOrBefore(aPresContext, this, aPrevFrame, nsLayoutAtoms::tableRowFrame);
|
2001-11-20 03:58:53 +03:00
|
|
|
PRInt32 rowIndex = (prevRow) ? prevRow->GetRowIndex() + 1 : startRowIndex;
|
2001-08-06 18:48:09 +04:00
|
|
|
tableFrame->InsertRows(*aPresContext, *this, rows, rowIndex, PR_TRUE);
|
|
|
|
|
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
|
|
|
nsTableFrame::AppendDirtyReflowCommand(&aPresShell, this);
|
|
|
|
if (tableFrame->RowIsSpannedInto(rowIndex) ||
|
|
|
|
tableFrame->RowHasSpanningCells(rowIndex + numRows - 1)) {
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
}
|
1999-08-02 06:18:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowGroupFrame::RemoveFrame(nsIPresContext* aPresContext,
|
1999-08-02 06:18:33 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (tableFrame) {
|
2001-03-13 09:38:59 +03:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
aOldFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType.get()) {
|
|
|
|
// remove the rows from the table (and flag a rebalance)
|
|
|
|
tableFrame->RemoveRows(*aPresContext, (nsTableRowFrame &)*aOldFrame, 1, PR_TRUE);
|
1999-08-02 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
|
|
|
|
nsTableFrame::AppendDirtyReflowCommand(&aPresShell, this);
|
1999-08-02 02:01:37 +04:00
|
|
|
}
|
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
mFrames.DestroyFrame(aPresContext, 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
|
|
|
|
nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext* aPresContext,
|
|
|
|
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;
|
1998-10-14 20:32:45 +04:00
|
|
|
aReflowState.reflowState.reflowCommand->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
|
|
|
|
nsTableRowGroupFrame::GetHeightOfRows(nsIPresContext* aPresContext)
|
1999-06-14 12:22:47 +04:00
|
|
|
{
|
2000-04-29 01:05:31 +04:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsresult rv = 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
|
2000-04-29 01:05:31 +04:00
|
|
|
nsIFrame* rowFrame = nsnull;
|
|
|
|
rv = FirstChild(aPresContext, nsnull, &rowFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
PRInt32 numRows = 0;
|
|
|
|
while ((NS_SUCCEEDED(rv)) && rowFrame) {
|
2000-04-29 01:05:31 +04:00
|
|
|
const nsStyleDisplay* rowDisplay;
|
1999-06-14 12:22:47 +04:00
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == rowDisplay->mDisplay) {
|
1999-06-14 12:22:47 +04:00
|
|
|
nsRect rowRect;
|
|
|
|
rowFrame->GetRect(rowRect);
|
2001-03-13 09:38:59 +03:00
|
|
|
height += rowRect.height;
|
|
|
|
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();
|
|
|
|
|
2001-10-22 18:37:03 +04:00
|
|
|
// Walk the list of children up to aKidFrame
|
|
|
|
for (nsIFrame* frame = mFrames.FirstChild(); frame && (frame != aKidFrame); frame->GetNextSibling(&frame)) {
|
|
|
|
nsCOMPtr<nsIAtom> fType;
|
|
|
|
frame->GetFrameType(getter_AddRefs(fType));
|
|
|
|
if (fType.get() == nsLayoutAtoms::tableRowFrame) {
|
|
|
|
// Update the running y-offset
|
|
|
|
nsSize kidSize;
|
|
|
|
frame->GetSize(kidSize);
|
|
|
|
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
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
|
|
|
|
aFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (frameType.get() == nsLayoutAtoms::tableRowFrame) {
|
|
|
|
PRInt32 rowIndex = ((nsTableRowFrame*)aFrame)->GetRowIndex();
|
|
|
|
|
|
|
|
// It's a simple row frame if there are no cells that span into or
|
|
|
|
// across the row
|
|
|
|
if (!aTableFrame->RowIsSpannedInto(rowIndex) &&
|
|
|
|
!aTableFrame->RowHasSpanningCells(rowIndex)) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-26 02:40:21 +04:00
|
|
|
nscoord
|
|
|
|
GetFrameYMost(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
aFrame->GetRect(rect);
|
|
|
|
return rect.YMost();
|
|
|
|
}
|
|
|
|
|
2000-09-15 10:11:29 +04:00
|
|
|
nsIFrame*
|
|
|
|
GetLastRowSibling(nsIFrame* aRowFrame)
|
|
|
|
{
|
|
|
|
nsIFrame* lastRowFrame = nsnull;
|
|
|
|
nsIFrame* lastFrame = aRowFrame;
|
|
|
|
while (lastFrame) {
|
|
|
|
nsCOMPtr<nsIAtom> fType;
|
|
|
|
lastFrame->GetFrameType(getter_AddRefs(fType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == fType.get()) {
|
|
|
|
lastRowFrame = lastFrame;
|
|
|
|
}
|
|
|
|
lastFrame->GetNextSibling(&lastFrame);
|
|
|
|
}
|
|
|
|
return lastRowFrame;
|
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
NS_METHOD
|
|
|
|
nsTableRowGroupFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
|
|
|
|
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
|
|
|
|
nsRect oldKidRect;
|
|
|
|
aNextFrame->GetRect(oldKidRect);
|
|
|
|
|
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);
|
|
|
|
|
1999-08-31 02:30:32 +04:00
|
|
|
nsSize kidMaxElementSize;
|
2000-03-09 11:45:26 +03:00
|
|
|
nsHTMLReflowMetrics desiredSize(aDesiredSize.maxElementSize ? &kidMaxElementSize : nsnull,
|
|
|
|
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
|
|
|
|
if (oldKidRect.height == desiredSize.height) {
|
|
|
|
// We don't need to do any painting. The row frame has made sure that
|
|
|
|
// the cell is properly positioned, and done any necessary repainting.
|
|
|
|
// Just calculate our desired height
|
2000-09-15 10:11:29 +04:00
|
|
|
aDesiredSize.height = GetFrameYMost(GetLastRowSibling(mFrames.FirstChild()));
|
1999-09-13 07:19:39 +04:00
|
|
|
} else {
|
|
|
|
// Inform the row of its new height.
|
|
|
|
((nsTableRowFrame*)aNextFrame)->DidResize(aPresContext, aReflowState.reflowState);
|
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...
|
2001-11-06 04:44:20 +03:00
|
|
|
if (!kidRect.IsEmpty()) {
|
|
|
|
Invalidate(aPresContext, kidRect);
|
|
|
|
}
|
|
|
|
|
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());
|
|
|
|
Invalidate(aPresContext, dirtyRect);
|
|
|
|
}
|
1999-09-13 07:19:39 +04:00
|
|
|
|
2001-05-14 18:28:00 +04:00
|
|
|
// Adjust the frames that follow
|
|
|
|
AdjustSiblingsAfterReflow(aPresContext, aReflowState, aNextFrame,
|
|
|
|
desiredSize.height - oldKidRect.height);
|
|
|
|
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
|
2000-09-15 10:11:29 +04:00
|
|
|
aDesiredSize.height = GetFrameYMost(GetLastRowSibling(mFrames.FirstChild()));
|
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,
|
|
|
|
// desiredSize.height - oldKidRect.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);
|
|
|
|
Invalidate(aPresContext, dirtyRect);
|
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
|
|
|
|
nsTableRowGroupFrame::IR_StyleChanged(nsIPresContext* aPresContext,
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-02-24 08:54:31 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::tableRowGroupFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-15 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
|
|
|
|
nsTableRowGroupFrame::Init(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Let the base class do its processing
|
|
|
|
rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext,
|
|
|
|
aPrevInFlow);
|
|
|
|
|
|
|
|
// record that children that are ignorable whitespace should be excluded
|
|
|
|
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-11-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
|
|
|
}
|
1998-11-20 04:01:25 +03:00
|
|
|
|
1999-08-31 07:09:40 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
|
|
|
{
|
1999-09-01 05:02:16 +04:00
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
PRUint32 sum = sizeof(*this);
|
|
|
|
*aResult = sum;
|
|
|
|
return NS_OK;
|
1999-08-31 07:09:40 +04: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()) {
|
|
|
|
if(!firstRowFrame) {
|
|
|
|
firstRowFrame = rowFrame;
|
|
|
|
}
|
|
|
|
lastRowFrame = rowFrame;
|
|
|
|
}
|
|
|
|
if (firstRowFrame) {
|
|
|
|
aBorder.top = firstRowFrame->GetTopBCBorderWidth(&aPixelsToTwips);
|
|
|
|
aBorder.bottom = lastRowFrame->GetBottomBCBorderWidth(&aPixelsToTwips);
|
|
|
|
}
|
|
|
|
|
|
|
|
return &aBorder;
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
if(!cellMap)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
if(aLineNumber >= cellMap->GetRowCount())
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
*aLineFlags = 0;/// should we fill these in later?
|
|
|
|
// not gonna touch aLineBounds right now
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
CellData* firstCellData = cellMap->GetDataAt(aLineNumber, 0);
|
2001-01-27 02:40:36 +03:00
|
|
|
if(!firstCellData)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2000-05-11 05:04:39 +04:00
|
|
|
*aFirstFrameOnLine = (nsIFrame*)firstCellData->GetCellFrame();
|
2000-05-14 04:10:25 +04:00
|
|
|
if(!(*aFirstFrameOnLine))
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
aFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (frameType.get() != nsLayoutAtoms::tableRowFrame) {
|
|
|
|
NS_WARNING("RowGroup contains a frame that is not a row");
|
|
|
|
*aLineNumberResult = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2000-05-11 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,
|
2001-03-13 01:25:55 +03:00
|
|
|
#ifdef IBMBIDI
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool aCouldBeReordered,
|
2001-03-13 01:25:55 +03:00
|
|
|
#endif // IBMBIDI
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame** aFrameFound,
|
|
|
|
PRBool* aXIsBeforeFirstFrame,
|
|
|
|
PRBool* aXIsAfterLastFrame)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
|
|
|
PRInt32 cellCount = 0;
|
|
|
|
CellData* cellData;
|
2002-01-04 13:52:48 +03:00
|
|
|
nsIFrame* tempFrame = nsnull;
|
2000-05-11 05:04:39 +04:00
|
|
|
nsRect tempRect;
|
|
|
|
nsRect& tempRectRef = tempRect;
|
|
|
|
nsresult rv;
|
|
|
|
|
2000-05-13 13:02:27 +04:00
|
|
|
nsTableFrame* parentFrame = nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, parentFrame);
|
2000-05-11 05:04:39 +04:00
|
|
|
nsTableCellMap* cellMap = parentFrame->GetCellMap();
|
|
|
|
if(!cellMap)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
cellCount = cellMap->GetNumCellsOriginatingInRow(aLineNumber);
|
|
|
|
|
|
|
|
*aXIsBeforeFirstFrame = PR_FALSE;
|
|
|
|
*aXIsAfterLastFrame = PR_FALSE;
|
|
|
|
|
2000-05-14 04:10:25 +04:00
|
|
|
PRBool gotParentRect = PR_FALSE;
|
2000-05-11 05:04:39 +04:00
|
|
|
for(int i =0;i < cellCount; i++)
|
|
|
|
{
|
2002-02-19 18:48:28 +03:00
|
|
|
cellData = cellMap->GetDataAt(aLineNumber, i);
|
2000-05-11 05:04:39 +04:00
|
|
|
tempFrame = (nsIFrame*)cellData->GetCellFrame();
|
2000-05-14 04:10:25 +04:00
|
|
|
|
|
|
|
if(!tempFrame)
|
|
|
|
continue;
|
2000-05-11 05:04:39 +04:00
|
|
|
|
|
|
|
tempFrame->GetRect(tempRectRef);//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
|
|
|
|
nsRect parentRect;
|
|
|
|
nsRect& parentRectRef = parentRect;
|
2000-06-08 06:51:58 +04:00
|
|
|
nsIFrame* tempParentFrame;
|
2000-05-11 05:04:39 +04:00
|
|
|
|
2000-06-08 06:51:58 +04:00
|
|
|
rv = tempFrame->GetParent(&tempParentFrame);
|
2000-05-11 05:04:39 +04:00
|
|
|
|
2001-10-13 13:27:46 +04:00
|
|
|
if(NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
if(!tempParentFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-05-11 05:04:39 +04:00
|
|
|
|
2000-06-08 06:51:58 +04:00
|
|
|
tempParentFrame->GetRect(parentRectRef);
|
2000-05-11 05:04:39 +04:00
|
|
|
aX -= parentRect.x;
|
2000-05-14 04:10:25 +04:00
|
|
|
gotParentRect = PR_TRUE;
|
2000-05-11 05:04:39 +04:00
|
|
|
}
|
|
|
|
|
2000-05-14 04:10:25 +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;
|
|
|
|
}
|
2000-05-14 04:10:25 +04:00
|
|
|
if(aX < tempRect.x)
|
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2000-05-11 05:04:39 +04:00
|
|
|
if(aX < (tempRect.x + tempRect.width))
|
|
|
|
{
|
|
|
|
*aFrameFound = tempFrame;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//x coord not found in frame, return last frame
|
|
|
|
*aXIsAfterLastFrame = PR_TRUE;
|
|
|
|
*aFrameFound = tempFrame;
|
2000-05-14 04:10:25 +04:00
|
|
|
if(!(*aFrameFound))
|
|
|
|
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;
|
|
|
|
nsresult result = aFrame->QueryInterface(NS_GET_IID(nsITableCellLayout),(void**)&cellFrame);
|
|
|
|
|
|
|
|
if(NS_FAILED(result) || !cellFrame)
|
|
|
|
return result?result:NS_ERROR_FAILURE;
|
|
|
|
|
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();
|
|
|
|
if(!cellMap)
|
|
|
|
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
|
|
|
|
|
|
|
if(!cellData)// if this isnt a valid cell, drop down and check the next line
|
|
|
|
{
|
2002-02-19 18:48:28 +03:00
|
|
|
cellData = cellMap->GetDataAt(aLineNumber + 1, 0);
|
2000-05-11 05:04:39 +04:00
|
|
|
if(!cellData)
|
|
|
|
{
|
|
|
|
//*aFrame = nsnull;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
2000-05-14 04:10:25 +04:00
|
|
|
if(!aFrame)
|
|
|
|
{
|
|
|
|
//PRInt32 numCellsInRow = cellMap->GetNumCellsOriginatingInRow(aLineNumber) - 1;
|
|
|
|
PRInt32 tempCol = colIndex + 1;
|
|
|
|
PRInt32 tempRow = aLineNumber;
|
|
|
|
while((tempCol > 0) && (!aFrame))
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
if(!aFrame && (tempCol==0))
|
|
|
|
{
|
|
|
|
while((tempRow > 0) && (!aFrame))
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|