1998-04-13 20:24:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#include "nsTableOuterFrame.h"
|
|
|
|
#include "nsTableFrame.h"
|
1998-06-09 04:51:44 +00:00
|
|
|
#include "nsIReflowCommand.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsVoidArray.h"
|
1998-04-22 06:37:57 +00:00
|
|
|
#include "nsIPtr.h"
|
1998-07-02 17:40:56 +00:00
|
|
|
#include "prinrval.h"
|
1998-10-01 04:46:11 +00:00
|
|
|
#include "nsHTMLIIDs.h"
|
1999-02-24 05:54:31 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
static PRBool gsDebug = PR_FALSE;
|
1998-07-02 17:40:56 +00:00
|
|
|
static PRBool gsTiming = PR_FALSE;
|
1998-10-09 19:59:45 +00:00
|
|
|
static PRBool gsDebugIR = PR_FALSE;
|
1998-04-13 20:24:54 +00:00
|
|
|
//#define NOISY
|
|
|
|
//#define NOISY_FLOW
|
1998-05-21 23:43:18 +00:00
|
|
|
#define NOISY_MARGINS
|
1998-04-13 20:24:54 +00:00
|
|
|
#else
|
|
|
|
static const PRBool gsDebug = PR_FALSE;
|
1998-07-02 17:40:56 +00:00
|
|
|
static const PRBool gsTiming = PR_FALSE;
|
1998-10-08 15:34:48 +00:00
|
|
|
static const PRBool gsDebugIR = PR_FALSE;
|
1998-04-13 20:24:54 +00:00
|
|
|
#endif
|
|
|
|
|
1999-04-04 00:06:48 +00:00
|
|
|
// these macros are defined to improve the readability of the main code
|
|
|
|
// XXX they need to be put in an include file and shared
|
|
|
|
#define TDBG_S(typ,str) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SP(typ,str,ptr) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(ptr)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SPD(typ,str,ptr,dec) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(ptr),(dec)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SPDD(typ,str,ptr,dec1,dec2) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(ptr),(dec1),(dec2)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SPDDDD(typ,str,ptr,dec1,dec2,dec3,dec4) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(ptr),(dec1),(dec2),(dec3),(dec4)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SFDD(typ,str,flt,dec1,dec2) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(flt),(dec1),(dec2)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SDF(typ,str,dec,flt) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(dec),(flt)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SDFDDD(typ,str,dec1,flt,dec2,dec3,dec4) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(dec1),(flt),(dec2),(dec3),(dec4)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SD(typ,str,dec) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(dec)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SDD(typ,str,dec1,dec2) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(dec1),(dec2)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SDDD(typ,str,dec1,dec2,dec3) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(dec1),(dec2),(dec3)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SDFD(typ,str,dec1,flt,dec2) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(dec1),(flt),(dec2)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SDDDD(typ,str,dec1,dec2,dec3,dec4) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(dec1),(dec2),(dec3),(dec4)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SDDDF(typ,str,dec1,dec2,dec3,flt) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(dec1),(dec2),(dec3),(flt)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SDDDDD(typ,str,dec1,dec2,dec3,dec4,dec5) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(dec1),(dec2),(dec3),(dec4),(dec5)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TDBG_SDDDDDD(typ,str,dec1,dec2,dec3,dec4,dec5,dec6) \
|
|
|
|
if (typ) { \
|
|
|
|
printf((str),(dec1),(dec2),(dec3),(dec4),(dec5),(dec6)); \
|
|
|
|
}
|
|
|
|
|
1998-04-22 06:37:57 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
struct OuterTableReflowState {
|
|
|
|
|
1998-04-16 22:21:32 +00:00
|
|
|
// The presentation context
|
|
|
|
nsIPresContext *pc;
|
|
|
|
|
1998-05-29 20:36:05 +00:00
|
|
|
// Our reflow state
|
1998-10-02 04:10:00 +00:00
|
|
|
const nsHTMLReflowState& reflowState;
|
1998-05-29 20:36:05 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// The total available size (computed from the parent)
|
|
|
|
nsSize availSize;
|
|
|
|
// The available size for the inner table frame
|
|
|
|
nsSize innerTableMaxSize;
|
|
|
|
|
|
|
|
// Margin tracking information
|
|
|
|
nscoord prevMaxPosBottomMargin;
|
|
|
|
nscoord prevMaxNegBottomMargin;
|
|
|
|
|
|
|
|
// Flags for whether the max size is unconstrained
|
|
|
|
PRBool unconstrainedWidth;
|
|
|
|
PRBool unconstrainedHeight;
|
|
|
|
|
|
|
|
// Running y-offset
|
|
|
|
nscoord y;
|
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
OuterTableReflowState(nsIPresContext& aPresContext,
|
1998-10-02 04:10:00 +00:00
|
|
|
const nsHTMLReflowState& aReflowState)
|
1998-05-29 20:36:05 +00:00
|
|
|
: reflowState(aReflowState)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-10-08 15:34:48 +00:00
|
|
|
pc = &aPresContext;
|
1999-01-05 23:31:18 +00:00
|
|
|
availSize.width = reflowState.availableWidth;
|
|
|
|
availSize.height = reflowState.availableHeight;
|
1998-04-13 20:24:54 +00:00
|
|
|
prevMaxPosBottomMargin = 0;
|
|
|
|
prevMaxNegBottomMargin = 0;
|
|
|
|
y=0; // border/padding/margin???
|
1999-01-05 23:31:18 +00:00
|
|
|
unconstrainedWidth = PRBool(aReflowState.availableWidth == NS_UNCONSTRAINEDSIZE);
|
|
|
|
unconstrainedHeight = PRBool(aReflowState.availableHeight == NS_UNCONSTRAINEDSIZE);
|
1998-06-03 00:43:53 +00:00
|
|
|
innerTableMaxSize.width=0;
|
|
|
|
innerTableMaxSize.height=0;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~OuterTableReflowState() {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------- nsTableOuterFrame ---------- */
|
|
|
|
|
1999-08-01 18:26:45 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame)
|
|
|
|
|
|
|
|
nsresult nsTableOuterFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(nsITableLayout::GetIID()))
|
|
|
|
{ // note there is no addref here, frames are not addref'd
|
|
|
|
*aInstancePtr = (void*)(nsITableLayout*)this;
|
|
|
|
return NS_OK;
|
|
|
|
} else {
|
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-11-10 06:05:32 +00:00
|
|
|
NS_IMETHODIMP nsTableOuterFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-09-16 17:19:20 +00:00
|
|
|
{
|
1999-01-15 22:52:05 +00:00
|
|
|
mFrames.SetFrames(aChildList);
|
1998-09-16 17:19:20 +00:00
|
|
|
|
|
|
|
// Set our internal member data
|
1999-01-15 22:52:05 +00:00
|
|
|
mInnerTableFrame = aChildList;
|
1998-10-21 22:29:00 +00:00
|
|
|
//XXX this should go through the child list looking for a displaytype==caption
|
1999-01-20 07:27:06 +00:00
|
|
|
if (1 < mFrames.GetLength()) {
|
|
|
|
nsIFrame *child;
|
1999-02-10 06:13:38 +00:00
|
|
|
nsresult result = aChildList->GetNextSibling(&child);
|
1999-04-04 00:06:48 +00:00
|
|
|
while ((NS_SUCCEEDED(result)) && (nsnull!=child)) {
|
1999-01-20 07:27:06 +00:00
|
|
|
const nsStyleDisplay* childDisplay;
|
|
|
|
child->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)childDisplay);
|
1999-04-04 00:06:48 +00:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CAPTION==childDisplay->mDisplay) {
|
1999-01-20 07:27:06 +00:00
|
|
|
mCaptionFrame = child;
|
|
|
|
break;
|
|
|
|
}
|
1999-02-10 06:13:38 +00:00
|
|
|
result = child->GetNextSibling(&child);
|
1999-01-20 07:27:06 +00:00
|
|
|
}
|
1998-09-16 17:19:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-04 00:06:48 +00:00
|
|
|
NS_METHOD nsTableOuterFrame::Paint(nsIPresContext& aPresContext,
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1999-04-04 00:06:48 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
// for debug...
|
1999-03-26 00:39:35 +00:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
|
1998-04-13 20:24:54 +00:00
|
|
|
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
|
|
|
|
1998-12-18 15:54:23 +00:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-05-20 00:52:00 +00:00
|
|
|
NS_IMETHODIMP nsTableOuterFrame::SetSelected(nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread)
|
|
|
|
{
|
|
|
|
nsresult result = nsFrame::SetSelected(aRange,aSelected, aSpread);
|
|
|
|
if (NS_SUCCEEDED(result) && mInnerTableFrame)
|
|
|
|
return mInnerTableFrame->SetSelected(aRange,aSelected, aSpread);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-10-14 16:32:45 +00:00
|
|
|
PRBool nsTableOuterFrame::NeedsReflow(const nsHTMLReflowState& aReflowState, const nsSize& aMaxSize)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
PRBool result=PR_TRUE;
|
1999-04-04 00:06:48 +00:00
|
|
|
if (nsnull != mInnerTableFrame) {
|
1998-10-14 16:32:45 +00:00
|
|
|
result = ((nsTableFrame *)mInnerTableFrame)->NeedsReflow(aReflowState, aMaxSize);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-06-19 00:34:12 +00:00
|
|
|
// Recover the reflow state to what it should be if aKidFrame is about
|
|
|
|
// to be reflowed
|
1998-10-08 15:34:48 +00:00
|
|
|
nsresult nsTableOuterFrame::RecoverState(OuterTableReflowState& aReflowState,
|
1998-06-19 00:34:12 +00:00
|
|
|
nsIFrame* aKidFrame)
|
|
|
|
{
|
1998-10-08 15:34:48 +00:00
|
|
|
#if 0
|
1998-06-22 05:34:17 +00:00
|
|
|
// Get aKidFrame's previous sibling
|
1998-06-19 00:34:12 +00:00
|
|
|
nsIFrame* prevKidFrame = nsnull;
|
1999-01-15 22:52:05 +00:00
|
|
|
for (nsIFrame* frame = mFrames.FirstChild(); frame != aKidFrame;) {
|
1998-06-19 00:34:12 +00:00
|
|
|
prevKidFrame = frame;
|
|
|
|
frame->GetNextSibling(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != prevKidFrame) {
|
|
|
|
nsRect rect;
|
|
|
|
|
|
|
|
// Set our running y-offset
|
|
|
|
prevKidFrame->GetRect(rect);
|
1998-10-08 15:34:48 +00:00
|
|
|
aReflowState.y = rect.YMost();
|
1998-06-19 00:34:12 +00:00
|
|
|
|
|
|
|
// Adjust the available space
|
1998-10-08 15:34:48 +00:00
|
|
|
if (PR_FALSE == aReflowState.unconstrainedHeight) {
|
|
|
|
aReflowState.availSize.height -= aReflowState.y;
|
1998-06-19 00:34:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the previous frame's bottom margin
|
|
|
|
const nsStyleSpacing* kidSpacing;
|
1998-12-02 16:45:20 +00:00
|
|
|
prevKidFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)kidSpacing);
|
1998-06-19 00:34:12 +00:00
|
|
|
nsMargin margin;
|
|
|
|
kidSpacing->CalcMarginFor(prevKidFrame, margin);
|
|
|
|
if (margin.bottom < 0) {
|
1998-10-08 15:34:48 +00:00
|
|
|
aReflowState.prevMaxNegBottomMargin = -margin.bottom;
|
1998-06-19 00:34:12 +00:00
|
|
|
} else {
|
1998-10-08 15:34:48 +00:00
|
|
|
aReflowState.prevMaxPosBottomMargin = margin.bottom;
|
1998-06-19 00:34:12 +00:00
|
|
|
}
|
|
|
|
}
|
1998-10-08 15:34:48 +00:00
|
|
|
#endif
|
|
|
|
|
1999-04-04 00:06:48 +00:00
|
|
|
aReflowState.y = 0;
|
1998-06-19 00:34:12 +00:00
|
|
|
|
|
|
|
// Set the inner table max size
|
|
|
|
nsSize innerTableSize(0,0);
|
|
|
|
|
|
|
|
mInnerTableFrame->GetSize(innerTableSize);
|
1998-10-08 15:34:48 +00:00
|
|
|
aReflowState.innerTableMaxSize.width = innerTableSize.width;
|
1999-01-05 23:31:18 +00:00
|
|
|
aReflowState.innerTableMaxSize.height = aReflowState.reflowState.availableHeight;
|
1998-06-19 00:34:12 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
nsresult nsTableOuterFrame::IncrementalReflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
OuterTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-06-19 00:34:12 +00:00
|
|
|
{
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR,"\nTOF IR: IncrementalReflow\n");
|
1998-10-01 04:46:11 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
// determine if this frame is the target or not
|
1999-04-04 00:06:48 +00:00
|
|
|
nsIFrame* target=nsnull;
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = aReflowState.reflowState.reflowCommand->GetTarget(target);
|
1999-04-04 00:06:48 +00:00
|
|
|
if ((PR_TRUE == NS_SUCCEEDED(rv)) && (nsnull != target)) {
|
|
|
|
if (this == target) {
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = IR_TargetIsMe(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-10-08 15:34:48 +00:00
|
|
|
// Get the next frame in the reflow chain
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetNext(nextFrame);
|
|
|
|
|
|
|
|
// Recover our reflow state
|
|
|
|
RecoverState(aReflowState, nextFrame);
|
|
|
|
rv = IR_TargetIsChild(aPresContext, aDesiredSize, aReflowState, aStatus, nextFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
nsresult nsTableOuterFrame::IR_TargetIsChild(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
OuterTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1999-04-04 00:06:48 +00:00
|
|
|
nsIFrame* aNextFrame)
|
1998-10-08 15:34:48 +00:00
|
|
|
{
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR,"TOF IR: IR_TargetIsChild\n");
|
1998-10-08 15:34:48 +00:00
|
|
|
nsresult rv;
|
1999-07-02 05:28:32 +00:00
|
|
|
if (!aNextFrame)
|
|
|
|
return NS_OK;
|
|
|
|
|
1999-04-04 00:06:48 +00:00
|
|
|
if (aNextFrame == mInnerTableFrame) {
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = IR_TargetIsInnerTableFrame(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
else if (aNextFrame==mCaptionFrame) {
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = IR_TargetIsCaptionFrame(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-10-21 22:29:00 +00:00
|
|
|
const nsStyleDisplay* nextDisplay;
|
|
|
|
aNextFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)nextDisplay);
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_HEADER_GROUP==nextDisplay->mDisplay ||
|
|
|
|
NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP==nextDisplay->mDisplay ||
|
|
|
|
NS_STYLE_DISPLAY_TABLE_ROW_GROUP ==nextDisplay->mDisplay ||
|
1999-04-04 00:06:48 +00:00
|
|
|
NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP==nextDisplay->mDisplay) {
|
1998-10-21 22:29:00 +00:00
|
|
|
rv = IR_TargetIsInnerTableFrame(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-10-21 22:29:00 +00:00
|
|
|
NS_ASSERTION(PR_FALSE, "illegal next frame in incremental reflow.");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
}
|
|
|
|
}
|
1998-10-08 15:34:48 +00:00
|
|
|
return rv;
|
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
nsresult nsTableOuterFrame::IR_TargetIsInnerTableFrame(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
OuterTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR,"TOF IR: IR_TargetIsInnerTableFrame\n");
|
1998-10-08 15:34:48 +00:00
|
|
|
nsresult rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
return rv;
|
|
|
|
}
|
1998-06-19 05:21:45 +00:00
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
nsresult nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
OuterTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR,"TOF IR: IR_TargetIsCaptionFrame\n");
|
|
|
|
PRBool innerTableNeedsReflow = PR_FALSE;
|
1998-10-09 19:59:45 +00:00
|
|
|
// remember the old width and height
|
|
|
|
nsRect priorCaptionRect;
|
|
|
|
mCaptionFrame->GetRect(priorCaptionRect);
|
|
|
|
// if the reflow type is a style change, also remember the prior style
|
|
|
|
nsIReflowCommand::ReflowType reflowCommandType;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetType(reflowCommandType);
|
1999-04-04 00:06:48 +00:00
|
|
|
const nsStyleText* priorCaptionTextStyle = nsnull;
|
|
|
|
if (nsIReflowCommand::StyleChanged == reflowCommandType) {
|
1998-12-02 16:45:20 +00:00
|
|
|
mCaptionFrame->GetStyleData(eStyleStruct_Text, ((const nsStyleStruct *&)priorCaptionTextStyle));
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
TDBG_SDDD(gsDebugIR,"TOF IR: prior caption width=%d height=%d, minWidth=%d\n",
|
|
|
|
priorCaptionRect.width, priorCaptionRect.height, mMinCaptionWidth);
|
1998-10-09 19:59:45 +00:00
|
|
|
|
|
|
|
// pass along the reflow command to the caption
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR,"TOF IR: passing down incremental reflow command to caption.\n");
|
1998-10-09 19:59:45 +00:00
|
|
|
nsSize captionMES(0,0);
|
|
|
|
nsHTMLReflowMetrics captionSize(&captionMES);
|
1999-04-04 00:06:48 +00:00
|
|
|
nsHTMLReflowState captionReflowState(aPresContext, aReflowState.reflowState, mCaptionFrame,
|
|
|
|
nsSize(mRect.width, aReflowState.reflowState.availableHeight),
|
|
|
|
aReflowState.reflowState.reason);
|
|
|
|
captionReflowState.reflowCommand = aReflowState.reflowState.reflowCommand;
|
1998-10-09 19:59:45 +00:00
|
|
|
rv = ReflowChild(mCaptionFrame, aPresContext, captionSize, captionReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SDDDD(gsDebugIR,"TOF IR: caption reflow returned %d with width=%d height=%d, minCaptionWidth=%d\n",
|
|
|
|
rv, captionSize.width, captionSize.height, captionMES.width);
|
|
|
|
if (NS_FAILED(rv)) {
|
1998-10-09 19:59:45 +00:00
|
|
|
return rv;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
if (mMinCaptionWidth != captionMES.width) {
|
|
|
|
// set the new caption min width, and set state to reflow the inner table if necessary
|
1998-10-09 19:59:45 +00:00
|
|
|
mMinCaptionWidth = captionMES.width;
|
1999-04-04 00:06:48 +00:00
|
|
|
if (mMinCaptionWidth > mRect.width) {
|
1998-10-09 19:59:45 +00:00
|
|
|
innerTableNeedsReflow=PR_TRUE;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-10-09 19:59:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// check if the caption alignment changed axis
|
1999-04-04 00:06:48 +00:00
|
|
|
if (nsIReflowCommand::StyleChanged == reflowCommandType) {
|
1998-10-09 19:59:45 +00:00
|
|
|
const nsStyleText* captionTextStyle;
|
1998-12-02 16:45:20 +00:00
|
|
|
mCaptionFrame->GetStyleData(eStyleStruct_Text, ((const nsStyleStruct *&)captionTextStyle));
|
1999-04-04 00:06:48 +00:00
|
|
|
if (PR_TRUE == IR_CaptionChangedAxis(priorCaptionTextStyle, captionTextStyle)) {
|
1998-10-09 19:59:45 +00:00
|
|
|
innerTableNeedsReflow=PR_TRUE;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-10-09 19:59:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// if we've determined that the inner table needs to be reflowed, do it here
|
|
|
|
nsSize innerTableSize;
|
1999-04-04 00:06:48 +00:00
|
|
|
if (PR_TRUE == innerTableNeedsReflow) {
|
|
|
|
TDBG_S(gsDebugIR,"inner table needs resize reflow.\n");
|
1998-10-09 19:59:45 +00:00
|
|
|
// Compute the width to use for the table. In the case of an auto sizing
|
|
|
|
// table this represents the maximum available width
|
1999-01-15 19:55:19 +00:00
|
|
|
nscoord tableWidth = ComputeAvailableTableWidth(aReflowState.reflowState);
|
1998-10-09 19:59:45 +00:00
|
|
|
|
|
|
|
// If the caption max element size is larger, then use it instead.
|
|
|
|
// XXX: caption align = left|right ignored here!
|
|
|
|
if (mMinCaptionWidth > tableWidth) {
|
|
|
|
tableWidth = mMinCaptionWidth;
|
|
|
|
}
|
|
|
|
nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize);
|
1999-04-04 00:06:48 +00:00
|
|
|
nsHTMLReflowState innerReflowState(aPresContext, aReflowState.reflowState, mInnerTableFrame,
|
|
|
|
nsSize(tableWidth, aReflowState.reflowState.availableHeight),
|
|
|
|
eReflowReason_Resize);
|
1998-10-09 19:59:45 +00:00
|
|
|
rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
1998-10-09 19:59:45 +00:00
|
|
|
return rv;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-10-09 19:59:45 +00:00
|
|
|
innerTableSize.SizeTo(innerSize.width, innerSize.height);
|
|
|
|
// set maxElementSize width if requested
|
1999-04-04 00:06:48 +00:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
1998-10-09 19:59:45 +00:00
|
|
|
((nsTableFrame *)mInnerTableFrame)->SetMaxElementSize(aDesiredSize.maxElementSize);
|
1999-04-04 00:06:48 +00:00
|
|
|
if (mMinCaptionWidth > aDesiredSize.maxElementSize->width) {
|
1998-10-09 19:59:45 +00:00
|
|
|
aDesiredSize.maxElementSize->width = mMinCaptionWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-04-04 00:06:48 +00:00
|
|
|
else {
|
|
|
|
TDBG_S(gsDebugIR,"skipping inner table resize reflow.\n");
|
1998-10-09 19:59:45 +00:00
|
|
|
nsRect innerTableRect;
|
|
|
|
mInnerTableFrame->GetRect(innerTableRect);
|
|
|
|
innerTableSize.SizeTo(innerTableRect.width, innerTableRect.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
// regardless of what we've done up to this point, place the caption and inner table
|
|
|
|
rv = SizeAndPlaceChildren(innerTableSize,
|
|
|
|
nsSize (captionSize.width, captionSize.height),
|
|
|
|
aReflowState);
|
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
return rv;
|
|
|
|
}
|
1998-06-19 05:21:45 +00:00
|
|
|
|
1998-10-21 22:29:00 +00:00
|
|
|
// IR_TargetIsMe is free to foward the request to the inner table frame
|
1998-10-08 15:34:48 +00:00
|
|
|
nsresult nsTableOuterFrame::IR_TargetIsMe(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
OuterTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
1999-04-04 00:06:48 +00:00
|
|
|
nsresult rv = NS_OK;
|
1998-10-08 15:34:48 +00:00
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowState.reflowCommand->GetType(type);
|
1999-04-04 00:06:48 +00:00
|
|
|
nsIFrame* objectFrame;
|
1998-10-09 19:59:45 +00:00
|
|
|
aReflowState.reflowState.reflowCommand->GetChildFrame(objectFrame);
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SD(gsDebugIR,"TOF IR: IncrementalReflow_TargetIsMe with type=%d\n", type);
|
|
|
|
switch (type) {
|
1999-08-01 22:01:37 +00:00
|
|
|
case nsIReflowCommand::ReflowDirty:
|
|
|
|
{
|
|
|
|
// Inner table is dirty so reflow it. Change the reflow state and set the
|
|
|
|
// reason to resize reflow.
|
|
|
|
// XXX It could also be the caption that is dirty...
|
|
|
|
((nsHTMLReflowState&)aReflowState.reflowState).reason = eReflowReason_Resize;
|
|
|
|
((nsHTMLReflowState&)aReflowState.reflowState).reflowCommand = nsnull;
|
|
|
|
|
|
|
|
// Get the inner table frame's current bounds. We'll use that when
|
|
|
|
// repainting it
|
|
|
|
// XXX It should really do the repainting, but because it think it's
|
|
|
|
// getting a resize reflow it won't know to...
|
|
|
|
nsRect dirtyRect;
|
|
|
|
mInnerTableFrame->GetRect(dirtyRect);
|
|
|
|
rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
|
|
|
|
// Repaint the inner table frame's entire visible area
|
|
|
|
dirtyRect.x = dirtyRect.y = 0;
|
|
|
|
Invalidate(dirtyRect);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
case nsIReflowCommand::FrameAppended :
|
|
|
|
case nsIReflowCommand::FrameInserted :
|
|
|
|
{
|
1999-04-04 00:06:48 +00:00
|
|
|
const nsStyleDisplay* childDisplay;
|
1998-12-02 16:45:20 +00:00
|
|
|
objectFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
|
1999-04-04 00:06:48 +00:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CAPTION == childDisplay->mDisplay) {
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = IR_CaptionInserted(aPresContext, aDesiredSize, aReflowState, aStatus,
|
|
|
|
objectFrame, PR_FALSE);
|
|
|
|
}
|
1999-04-04 00:06:48 +00:00
|
|
|
else {
|
|
|
|
TDBG_S(gsDebugIR,"TOF IR: calling inner table reflow.\n");
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
}
|
|
|
|
break;
|
1998-06-19 05:21:45 +00:00
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
/*
|
|
|
|
case nsIReflowCommand::FrameReplaced :
|
|
|
|
// if the frame to be replaced is mCaptionFrame
|
|
|
|
if (mCaptionFrame==objectFrame)
|
|
|
|
{
|
|
|
|
// verify that the new frame is a caption frame
|
|
|
|
const nsStyleDisplay *newFrameDisplay;
|
1998-12-02 16:45:20 +00:00
|
|
|
newFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)newFrameDisplay));
|
1998-10-08 15:34:48 +00:00
|
|
|
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_CAPTION == childDisplay->mDisplay, "bad new frame");
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_CAPTION == childDisplay->mDisplay)
|
|
|
|
{
|
|
|
|
rv = IR_CaptionInserted(aPresContext, aDesiredSize, aReflowState, aStatus,
|
|
|
|
objectFrame, PR_TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
1998-10-01 04:46:11 +00:00
|
|
|
}
|
1998-10-08 15:34:48 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (PR_TRUE==gsDebugIR) printf("TOF IR: calling inner table reflow.\n");
|
|
|
|
rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
}
|
|
|
|
*/
|
1998-06-23 05:43:27 +00:00
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
case nsIReflowCommand::FrameRemoved :
|
1999-04-04 00:06:48 +00:00
|
|
|
if (mCaptionFrame==objectFrame) {
|
1998-10-11 09:18:27 +00:00
|
|
|
rv = IR_CaptionRemoved(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-01 04:46:11 +00:00
|
|
|
}
|
1999-04-04 00:06:48 +00:00
|
|
|
else {
|
|
|
|
TDBG_S(gsDebugIR,"TOF IR: calling inner table reflow.\n");
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
}
|
|
|
|
break;
|
1998-09-30 18:11:48 +00:00
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
case nsIReflowCommand::StyleChanged :
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR,"TOF IR: calling inner table reflow.\n");
|
1998-10-30 07:57:44 +00:00
|
|
|
rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-08 15:34:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::ContentChanged :
|
|
|
|
NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
break;
|
1998-10-01 04:46:11 +00:00
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
case nsIReflowCommand::PullupReflow:
|
|
|
|
case nsIReflowCommand::PushReflow:
|
|
|
|
case nsIReflowCommand::CheckPullupReflow :
|
|
|
|
case nsIReflowCommand::UserDefined :
|
1999-03-05 04:19:09 +00:00
|
|
|
default:
|
1998-10-11 09:18:27 +00:00
|
|
|
NS_NOTYETIMPLEMENTED("unimplemented reflow command type");
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR,"TOF IR: reflow command not implemented.\n");
|
1998-10-08 15:34:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
OuterTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR,"TOF IR: IR_InnerTableReflow\n");
|
1998-10-08 15:34:48 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
const nsStyleText* captionTextStyle=nsnull;
|
|
|
|
nsMargin captionMargin;
|
|
|
|
// remember the old width and height
|
|
|
|
nsRect priorInnerTableRect;
|
|
|
|
mInnerTableFrame->GetRect(priorInnerTableRect);
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SDD(gsDebugIR,"TOF IR: prior width=%d height=%d\n", priorInnerTableRect.width, priorInnerTableRect.height);
|
1998-10-08 15:34:48 +00:00
|
|
|
// pass along the reflow command to the inner table
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR,"TOF IR: passing down incremental reflow command to inner table.\n");
|
1998-10-08 15:34:48 +00:00
|
|
|
nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize);
|
1999-01-05 23:31:18 +00:00
|
|
|
nscoord tableMaxWidth = PR_MAX(aReflowState.reflowState.availableWidth, mMinCaptionWidth);
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SDD(gsDebugIR,"TOF IR: mincaptionWidth=%d, tableMaxWidth=%d.\n", mMinCaptionWidth, tableMaxWidth);
|
|
|
|
nsHTMLReflowState innerReflowState(aPresContext, aReflowState.reflowState, mInnerTableFrame,
|
1999-01-05 23:31:18 +00:00
|
|
|
nsSize(tableMaxWidth, aReflowState.reflowState.availableHeight));
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SDDD(gsDebugIR,"TOF IR: inner table reflow returned %d with width=%d height=%d\n", rv, innerSize.width, innerSize.height);
|
1998-10-08 15:34:48 +00:00
|
|
|
// if there is a caption and the width or height of the inner table changed from a successful reflow,
|
|
|
|
// then reflow or move the caption as needed
|
1999-04-04 00:06:48 +00:00
|
|
|
if ((nsnull != mCaptionFrame) && (PR_TRUE==NS_SUCCEEDED(rv))) {
|
1998-10-08 15:34:48 +00:00
|
|
|
// remember the old caption height
|
|
|
|
nsRect oldCaptionRect;
|
|
|
|
mCaptionFrame->GetRect(oldCaptionRect);
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SD(gsDebugIR,"TOF IR: prior caption height = %d\n", oldCaptionRect.height);
|
1998-10-08 15:34:48 +00:00
|
|
|
nsHTMLReflowMetrics captionSize(nsnull); // don't ask for MES, it hasn't changed
|
1999-04-04 00:06:48 +00:00
|
|
|
PRBool captionDimChanged = PR_FALSE;
|
|
|
|
PRBool captionWasReflowed = PR_FALSE;
|
|
|
|
if (priorInnerTableRect.width != innerSize.width) {
|
|
|
|
// the table width changed, so reflow the caption
|
|
|
|
nsHTMLReflowState captionReflowState(aPresContext, aReflowState.reflowState, mCaptionFrame,
|
|
|
|
nsSize(innerSize.width, aReflowState.reflowState.availableHeight),
|
|
|
|
eReflowReason_Resize);
|
|
|
|
nsIHTMLReflow* htmlReflow;
|
|
|
|
if (NS_OK == mCaptionFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
|
|
|
// reflow the caption
|
|
|
|
TDBG_S(gsDebugIR,"TOF IR: table width changed, resize-reflowing caption.\n");
|
1998-10-08 15:34:48 +00:00
|
|
|
htmlReflow->WillReflow(aPresContext);
|
|
|
|
rv = htmlReflow->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
captionWasReflowed = PR_TRUE;
|
|
|
|
TDBG_SDDD(gsDebugIR,"TOF IR: caption reflow returned %d with width=%d height=%d\n", rv, captionSize.width, captionSize.height);
|
|
|
|
if ((oldCaptionRect.height!=captionSize.height) ||
|
|
|
|
(oldCaptionRect.width!=captionSize.width)) {
|
1998-10-08 15:34:48 +00:00
|
|
|
captionDimChanged=PR_TRUE;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-10-08 15:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
1999-04-04 00:06:48 +00:00
|
|
|
else {
|
|
|
|
TDBG_S(gsDebugIR,"TOF IR: skipping caption reflow\n");
|
1998-10-09 19:59:45 +00:00
|
|
|
}
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SD(gsDebugIR,"TOF IR: captionDimChanged = %d\n", captionDimChanged);
|
1998-10-09 19:59:45 +00:00
|
|
|
// XXX: should just call SizeAndPlaceChildren regardless
|
1998-10-08 15:34:48 +00:00
|
|
|
// find where to place the caption
|
|
|
|
const nsStyleSpacing* spacing;
|
1998-12-02 16:45:20 +00:00
|
|
|
mCaptionFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
1998-10-08 15:34:48 +00:00
|
|
|
spacing->CalcMarginFor(mCaptionFrame, captionMargin);
|
1998-12-02 16:45:20 +00:00
|
|
|
mCaptionFrame->GetStyleData(eStyleStruct_Text, ((const nsStyleStruct *&)captionTextStyle));
|
1999-04-04 00:06:48 +00:00
|
|
|
if ((priorInnerTableRect.height!=innerSize.height) ||
|
|
|
|
(PR_TRUE==captionDimChanged)) {
|
1998-10-08 15:34:48 +00:00
|
|
|
// Compute the caption's y-origin
|
|
|
|
nscoord captionY = captionMargin.top;
|
|
|
|
if ((captionTextStyle->mVerticalAlign.GetUnit()==eStyleUnit_Enumerated) &&
|
1999-04-04 00:06:48 +00:00
|
|
|
(captionTextStyle->mVerticalAlign.GetIntValue()==NS_STYLE_VERTICAL_ALIGN_BOTTOM)) {
|
1998-10-08 15:34:48 +00:00
|
|
|
captionY += innerSize.height;
|
|
|
|
}
|
|
|
|
// Place the caption
|
|
|
|
nsRect captionRect(captionMargin.left, captionY, 0, 0);
|
1999-04-04 00:06:48 +00:00
|
|
|
if (PR_TRUE==captionWasReflowed) {
|
1998-10-08 15:34:48 +00:00
|
|
|
captionRect.SizeTo(captionSize.width, captionSize.height);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-10-08 15:34:48 +00:00
|
|
|
captionRect.SizeTo(oldCaptionRect.width, oldCaptionRect.height);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-10-08 15:34:48 +00:00
|
|
|
mCaptionFrame->SetRect(captionRect);
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SDDDD(gsDebugIR," TOF IR: captionRect=%d %d %d %d\n", captionRect.x, captionRect.y, captionRect.width, captionRect.height);
|
1998-10-08 15:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if anything above failed, we just want to return an error at this point
|
1999-04-04 00:06:48 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
1998-10-08 15:34:48 +00:00
|
|
|
return rv;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-10-08 15:34:48 +00:00
|
|
|
// Place the inner table
|
|
|
|
nsRect updatedCaptionRect(0,0,0,0);
|
1999-04-04 00:06:48 +00:00
|
|
|
if (nsnull != mCaptionFrame) {
|
1998-10-08 15:34:48 +00:00
|
|
|
mCaptionFrame->GetRect(updatedCaptionRect);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-10-08 15:34:48 +00:00
|
|
|
nscoord innerY; // innerY is the y-offset of the inner table
|
1999-04-04 00:06:48 +00:00
|
|
|
if (nsnull != mCaptionFrame) {
|
|
|
|
// factor in caption and it's margin
|
1998-10-08 15:34:48 +00:00
|
|
|
// we're guaranteed that captionMargin and captionTextStyle are set at this point
|
1999-04-04 00:06:48 +00:00
|
|
|
if ((captionTextStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) &&
|
|
|
|
(captionTextStyle->mVerticalAlign.GetIntValue() == NS_STYLE_VERTICAL_ALIGN_BOTTOM)) {
|
|
|
|
// bottom caption
|
1998-10-08 15:34:48 +00:00
|
|
|
innerY = 0; // the inner table goes at the top of the outer table
|
|
|
|
// the total v-space consumed is the inner table height + the caption height + the margin between them
|
|
|
|
aReflowState.y = innerSize.height + updatedCaptionRect.YMost() + captionMargin.top;
|
|
|
|
}
|
1999-04-04 00:06:48 +00:00
|
|
|
else { // top caption
|
1998-10-08 15:34:48 +00:00
|
|
|
innerY = updatedCaptionRect.YMost() + captionMargin.bottom;
|
|
|
|
// the total v-space consumed is the inner table height + the caption height + the margin between them
|
|
|
|
aReflowState.y = innerY + innerSize.height;
|
|
|
|
}
|
|
|
|
}
|
1999-04-04 00:06:48 +00:00
|
|
|
else { // no caption
|
1998-10-08 15:34:48 +00:00
|
|
|
innerY=0;
|
|
|
|
aReflowState.y = innerSize.height;
|
|
|
|
}
|
|
|
|
nsRect innerRect(0, innerY, innerSize.width, innerSize.height);
|
|
|
|
mInnerTableFrame->SetRect(innerRect);
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SDDDD(gsDebugIR, " TOF IR: innerRect=%d %d %d %d\n", innerRect.x, innerRect.y, innerRect.width, innerRect.height);
|
1998-10-09 19:59:45 +00:00
|
|
|
|
|
|
|
aReflowState.innerTableMaxSize.width = innerSize.width;
|
1998-10-08 15:34:48 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* the only difference between an insert and a replace is a replace
|
|
|
|
checks the old maxElementSize and reflows the table only if it
|
|
|
|
has changed
|
|
|
|
*/
|
|
|
|
nsresult nsTableOuterFrame::IR_CaptionInserted(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
OuterTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1999-04-04 00:06:48 +00:00
|
|
|
nsIFrame* aCaptionFrame,
|
1998-10-08 15:34:48 +00:00
|
|
|
PRBool aReplace)
|
|
|
|
{
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR,"TOF IR: CaptionInserted\n");
|
1998-10-08 15:34:48 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nscoord oldCaptionMES = 0;
|
1999-04-04 00:06:48 +00:00
|
|
|
NS_PRECONDITION(nsnull != aCaptionFrame, "null arg: aCaptionFrame");
|
|
|
|
if (PR_TRUE == aReplace && nsnull != mCaptionFrame) {
|
1998-10-08 15:34:48 +00:00
|
|
|
oldCaptionMES = mMinCaptionWidth;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-10-08 15:34:48 +00:00
|
|
|
// make aCaptionFrame this table's caption
|
|
|
|
mCaptionFrame = aCaptionFrame;
|
1998-10-09 19:59:45 +00:00
|
|
|
mInnerTableFrame->SetNextSibling(mCaptionFrame);
|
1998-10-08 15:34:48 +00:00
|
|
|
|
|
|
|
// reflow the caption frame, getting it's MES
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR,"TOF IR: initial-reflowing caption\n");
|
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
nsSize maxElementSize;
|
|
|
|
nsHTMLReflowMetrics captionSize(&maxElementSize);
|
1999-04-04 00:06:48 +00:00
|
|
|
nsHTMLReflowState captionReflowState(aPresContext, aReflowState.reflowState, mCaptionFrame,
|
1999-01-05 23:31:18 +00:00
|
|
|
nsSize(mRect.width, aReflowState.reflowState.availableHeight),
|
1998-10-08 15:34:48 +00:00
|
|
|
eReflowReason_Initial);
|
|
|
|
nsIHTMLReflow* htmlReflow;
|
|
|
|
|
1999-04-04 00:06:48 +00:00
|
|
|
if (NS_OK == mCaptionFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
|
|
|
// initial reflow of the caption
|
1998-10-08 15:34:48 +00:00
|
|
|
htmlReflow->WillReflow(aPresContext);
|
1998-10-09 19:59:45 +00:00
|
|
|
rv = htmlReflow->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
1998-10-09 19:59:45 +00:00
|
|
|
return rv;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
TDBG_SDDDD(gsDebugIR, "TOF IR: caption reflow returned %d with width =%d, height = %d, minWidth=%d\n",
|
|
|
|
rv, captionSize.width, captionSize.height, maxElementSize.width);
|
1998-10-08 15:34:48 +00:00
|
|
|
mMinCaptionWidth = maxElementSize.width;
|
|
|
|
// get the caption's alignment
|
|
|
|
const nsStyleText* captionTextStyle;
|
1998-12-02 16:45:20 +00:00
|
|
|
mCaptionFrame->GetStyleData(eStyleStruct_Text, ((const nsStyleStruct *&)captionTextStyle));
|
1999-04-04 00:06:48 +00:00
|
|
|
nsStyleUnit vAlignUnit = captionTextStyle->mVerticalAlign.GetUnit();
|
1998-10-09 19:59:45 +00:00
|
|
|
if (PR_TRUE || // XXX: this is a hack because we don't support left|right captions yet
|
1999-04-04 00:06:48 +00:00
|
|
|
(vAlignUnit != eStyleUnit_Enumerated) || // default is "top"
|
|
|
|
((vAlignUnit == eStyleUnit_Enumerated) &&
|
|
|
|
((vAlignUnit == NS_STYLE_VERTICAL_ALIGN_TOP) ||
|
|
|
|
(vAlignUnit == NS_STYLE_VERTICAL_ALIGN_BOTTOM)))) {
|
1998-10-08 15:34:48 +00:00
|
|
|
// XXX: caption align = left|right ignored here!
|
1998-10-09 19:59:45 +00:00
|
|
|
// if the caption's MES > table width, reflow the inner table
|
1998-10-08 15:34:48 +00:00
|
|
|
nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize);
|
1999-04-04 00:06:48 +00:00
|
|
|
if ((oldCaptionMES != mMinCaptionWidth) && (mMinCaptionWidth > mRect.width)) {
|
|
|
|
TDBG_S(gsDebugIR,"TOF IR: resize-reflowing inner table\n");
|
|
|
|
nsHTMLReflowState innerReflowState(aPresContext, aReflowState.reflowState, mInnerTableFrame,
|
1999-01-05 23:31:18 +00:00
|
|
|
nsSize(mMinCaptionWidth, aReflowState.reflowState.availableHeight),
|
1998-10-09 19:59:45 +00:00
|
|
|
eReflowReason_Resize);
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SDDD(gsDebugIR,"TOF IR: inner table reflow returned %d with width =%d, height = %d\n",
|
|
|
|
rv, innerSize.width, innerSize.height);
|
1998-10-08 15:34:48 +00:00
|
|
|
}
|
1999-04-04 00:06:48 +00:00
|
|
|
else { // set innerSize as if the inner table were reflowed
|
|
|
|
TDBG_S(gsDebugIR,"TOF IR: skipping reflow of inner table\n");
|
1998-10-08 15:34:48 +00:00
|
|
|
innerSize.height = mRect.height;
|
1999-04-04 00:06:48 +00:00
|
|
|
innerSize.width = mRect.width;
|
1998-10-08 15:34:48 +00:00
|
|
|
}
|
|
|
|
// set maxElementSize width if requested
|
1999-04-04 00:06:48 +00:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
1998-10-09 19:59:45 +00:00
|
|
|
((nsTableFrame *)mInnerTableFrame)->SetMaxElementSize(aDesiredSize.maxElementSize);
|
1999-04-04 00:06:48 +00:00
|
|
|
if (mMinCaptionWidth > aDesiredSize.maxElementSize->width) {
|
1998-10-08 15:34:48 +00:00
|
|
|
aDesiredSize.maxElementSize->width = mMinCaptionWidth;
|
|
|
|
}
|
|
|
|
}
|
1998-10-09 19:59:45 +00:00
|
|
|
|
|
|
|
rv = SizeAndPlaceChildren(nsSize (innerSize.width, innerSize.height),
|
|
|
|
nsSize (captionSize.width, captionSize.height),
|
|
|
|
aReflowState);
|
1998-10-08 15:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-11 09:18:27 +00:00
|
|
|
nsresult nsTableOuterFrame::IR_CaptionRemoved(nsIPresContext& aPresContext,
|
1998-10-08 15:34:48 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
OuterTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR,"TOF IR: CaptionRemoved\n");
|
1998-10-08 15:34:48 +00:00
|
|
|
nsresult rv = NS_OK;
|
1999-04-04 00:06:48 +00:00
|
|
|
if (nsnull != mCaptionFrame) {
|
1998-10-08 15:34:48 +00:00
|
|
|
// get the caption's alignment
|
|
|
|
const nsStyleText* captionTextStyle;
|
1998-12-02 16:45:20 +00:00
|
|
|
mCaptionFrame->GetStyleData(eStyleStruct_Text, ((const nsStyleStruct *&)captionTextStyle));
|
1998-10-09 19:59:45 +00:00
|
|
|
// if the caption's MES > table width, reflow the inner table minus the MES
|
1998-10-08 15:34:48 +00:00
|
|
|
nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize);
|
|
|
|
nscoord oldMinCaptionWidth = mMinCaptionWidth;
|
|
|
|
// set the cached min caption width to 0 here, so it can't effect inner table reflow
|
|
|
|
mMinCaptionWidth = 0;
|
1999-04-04 00:06:48 +00:00
|
|
|
mCaptionFrame = nsnull;
|
1998-10-09 19:59:45 +00:00
|
|
|
mInnerTableFrame->SetNextSibling(nsnull);
|
1999-04-04 00:06:48 +00:00
|
|
|
if (oldMinCaptionWidth > mRect.width) {
|
|
|
|
// the old caption width had an effect on the inner table width, so reflow the inner table
|
|
|
|
TDBG_S(gsDebugIR,"TOF IR: reflowing inner table\n");
|
|
|
|
nsHTMLReflowState innerReflowState(aPresContext, aReflowState.reflowState, mInnerTableFrame,
|
|
|
|
nsSize(aReflowState.reflowState.availableWidth,
|
|
|
|
aReflowState.reflowState.availableHeight));
|
1998-10-08 15:34:48 +00:00
|
|
|
// ReflowChild sets MES
|
1998-10-09 19:59:45 +00:00
|
|
|
rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
1998-10-09 19:59:45 +00:00
|
|
|
return rv;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-10-09 19:59:45 +00:00
|
|
|
// set the output state
|
|
|
|
aReflowState.innerTableMaxSize.width = innerSize.width;
|
|
|
|
aReflowState.y = innerSize.height;
|
|
|
|
}
|
1999-04-04 00:06:48 +00:00
|
|
|
else {
|
|
|
|
TDBG_S(gsDebugIR, "TOF IR: skipping reflow of inner table\n");
|
1998-10-09 19:59:45 +00:00
|
|
|
nsRect innerRect;
|
|
|
|
mInnerTableFrame->GetRect(innerRect);
|
|
|
|
aReflowState.innerTableMaxSize.width = innerRect.width;
|
|
|
|
aReflowState.y = innerRect.height;
|
1998-10-08 15:34:48 +00:00
|
|
|
}
|
|
|
|
// if the caption was a top caption, move the inner table to the correct offset
|
|
|
|
if ((captionTextStyle->mVerticalAlign.GetUnit()==eStyleUnit_Enumerated) &&
|
1999-04-04 00:06:48 +00:00
|
|
|
(captionTextStyle->mVerticalAlign.GetIntValue()==NS_STYLE_VERTICAL_ALIGN_BOTTOM)) {
|
1998-10-08 15:34:48 +00:00
|
|
|
mInnerTableFrame->MoveTo(0,0);
|
|
|
|
}
|
1998-10-01 04:46:11 +00:00
|
|
|
}
|
1999-04-04 00:06:48 +00:00
|
|
|
else {
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-10-01 04:46:11 +00:00
|
|
|
|
|
|
|
return rv;
|
1998-06-19 00:34:12 +00:00
|
|
|
}
|
|
|
|
|
1998-10-09 19:59:45 +00:00
|
|
|
PRBool nsTableOuterFrame::IR_CaptionChangedAxis(const nsStyleText* aOldStyle,
|
|
|
|
const nsStyleText* aNewStyle) const
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
//XXX: write me to support left|right captions!
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-04-04 00:06:48 +00:00
|
|
|
nsresult nsTableOuterFrame::SizeAndPlaceChildren(const nsSize& aInnerSize,
|
|
|
|
const nsSize& aCaptionSize,
|
|
|
|
OuterTableReflowState& aReflowState)
|
1998-10-09 19:59:45 +00:00
|
|
|
{
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_S(gsDebugIR, " TOF IR: SizeAndPlaceChildren\n");
|
1998-10-09 19:59:45 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// find where to place the caption
|
|
|
|
nsMargin captionMargin;
|
|
|
|
const nsStyleSpacing* spacing;
|
1998-12-02 16:45:20 +00:00
|
|
|
mCaptionFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
1998-10-09 19:59:45 +00:00
|
|
|
spacing->CalcMarginFor(mCaptionFrame, captionMargin);
|
|
|
|
// Compute the caption's y-origin
|
|
|
|
nscoord captionY = captionMargin.top;
|
|
|
|
const nsStyleText* captionTextStyle;
|
1998-12-02 16:45:20 +00:00
|
|
|
mCaptionFrame->GetStyleData(eStyleStruct_Text, ((const nsStyleStruct *&)captionTextStyle));
|
1998-10-09 19:59:45 +00:00
|
|
|
if ((captionTextStyle->mVerticalAlign.GetUnit()==eStyleUnit_Enumerated) &&
|
1999-04-04 00:06:48 +00:00
|
|
|
(captionTextStyle->mVerticalAlign.GetIntValue()==NS_STYLE_VERTICAL_ALIGN_BOTTOM)) {
|
1998-10-09 19:59:45 +00:00
|
|
|
captionY += aInnerSize.height;
|
|
|
|
}
|
|
|
|
// Place the caption
|
|
|
|
nsRect captionRect(captionMargin.left, captionY, 0, 0);
|
|
|
|
captionRect.SizeTo(aCaptionSize.width, aCaptionSize.height);
|
|
|
|
mCaptionFrame->SetRect(captionRect);
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SDDDD(gsDebugIR, " TOF IR: captionRect=%d %d %d %d\n", captionRect.x, captionRect.y,
|
|
|
|
captionRect.width, captionRect.height);
|
1998-10-09 19:59:45 +00:00
|
|
|
|
|
|
|
// Place the inner table
|
|
|
|
nscoord innerY;
|
|
|
|
if ((captionTextStyle->mVerticalAlign.GetUnit()==eStyleUnit_Enumerated) &&
|
1999-04-04 00:06:48 +00:00
|
|
|
(captionTextStyle->mVerticalAlign.GetIntValue()==NS_STYLE_VERTICAL_ALIGN_BOTTOM)) {
|
|
|
|
// bottom caption
|
1998-10-09 19:59:45 +00:00
|
|
|
innerY = 0;
|
|
|
|
aReflowState.y = captionRect.YMost() + captionMargin.bottom;
|
|
|
|
}
|
1999-04-04 00:06:48 +00:00
|
|
|
else { // top caption
|
1998-10-09 19:59:45 +00:00
|
|
|
innerY = captionRect.YMost() + captionMargin.bottom;
|
|
|
|
aReflowState.y = innerY + aInnerSize.height;
|
|
|
|
}
|
|
|
|
nsRect innerRect(0, innerY, aInnerSize.width, aInnerSize.height);
|
|
|
|
mInnerTableFrame->SetRect(innerRect);
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SDDDD(gsDebugIR, " TOF IR: innerRect=%d %d %d %d\n", innerRect.x, innerRect.y, innerRect.width, innerRect.height);
|
1998-10-09 19:59:45 +00:00
|
|
|
aReflowState.innerTableMaxSize.width = aInnerSize.width;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-04-04 00:06:48 +00:00
|
|
|
// computes the table width
|
1999-01-15 19:55:19 +00:00
|
|
|
nscoord nsTableOuterFrame::ComputeAvailableTableWidth(const nsHTMLReflowState& aReflowState)
|
1998-07-09 14:30:34 +00:00
|
|
|
{
|
|
|
|
nscoord maxWidth;
|
|
|
|
|
|
|
|
// Figure out the overall table width constraint. Default case, get 100% of
|
|
|
|
// available space
|
1999-01-05 23:31:18 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth) {
|
|
|
|
maxWidth = aReflowState.availableWidth;
|
1998-07-09 14:30:34 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
const nsStylePosition* position =
|
|
|
|
(const nsStylePosition*)mStyleContext->GetStyleData(eStyleStruct_Position);
|
|
|
|
|
|
|
|
switch (position->mWidth.GetUnit()) {
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
maxWidth = position->mWidth.GetCoordValue();
|
1998-11-25 18:43:56 +00:00
|
|
|
// NAV4 compatibility: 0-coord-width == auto-width
|
1999-03-06 05:03:09 +00:00
|
|
|
// XXX This doesn't belong here. If the HTML attribute "width=0" should work
|
|
|
|
// like 'auto', then have the style mapping code in the content object
|
|
|
|
// handle it...
|
1999-04-04 00:06:48 +00:00
|
|
|
if (0 == maxWidth) {
|
1999-01-05 23:31:18 +00:00
|
|
|
maxWidth = aReflowState.availableWidth;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-07-09 14:30:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Auto:
|
1999-01-05 23:31:18 +00:00
|
|
|
maxWidth = aReflowState.availableWidth;
|
1998-07-09 14:30:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Percent:
|
1999-04-04 00:06:48 +00:00
|
|
|
maxWidth = (nscoord)((float)aReflowState.availableWidth * position->mWidth.GetPercentValue());
|
1998-11-25 18:43:56 +00:00
|
|
|
// NAV4 compatibility: 0-percent-width == auto-width
|
1999-03-06 05:03:09 +00:00
|
|
|
// XXX Ditto...
|
1999-04-04 00:06:48 +00:00
|
|
|
if (0 == maxWidth) {
|
1999-01-05 23:31:18 +00:00
|
|
|
maxWidth = aReflowState.availableWidth;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-07-09 14:30:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eStyleUnit_Proportional:
|
|
|
|
case eStyleUnit_Inherit:
|
|
|
|
// XXX for now these fall through
|
|
|
|
|
|
|
|
default:
|
1999-01-05 23:31:18 +00:00
|
|
|
maxWidth = aReflowState.availableWidth;
|
1998-07-09 14:30:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subtract out border and padding
|
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
nsMargin borderPadding;
|
|
|
|
spacing->CalcBorderPaddingFor(this, borderPadding);
|
|
|
|
|
|
|
|
maxWidth -= borderPadding.left + borderPadding.right;
|
|
|
|
if (maxWidth <= 0) {
|
|
|
|
// Nonsense style specification
|
|
|
|
maxWidth = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return maxWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reflow is a multi-step process.
|
|
|
|
* 1. First we reflow the caption frame and get its maximum element size. We
|
|
|
|
* do this once during our initial reflow and whenever the caption changes
|
|
|
|
* incrementally
|
|
|
|
* 2. Next we reflow the inner table. This gives us the actual table width.
|
|
|
|
* The table must be at least as wide as the caption maximum element size
|
|
|
|
* 3. Now that we have the table width we reflow the caption and gets its
|
|
|
|
* desired height
|
|
|
|
* 4. Then we place the caption and the inner table
|
|
|
|
*
|
|
|
|
* If the table height is constrained, e.g. page mode, then it's possible the
|
|
|
|
* inner table no longer fits and has to be reflowed again this time with s
|
|
|
|
* smaller available height
|
1998-04-13 20:24:54 +00:00
|
|
|
*/
|
1999-04-04 00:06:48 +00:00
|
|
|
NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 04:10:00 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-04-04 00:06:48 +00:00
|
|
|
nsReflowStatus& aStatus)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-10-09 19:59:45 +00:00
|
|
|
nsresult rv = NS_OK;
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SPDD(gsDebug,"%p: nsTableOuterFrame::Reflow : maxSize=%d,%d\n",
|
|
|
|
this, aReflowState.availableWidth, aReflowState.availableHeight);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-07-02 17:40:56 +00:00
|
|
|
PRIntervalTime startTime;
|
|
|
|
if (gsTiming) {
|
|
|
|
startTime = PR_IntervalNow();
|
|
|
|
}
|
|
|
|
|
1998-06-22 21:59:43 +00:00
|
|
|
// Initialize out parameters
|
1999-04-04 00:06:48 +00:00
|
|
|
aDesiredSize.width = 0;
|
1998-10-08 15:34:48 +00:00
|
|
|
aDesiredSize.height = 0;
|
1998-05-25 17:31:49 +00:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-06-22 21:59:43 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-06-19 05:21:45 +00:00
|
|
|
// Initialize our local reflow state
|
1998-10-08 15:34:48 +00:00
|
|
|
OuterTableReflowState state(aPresContext, aReflowState);
|
1998-06-19 00:34:12 +00:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
1998-10-09 19:59:45 +00:00
|
|
|
rv = IncrementalReflow(aPresContext, aDesiredSize, state, aStatus);
|
1998-06-19 00:34:12 +00:00
|
|
|
} else {
|
1998-06-22 21:59:43 +00:00
|
|
|
if (eReflowReason_Initial == aReflowState.reason) {
|
|
|
|
// Set up our kids. They're already present, on an overflow list,
|
|
|
|
// or there are none so we'll create them now
|
|
|
|
MoveOverflowToChildList();
|
|
|
|
|
1998-07-09 14:30:34 +00:00
|
|
|
// Lay out the caption and get its maximum element size
|
1998-07-08 20:21:17 +00:00
|
|
|
if (nsnull != mCaptionFrame) {
|
1998-10-01 04:46:11 +00:00
|
|
|
nsSize maxElementSize;
|
|
|
|
nsHTMLReflowMetrics captionSize(&maxElementSize);
|
1999-04-04 00:06:48 +00:00
|
|
|
nsHTMLReflowState captionReflowState(aPresContext, aReflowState, mCaptionFrame,
|
1998-10-01 04:46:11 +00:00
|
|
|
nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE),
|
|
|
|
eReflowReason_Initial);
|
|
|
|
nsIHTMLReflow* htmlReflow;
|
|
|
|
|
|
|
|
if (NS_OK == mCaptionFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
|
|
|
htmlReflow->WillReflow(aPresContext);
|
1998-10-09 19:59:45 +00:00
|
|
|
rv = htmlReflow->Reflow(aPresContext, captionSize, captionReflowState, aStatus);
|
1998-10-01 04:46:11 +00:00
|
|
|
mMinCaptionWidth = maxElementSize.width;
|
|
|
|
}
|
1998-07-08 20:21:17 +00:00
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
}
|
1998-06-22 21:59:43 +00:00
|
|
|
|
1998-09-20 04:50:08 +00:00
|
|
|
// At this point, we must have an inner table frame, and we might have a caption
|
1999-01-15 22:52:05 +00:00
|
|
|
NS_ASSERTION(mFrames.NotEmpty(), "no children");
|
1998-07-08 20:21:17 +00:00
|
|
|
NS_ASSERTION(nsnull != mInnerTableFrame, "no mInnerTableFrame");
|
1998-07-02 17:40:56 +00:00
|
|
|
|
1998-07-09 14:30:34 +00:00
|
|
|
// Compute the width to use for the table. In the case of an auto sizing
|
|
|
|
// table this represents the maximum available width
|
1999-01-15 19:55:19 +00:00
|
|
|
nscoord tableWidth = ComputeAvailableTableWidth(aReflowState);
|
1998-07-09 14:30:34 +00:00
|
|
|
|
|
|
|
// If the caption max element size is larger, then use it instead.
|
1998-10-08 15:34:48 +00:00
|
|
|
// XXX: caption align = left|right ignored here!
|
1998-07-09 14:30:34 +00:00
|
|
|
if (mMinCaptionWidth > tableWidth) {
|
|
|
|
tableWidth = mMinCaptionWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
// First reflow the inner table
|
1999-04-04 00:06:48 +00:00
|
|
|
nsHTMLReflowState innerReflowState(aPresContext, aReflowState, mInnerTableFrame,
|
1999-01-05 23:31:18 +00:00
|
|
|
nsSize(tableWidth, aReflowState.availableHeight));
|
1998-10-01 04:46:11 +00:00
|
|
|
nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize);
|
1998-10-06 00:27:22 +00:00
|
|
|
|
1998-10-09 19:59:45 +00:00
|
|
|
rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus);
|
1998-10-06 00:27:22 +00:00
|
|
|
|
|
|
|
// Table's max element size is the MAX of the caption's max element size
|
|
|
|
// and the inner table's max element size...
|
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
if (mMinCaptionWidth > aDesiredSize.maxElementSize->width) {
|
|
|
|
aDesiredSize.maxElementSize->width = mMinCaptionWidth;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
}
|
1998-07-09 14:30:34 +00:00
|
|
|
state.innerTableMaxSize.width = innerSize.width;
|
|
|
|
|
|
|
|
// Now that we know the table width we can reflow the caption, and
|
|
|
|
// place the caption and the inner table
|
|
|
|
if (nsnull != mCaptionFrame) {
|
|
|
|
// Get the caption's margin
|
|
|
|
nsMargin captionMargin;
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
|
1998-12-02 16:45:20 +00:00
|
|
|
mCaptionFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
|
1998-07-09 14:30:34 +00:00
|
|
|
spacing->CalcMarginFor(mCaptionFrame, captionMargin);
|
|
|
|
|
|
|
|
// Compute the caption's y-origin
|
|
|
|
nscoord captionY = captionMargin.top;
|
1998-09-20 04:50:08 +00:00
|
|
|
const nsStyleText* captionTextStyle;
|
1998-12-02 16:45:20 +00:00
|
|
|
mCaptionFrame->GetStyleData(eStyleStruct_Text, ((const nsStyleStruct *&)captionTextStyle));
|
1998-09-20 04:50:08 +00:00
|
|
|
if ((captionTextStyle->mVerticalAlign.GetUnit()==eStyleUnit_Enumerated) &&
|
|
|
|
(captionTextStyle->mVerticalAlign.GetIntValue()==NS_STYLE_VERTICAL_ALIGN_BOTTOM)) {
|
1998-07-09 14:30:34 +00:00
|
|
|
captionY += innerSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reflow the caption. Let it be as high as it wants
|
1999-04-04 00:06:48 +00:00
|
|
|
nsHTMLReflowState captionReflowState(aPresContext, state.reflowState, mCaptionFrame,
|
1998-10-02 04:10:00 +00:00
|
|
|
nsSize(innerSize.width, NS_UNCONSTRAINEDSIZE),
|
|
|
|
eReflowReason_Resize);
|
1998-10-01 04:46:11 +00:00
|
|
|
nsHTMLReflowMetrics captionSize(nsnull);
|
|
|
|
nsIHTMLReflow* htmlReflow;
|
|
|
|
nsRect captionRect(captionMargin.left, captionY, 0, 0);
|
|
|
|
|
|
|
|
if (NS_OK == mCaptionFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) {
|
|
|
|
nsReflowStatus captionStatus;
|
|
|
|
htmlReflow->WillReflow(aPresContext);
|
|
|
|
htmlReflow->Reflow(aPresContext, captionSize, captionReflowState,
|
|
|
|
captionStatus);
|
|
|
|
NS_ASSERTION(NS_FRAME_IS_COMPLETE(captionStatus), "unexpected reflow status");
|
|
|
|
|
|
|
|
// XXX If the height is constrained then we need to check whether the inner
|
|
|
|
// table still fits...
|
|
|
|
|
|
|
|
// Place the caption
|
|
|
|
captionRect.SizeTo(captionSize.width, captionSize.height);
|
|
|
|
mCaptionFrame->SetRect(captionRect);
|
|
|
|
}
|
1998-07-09 14:30:34 +00:00
|
|
|
|
|
|
|
// Place the inner table
|
|
|
|
nscoord innerY;
|
1998-09-20 04:50:08 +00:00
|
|
|
if ((captionTextStyle->mVerticalAlign.GetUnit()!=eStyleUnit_Enumerated) ||
|
|
|
|
(captionTextStyle->mVerticalAlign.GetIntValue()!=NS_STYLE_VERTICAL_ALIGN_BOTTOM)) {
|
|
|
|
// top caption
|
1998-07-09 14:30:34 +00:00
|
|
|
innerY = captionRect.YMost() + captionMargin.bottom;
|
|
|
|
state.y = innerY + innerSize.height;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-09-20 04:50:08 +00:00
|
|
|
// bottom caption
|
1999-04-04 00:06:48 +00:00
|
|
|
innerY = 0;
|
1998-07-09 14:30:34 +00:00
|
|
|
state.y = captionRect.YMost() + captionMargin.bottom;
|
|
|
|
}
|
|
|
|
nsRect innerRect(0, innerY, innerSize.width, innerSize.height);
|
|
|
|
mInnerTableFrame->SetRect(innerRect);
|
|
|
|
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-07-09 14:30:34 +00:00
|
|
|
// Place the inner table
|
|
|
|
nsRect innerRect(0, 0, innerSize.width, innerSize.height);
|
|
|
|
mInnerTableFrame->SetRect(innerRect);
|
|
|
|
state.y = innerSize.height;
|
1998-06-19 00:34:12 +00:00
|
|
|
}
|
1998-06-19 05:21:45 +00:00
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
|
1998-07-09 14:30:34 +00:00
|
|
|
// Return our desired rect
|
1999-04-04 00:06:48 +00:00
|
|
|
aDesiredSize.width = state.innerTableMaxSize.width;
|
|
|
|
aDesiredSize.height = state.y;
|
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
1998-07-02 21:24:56 +00:00
|
|
|
aDesiredSize.descent = 0;
|
1998-06-19 05:21:45 +00:00
|
|
|
|
1999-04-04 00:06:48 +00:00
|
|
|
if ((PR_TRUE == gsDebug) || (PR_TRUE == gsDebugIR)) {
|
|
|
|
if (nsnull!=aDesiredSize.maxElementSize) {
|
1998-06-23 23:23:21 +00:00
|
|
|
printf("%p: Outer frame Reflow complete, returning %s with aDesiredSize = %d,%d and aMaxElementSize=%d,%d\n",
|
|
|
|
this, NS_FRAME_IS_COMPLETE(aStatus)? "Complete" : "Not Complete",
|
1998-06-19 05:21:45 +00:00
|
|
|
aDesiredSize.width, aDesiredSize.height,
|
|
|
|
aDesiredSize.maxElementSize->width, aDesiredSize.maxElementSize->height);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-06-23 23:23:21 +00:00
|
|
|
printf("%p: Outer frame Reflow complete, returning %s with aDesiredSize = %d,%d and NSNULL aMaxElementSize\n",
|
|
|
|
this, NS_FRAME_IS_COMPLETE(aStatus)? "Complete" : "Not Complete",
|
1998-06-19 05:21:45 +00:00
|
|
|
aDesiredSize.width, aDesiredSize.height);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-07-02 17:40:56 +00:00
|
|
|
if (gsTiming) {
|
|
|
|
PRIntervalTime endTime = PR_IntervalNow();
|
1999-03-05 04:19:09 +00:00
|
|
|
printf("Table reflow took %d ticks for frame %p\n",
|
1998-07-02 17:40:56 +00:00
|
|
|
endTime-startTime, this);/* XXX need to use LL_* macros! */
|
|
|
|
}
|
|
|
|
|
1998-10-09 19:59:45 +00:00
|
|
|
return rv;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Position and size aKidFrame and update our reflow state. The origin of
|
|
|
|
// aKidRect is relative to the upper-left origin of our frame, and includes
|
|
|
|
// any left/top margin.
|
1999-04-04 00:06:48 +00:00
|
|
|
void nsTableOuterFrame::PlaceChild(OuterTableReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
const nsRect& aKidRect,
|
|
|
|
nsSize* aMaxElementSize,
|
|
|
|
nsSize& aKidMaxElementSize)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-04-04 00:06:48 +00:00
|
|
|
TDBG_SPDDDD(gsDebug,"outer table place child: %p with aKidRect %d %d %d %d\n",
|
|
|
|
aKidFrame, aKidRect.x, aKidRect.y, aKidRect.width, aKidRect.height);
|
1998-04-13 20:24:54 +00:00
|
|
|
// Place and size the child
|
|
|
|
aKidFrame->SetRect(aKidRect);
|
|
|
|
|
|
|
|
// Adjust the running y-offset
|
1998-10-08 15:34:48 +00:00
|
|
|
aReflowState.y += aKidRect.height;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
// If our height is constrained then update the available height
|
1998-10-08 15:34:48 +00:00
|
|
|
if (PR_FALSE == aReflowState.unconstrainedHeight) {
|
|
|
|
aReflowState.availSize.height -= aKidRect.height;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-01-15 19:55:19 +00:00
|
|
|
/* Update the maximum element size, which is the max of:
|
1998-04-13 20:24:54 +00:00
|
|
|
* the maxElementSize of our first row
|
1999-01-15 19:55:19 +00:00
|
|
|
* or the maxElementSize of the caption if we include it
|
1998-04-13 20:24:54 +00:00
|
|
|
*/
|
1999-04-04 00:06:48 +00:00
|
|
|
if (aKidFrame == mCaptionFrame) {
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull != aMaxElementSize) {
|
|
|
|
aMaxElementSize->width = aKidMaxElementSize.width;
|
|
|
|
aMaxElementSize->height = aKidMaxElementSize.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-17 01:41:24 +00:00
|
|
|
NS_METHOD nsTableOuterFrame::VerifyTree() const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-04-16 22:21:32 +00:00
|
|
|
/**
|
|
|
|
* Remove and delete aChild's next-in-flow(s). Updates the sibling and flow
|
|
|
|
* pointers.
|
|
|
|
*
|
|
|
|
* Updates the child count and content offsets of all containers that are
|
|
|
|
* affected
|
|
|
|
*
|
|
|
|
* Overloaded here because nsContainerFrame makes assumptions about pseudo-frames
|
|
|
|
* that are not true for tables.
|
|
|
|
*
|
|
|
|
* @param aChild child this child's next-in-flow
|
|
|
|
* @return PR_TRUE if successful and PR_FALSE otherwise
|
|
|
|
*/
|
1999-04-04 00:06:48 +00:00
|
|
|
void nsTableOuterFrame::DeleteChildsNextInFlow(nsIPresContext& aPresContext,
|
|
|
|
nsIFrame* aChild)
|
1998-04-16 22:21:32 +00:00
|
|
|
{
|
1999-04-12 23:46:02 +00:00
|
|
|
NS_PRECONDITION(mFrames.ContainsFrame(aChild), "bad geometric parent");
|
1998-04-16 22:21:32 +00:00
|
|
|
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIFrame* nextInFlow;
|
|
|
|
|
1999-02-24 04:48:08 +00:00
|
|
|
aChild->GetNextInFlow(&nextInFlow);
|
1998-04-17 01:41:24 +00:00
|
|
|
|
|
|
|
NS_PRECONDITION(nsnull != nextInFlow, "null next-in-flow");
|
|
|
|
nsTableOuterFrame* parent;
|
|
|
|
|
1999-02-10 01:36:30 +00:00
|
|
|
nextInFlow->GetParent((nsIFrame**)&parent);
|
1998-04-16 22:21:32 +00:00
|
|
|
|
|
|
|
// If the next-in-flow has a next-in-flow then delete it too (and
|
|
|
|
// delete it first).
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIFrame* nextNextInFlow;
|
|
|
|
|
1999-02-24 04:48:08 +00:00
|
|
|
nextInFlow->GetNextInFlow(&nextNextInFlow);
|
1998-04-17 01:41:24 +00:00
|
|
|
if (nsnull != nextNextInFlow) {
|
1998-08-28 03:02:39 +00:00
|
|
|
parent->DeleteChildsNextInFlow(aPresContext, nextInFlow);
|
1998-04-16 22:21:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Disconnect the next-in-flow from the flow list
|
|
|
|
nextInFlow->BreakFromPrevFlow();
|
|
|
|
|
|
|
|
// Take the next-in-flow out of the parent's child list
|
1999-01-15 22:52:05 +00:00
|
|
|
if (parent->mFrames.FirstChild() == nextInFlow) {
|
|
|
|
nsIFrame* nextSibling;
|
1999-02-10 06:13:38 +00:00
|
|
|
nextInFlow->GetNextSibling(&nextSibling);
|
1999-01-15 22:52:05 +00:00
|
|
|
parent->mFrames.SetFrames(nextSibling);
|
1998-04-16 22:21:32 +00:00
|
|
|
|
|
|
|
} else {
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIFrame* nextSibling;
|
|
|
|
|
1998-04-16 22:21:32 +00:00
|
|
|
// Because the next-in-flow is not the first child of the parent
|
|
|
|
// we know that it shares a parent with aChild. Therefore, we need
|
|
|
|
// to capture the next-in-flow's next sibling (in case the
|
|
|
|
// next-in-flow is the last next-in-flow for aChild AND the
|
|
|
|
// next-in-flow is not the last child in parent)
|
1999-02-10 06:13:38 +00:00
|
|
|
aChild->GetNextSibling(&nextSibling);
|
1998-04-17 01:41:24 +00:00
|
|
|
NS_ASSERTION(nextSibling == nextInFlow, "unexpected sibling");
|
1998-04-16 22:21:32 +00:00
|
|
|
|
1999-02-10 06:13:38 +00:00
|
|
|
nextInFlow->GetNextSibling(&nextSibling);
|
1998-04-17 01:41:24 +00:00
|
|
|
aChild->SetNextSibling(nextSibling);
|
1998-04-16 22:21:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the next-in-flow frame and adjust it's parent's child count
|
1999-07-22 02:24:52 +00:00
|
|
|
nextInFlow->Destroy(aPresContext);
|
1998-04-16 22:21:32 +00:00
|
|
|
|
1998-04-17 01:41:24 +00:00
|
|
|
#ifdef NS_DEBUG
|
1999-02-24 04:48:08 +00:00
|
|
|
aChild->GetNextInFlow(&nextInFlow);
|
1998-04-17 01:41:24 +00:00
|
|
|
NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow");
|
|
|
|
#endif
|
1998-04-16 22:21:32 +00:00
|
|
|
}
|
|
|
|
|
1999-02-24 05:54:31 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::tableOuterFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-16 22:21:32 +00:00
|
|
|
|
1999-08-01 16:20:14 +00:00
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
|
|
|
/*------------------ nsITableLayout methods ------------------------------*/
|
1999-07-31 22:11:50 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
|
|
|
nsIDOMElement* &aCell, //out params
|
|
|
|
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
|
|
|
PRInt32& aRowSpan, PRInt32& aColSpan,
|
|
|
|
PRBool& aIsSelected)
|
|
|
|
{
|
|
|
|
if (!mInnerTableFrame) { return NS_ERROR_NOT_INITIALIZED; }
|
|
|
|
nsITableLayout *inner;
|
|
|
|
nsresult result = mInnerTableFrame->QueryInterface(nsITableLayout::GetIID(), (void **)&inner);
|
|
|
|
if (NS_SUCCEEDED(result) && inner)
|
|
|
|
{
|
|
|
|
return (inner->GetCellDataAt(aRowIndex, aColIndex, aCell,
|
|
|
|
aStartRowIndex, aStartColIndex,
|
|
|
|
aRowSpan, aColSpan, aIsSelected));
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
1999-08-01 16:20:14 +00:00
|
|
|
NS_IMETHODIMP nsTableOuterFrame::GetTableSize(PRInt32& aRowCount, PRInt32& aColCount)
|
|
|
|
{
|
|
|
|
if (!mInnerTableFrame) { return NS_ERROR_NOT_INITIALIZED; }
|
|
|
|
nsITableLayout *inner;
|
|
|
|
nsresult result = mInnerTableFrame->QueryInterface(nsITableLayout::GetIID(), (void **)&inner);
|
|
|
|
if (NS_SUCCEEDED(result) && inner)
|
|
|
|
{
|
|
|
|
return (inner->GetTableSize(aRowCount, aColCount));
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------- end of nsITableLayout implementation ------------------*/
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-09-15 17:58:24 +00:00
|
|
|
nsresult
|
1999-05-11 22:03:29 +00:00
|
|
|
NS_NewTableOuterFrame(nsIFrame** aNewFrame)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-05-11 22:03:29 +00:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
nsTableOuterFrame* it = new nsTableOuterFrame;
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-11 22:03:29 +00:00
|
|
|
*aNewFrame = it;
|
1998-04-13 20:24:54 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-02 21:59:54 +00:00
|
|
|
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetFrameName(nsString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName("TableOuter", aResult);
|
|
|
|
}
|