1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-14 00:24:54 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
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"
|
1998-06-23 09:43:27 +04:00
|
|
|
#include "nsIReflowCommand.h"
|
1998-10-01 08:46:11 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1999-01-18 02:35:56 +03:00
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
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
|
|
|
|
|
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
|
|
|
}
|
|
|
|
else if (aIID.Equals(NS_GET_IID(nsILineIterator)))
|
|
|
|
{ // note there is no addref here, frames are not addref'd
|
|
|
|
*aInstancePtr = (void*)(nsILineIterator*)this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else {
|
1999-01-30 18:52:19 +03:00
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-14 12:01:00 +04:00
|
|
|
NS_METHOD nsTableRowGroupFrame::GetRowCount(PRInt32 &aCount, PRBool aDeepCount)
|
1998-09-16 00:36:42 +04:00
|
|
|
{
|
|
|
|
// init out-param
|
|
|
|
aCount=0;
|
|
|
|
|
|
|
|
// loop through children, adding one to aCount for every legit row
|
1999-06-23 07:02:21 +04:00
|
|
|
nsIFrame *childFrame = GetFirstFrame();
|
1998-09-16 00:36:42 +04:00
|
|
|
while (PR_TRUE)
|
|
|
|
{
|
|
|
|
if (nsnull==childFrame)
|
|
|
|
break;
|
|
|
|
const nsStyleDisplay *childDisplay;
|
1998-12-02 19:45:20 +03:00
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-09-16 00:36:42 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
|
|
|
aCount++;
|
1999-06-14 12:01:00 +04:00
|
|
|
else if (aDeepCount && NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay) {
|
|
|
|
PRInt32 childRowGroupCount;
|
|
|
|
((nsTableRowGroupFrame*)childFrame)->GetRowCount(childRowGroupCount);
|
|
|
|
aCount += childRowGroupCount;
|
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
GetNextFrame(childFrame, &childFrame);
|
1998-09-16 00:36:42 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
PRInt32 nsTableRowGroupFrame::GetStartRowIndex()
|
|
|
|
{
|
|
|
|
PRInt32 result = -1;
|
1999-06-23 07:02:21 +04:00
|
|
|
nsIFrame *childFrame = GetFirstFrame();
|
1998-12-23 18:47:43 +03:00
|
|
|
while (PR_TRUE)
|
|
|
|
{
|
|
|
|
if (nsnull==childFrame)
|
|
|
|
break;
|
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
result = ((nsTableRowFrame *)childFrame)->GetRowIndex();
|
|
|
|
break;
|
|
|
|
}
|
1999-06-14 12:01:00 +04:00
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == childDisplay->mDisplay) {
|
|
|
|
result = ((nsTableRowGroupFrame*)childFrame)->GetStartRowIndex();
|
|
|
|
if (result != -1)
|
|
|
|
break;
|
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
|
|
|
|
GetNextFrame(childFrame, &childFrame);
|
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);
|
|
|
|
|
|
|
|
if (nsLayoutAtoms::tableCellFrame == frameType) {
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsIContent* content1;
|
|
|
|
nsIContent* content2;
|
|
|
|
originalCellFrame->GetContent(&content1);
|
|
|
|
copyCellFrame->GetContent(&content2);
|
|
|
|
NS_ASSERTION(content1 == content2, "cell frames have different content");
|
|
|
|
NS_IF_RELEASE(content1);
|
|
|
|
NS_IF_RELEASE(content2);
|
|
|
|
#endif
|
|
|
|
PRInt32 colIndex;
|
|
|
|
((nsTableCellFrame*)originalCellFrame)->GetColIndex(colIndex);
|
|
|
|
((nsTableCellFrame*)copyCellFrame)->InitCellFrame(colIndex);
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
|
|
|
|
// Move to the next cell frame
|
|
|
|
copyCellFrame->GetNextSibling(©CellFrame);
|
|
|
|
originalCellFrame->GetNextSibling(&originalCellFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move to the next row frame
|
1999-06-23 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,
|
1999-06-08 01:10:25 +04:00
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-06-08 01:10:25 +04:00
|
|
|
nsresult rv;
|
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
|
|
|
nsCompatibility mode;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetCompatibilityMode(&mode);
|
1999-06-08 01:10:25 +04:00
|
|
|
if (eCompatibility_Standard == mode) {
|
|
|
|
const nsStyleDisplay* disp =
|
|
|
|
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
|
2000-03-17 13:15:13 +03:00
|
|
|
if (disp->IsVisibleOrCollapsed()) {
|
1999-06-08 01:10:25 +04:00
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
const nsStyleColor* color =
|
|
|
|
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv) || (nsnull == tableFrame)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
nsRect rect(0,0,mRect.width, mRect.height);
|
1999-06-08 01:10:25 +04:00
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, *color, *spacing, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-18 18:54:23 +03:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1999-09-18 03:33:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
/*nsFrame::Paint(aPresContext, 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
|
|
|
|
/** 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,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
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);
|
1998-12-18 18:54:23 +03:00
|
|
|
kid->Paint(aPresContext, aRenderingContext, kidDamageArea, aWhichLayer);
|
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
|
1999-11-24 09:03:41 +03:00
|
|
|
void nsTableRowGroupFrame::PlaceChild(nsIPresContext* aPresContext,
|
1998-10-20 03:43:06 +04:00
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame,
|
1999-11-19 18:33:29 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
1998-10-20 03:43:06 +04:00
|
|
|
nsSize* aMaxElementSize,
|
|
|
|
nsSize& aKidMaxElementSize)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
// Place and size the child
|
1999-11-19 18:33:29 +03:00
|
|
|
FinishReflowChild(aKidFrame, aPresContext, aDesiredSize, aX, aY, 0);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Adjust the running y-offset
|
1999-11-19 18:33:29 +03:00
|
|
|
aReflowState.y += aDesiredSize.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// If our height is constrained then update the available height
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_FALSE == aReflowState.unconstrainedHeight) {
|
1999-11-19 18:33:29 +03:00
|
|
|
aReflowState.availSize.height -= aDesiredSize.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update the maximum element size
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_TRUE==aReflowState.firstRow)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-10-20 03:43:06 +04:00
|
|
|
aReflowState.firstRow = PR_FALSE;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull != aMaxElementSize) {
|
|
|
|
aMaxElementSize->width = aKidMaxElementSize.width;
|
|
|
|
aMaxElementSize->height = aKidMaxElementSize.height;
|
|
|
|
}
|
|
|
|
}
|
1998-08-07 06:11:51 +04:00
|
|
|
else if (nsnull != aMaxElementSize) {
|
|
|
|
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, aKidMaxElementSize.width);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reflow the frames we've already created
|
|
|
|
*
|
|
|
|
* @param aPresContext presentation context to use
|
1998-10-20 03:43:06 +04:00
|
|
|
* @param aReflowState current inline state
|
1998-04-14 00:24:54 +04:00
|
|
|
* @return true if we successfully reflowed all the mapped children and false
|
|
|
|
* otherwise, e.g. we pushed children to the next in flow
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableRowGroupFrame::ReflowMappedChildren(nsIPresContext* aPresContext,
|
1998-10-20 03:43:06 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsTableRowFrame * aStartFrame,
|
|
|
|
nsReflowReason aReason,
|
1999-08-02 02:01:37 +04:00
|
|
|
PRBool aDoSiblings,
|
|
|
|
PRBool aDirtyOnly)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
nsSize kidMaxElementSize;
|
1998-10-20 03:43:06 +04:00
|
|
|
nsSize* pKidMaxElementSize = (nsnull != aDesiredSize.maxElementSize) ? &kidMaxElementSize : nsnull;
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv) || !tableFrame) return rv;
|
|
|
|
|
|
|
|
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
|
1999-06-23 07:02:21 +04:00
|
|
|
|
2000-01-17 06:57:00 +03:00
|
|
|
if (!ContinueReflow(nsnull, aPresContext, aReflowState.y, aReflowState.availSize.height))
|
1999-06-23 07:02:21 +04:00
|
|
|
return rv;
|
|
|
|
|
1998-10-20 03:43:06 +04:00
|
|
|
nsIFrame* kidFrame;
|
1999-06-23 07:02:21 +04:00
|
|
|
if (nsnull==aStartFrame) {
|
|
|
|
kidFrame = GetFirstFrameForReflow(aPresContext);
|
|
|
|
ReflowBeforeRowLayout(aPresContext, aDesiredSize, aReflowState, aStatus, aReason);
|
|
|
|
}
|
1998-10-20 03:43:06 +04:00
|
|
|
else
|
|
|
|
kidFrame = aStartFrame;
|
1999-06-23 07:02:21 +04:00
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
PRUint8 borderStyle = aReflowState.tableFrame->GetBorderCollapseStyle();
|
1999-06-23 07:02:21 +04:00
|
|
|
|
1998-10-20 03:43:06 +04:00
|
|
|
for ( ; nsnull != kidFrame; )
|
|
|
|
{
|
1999-08-02 02:01:37 +04:00
|
|
|
// Get the frame state bits
|
|
|
|
nsFrameState frameState;
|
|
|
|
kidFrame->GetFrameState(&frameState);
|
|
|
|
|
|
|
|
// See if we should only reflow the dirty child frames
|
|
|
|
PRBool doReflowChild = PR_TRUE;
|
|
|
|
if (aDirtyOnly) {
|
|
|
|
if ((frameState & NS_FRAME_IS_DIRTY) == 0) {
|
|
|
|
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);
|
|
|
|
if (0>=kidAvailSize.height)
|
|
|
|
kidAvailSize.height = 1; // XXX: HaCk - we don't handle negative heights yet
|
|
|
|
nsHTMLReflowMetrics desiredSize(pKidMaxElementSize);
|
|
|
|
desiredSize.width=desiredSize.height=desiredSize.ascent=desiredSize.descent=0;
|
|
|
|
|
|
|
|
// Reflow the child into the available space, giving it as much room as
|
|
|
|
// it wants. We'll deal with splitting later after we've computed the row
|
|
|
|
// heights, taking into account cells with row spans...
|
|
|
|
kidAvailSize.height = NS_UNCONSTRAINEDSIZE;
|
1999-08-03 06:41:27 +04:00
|
|
|
nsReflowReason reason = aReason;
|
1999-08-02 02:01:37 +04:00
|
|
|
if (aDirtyOnly) {
|
|
|
|
if (frameState & NS_FRAME_FIRST_REFLOW) {
|
|
|
|
// Newly inserted frame
|
1999-08-03 06:41:27 +04:00
|
|
|
reason = eReflowReason_Initial;
|
1999-08-02 02:01:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState, kidFrame,
|
1999-08-03 06:41:27 +04:00
|
|
|
kidAvailSize, reason);
|
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()) {
|
|
|
|
kidReflowState.isTopOfPage = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-08-02 02:01:37 +04:00
|
|
|
if (aReflowState.tableFrame->RowGroupsShouldBeConstrained()) {
|
|
|
|
// Only applies to the tree widget.
|
|
|
|
const nsStyleDisplay *rowDisplay;
|
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)rowDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay &&
|
|
|
|
aReflowState.availSize.height != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
kidReflowState.availableHeight = aReflowState.availSize.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
|
|
|
|
0, aReflowState.y, 0, aStatus);
|
1999-08-02 02:01:37 +04:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Place the child
|
1999-08-02 02:01:37 +04:00
|
|
|
nsRect kidRect (0, aReflowState.y, desiredSize.width, desiredSize.height);
|
1999-11-19 18:33:29 +03:00
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame, desiredSize, 0,
|
|
|
|
aReflowState.y, aDesiredSize.maxElementSize, kidMaxElementSize);
|
1999-08-02 02:01:37 +04:00
|
|
|
|
|
|
|
/* if the table has collapsing borders, we need to reset the length of the shared vertical borders
|
|
|
|
* for the table and the cells that overlap this row
|
|
|
|
*/
|
2000-04-29 01:05:31 +04:00
|
|
|
if ((eReflowReason_Initial != aReflowState.reflowState.reason) &&
|
|
|
|
(NS_STYLE_BORDER_COLLAPSE==borderStyle)) {
|
1999-08-02 02:01:37 +04:00
|
|
|
const nsStyleDisplay *childDisplay;
|
|
|
|
kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == childDisplay->mDisplay) {
|
1999-08-02 02:01:37 +04:00
|
|
|
PRInt32 rowIndex = ((nsTableRowFrame*)kidFrame)->GetRowIndex();
|
|
|
|
aReflowState.tableFrame->SetBorderEdgeLength(NS_SIDE_LEFT,
|
|
|
|
rowIndex,
|
|
|
|
kidRect.height);
|
|
|
|
aReflowState.tableFrame->SetBorderEdgeLength(NS_SIDE_RIGHT,
|
|
|
|
rowIndex,
|
|
|
|
kidRect.height);
|
|
|
|
PRInt32 colCount = aReflowState.tableFrame->GetColCount();
|
|
|
|
PRInt32 colIndex = 0;
|
|
|
|
nsIFrame *cellFrame;
|
|
|
|
for (colIndex = 0; colIndex < colCount; colIndex++) {
|
1999-08-19 23:52:37 +04:00
|
|
|
cellFrame = aReflowState.tableFrame->GetCellInfoAt(rowIndex, colIndex);
|
1999-08-02 02:01:37 +04:00
|
|
|
if (cellFrame) {
|
|
|
|
const nsStyleDisplay *cellDisplay;
|
|
|
|
cellFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)cellDisplay));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CELL == cellDisplay->mDisplay) {
|
|
|
|
((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_LEFT,
|
|
|
|
rowIndex,
|
|
|
|
kidRect.height);
|
|
|
|
((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_RIGHT,
|
|
|
|
rowIndex,
|
|
|
|
kidRect.height);
|
|
|
|
}
|
1998-12-30 09:48:15 +03:00
|
|
|
}
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
aReflowState.y += cellSpacingY;
|
1999-08-03 06:41:27 +04:00
|
|
|
} else {
|
|
|
|
// Adjust the running y-offset so we know where the next row should
|
|
|
|
// be placed
|
|
|
|
nsSize kidSize;
|
|
|
|
|
|
|
|
kidFrame->GetSize(kidSize);
|
2000-04-29 01:05:31 +04:00
|
|
|
aReflowState.y += kidSize.height + cellSpacingY;
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
|
1998-10-20 03:43:06 +04:00
|
|
|
if (PR_FALSE==aDoSiblings)
|
|
|
|
break;
|
|
|
|
|
2000-01-17 06:57:00 +03:00
|
|
|
if (!ContinueReflow(kidFrame, aPresContext, aReflowState.y, aReflowState.availSize.height))
|
1999-06-23 07:02:21 +04:00
|
|
|
break;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Get the next child
|
1999-06-23 07:02:21 +04:00
|
|
|
GetNextFrameForReflow(aPresContext, kidFrame, &kidFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-06-30 00:20:40 +04:00
|
|
|
// Call our post-row reflow hook
|
|
|
|
ReflowAfterRowLayout(aPresContext, aDesiredSize, aReflowState, aStatus, aReason);
|
1998-10-20 03:43:06 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
1999-02-20 06:15:03 +03:00
|
|
|
* Pull-up all the row frames from our next-in-flow
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableRowGroupFrame::PullUpAllRowFrames(nsIPresContext* aPresContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-20 06:15:03 +03:00
|
|
|
if (mNextInFlow) {
|
|
|
|
nsTableRowGroupFrame* nextInFlow = (nsTableRowGroupFrame*)mNextInFlow;
|
|
|
|
|
|
|
|
while (nsnull != nextInFlow) {
|
1999-03-05 09:00:40 +03:00
|
|
|
// Any frames on the next-in-flow's overflow list?
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIFrame* nextOverflowFrames = nextInFlow->GetOverflowFrames(aPresContext,
|
1999-10-21 09:11:43 +04:00
|
|
|
PR_TRUE);
|
|
|
|
if (nextOverflowFrames) {
|
1999-03-05 09:00:40 +03:00
|
|
|
// Yes, append them to its child list
|
1999-10-21 09:11:43 +04:00
|
|
|
nextInFlow->mFrames.AppendFrames(nextInFlow, nextOverflowFrames);
|
1998-04-17 02:21:32 +04:00
|
|
|
}
|
1999-03-05 09:00:40 +03:00
|
|
|
|
|
|
|
// Any row frames?
|
|
|
|
if (nextInFlow->mFrames.NotEmpty()) {
|
1999-04-13 06:38:09 +04:00
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
1999-06-23 07:02:21 +04:00
|
|
|
for (nsIFrame* f = nextInFlow->GetFirstFrame(); f; GetNextFrame(f, &f)) {
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, nextInFlow, this);
|
1999-04-13 06:38:09 +04:00
|
|
|
}
|
1999-03-05 09:00:40 +03:00
|
|
|
// Append them to our child list
|
1999-04-13 04:06:17 +04:00
|
|
|
mFrames.AppendFrames(this, nextInFlow->mFrames);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-03-05 09:00:40 +03:00
|
|
|
// Move to the next-in-flow
|
|
|
|
nextInFlow->GetNextInFlow((nsIFrame**)&nextInFlow);
|
1998-04-17 02:21:32 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-20 06:15:03 +03:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-06-23 07:02:21 +04:00
|
|
|
void nsTableRowGroupFrame::GetNextRowSibling(nsIFrame** aRowFrame)
|
1999-03-17 02:42:38 +03:00
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
if (!*aRowFrame) return;
|
1999-06-23 07:02:21 +04:00
|
|
|
GetNextFrame(*aRowFrame, aRowFrame);
|
|
|
|
while(*aRowFrame) {
|
1999-03-17 02:42:38 +03:00
|
|
|
const nsStyleDisplay *display;
|
|
|
|
(*aRowFrame)->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == display->mDisplay) {
|
|
|
|
return;
|
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
GetNextFrame(*aRowFrame, aRowFrame);
|
1999-03-17 02:42:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-03 17:04:49 +03:00
|
|
|
// allocate the height of rows which have no cells originating in them
|
|
|
|
// except with cells with rowspan > 1. Store the height as negative
|
|
|
|
// to distinguish them from regular rows.
|
|
|
|
void
|
|
|
|
AllocateSpecialHeight(nsIPresContext* aPresContext,
|
|
|
|
nsTableFrame* aTableFrame,
|
|
|
|
nsIFrame* aRowFrame,
|
|
|
|
nscoord& aHeight)
|
|
|
|
{
|
|
|
|
nsIFrame* cellFrame;
|
|
|
|
aRowFrame->FirstChild(aPresContext, nsnull, &cellFrame);
|
|
|
|
while (cellFrame) {
|
|
|
|
nsCOMPtr<nsIAtom> cellType;
|
|
|
|
cellFrame->GetFrameType(getter_AddRefs(cellType));
|
2000-02-03 18:41:04 +03:00
|
|
|
if (nsLayoutAtoms::tableCellFrame == cellType.get()) {
|
2000-02-03 17:04:49 +03:00
|
|
|
PRInt32 rowSpan = aTableFrame->GetEffectiveRowSpan((nsTableCellFrame&)*cellFrame);
|
|
|
|
if (rowSpan > 1) {
|
|
|
|
// use a simple average to allocate the special row. This is not exact,
|
|
|
|
// but much better than nothing.
|
2000-02-04 05:49:27 +03:00
|
|
|
nsSize cellDesSize = ((nsTableCellFrame*)cellFrame)->GetDesiredSize();
|
2000-02-03 17:04:49 +03:00
|
|
|
((nsTableRowFrame*)aRowFrame)->CalculateCellActualSize(cellFrame, cellDesSize.width,
|
2000-02-04 05:49:27 +03:00
|
|
|
cellDesSize.height, cellDesSize.width);
|
2000-02-03 17:04:49 +03:00
|
|
|
PRInt32 propHeight = NSToCoordRound((float)cellDesSize.height / (float)rowSpan);
|
|
|
|
// special rows store the largest negative value
|
|
|
|
aHeight = PR_MIN(aHeight, -propHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cellFrame->GetNextSibling(&cellFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-20 04:01:25 +03:00
|
|
|
/* CalculateRowHeights provides default heights for all rows in the rowgroup.
|
|
|
|
* Actual row heights are ultimately determined by the table, when the table
|
|
|
|
* height attribute is factored in.
|
|
|
|
*/
|
2000-04-29 01:05:31 +04:00
|
|
|
void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-11-20 04:01:25 +03:00
|
|
|
const nsHTMLReflowState& aReflowState)
|
1998-06-30 06:11:07 +04:00
|
|
|
{
|
2000-02-03 17:04:49 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
1999-05-27 02:22:23 +04:00
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2000-02-03 17:04:49 +03:00
|
|
|
if (NS_FAILED(rv) || nsnull==tableFrame) return;
|
|
|
|
|
1999-05-27 02:22:23 +04:00
|
|
|
// all table cells have the same top and bottom margins, namely cellSpacingY
|
|
|
|
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
|
|
|
|
|
1999-08-21 03:27:39 +04:00
|
|
|
PRBool hasRowSpanningCell = PR_FALSE;
|
1998-06-30 06:11:07 +04:00
|
|
|
PRInt32 numRows;
|
1999-06-14 12:01:00 +04:00
|
|
|
GetRowCount(numRows, PR_FALSE);
|
2000-02-03 17:04:49 +03:00
|
|
|
// collect the current height of each row. rows which have 0 height because
|
|
|
|
// they have no cells originating in them without rowspans > 1, are referred to as
|
|
|
|
// special rows. The current height of a special row will be a negative number until
|
|
|
|
// it comes time to actually resize frames.
|
1999-12-16 03:37:03 +03:00
|
|
|
nscoord* rowHeights = nsnull;
|
|
|
|
if (numRows > 0) {
|
|
|
|
rowHeights = new nscoord[numRows];
|
|
|
|
if (!rowHeights) return;
|
|
|
|
nsCRT::memset (rowHeights, 0, numRows*sizeof(nscoord));
|
1999-12-16 04:51:06 +03:00
|
|
|
} // else - tree row groups need not have rows directly beneath them
|
1998-06-30 06:11:07 +04:00
|
|
|
|
2000-02-03 17:04:49 +03:00
|
|
|
// Step 1: get the height of the tallest cell in the row and save it for
|
|
|
|
// pass 2. This height is for table cells that originate in this
|
|
|
|
// row and that don't span into the rows that follow
|
1999-06-23 07:02:21 +04:00
|
|
|
nsIFrame* rowFrame = GetFirstFrame();
|
1998-09-16 00:36:42 +04:00
|
|
|
PRInt32 rowIndex = 0;
|
1999-02-22 06:28:00 +03:00
|
|
|
|
|
|
|
// For row groups that are split across pages, the first row frame won't
|
|
|
|
// necessarily be index 0
|
1999-06-14 12:01:00 +04:00
|
|
|
PRInt32 startRowIndex = -1;
|
2000-02-03 17:04:49 +03:00
|
|
|
while (rowFrame) {
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
rowFrame->GetFrameType(getter_AddRefs(frameType));
|
2000-02-03 18:41:04 +03:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType.get()) {
|
1999-06-14 12:01:00 +04:00
|
|
|
if (startRowIndex == -1) {
|
|
|
|
startRowIndex = ((nsTableRowFrame*)rowFrame)->GetRowIndex();
|
|
|
|
}
|
1998-09-16 00:36:42 +04:00
|
|
|
// get the height of the tallest cell in the row (excluding cells that span rows)
|
2000-04-29 01:05:31 +04:00
|
|
|
rowHeights[rowIndex] = ((nsTableRowFrame*)rowFrame)->GetTallestChild();
|
1999-08-21 03:27:39 +04:00
|
|
|
// See if a cell spans into the row. If so we'll have to do step 2
|
|
|
|
if (!hasRowSpanningCell) {
|
|
|
|
if (tableFrame->RowIsSpannedInto(rowIndex + startRowIndex)) {
|
|
|
|
hasRowSpanningCell = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
2000-02-03 17:04:49 +03:00
|
|
|
// special rows need to have some values, so they will get allocations
|
|
|
|
// later. If left at 0, they would get nothing.
|
|
|
|
if (0 == rowHeights[rowIndex]) {
|
|
|
|
AllocateSpecialHeight(aPresContext, tableFrame, rowFrame, rowHeights[rowIndex]);
|
|
|
|
}
|
1998-09-16 00:36:42 +04:00
|
|
|
rowIndex++;
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
2000-02-03 17:04:49 +03:00
|
|
|
GetNextFrame(rowFrame, &rowFrame); // Get the next row
|
1999-05-27 02:22:23 +04:00
|
|
|
}
|
1998-06-30 06:11:07 +04:00
|
|
|
|
2000-02-03 17:04:49 +03:00
|
|
|
// Step 2: Now account for cells that span rows. We only do this if there are cells
|
|
|
|
// that span rows. A spanning cell's height is the sum of the heights of the
|
|
|
|
// rows it spans, or it's own desired height, whichever is greater.
|
|
|
|
// If the cell's desired height is the larger value, resize the rows and contained
|
|
|
|
// cells by an equal percentage of the additional space.
|
|
|
|
// We go through this loop twice. The first time, we are adjusting cell heights
|
|
|
|
// on the fly. The second time through the loop, we're ensuring that subsequent
|
|
|
|
// row-spanning cells didn't change prior calculations. Since we are guaranteed
|
|
|
|
// to have found the max height spanners the first time through, we know we only
|
|
|
|
// need two passes, not an arbitrary number.
|
1999-08-21 03:27:39 +04:00
|
|
|
if (hasRowSpanningCell) {
|
|
|
|
nscoord deltaY = 0;
|
2000-02-03 17:04:49 +03:00
|
|
|
for (PRInt32 counter = 0; counter < 2; counter++) {
|
1999-08-21 03:27:39 +04:00
|
|
|
rowFrame = GetFirstFrame();
|
|
|
|
rowIndex = 0;
|
2000-02-03 17:04:49 +03:00
|
|
|
while (rowFrame) {
|
|
|
|
nsCOMPtr<nsIAtom> rowType;
|
|
|
|
rowFrame->GetFrameType(getter_AddRefs(rowType));
|
2000-02-03 18:41:04 +03:00
|
|
|
if (nsLayoutAtoms::tableRowFrame == rowType.get()) {
|
1999-08-21 03:27:39 +04:00
|
|
|
// check this row for a cell with rowspans
|
2000-02-03 17:04:49 +03:00
|
|
|
nsIFrame* cellFrame;
|
2000-01-22 04:16:50 +03:00
|
|
|
rowFrame->FirstChild(aPresContext, nsnull, &cellFrame);
|
2000-02-03 17:04:49 +03:00
|
|
|
while (cellFrame) {
|
|
|
|
nsCOMPtr<nsIAtom> cellType;
|
|
|
|
cellFrame->GetFrameType(getter_AddRefs(cellType));
|
2000-02-03 18:41:04 +03:00
|
|
|
if (nsLayoutAtoms::tableCellFrame == cellType.get()) {
|
1999-08-21 03:27:39 +04:00
|
|
|
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(rowIndex + startRowIndex,
|
2000-02-01 06:23:29 +03:00
|
|
|
(nsTableCellFrame&)*cellFrame);
|
2000-02-03 17:04:49 +03:00
|
|
|
if (rowSpan > 1) { // found a cell with rowspan > 1, determine the height
|
|
|
|
// of the rows it spans
|
1999-08-21 03:27:39 +04:00
|
|
|
nscoord heightOfRowsSpanned = 0;
|
2000-04-29 01:05:31 +04:00
|
|
|
nscoord cellSpacingOfRowsSpanned = 0;
|
2000-02-03 17:04:49 +03:00
|
|
|
PRInt32 spanX;
|
2000-02-04 05:49:27 +03:00
|
|
|
PRBool cellsOrigInSpan = PR_FALSE; // do any cells originate in the spanned rows
|
2000-02-03 17:04:49 +03:00
|
|
|
for (spanX = 0; spanX < rowSpan; spanX++) {
|
2000-02-04 05:49:27 +03:00
|
|
|
PRInt32 rIndex = rowIndex + spanX;
|
|
|
|
if (rowHeights[rIndex] > 0) {
|
2000-02-03 17:04:49 +03:00
|
|
|
// don't consider negative values of special rows
|
2000-02-04 05:49:27 +03:00
|
|
|
heightOfRowsSpanned += rowHeights[rowIndex + spanX];
|
|
|
|
cellsOrigInSpan = PR_TRUE;
|
2000-02-03 17:04:49 +03:00
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
if (0 != spanX) {
|
|
|
|
cellSpacingOfRowsSpanned += cellSpacingY;
|
|
|
|
}
|
1999-08-21 03:27:39 +04:00
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
nscoord availHeightOfRowsSpanned = heightOfRowsSpanned + cellSpacingOfRowsSpanned;
|
1999-08-21 03:27:39 +04:00
|
|
|
|
|
|
|
// see if the cell's height fits within the rows it spans. If this is
|
|
|
|
// pass 1 then use the cell's desired height and not the current height
|
|
|
|
// of its frame. That way this works for incremental reflow, too
|
|
|
|
nsSize cellFrameSize;
|
|
|
|
cellFrame->GetSize(cellFrameSize);
|
|
|
|
if (0 == counter) {
|
2000-02-03 17:04:49 +03:00
|
|
|
nsSize cellDesSize = ((nsTableCellFrame*)cellFrame)->GetDesiredSize();
|
|
|
|
((nsTableRowFrame*)rowFrame)->CalculateCellActualSize(cellFrame, cellDesSize.width,
|
|
|
|
cellDesSize.height, cellDesSize.width);
|
|
|
|
cellFrameSize.height = cellDesSize.height;
|
1999-08-21 03:27:39 +04:00
|
|
|
}
|
|
|
|
|
2000-02-03 17:04:49 +03:00
|
|
|
if (availHeightOfRowsSpanned >= cellFrameSize.height) {
|
2000-04-29 01:05:31 +04:00
|
|
|
// the cell's height fits with the available space of the rows it
|
1999-08-21 03:27:39 +04:00
|
|
|
// spans. Set the cell frame's height
|
1999-11-24 09:03:41 +03:00
|
|
|
cellFrame->SizeTo(aPresContext, cellFrameSize.width, availHeightOfRowsSpanned);
|
1999-08-21 03:27:39 +04:00
|
|
|
// Realign cell content based on new height
|
2000-02-12 04:55:40 +03:00
|
|
|
((nsTableCellFrame*)cellFrame)->VerticallyAlignChild(aPresContext, aReflowState);
|
1999-08-21 03:27:39 +04:00
|
|
|
}
|
2000-02-03 17:04:49 +03:00
|
|
|
else {
|
1999-08-21 03:27:39 +04:00
|
|
|
// the cell's height is larger than the available space of the rows it
|
|
|
|
// spans so distribute the excess height to the rows affected
|
2000-02-04 05:49:27 +03:00
|
|
|
nscoord excessAvail = cellFrameSize.height - availHeightOfRowsSpanned;
|
|
|
|
nscoord excessBasis = excessAvail;
|
1999-08-21 03:27:39 +04:00
|
|
|
|
2000-02-03 17:04:49 +03:00
|
|
|
nsTableRowFrame* rowFrameToBeResized = (nsTableRowFrame *)rowFrame;
|
|
|
|
// iterate every row starting at last row spanned and up to the row with
|
|
|
|
// the spanning cell. do this bottom up so that special rows can get a full
|
|
|
|
// allocation before other rows.
|
2000-02-04 05:49:27 +03:00
|
|
|
PRInt32 startRowIndex = rowIndex + rowSpan - 1;
|
|
|
|
for (PRInt32 rowX = startRowIndex; (rowX >= rowIndex) && (excessAvail > 0); rowX--) {
|
|
|
|
nscoord excessForRow = 0;
|
|
|
|
// special rows gets as much as they can
|
|
|
|
if (rowHeights[rowX] <= 0) {
|
|
|
|
if ((rowX == startRowIndex) || (!cellsOrigInSpan)) {
|
|
|
|
if (0 == rowHeights[rowX]) {
|
|
|
|
// give it all since no cell originates in the row
|
|
|
|
excessForRow = excessBasis;
|
|
|
|
}
|
|
|
|
else { // don't let the allocation excced what it needs
|
|
|
|
excessForRow = (excessBasis > -rowHeights[rowX]) ? -rowHeights[rowX] : excessBasis;
|
|
|
|
}
|
2000-02-03 17:04:49 +03:00
|
|
|
rowHeights[rowX] = excessForRow;
|
2000-02-04 05:49:27 +03:00
|
|
|
excessBasis -= excessForRow;
|
|
|
|
excessAvail -= excessForRow;
|
2000-02-03 17:04:49 +03:00
|
|
|
}
|
|
|
|
}
|
2000-02-04 05:49:27 +03:00
|
|
|
else if (cellsOrigInSpan) { // normal rows
|
2000-02-03 17:04:49 +03:00
|
|
|
// The amount of additional space each normal row gets is based on the
|
|
|
|
// percentage of space it occupies, i.e. they don't all get the
|
|
|
|
// same amount of available space
|
|
|
|
float percent = ((float)rowHeights[rowX]) / ((float)heightOfRowsSpanned);
|
1999-08-21 03:27:39 +04:00
|
|
|
|
2000-02-03 17:04:49 +03:00
|
|
|
// give rows their percentage, except for the first row which gets
|
|
|
|
// the remainder
|
|
|
|
excessForRow = (rowX == rowIndex)
|
2000-02-04 05:49:27 +03:00
|
|
|
? excessAvail
|
|
|
|
: NSToCoordRound(((float)(excessBasis)) * percent);
|
2000-02-03 17:04:49 +03:00
|
|
|
// update the row height
|
|
|
|
rowHeights[rowX] += excessForRow;
|
2000-02-04 05:49:27 +03:00
|
|
|
excessAvail -= excessForRow;
|
2000-02-03 17:04:49 +03:00
|
|
|
}
|
1999-08-21 03:27:39 +04:00
|
|
|
// Get the next row frame
|
|
|
|
GetNextRowSibling((nsIFrame**)&rowFrameToBeResized);
|
|
|
|
}
|
2000-02-04 05:49:27 +03:00
|
|
|
// if excessAvail is > 0 it is because !cellsOrigInSpan and the
|
|
|
|
// allocation involving special rows couldn't allocate everything.
|
|
|
|
// just give the remainder to the last row spanned.
|
|
|
|
if (excessAvail > 0) {
|
|
|
|
if (rowHeights[startRowIndex] >= 0) {
|
|
|
|
rowHeights[startRowIndex] += excessAvail;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rowHeights[startRowIndex] = excessAvail;
|
|
|
|
}
|
|
|
|
}
|
1998-09-16 00:36:42 +04:00
|
|
|
}
|
|
|
|
}
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
2000-02-03 17:04:49 +03:00
|
|
|
cellFrame->GetNextSibling(&cellFrame); // Get the next row child (cell frame)
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
1999-08-21 03:27:39 +04:00
|
|
|
|
|
|
|
// If this is pass 2 then resize the row to its final size and move the
|
|
|
|
// row's position if the previous rows have caused a shift
|
|
|
|
if (1 == counter) {
|
1999-12-14 01:56:31 +03:00
|
|
|
PRBool movedFrame = (deltaY != 0);
|
|
|
|
nsRect rowBounds;
|
1999-08-21 03:27:39 +04:00
|
|
|
|
|
|
|
// Move the row to the correct position
|
1999-12-14 01:56:31 +03:00
|
|
|
rowFrame->GetRect(rowBounds); // added
|
1999-08-21 03:27:39 +04:00
|
|
|
rowBounds.y += deltaY;
|
|
|
|
|
|
|
|
// Adjust our running delta
|
2000-02-04 05:49:27 +03:00
|
|
|
nscoord rowHeight = (rowHeights[rowIndex] > 0) ? rowHeights[rowIndex] : 0;
|
|
|
|
deltaY += rowHeight - rowBounds.height;
|
1999-08-21 03:27:39 +04:00
|
|
|
|
|
|
|
// Resize the row to its final size and position
|
2000-02-04 05:49:27 +03:00
|
|
|
rowBounds.height = rowHeight;
|
1999-11-24 09:03:41 +03:00
|
|
|
rowFrame->SetRect(aPresContext, rowBounds);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
if (movedFrame) {
|
|
|
|
// Make sure any views are positioned properly
|
2000-02-03 17:04:49 +03:00
|
|
|
nsIView* view;
|
1999-12-14 01:56:31 +03:00
|
|
|
rowFrame->GetView(aPresContext, &view);
|
|
|
|
if (view) {
|
|
|
|
nsContainerFrame::PositionFrameView(aPresContext, rowFrame, view);
|
|
|
|
} else {
|
|
|
|
nsContainerFrame::PositionChildViews(aPresContext, rowFrame);
|
|
|
|
}
|
|
|
|
}
|
1999-08-21 03:27:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
rowIndex++;
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
2000-02-03 17:04:49 +03:00
|
|
|
GetNextFrame(rowFrame, &rowFrame); // Get the next rowgroup child (row frame)
|
1999-06-23 07:02:21 +04:00
|
|
|
}
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// step 3: notify the rows of their new heights
|
1999-08-21 03:27:39 +04:00
|
|
|
nscoord rowGroupHeight = 0;
|
1999-06-23 07:02:21 +04:00
|
|
|
rowFrame = GetFirstFrame();
|
1999-08-19 07:51:25 +04:00
|
|
|
rowIndex = 0;
|
2000-02-03 17:04:49 +03:00
|
|
|
while (rowFrame) {
|
2000-02-11 06:55:33 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) {
|
|
|
|
nsCOMPtr<nsIAtom> rowType;
|
|
|
|
rowFrame->GetFrameType(getter_AddRefs(rowType));
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == rowType.get()) {
|
|
|
|
// Notify the row of the new size
|
|
|
|
((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
|
|
|
|
}
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
1999-08-21 03:27:39 +04:00
|
|
|
|
|
|
|
// Update the running row group height. The height includes frames that
|
|
|
|
// aren't rows as well
|
2000-02-03 17:04:49 +03:00
|
|
|
nsSize rowSize;
|
1999-08-21 03:27:39 +04:00
|
|
|
rowFrame->GetSize(rowSize);
|
|
|
|
rowGroupHeight += rowSize.height;
|
2000-04-29 01:05:31 +04:00
|
|
|
if (0 != rowIndex) {
|
|
|
|
rowGroupHeight += cellSpacingY;
|
|
|
|
}
|
1999-08-21 03:27:39 +04:00
|
|
|
|
2000-02-03 17:04:49 +03:00
|
|
|
GetNextFrame(rowFrame, &rowFrame); // Get the next row
|
1999-08-19 07:51:25 +04:00
|
|
|
rowIndex++;
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
|
|
|
|
2000-02-03 17:04:49 +03:00
|
|
|
aDesiredSize.height = rowGroupHeight; // Adjust our desired size
|
|
|
|
delete [] rowHeights; // cleanup
|
1998-06-30 06:11:07 +04: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
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowGroupFrame::AdjustSiblingsAfterReflow(nsIPresContext* aPresContext,
|
1999-08-19 07:51:25 +04:00
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame,
|
1999-08-31 02:30:32 +04:00
|
|
|
nsSize* aMaxElementSize,
|
1999-08-19 07:51:25 +04:00
|
|
|
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;
|
|
|
|
|
1999-08-31 02:30:32 +04:00
|
|
|
// Move the frames that follow aKidFrame by aDeltaY and update the max element
|
|
|
|
// size
|
|
|
|
nsIFrame* kidFrame;
|
|
|
|
for (aKidFrame->GetNextSibling(&kidFrame); kidFrame; kidFrame->GetNextSibling(&kidFrame)) {
|
|
|
|
// Update the max element size
|
|
|
|
if (aMaxElementSize) {
|
2000-01-15 08:39:58 +03:00
|
|
|
const nsStyleDisplay *display;
|
|
|
|
aKidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == display->mDisplay) {
|
|
|
|
nsSize kidMaxElementSize;
|
|
|
|
((nsTableRowFrame*)kidFrame)->GetMaxElementSize(kidMaxElementSize);
|
|
|
|
|
|
|
|
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, kidMaxElementSize.width);
|
|
|
|
}
|
1999-08-31 02:30:32 +04:00
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
|
1999-08-31 02:30:32 +04:00
|
|
|
// 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);
|
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
|
|
|
|
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;
|
1998-12-15 19:39:09 +03:00
|
|
|
nsresult rv = NS_OK;
|
1998-12-14 04:24:11 +03:00
|
|
|
|
|
|
|
// Walk each of the row frames looking for the first row frame that
|
|
|
|
// doesn't fit in the available space
|
1999-06-23 07:02:21 +04:00
|
|
|
for (nsIFrame* rowFrame = GetFirstFrame(); rowFrame; GetNextFrame(rowFrame, &rowFrame)) {
|
1998-12-14 04:24:11 +03:00
|
|
|
nsRect bounds;
|
|
|
|
|
1999-02-22 06:28:00 +03:00
|
|
|
rowFrame->GetRect(bounds);
|
1999-01-06 02:31:18 +03:00
|
|
|
if (bounds.YMost() > aReflowState.availableHeight) {
|
1998-12-14 04:24:11 +03:00
|
|
|
// If this is the first row frame then we need to split it
|
1999-02-22 06:28:00 +03:00
|
|
|
if (!prevRowFrame) {
|
1998-12-14 04:24:11 +03:00
|
|
|
// Reflow the row in the available space and have it split
|
1999-02-22 06:28:00 +03:00
|
|
|
nsSize availSize(aReflowState.availableWidth,
|
|
|
|
aReflowState.availableHeight - bounds.y);
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState rowReflowState(aPresContext, aReflowState, rowFrame,
|
1999-02-22 06:28:00 +03:00
|
|
|
availSize, eReflowReason_Resize);
|
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);
|
1999-11-19 18:33:29 +03:00
|
|
|
rowFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
1999-02-22 06:28:00 +03:00
|
|
|
((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
|
1998-12-15 19:39:09 +03:00
|
|
|
aDesiredSize.height = desiredSize.height;
|
1998-12-14 04:24:11 +03:00
|
|
|
|
1998-12-16 00:26:05 +03:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
1999-02-22 06:28:00 +03:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
// Verify it doesn't already have a next-in-flow. The reason it should
|
|
|
|
// not already have a next-in-flow is that ReflowMappedChildren() reflows
|
|
|
|
// the row frames with an unconstrained available height
|
|
|
|
nsIFrame* nextInFlow;
|
1999-02-24 07:48:08 +03:00
|
|
|
rowFrame->GetNextInFlow(&nextInFlow);
|
1999-02-22 06:28:00 +03:00
|
|
|
NS_ASSERTION(!nextInFlow, "row frame already has next-in-flow");
|
|
|
|
#endif
|
1998-12-16 00:26:05 +03:00
|
|
|
// Create a continuing frame, add it to the child list, and then push it
|
|
|
|
// and the frames that follow
|
1999-02-22 06:28:00 +03:00
|
|
|
nsIFrame* contRowFrame;
|
1999-02-24 07:03:50 +03:00
|
|
|
nsIPresShell* presShell;
|
|
|
|
nsIStyleSet* styleSet;
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetShell(&presShell);
|
1999-02-24 07:03:50 +03:00
|
|
|
presShell->GetStyleSet(&styleSet);
|
|
|
|
NS_RELEASE(presShell);
|
1999-11-24 09:03:41 +03:00
|
|
|
styleSet->CreateContinuingFrame(aPresContext, rowFrame, this, &contRowFrame);
|
1999-02-24 07:03:50 +03:00
|
|
|
NS_RELEASE(styleSet);
|
1998-12-16 00:26:05 +03:00
|
|
|
|
|
|
|
// Add it to the child list
|
1999-02-22 06:28:00 +03:00
|
|
|
nsIFrame* nextRow;
|
1999-06-23 07:02:21 +04:00
|
|
|
GetNextFrame(rowFrame, &nextRow);
|
1999-10-29 08:57:02 +04:00
|
|
|
contRowFrame->SetNextSibling(nextRow);
|
|
|
|
rowFrame->SetNextSibling(contRowFrame);
|
1999-06-23 07:02:21 +04:00
|
|
|
|
1999-02-22 06:28:00 +03:00
|
|
|
// Push the continuing row frame and the frames that follow
|
1999-11-24 09:03:41 +03:00
|
|
|
PushChildren(aPresContext, contRowFrame, rowFrame);
|
1999-03-09 18:35:43 +03:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// The row frame is complete. It may be the case that it's minimum
|
|
|
|
// height was greater than the available height we gave it
|
|
|
|
nsIFrame* nextRowFrame;
|
|
|
|
|
|
|
|
// Push the frame that follows
|
1999-06-23 07:02:21 +04:00
|
|
|
GetNextFrame(rowFrame, &nextRowFrame);
|
|
|
|
|
1999-03-09 18:35:43 +03:00
|
|
|
if (nextRowFrame) {
|
1999-11-24 09:03:41 +03:00
|
|
|
PushChildren(aPresContext, nextRowFrame, rowFrame);
|
1999-03-09 18:35:43 +03:00
|
|
|
}
|
|
|
|
aStatus = nextRowFrame ? NS_FRAME_NOT_COMPLETE : NS_FRAME_COMPLETE;
|
1998-12-16 00:26:05 +03:00
|
|
|
}
|
|
|
|
|
1998-12-14 04:24:11 +03:00
|
|
|
} else {
|
1999-02-22 06:28:00 +03:00
|
|
|
// See whether the row frame has cells that span into it
|
2000-01-15 08:39:58 +03:00
|
|
|
const nsStyleDisplay *display;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW != display->mDisplay) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "uh oh, not a row frame...");
|
|
|
|
}
|
1999-02-22 06:28:00 +03:00
|
|
|
PRInt32 rowIndex = ((nsTableRowFrame*)rowFrame)->GetRowIndex();
|
|
|
|
PRInt32 colCount = aTableFrame->GetColCount();
|
|
|
|
nsTableCellFrame* prevCellFrame = nsnull;
|
|
|
|
|
|
|
|
for (PRInt32 colIndex = 0; colIndex < colCount; colIndex++) {
|
1999-08-19 23:52:37 +04:00
|
|
|
nsTableCellFrame* cellFrame = aTableFrame->GetCellInfoAt(rowIndex, colIndex);
|
2000-05-03 03:47:01 +04:00
|
|
|
if (!cellFrame) {
|
|
|
|
// There is no cell at this column index. Go check the next column index
|
|
|
|
continue;
|
|
|
|
}
|
1999-02-22 06:28:00 +03:00
|
|
|
|
|
|
|
// See if the cell frame is really in this row, or whether it's a
|
|
|
|
// row span from a previous row
|
|
|
|
PRInt32 realRowIndex;
|
|
|
|
cellFrame->GetRowIndex(realRowIndex);
|
|
|
|
if (realRowIndex == rowIndex) {
|
|
|
|
prevCellFrame = cellFrame;
|
|
|
|
} else {
|
|
|
|
// This cell frame spans into the row we're pushing, so we need to:
|
|
|
|
// - reflow the cell frame into the new smaller space
|
|
|
|
// - create a continuing frame for the cell frame (we do this regardless
|
|
|
|
// of whether it's complete)
|
|
|
|
// - add the continuing frame to the row frame we're pushing
|
|
|
|
nsIFrame* parentFrame;
|
|
|
|
nsPoint firstRowOrigin, lastRowOrigin;
|
|
|
|
nsReflowStatus status;
|
|
|
|
|
|
|
|
// Ask the cell frame's parent to reflow it to the height of all the
|
|
|
|
// rows it spans between its parent frame and the row we're pushing
|
|
|
|
cellFrame->GetParent(&parentFrame);
|
|
|
|
parentFrame->GetOrigin(firstRowOrigin);
|
|
|
|
rowFrame->GetOrigin(lastRowOrigin);
|
|
|
|
((nsTableRowFrame*)parentFrame)->ReflowCellFrame(aPresContext,
|
|
|
|
aReflowState, cellFrame, lastRowOrigin.y - firstRowOrigin.y, status);
|
|
|
|
|
|
|
|
// Create the continuing cell frame
|
|
|
|
nsIFrame* contCellFrame;
|
1999-02-24 07:03:50 +03:00
|
|
|
nsIPresShell* presShell;
|
|
|
|
nsIStyleSet* styleSet;
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetShell(&presShell);
|
1999-02-24 07:03:50 +03:00
|
|
|
presShell->GetStyleSet(&styleSet);
|
|
|
|
NS_RELEASE(presShell);
|
1999-11-24 09:03:41 +03:00
|
|
|
styleSet->CreateContinuingFrame(aPresContext, cellFrame, rowFrame, &contCellFrame);
|
1999-02-24 07:03:50 +03:00
|
|
|
NS_RELEASE(styleSet);
|
1999-02-22 06:28:00 +03:00
|
|
|
|
|
|
|
// Add it to the row's child list
|
|
|
|
((nsTableRowFrame*)rowFrame)->InsertCellFrame((nsTableCellFrame*)contCellFrame,
|
|
|
|
prevCellFrame);
|
|
|
|
prevCellFrame = (nsTableCellFrame*)contCellFrame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
aDesiredSize.height = bounds.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-02-22 06:28:00 +03:00
|
|
|
prevRowFrame = rowFrame;
|
1998-12-14 04:24:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/** Layout the entire row group.
|
|
|
|
* This method stacks rows vertically according to HTML 4.0 rules.
|
|
|
|
* Rows are responsible for layout of their children.
|
|
|
|
*/
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD
|
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);
|
1999-08-24 16:01:31 +04:00
|
|
|
if (nsDebugTable::gRflRowGrp) nsTableFrame::DebugReflow("TRG::Rfl", this, &aReflowState, nsnull);
|
1998-10-14 20:32:45 +04:00
|
|
|
nsresult rv=NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-07-03 03:19:31 +04:00
|
|
|
// Initialize out parameter
|
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
|
|
|
}
|
|
|
|
|
1998-11-04 23:09:19 +03:00
|
|
|
nsTableFrame *tableFrame=nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
else if (tableFrame == nsnull)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
RowGroupReflowState state(aPresContext, aReflowState, tableFrame);
|
1998-07-03 03:19:31 +04:00
|
|
|
|
1998-06-23 09:43:27 +04:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
1998-11-04 23:09:19 +03:00
|
|
|
rv = IncrementalReflow(aPresContext, aDesiredSize, state, aStatus);
|
1998-06-23 09:43:27 +04:00
|
|
|
} else {
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
|
|
|
// Check for an overflow list
|
1999-11-24 09:03:41 +03:00
|
|
|
MoveOverflowToChildList(aPresContext);
|
1998-06-23 09:43:27 +04:00
|
|
|
|
1999-02-20 06:15:03 +03:00
|
|
|
// Reflow the existing frames. Before we do, pull-up any row frames from
|
|
|
|
// our next-in-flow.
|
|
|
|
// XXX It would be more efficient to do this if we have room left after
|
|
|
|
// reflowing the frames we have, the problem is we don't know if we have
|
|
|
|
// room left until after we call CalculateRowHeights()...
|
|
|
|
PullUpAllRowFrames(aPresContext);
|
1999-06-23 07:02:21 +04:00
|
|
|
rv = ReflowMappedChildren(aPresContext, aDesiredSize, state, aStatus,
|
1998-10-20 03:43:06 +04:00
|
|
|
nsnull, aReflowState.reason, PR_TRUE);
|
1998-06-23 09:43:27 +04:00
|
|
|
|
|
|
|
// Return our desired rect
|
1999-01-06 02:31:18 +03:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
1998-06-30 06:11:07 +04:00
|
|
|
aDesiredSize.height = state.y;
|
|
|
|
|
1999-01-18 02:35:56 +03:00
|
|
|
// account for scroll bars. XXX needs optimization/caching
|
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
nsIAtom* pseudoTag;
|
|
|
|
|
|
|
|
mStyleContext->GetPseudoType(pseudoTag);
|
1999-08-08 05:19:36 +04:00
|
|
|
if (pseudoTag == nsLayoutAtoms::scrolledContentPseudo) {
|
1999-01-18 02:35:56 +03:00
|
|
|
nsIFrame* scrollFrame;
|
1999-02-10 04:36:30 +03:00
|
|
|
GetParent(&scrollFrame);
|
1999-01-18 02:35:56 +03:00
|
|
|
const nsStyleDisplay *display;
|
|
|
|
scrollFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
|
|
|
if ((NS_STYLE_OVERFLOW_SCROLL == display->mOverflow) ||
|
|
|
|
(NS_STYLE_OVERFLOW_AUTO == display->mOverflow)) {
|
|
|
|
float sbWidth, sbHeight;
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIDeviceContext> dc;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetDeviceContext(getter_AddRefs(dc));
|
1999-01-18 02:35:56 +03:00
|
|
|
|
|
|
|
dc->GetScrollBarDimensions(sbWidth, sbHeight);
|
|
|
|
aDesiredSize.maxElementSize->width += NSToCoordRound(sbWidth);
|
|
|
|
// If scrollbars are always visible then add in the hor sb height
|
|
|
|
if (NS_STYLE_OVERFLOW_SCROLL == display->mOverflow) {
|
|
|
|
aDesiredSize.maxElementSize->height += NSToCoordRound(sbHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(pseudoTag);
|
|
|
|
}
|
|
|
|
|
1998-06-30 06:11:07 +04:00
|
|
|
// shrink wrap rows to height of tallest cell in that row
|
2000-02-11 06:55:33 +03:00
|
|
|
PRBool isTableUnconstrainedReflow = NS_UNCONSTRAINEDSIZE ==
|
|
|
|
aReflowState.parentReflowState->availableWidth;
|
|
|
|
|
|
|
|
// Skip this step if possible. We can skip it if the table is going to be
|
|
|
|
// 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
|
|
|
|
if ((eReflowReason_Initial != aReflowState.reason) || isTableUnconstrainedReflow) {
|
1998-11-20 04:01:25 +03:00
|
|
|
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState);
|
|
|
|
}
|
1998-12-14 04:24:11 +03:00
|
|
|
|
|
|
|
// See if all the frames fit
|
1999-06-23 07:02:21 +04:00
|
|
|
if (aDesiredSize.height > aReflowState.availableHeight &&
|
|
|
|
!tableFrame->RowGroupsShouldBeConstrained()) {
|
1998-12-14 04:24:11 +03:00
|
|
|
// Nope, find a place to split the row group
|
1999-02-22 06:28:00 +03:00
|
|
|
SplitRowGroup(aPresContext, aDesiredSize, aReflowState, tableFrame, aStatus);
|
1998-12-14 04:24:11 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-08-31 02:30:32 +04:00
|
|
|
// If we computed our max element element size, then cache it so we can return
|
|
|
|
// it later when asked
|
|
|
|
if (aDesiredSize.maxElementSize) {
|
|
|
|
mMaxElementSize = *aDesiredSize.maxElementSize;
|
|
|
|
}
|
|
|
|
|
2000-01-03 01:55:48 +03:00
|
|
|
if (nsDebugTable::gRflRowGrp) nsTableFrame::DebugReflow("TRG::Rfl ex", this, nsnull, &aDesiredSize, aStatus);
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableRowGroupFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
1998-10-14 20:32:45 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-11-04 23:09:19 +03:00
|
|
|
RowGroupReflowState& aReflowState,
|
1998-10-14 20:32:45 +04:00
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// determine if this frame is the target or not
|
|
|
|
nsIFrame *target=nsnull;
|
1998-11-04 23:09:19 +03:00
|
|
|
rv = aReflowState.reflowState.reflowCommand->GetTarget(target);
|
1998-10-14 20:32:45 +04:00
|
|
|
if ((PR_TRUE==NS_SUCCEEDED(rv)) && (nsnull!=target))
|
|
|
|
{
|
|
|
|
if (this==target)
|
1998-11-04 23:09:19 +03:00
|
|
|
rv = IR_TargetIsMe(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-14 20:32:45 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Get the next frame in the reflow chain
|
|
|
|
nsIFrame* nextFrame;
|
1998-11-04 23:09:19 +03:00
|
|
|
aReflowState.reflowState.reflowCommand->GetNext(nextFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
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 06:18:33 +04:00
|
|
|
// Helper function. It marks the table frame as dirty and generates
|
|
|
|
// a reflow command
|
|
|
|
nsresult
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableRowGroupFrame::AddTableDirtyReflowCommand(nsIPresContext* aPresContext,
|
1999-08-02 06:18:33 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIFrame* aTableFrame)
|
|
|
|
{
|
|
|
|
nsFrameState frameState;
|
|
|
|
nsIFrame* tableParentFrame;
|
|
|
|
nsIReflowCommand* reflowCmd;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Mark the table frame as dirty
|
|
|
|
aTableFrame->GetFrameState(&frameState);
|
|
|
|
frameState |= NS_FRAME_IS_DIRTY;
|
|
|
|
aTableFrame->SetFrameState(frameState);
|
|
|
|
|
|
|
|
// Target the reflow comamnd at its parent frame
|
|
|
|
aTableFrame->GetParent(&tableParentFrame);
|
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, tableParentFrame,
|
|
|
|
nsIReflowCommand::ReflowDirty);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// Add the reflow command
|
|
|
|
rv = aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
#if 0
|
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
|
|
|
nsIReflowCommand* reflowCmd;
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(NS_NewHTMLReflowCommand(&reflowCmd, this,
|
|
|
|
nsIReflowCommand::ReflowDirty))) {
|
|
|
|
aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// this does not get called for trees
|
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
|
|
|
|
nsVoidArray rows;
|
|
|
|
for (nsIFrame* rowFrame = aFrameList; rowFrame; rowFrame->GetNextSibling(&rowFrame)) {
|
|
|
|
nsIAtom* frameType;
|
|
|
|
rowFrame->GetFrameType(&frameType);
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType) {
|
|
|
|
rows.AppendElement(rowFrame);
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
}
|
1999-08-02 02:01:37 +04:00
|
|
|
|
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-01-13 08:29:38 +03:00
|
|
|
tableFrame->AppendRows(*aPresContext, *this, rows);
|
1999-08-02 02:01:37 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// Because the number of columns may have changed invalidate the column widths
|
|
|
|
tableFrame->InvalidateColumnWidths();
|
1999-08-07 19:12:50 +04:00
|
|
|
|
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
|
|
|
|
nsIReflowCommand* reflowCmd;
|
1999-08-02 02:01:37 +04:00
|
|
|
|
1999-10-30 00:25:13 +04:00
|
|
|
if (NS_SUCCEEDED(NS_NewHTMLReflowCommand(&reflowCmd, this,
|
|
|
|
nsIReflowCommand::ReflowDirty))) {
|
|
|
|
aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
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-12-14 01:56:31 +03:00
|
|
|
// this does not get called for trees
|
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)
|
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
// collect the new row frames in an array
|
|
|
|
nsVoidArray rows;
|
|
|
|
for (nsIFrame* rowFrame = aFrameList; rowFrame; rowFrame->GetNextSibling(&rowFrame)) {
|
|
|
|
nsIAtom* frameType;
|
|
|
|
rowFrame->GetFrameType(&frameType);
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType) {
|
|
|
|
rows.AppendElement(rowFrame);
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(frameType);
|
|
|
|
}
|
1999-08-02 06:18:33 +04:00
|
|
|
|
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);
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
if (rows.Count() > 0) {
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (tableFrame) {
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableRowFrame* prevRow = (nsTableRowFrame *)nsTableFrame::GetFrameAtOrBefore(aPresContext, this, aPrevFrame, nsLayoutAtoms::tableRowFrame);
|
2000-01-15 23:10:00 +03:00
|
|
|
PRInt32 rowIndex = (prevRow) ? prevRow->GetRowIndex() + 1 : 0;
|
2000-01-13 08:29:38 +03:00
|
|
|
tableFrame->InsertRows(*aPresContext, *this, rows, rowIndex, PR_TRUE);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
// Reflow the new frames. They're already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
|
|
|
nsIReflowCommand* reflowCmd;
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(NS_NewHTMLReflowCommand(&reflowCmd, this,
|
|
|
|
nsIReflowCommand::ReflowDirty))) {
|
|
|
|
aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
1999-08-02 06:18:33 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// Because the number of columns may have changed invalidate the column widths
|
|
|
|
tableFrame->InvalidateColumnWidths();
|
1999-08-02 06:18:33 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// Generate a reflow command so we reflow the table itself. This will
|
|
|
|
// do a pass-1 reflow of all the rows including any rows we just added
|
|
|
|
AddTableDirtyReflowCommand(aPresContext, aPresShell, tableFrame);
|
|
|
|
}
|
|
|
|
}
|
1999-08-02 06:18:33 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// this does not get called for trees
|
1999-08-02 06:18:33 +04:00
|
|
|
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) {
|
|
|
|
nsIAtom* frameType;
|
|
|
|
aOldFrame->GetFrameType(&frameType);
|
|
|
|
if (nsLayoutAtoms::tableRowFrame == frameType) {
|
|
|
|
PRInt32 firstRowIndex = ((nsTableRowFrame *)aOldFrame)->GetRowIndex();
|
|
|
|
|
|
|
|
tableFrame->RemoveRows(*aPresContext, firstRowIndex, 1, PR_TRUE);
|
|
|
|
// Because the number of columns may have changed invalidate the column widths
|
|
|
|
tableFrame->InvalidateColumnWidths();
|
1999-08-02 06:18:33 +04:00
|
|
|
|
|
|
|
// Because we haven't added any new frames we don't need to do a pass1
|
|
|
|
// reflow. Just generate a reflow command so we reflow the table itself
|
|
|
|
AddTableDirtyReflowCommand(aPresContext, aPresShell, tableFrame);
|
1999-08-02 02:01:37 +04:00
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
NS_IF_RELEASE(frameType);
|
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
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext* aPresContext,
|
1998-10-14 20:32:45 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_FRAME_COMPLETE;
|
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetType(type);
|
|
|
|
nsIFrame *objectFrame;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetChildFrame(objectFrame);
|
1998-10-30 10:57:44 +03:00
|
|
|
const nsStyleDisplay *childDisplay=nsnull;
|
|
|
|
if (nsnull!=objectFrame)
|
1998-12-02 19:45:20 +03:00
|
|
|
objectFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1998-10-14 20:32:45 +04:00
|
|
|
switch (type)
|
|
|
|
{
|
1999-08-02 02:01:37 +04:00
|
|
|
case nsIReflowCommand::ReflowDirty:
|
1999-08-03 06:41:27 +04:00
|
|
|
// Reflow the dirty child frames. Typically this is newly added frames.
|
1999-08-02 02:01:37 +04:00
|
|
|
// XXX What we really should do is do a pass-1 reflow of newly added
|
1999-08-03 06:41:27 +04:00
|
|
|
// frames (only if necessary, i.e., the table isn't fixed layout), then
|
1999-08-02 02:01:37 +04:00
|
|
|
// see if column widtsh changed and decide whether to do the pass-2 reflow
|
|
|
|
// of just the dirty rows or have the table rebalance column widths and
|
|
|
|
// do a pass-2 reflow of all rows
|
|
|
|
rv = ReflowMappedChildren(aPresContext, aDesiredSize, aReflowState, aStatus,
|
|
|
|
nsnull, aReflowState.reflowState.reason, PR_TRUE, PR_TRUE);
|
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// If any column widths have to change due to this, rebalance column widths.
|
|
|
|
// XXX need to calculate this, but for now just do it
|
1999-08-02 02:01:37 +04:00
|
|
|
aReflowState.tableFrame->InvalidateColumnWidths();
|
|
|
|
break;
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
case nsIReflowCommand::StyleChanged :
|
1998-10-30 10:57:44 +03:00
|
|
|
rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-14 20:32:45 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::ContentChanged :
|
|
|
|
NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
break;
|
|
|
|
|
1999-03-05 07:19:09 +03:00
|
|
|
default:
|
1999-08-02 06:18:33 +04:00
|
|
|
NS_NOTYETIMPLEMENTED("unexpected reflow command type");
|
1998-10-14 20:32:45 +04:00
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
NS_METHOD nsTableRowGroupFrame::GetHeightOfRows(nsIPresContext* aPresContext,
|
|
|
|
nscoord& aResult)
|
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);
|
|
|
|
if (NS_FAILED(rv) || !tableFrame) return rv;
|
|
|
|
|
|
|
|
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
|
|
|
|
|
1999-06-14 12:22:47 +04:00
|
|
|
// the rows in rowGroupFrame need to be expanded by rowHeightDelta[i]
|
|
|
|
// and the rowgroup itself needs to be expanded by SUM(row height deltas)
|
2000-04-29 01:05:31 +04:00
|
|
|
nsIFrame* rowFrame = nsnull;
|
|
|
|
rv = FirstChild(aPresContext, nsnull, &rowFrame);
|
|
|
|
while ((NS_SUCCEEDED(rv)) && (nsnull!=rowFrame)) {
|
|
|
|
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);
|
|
|
|
aResult += rowRect.height;
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
else if (NS_STYLE_DISPLAY_TABLE_ROW_GROUP == rowDisplay->mDisplay) {
|
2000-01-22 04:16:50 +03:00
|
|
|
((nsTableRowGroupFrame*)rowFrame)->GetHeightOfRows(aPresContext, aResult);
|
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
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Recovers the reflow state to what it should be if aKidFrame is about
|
|
|
|
// to be reflowed. Restores the following:
|
|
|
|
// - availSize
|
|
|
|
// - y
|
|
|
|
// - firstRow
|
|
|
|
nsresult
|
|
|
|
nsTableRowGroupFrame::RecoverState(RowGroupReflowState& aReflowState,
|
1999-08-31 02:30:32 +04:00
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nsSize* aMaxElementSize)
|
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();
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Walk the list of children looking for aKidFrame
|
|
|
|
for (nsIFrame* frame = mFrames.FirstChild(); frame; frame->GetNextSibling(&frame)) {
|
|
|
|
if (frame == aKidFrame) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the running y-offset
|
|
|
|
nsSize kidSize;
|
|
|
|
frame->GetSize(kidSize);
|
2000-05-10 04:54:00 +04:00
|
|
|
aReflowState.y += cellSpacingY + kidSize.height;
|
1999-08-19 07:51:25 +04:00
|
|
|
|
|
|
|
// If our height is constrained then update the available height
|
|
|
|
if (PR_FALSE == aReflowState.unconstrainedHeight) {
|
|
|
|
aReflowState.availSize.height -= kidSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the maximum element size
|
1999-08-31 02:30:32 +04:00
|
|
|
if (aMaxElementSize) {
|
2000-01-15 08:39:58 +03:00
|
|
|
const nsStyleDisplay *display;
|
|
|
|
frame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display));
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW == display->mDisplay) {
|
|
|
|
// Get the row frame's cached max element size
|
|
|
|
nsSize kidMaxElementSize;
|
|
|
|
((nsTableRowFrame*)frame)->GetMaxElementSize(kidMaxElementSize);
|
|
|
|
|
|
|
|
if (aReflowState.firstRow) {
|
|
|
|
aMaxElementSize->width = kidMaxElementSize.width;
|
|
|
|
aMaxElementSize->height = kidMaxElementSize.height;
|
|
|
|
} else {
|
|
|
|
aMaxElementSize->width = PR_MAX(aMaxElementSize->width, kidMaxElementSize.width);
|
|
|
|
}
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
|
|
|
}
|
1999-08-31 02:30:32 +04:00
|
|
|
|
|
|
|
aReflowState.firstRow = PR_FALSE;
|
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;
|
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableRowGroupFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
|
1998-10-14 20:32:45 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame * aNextFrame)
|
|
|
|
|
|
|
|
{
|
|
|
|
nsresult rv;
|
2000-01-17 20:45:17 +03:00
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Recover the state as if aNextFrame is about to be reflowed
|
1999-08-31 02:30:32 +04:00
|
|
|
RecoverState(aReflowState, aNextFrame, aDesiredSize.maxElementSize);
|
1998-10-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...
|
|
|
|
nsSize kidAvailSize(aReflowState.availSize.width, NS_UNCONSTRAINEDSIZE);
|
1999-08-19 07:51:25 +04:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
|
2000-01-17 20:45:17 +03:00
|
|
|
aNextFrame, kidAvailSize);
|
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);
|
1999-11-19 18:33:29 +03:00
|
|
|
PlaceChild(aPresContext, aReflowState, aNextFrame, desiredSize, 0,
|
|
|
|
aReflowState.y, aDesiredSize.maxElementSize, kidMaxElementSize);
|
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)) {
|
1999-09-01 09:16:12 +04:00
|
|
|
// If the row has no cells that span into or across the row, then we
|
|
|
|
// don't have to call CalculateRowHeights() which is quite expensive
|
|
|
|
if (IsSimpleRowFrame(aReflowState.tableFrame, aNextFrame)) {
|
1999-09-13 07:19:39 +04:00
|
|
|
// XXX This optimization isn't ready to be enabled yet, because the
|
|
|
|
// row frame code needs to change to size the cell frame and vertically
|
|
|
|
// align it and either bitblt it into its new position or repaint
|
|
|
|
#if 0
|
|
|
|
// 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
|
|
|
|
nsIFrame* lastKidFrame = mFrames.LastChild();
|
|
|
|
nsRect lastKidRect;
|
|
|
|
|
|
|
|
lastKidFrame->GetRect(lastKidRect);
|
|
|
|
aDesiredSize.height = lastKidRect.YMost();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
#endif
|
|
|
|
// Inform the row of its new height.
|
|
|
|
((nsTableRowFrame*)aNextFrame)->DidResize(aPresContext, aReflowState.reflowState);
|
|
|
|
|
|
|
|
// 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...
|
1999-11-24 09:03:41 +03:00
|
|
|
Invalidate(aPresContext, kidRect);
|
1999-09-13 07:19:39 +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());
|
1999-11-24 09:03:41 +03:00
|
|
|
Invalidate(aPresContext, dirtyRect);
|
1999-09-13 07:19:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Adjust the frames that follow
|
|
|
|
AdjustSiblingsAfterReflow(aPresContext, aReflowState, aNextFrame,
|
|
|
|
aDesiredSize.maxElementSize,
|
|
|
|
desiredSize.height - oldKidRect.height);
|
|
|
|
aDesiredSize.height = aReflowState.y;
|
|
|
|
#if 0
|
|
|
|
}
|
|
|
|
#endif
|
1999-08-19 07:51:25 +04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
// Adjust the frames that follow...
|
1999-08-31 02:30:32 +04:00
|
|
|
AdjustSiblingsAfterReflow(aPresContext, aReflowState, aNextFrame,
|
1999-12-16 03:37:03 +03:00
|
|
|
aDesiredSize.maxElementSize,
|
|
|
|
desiredSize.height - oldKidRect.height);
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
// Now recalculate the row heights
|
|
|
|
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState.reflowState);
|
1999-12-16 03:37:03 +03:00
|
|
|
|
1999-09-13 07:19:39 +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);
|
1999-11-24 09:03:41 +03:00
|
|
|
Invalidate(aPresContext, dirtyRect);
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return our desired width
|
1999-01-06 02:31:18 +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
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableRowGroupFrame::IR_StyleChanged(nsIPresContext* aPresContext,
|
1998-10-30 10:57:44 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
RowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// we presume that all the easy optimizations were done in the nsHTMLStyleSheet before we were called here
|
|
|
|
// XXX: we can optimize this when we know which style attribute changed
|
1998-11-04 23:09:19 +03:00
|
|
|
aReflowState.tableFrame->InvalidateFirstPassCache();
|
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;
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetFrameName(nsString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName("TableRowGroup", aResult);
|
|
|
|
}
|
1998-11-20 04:01:25 +03:00
|
|
|
|
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
|
|
|
|
|
|
|
//nsILineIterator methods for nsTableFrame
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetNumLines(PRInt32* aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
return GetRowCount(*aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetDirection(PRBool* aIsRightToLeft)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsRightToLeft);
|
|
|
|
*aIsRightToLeft = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::GetLine(PRInt32 aLineNumber, nsIFrame** aFirstFrameOnLine, PRInt32* aNumFramesOnLine,
|
|
|
|
nsRect& aLineBounds, PRUint32* aLineFlags)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
|
CellData* firstCellData = cellMap->GetCellAt(aLineNumber, 0);
|
|
|
|
*aFirstFrameOnLine = (nsIFrame*)firstCellData->GetCellFrame();
|
2000-05-14 04:10:25 +04:00
|
|
|
if(!(*aFirstFrameOnLine))
|
|
|
|
{
|
|
|
|
while((aLineNumber > 0)&&(!(*aFirstFrameOnLine)))
|
|
|
|
{
|
|
|
|
aLineNumber--;
|
|
|
|
firstCellData = cellMap->GetCellAt(aLineNumber, 0);
|
|
|
|
*aFirstFrameOnLine = (nsIFrame*)firstCellData->GetCellFrame();
|
|
|
|
}
|
|
|
|
}
|
2000-05-11 05:04:39 +04:00
|
|
|
*aNumFramesOnLine = cellMap->GetNumCellsOriginatingInRow(aLineNumber);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::FindLineContaining(nsIFrame* aFrame, PRInt32* aLineNumberResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFrame);
|
|
|
|
NS_ENSURE_ARG_POINTER(aLineNumberResult);
|
|
|
|
|
|
|
|
nsTableRowFrame* rowFrame = (nsTableRowFrame*)aFrame;
|
|
|
|
*aLineNumberResult = rowFrame->GetRowIndex();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::FindLineAt(nscoord aY, PRInt32* aLineNumberResult)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableRowGroupFrame::FindFrameAt(PRInt32 aLineNumber, nscoord aX, nsIFrame** aFrameFound,
|
|
|
|
PRBool* aXIsBeforeFirstFrame, PRBool* aXIsAfterLastFrame)
|
|
|
|
{
|
|
|
|
PRInt32 cellCount = 0;
|
|
|
|
CellData* cellData;
|
|
|
|
nsIFrame* tempFrame;
|
|
|
|
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++)
|
|
|
|
{
|
|
|
|
cellData = cellMap->GetCellAt(aLineNumber, i);
|
|
|
|
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;
|
|
|
|
nsIFrame* parentFrame;
|
|
|
|
|
|
|
|
rv = tempFrame->GetParent(&parentFrame);
|
|
|
|
|
|
|
|
if(NS_FAILED(rv) || !parentFrame)
|
|
|
|
return rv?rv:NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
parentFrame->GetRect(parentRectRef);
|
|
|
|
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
|
|
|
|
nsTableRowGroupFrame::GetNextSibling(nsIFrame*& aFrame, PRInt32 aLineNumber)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
nsIFrame* tempFrame;
|
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);
|
|
|
|
|
|
|
|
CellData* cellData = cellMap->GetCellAt(aLineNumber, colIndex + 1);
|
|
|
|
|
|
|
|
if(!cellData)// if this isnt a valid cell, drop down and check the next line
|
|
|
|
{
|
|
|
|
cellData = cellMap->GetCellAt(aLineNumber + 1, 0);
|
|
|
|
if(!cellData)
|
|
|
|
{
|
|
|
|
//*aFrame = nsnull;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
2000-05-14 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--;
|
|
|
|
cellData = cellMap->GetCellAt(aLineNumber, tempCol);
|
|
|
|
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
|
|
|
if(!aFrame && (tempCol==0))
|
|
|
|
{
|
|
|
|
while((tempRow > 0) && (!aFrame))
|
|
|
|
{
|
|
|
|
tempRow--;
|
|
|
|
cellData = cellMap->GetCellAt(tempRow, 0);
|
|
|
|
aFrame = (nsIFrame*)cellData->GetCellFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-05-11 05:04:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-11 18:56:29 +04:00
|
|
|
//end nsLineIterator methods
|
|
|
|
|