1998-04-14 00:24:54 +04: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 "nsTableCellFrame.h"
|
1998-11-11 22:56:02 +03:00
|
|
|
#include "nsTableFrame.h"
|
1998-06-09 08:51:44 +04:00
|
|
|
#include "nsIReflowCommand.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
1998-09-15 21:58:24 +04:00
|
|
|
#include "nsIHTMLContent.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
1998-10-06 04:44:35 +04:00
|
|
|
#include "nsHTMLParts.h"
|
1998-06-11 04:13:18 +04:00
|
|
|
#include "nsHTMLValue.h"
|
1998-05-02 00:44:55 +04:00
|
|
|
#include "nsHTMLAtoms.h"
|
1998-06-05 06:36:25 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1998-10-06 04:44:35 +04:00
|
|
|
#include "nsVoidArray.h"
|
1998-06-05 06:36:25 +04:00
|
|
|
#include "nsIPtr.h"
|
1998-05-22 03:43:18 +04:00
|
|
|
#include "nsIView.h"
|
1998-07-23 22:05:03 +04:00
|
|
|
#include "nsStyleUtil.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
NS_DEF_PTR(nsIStyleContext);
|
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
static PRBool gsDebug = PR_FALSE;
|
1998-06-24 03:23:21 +04:00
|
|
|
static PRBool gsDebugNT = PR_FALSE;
|
1998-05-03 07:51:48 +04:00
|
|
|
//#define NOISY_STYLE
|
1998-04-14 00:24:54 +04:00
|
|
|
//#define NOISY_FLOW
|
|
|
|
#else
|
|
|
|
static const PRBool gsDebug = PR_FALSE;
|
1998-06-24 03:23:21 +04:00
|
|
|
static const PRBool gsDebugNT = PR_FALSE;
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
nsTableCellFrame::nsTableCellFrame(nsIContent* aContent,
|
|
|
|
nsIFrame* aParentFrame)
|
1998-10-20 21:45:07 +04:00
|
|
|
: nsHTMLContainerFrame(aContent, aParentFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-06-11 04:13:18 +04:00
|
|
|
mColIndex=0;
|
1998-07-02 21:40:56 +04:00
|
|
|
mPriorAvailWidth=0;
|
1998-07-11 04:00:31 +04:00
|
|
|
mDesiredSize.width=0;
|
|
|
|
mDesiredSize.height=0;
|
|
|
|
mMaxElementSize.width=0;
|
|
|
|
mMaxElementSize.height=0;
|
|
|
|
mPass1DesiredSize.width=0;
|
|
|
|
mPass1DesiredSize.height=0;
|
|
|
|
mPass1MaxElementSize.width=0;
|
|
|
|
mPass1MaxElementSize.height=0;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableCellFrame::~nsTableCellFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-09-16 21:19:20 +04:00
|
|
|
NS_IMETHODIMP
|
1998-11-10 09:05:32 +03:00
|
|
|
nsTableCellFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-09-16 21:19:20 +04:00
|
|
|
{
|
|
|
|
// Create body pseudo frame
|
1998-10-06 04:44:35 +04:00
|
|
|
NS_NewBodyFrame(mContent, this, mFirstChild, NS_BODY_NO_AUTO_MARGINS);
|
1998-09-16 21:19:20 +04:00
|
|
|
|
|
|
|
// Resolve style and set the style context
|
|
|
|
nsIStyleContext* styleContext =
|
1998-11-03 23:33:43 +03:00
|
|
|
aPresContext.ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::cellContentPseudo, mStyleContext); // styleContext: ADDREF++
|
1998-09-16 21:19:20 +04:00
|
|
|
mFirstChild->SetStyleContext(&aPresContext, styleContext);
|
|
|
|
NS_RELEASE(styleContext); // styleContext: ADDREF--
|
|
|
|
|
|
|
|
// Set the geometric and content parent for each of the child frames
|
|
|
|
for (nsIFrame* frame = aChildList; nsnull != frame; frame->GetNextSibling(frame)) {
|
|
|
|
frame->SetGeometricParent(mFirstChild);
|
|
|
|
frame->SetContentParent(mFirstChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Queue up the frames for the block frame
|
1998-11-10 09:05:32 +03:00
|
|
|
return mFirstChild->SetInitialChildList(aPresContext, nsnull, aChildList);
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsTableCellFrame::Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-06-05 10:09:09 +04:00
|
|
|
const nsStyleDisplay* disp =
|
|
|
|
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-27 03:17:29 +04:00
|
|
|
if (disp->mVisible) {
|
1998-06-05 10:09:09 +04:00
|
|
|
const nsStyleColor* myColor =
|
|
|
|
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
const nsStyleSpacing* mySpacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
1998-05-27 03:17:29 +04:00
|
|
|
NS_ASSERTION(nsnull!=myColor, "bad style color");
|
|
|
|
NS_ASSERTION(nsnull!=mySpacing, "bad style spacing");
|
1998-04-30 04:27:59 +04:00
|
|
|
|
1998-07-22 09:02:07 +04:00
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
1998-05-27 03:17:29 +04:00
|
|
|
|
1998-07-31 04:32:27 +04:00
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
1998-09-26 21:17:20 +04:00
|
|
|
aDirtyRect, rect, *myColor, 0, 0);
|
1998-10-30 10:57:44 +03:00
|
|
|
|
|
|
|
//XXX: this could be calculated once and remembered
|
|
|
|
// get border padding values
|
1998-11-11 22:56:02 +03:00
|
|
|
//XXX: also check style for rule on rendering empty cells
|
1998-10-30 10:57:44 +03:00
|
|
|
nsMargin borderPadding;
|
|
|
|
const nsStyleSpacing* cellSpacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing , ((nsStyleStruct *&)cellSpacing));
|
|
|
|
cellSpacing->CalcBorderPaddingFor(this, borderPadding);
|
|
|
|
nscoord contentWidth = mPass1DesiredSize.width - (borderPadding.left+borderPadding.right);
|
|
|
|
nscoord contentHeight = mPass1DesiredSize.height - (borderPadding.top+borderPadding.bottom);
|
1998-07-31 04:32:27 +04:00
|
|
|
// empty cells do not render their border
|
1998-10-30 10:57:44 +03:00
|
|
|
if (0<contentWidth || 0<contentHeight)
|
1998-07-27 11:37:57 +04:00
|
|
|
{
|
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, *mySpacing, 0);
|
|
|
|
}
|
1998-05-27 03:17:29 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// for debug...
|
|
|
|
if (nsIFrame::GetShowFrameBorders()) {
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0,128,128));
|
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect);
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
PRIntn
|
|
|
|
nsTableCellFrame::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
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Align the cell's child frame within the cell
|
|
|
|
*
|
|
|
|
*/
|
1998-04-14 00:24:54 +04:00
|
|
|
void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext)
|
1998-04-25 22:48:48 +04:00
|
|
|
{
|
1998-06-05 10:09:09 +04:00
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
const nsStyleText* textStyle =
|
|
|
|
(const nsStyleText*)mStyleContext->GetStyleData(eStyleStruct_Text);
|
1998-05-13 02:28:01 +04:00
|
|
|
nsMargin borderPadding;
|
|
|
|
spacing->CalcBorderPaddingFor(this, borderPadding);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-13 02:28:01 +04:00
|
|
|
nscoord topInset = borderPadding.top;
|
|
|
|
nscoord bottomInset = borderPadding.bottom;
|
1998-04-29 03:57:01 +04:00
|
|
|
PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
|
|
|
|
if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
|
|
|
|
verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue();
|
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
nscoord height = mRect.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
nsRect kidRect;
|
|
|
|
mFirstChild->GetRect(kidRect);
|
|
|
|
nscoord childHeight = kidRect.height;
|
|
|
|
|
|
|
|
|
|
|
|
// Vertically align the child
|
|
|
|
nscoord kidYTop = 0;
|
1998-04-28 01:26:48 +04:00
|
|
|
switch (verticalAlignFlags)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BASELINE:
|
|
|
|
// Align the child's baseline at the max baseline
|
|
|
|
//kidYTop = aMaxAscent - kidAscent;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_TOP:
|
|
|
|
// Align the top of the child frame with the top of the box,
|
|
|
|
// minus the top padding
|
|
|
|
kidYTop = topInset;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
|
|
|
kidYTop = height - childHeight - bottomInset;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
|
|
|
|
kidYTop = height/2 - childHeight/2;
|
|
|
|
}
|
|
|
|
mFirstChild->MoveTo(kidRect.x, kidYTop);
|
|
|
|
}
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
PRInt32 nsTableCellFrame::GetRowSpan()
|
|
|
|
{
|
|
|
|
PRInt32 rowSpan=1;
|
|
|
|
nsIHTMLContent *hc=nsnull;
|
|
|
|
nsresult rv = mContent->QueryInterface(kIHTMLContentIID, (void**) &hc);
|
|
|
|
if (NS_OK==rv)
|
|
|
|
{
|
|
|
|
nsHTMLValue val;
|
|
|
|
hc->GetAttribute(nsHTMLAtoms::rowspan, val);
|
|
|
|
if (eHTMLUnit_Integer == val.GetUnit()) {
|
|
|
|
rowSpan=val.GetIntValue();
|
|
|
|
}
|
|
|
|
NS_RELEASE(hc);
|
|
|
|
}
|
|
|
|
return rowSpan;
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
PRInt32 nsTableCellFrame::GetColSpan()
|
|
|
|
{
|
|
|
|
PRInt32 colSpan=1;
|
|
|
|
nsIHTMLContent *hc=nsnull;
|
|
|
|
nsresult rv = mContent->QueryInterface(kIHTMLContentIID, (void**) &hc);
|
|
|
|
if (NS_OK==rv)
|
|
|
|
{
|
|
|
|
nsHTMLValue val;
|
|
|
|
hc->GetAttribute(nsHTMLAtoms::colspan, val);
|
|
|
|
if (eHTMLUnit_Integer == val.GetUnit()) {
|
|
|
|
colSpan=val.GetIntValue();
|
|
|
|
}
|
|
|
|
NS_RELEASE(hc);
|
|
|
|
}
|
|
|
|
return colSpan;
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
|
|
|
*/
|
1998-07-15 06:53:09 +04:00
|
|
|
NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext,
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-05-25 21:31:49 +04:00
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
//PreReflowCheck();
|
|
|
|
#endif
|
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1998-06-03 04:43:53 +04:00
|
|
|
// Initialize out parameter
|
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
|
|
|
}
|
|
|
|
|
1998-05-12 08:17:56 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-06-24 03:23:21 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
|
|
|
printf("%p nsTableCellFrame::Reflow: maxSize=%d,%d\n",
|
|
|
|
this, aReflowState.maxSize.width, aReflowState.maxSize.height);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-25 21:31:49 +04:00
|
|
|
nsSize availSize(aReflowState.maxSize);
|
1998-04-14 00:24:54 +04:00
|
|
|
nsSize maxElementSize;
|
1998-05-25 21:31:49 +04:00
|
|
|
nsSize *pMaxElementSize = aDesiredSize.maxElementSize;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE==aReflowState.maxSize.width)
|
1998-04-14 00:24:54 +04:00
|
|
|
pMaxElementSize = &maxElementSize;
|
|
|
|
nscoord x = 0;
|
|
|
|
// SEC: what about ascent and decent???
|
|
|
|
|
|
|
|
// Compute the insets (sum of border and padding)
|
1998-06-05 10:09:09 +04:00
|
|
|
const nsStyleSpacing* spacing =
|
|
|
|
(const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-05-13 02:28:01 +04:00
|
|
|
nsMargin borderPadding;
|
|
|
|
spacing->CalcBorderPaddingFor(this, borderPadding);
|
|
|
|
|
|
|
|
nscoord topInset = borderPadding.top;
|
|
|
|
nscoord rightInset = borderPadding.right;
|
|
|
|
nscoord bottomInset = borderPadding.bottom;
|
|
|
|
nscoord leftInset = borderPadding.left;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
// Get the margin information, available space should
|
|
|
|
// be reduced accordingly
|
|
|
|
nsMargin margin(0,0,0,0);
|
1998-09-24 20:37:22 +04:00
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
1998-05-22 03:43:18 +04:00
|
|
|
tableFrame->GetCellMarginData(this,margin);
|
|
|
|
|
1998-07-07 01:00:11 +04:00
|
|
|
// reduce available space by insets, if we're in a constrained situation
|
1998-06-26 04:48:44 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE!=availSize.width)
|
1998-07-07 01:00:11 +04:00
|
|
|
availSize.width -= leftInset+rightInset;
|
1998-06-26 04:48:44 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE!=availSize.height)
|
|
|
|
availSize.height -= topInset+bottomInset+margin.top+margin.bottom;
|
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason)
|
|
|
|
{
|
1998-07-17 02:15:02 +04:00
|
|
|
// XXX We *must* do this otherwise incremental reflow that's
|
|
|
|
// passing through will not work right.
|
|
|
|
nsIFrame* next;
|
|
|
|
aReflowState.reflowCommand->GetNext(next);
|
1998-10-30 10:57:44 +03:00
|
|
|
|
|
|
|
// if it is a StyleChanged reflow targeted at this cell frame,
|
|
|
|
// handle that here
|
|
|
|
// first determine if this frame is the target or not
|
|
|
|
nsIFrame *target=nsnull;
|
|
|
|
rv = aReflowState.reflowCommand->GetTarget(target);
|
|
|
|
if ((PR_TRUE==NS_SUCCEEDED(rv)) && (nsnull!=target))
|
|
|
|
{
|
|
|
|
if (this==target)
|
|
|
|
{
|
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowCommand->GetType(type);
|
|
|
|
if (nsIReflowCommand::StyleChanged==type)
|
|
|
|
{
|
|
|
|
nsresult rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if any of these conditions are not true, we just pass the reflow command down
|
1998-07-17 02:15:02 +04:00
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Try to reflow the child into the available space. It might not
|
|
|
|
// fit or might need continuing.
|
1998-04-23 21:29:07 +04:00
|
|
|
if (availSize.height < 0)
|
|
|
|
availSize.height = 1;
|
1998-09-24 20:37:22 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
if (gsDebug==PR_TRUE)
|
1998-09-10 00:00:40 +04:00
|
|
|
printf(" nsTableCellFrame::Reflow calling ReflowChild with availSize=%d,%d\n",
|
1998-04-14 00:24:54 +04:00
|
|
|
availSize.width, availSize.height);
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics kidSize(pMaxElementSize);
|
1998-06-03 04:43:53 +04:00
|
|
|
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
1998-07-02 21:40:56 +04:00
|
|
|
SetPriorAvailWidth(aReflowState.maxSize.width);
|
1998-10-12 18:48:02 +04:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState,
|
|
|
|
availSize);
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1998-10-06 04:27:22 +04:00
|
|
|
ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState, aStatus);
|
1998-09-10 00:00:40 +04:00
|
|
|
#ifdef NS_DEBUG
|
1998-10-06 04:27:22 +04:00
|
|
|
if (kidSize.width > availSize.width)
|
|
|
|
{
|
1998-11-10 02:35:05 +03:00
|
|
|
printf("WARNING: cell ");
|
|
|
|
mFirstChild->ListTag(stdout);
|
|
|
|
printf(" content returned desired width %d given avail width %d\n",
|
1998-10-06 04:27:22 +04:00
|
|
|
kidSize.width, availSize.width);
|
1998-10-01 08:46:11 +04:00
|
|
|
}
|
1998-10-06 04:27:22 +04:00
|
|
|
#endif
|
1998-06-24 03:23:21 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
if (nsnull!=pMaxElementSize)
|
1998-08-04 00:27:59 +04:00
|
|
|
printf(" %p cellFrame child returned desiredSize=%d,%d, and maxElementSize=%d,%d\n",
|
1998-06-24 03:23:21 +04:00
|
|
|
this, kidSize.width, kidSize.height,
|
1998-04-14 00:24:54 +04:00
|
|
|
pMaxElementSize->width, pMaxElementSize->height);
|
|
|
|
else
|
1998-08-04 00:27:59 +04:00
|
|
|
printf(" %p cellFrame child returned desiredSize=%d,%d, and maxElementSize=nsnull\n",
|
1998-06-24 03:23:21 +04:00
|
|
|
this, kidSize.width, kidSize.height);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
// Place the child
|
1998-09-10 00:00:40 +04:00
|
|
|
//////////////////////////////// HACK //////////////////////////////
|
|
|
|
kidSize.width = PR_MIN(kidSize.width, availSize.width);
|
|
|
|
///////////////////////////// END HACK /////////////////////////////
|
1998-05-22 03:43:18 +04:00
|
|
|
mFirstChild->SetRect(nsRect(leftInset, topInset,
|
1998-06-05 06:36:25 +04:00
|
|
|
kidSize.width, kidSize.height));
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// Return our size and our result
|
1998-06-05 06:36:25 +04:00
|
|
|
|
|
|
|
// first, compute the height
|
|
|
|
// the height can be set w/o being restricted by aMaxSize.height
|
|
|
|
nscoord cellHeight = kidSize.height;
|
1998-07-13 23:22:45 +04:00
|
|
|
// NAV4 compatibility: only add insets if cell content was not 0 height
|
|
|
|
if (0!=kidSize.height)
|
|
|
|
cellHeight += topInset + bottomInset;
|
1998-06-24 03:23:21 +04:00
|
|
|
if (PR_TRUE==gsDebugNT)
|
|
|
|
printf(" %p cellFrame height set to %d from kidSize=%d and insets %d,%d\n",
|
|
|
|
this, cellHeight, kidSize.height, topInset, bottomInset);
|
1998-06-05 06:36:25 +04:00
|
|
|
// next determine the cell's width
|
1998-07-07 01:00:11 +04:00
|
|
|
nscoord cellWidth = kidSize.width; // at this point, we've factored in the cell's style attributes
|
1998-07-02 21:40:56 +04:00
|
|
|
|
1998-06-27 03:31:33 +04:00
|
|
|
// Nav4 hack for 0 width cells. If the cell has any content, it must have a desired width of at least 1
|
1998-07-13 23:22:45 +04:00
|
|
|
// see testcase "cellHeights.html"
|
1998-06-30 00:38:22 +04:00
|
|
|
/*
|
1998-06-27 03:31:33 +04:00
|
|
|
if (0==cellWidth)
|
|
|
|
{
|
|
|
|
PRInt32 childCount;
|
|
|
|
mFirstChild->ChildCount(childCount);
|
|
|
|
if (0!=childCount)
|
|
|
|
{
|
|
|
|
nsIFrame *grandChild;
|
|
|
|
mFirstChild->FirstChild(grandChild);
|
|
|
|
grandChild->ChildCount(childCount);
|
|
|
|
if (0!=childCount)
|
|
|
|
{
|
1998-08-01 03:34:45 +04:00
|
|
|
nscoord one = ((nscoord)(NSIntPixelsToTwips(1, aPresContext.GetPixelsToTwips())));
|
1998-07-31 04:32:27 +04:00
|
|
|
cellWidth = 1;
|
|
|
|
if (gsDebug)
|
|
|
|
printf ("setting cellWidth=1 because it was 0 but there's some content\n");
|
1998-06-27 03:31:33 +04:00
|
|
|
if (nsnull!=aDesiredSize.maxElementSize && 0==pMaxElementSize->width)
|
1998-07-31 04:32:27 +04:00
|
|
|
pMaxElementSize->width=1; // insets added in below
|
1998-06-27 03:31:33 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-06-30 00:38:22 +04:00
|
|
|
*/
|
1998-06-27 03:31:33 +04:00
|
|
|
// end Nav4 hack for 0 width cells
|
1998-06-05 06:36:25 +04:00
|
|
|
|
1998-07-31 04:32:27 +04:00
|
|
|
// NAV4 compatibility: only add insets if cell content was not 0 width
|
|
|
|
if (0!=cellWidth)
|
|
|
|
cellWidth += leftInset + rightInset; // factor in insets
|
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
// set the cell's desired size and max element size
|
|
|
|
aDesiredSize.width = cellWidth;
|
|
|
|
aDesiredSize.height = cellHeight;
|
1998-04-14 00:24:54 +04:00
|
|
|
aDesiredSize.ascent = topInset;
|
|
|
|
aDesiredSize.descent = bottomInset;
|
1998-05-25 21:31:49 +04:00
|
|
|
if (nsnull!=aDesiredSize.maxElementSize)
|
1998-04-21 02:49:15 +04:00
|
|
|
{
|
1998-05-25 21:31:49 +04:00
|
|
|
*aDesiredSize.maxElementSize = *pMaxElementSize;
|
1998-07-14 00:41:38 +04:00
|
|
|
// NAV4 compatibility: only add insets if cell content was not 0 min height
|
|
|
|
if (0!=pMaxElementSize->height)
|
|
|
|
aDesiredSize.maxElementSize->height += topInset + bottomInset;
|
|
|
|
// NAV4 compatibility: only add insets if cell content was not 0 min width
|
|
|
|
if (0!=pMaxElementSize->width)
|
|
|
|
aDesiredSize.maxElementSize->width += leftInset + rightInset;
|
1998-04-21 02:49:15 +04:00
|
|
|
}
|
1998-10-03 00:36:35 +04:00
|
|
|
// remember my desired size for this reflow
|
1998-07-11 04:00:31 +04:00
|
|
|
SetDesiredSize(aDesiredSize);
|
1998-10-03 00:36:35 +04:00
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
if (PR_TRUE==gsDebug || PR_TRUE==gsDebugNT)
|
|
|
|
printf(" %p cellFrame returning aDesiredSize=%d,%d\n",
|
|
|
|
this, aDesiredSize.width, aDesiredSize.height);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-08 19:34:48 +04:00
|
|
|
aDesiredSize.ascent=aDesiredSize.height;
|
|
|
|
aDesiredSize.descent=0;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
//PostReflowCheck(result);
|
|
|
|
#endif
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_METHOD nsTableCellFrame::IR_StyleChanged(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
if (PR_TRUE==gsDebug) printf("Cell IR: IR_StyleChanged for frame %p\n", this);
|
|
|
|
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
|
|
|
|
nsTableFrame* tableFrame=nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if ((NS_SUCCEEDED(rv)) && (nsnull!=tableFrame))
|
|
|
|
{
|
|
|
|
tableFrame->InvalidateCellMap();
|
|
|
|
tableFrame->InvalidateFirstPassCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
// we are obligated to pass along the reflow command to our children before doing anything else
|
|
|
|
/*
|
|
|
|
nsIFrame *childFrame = mFirstChild;
|
|
|
|
while (nsnull!=childFrame)
|
|
|
|
{
|
|
|
|
nsHTMLReflowState childReflowState(aPresContext, childFrame, aReflowState,
|
|
|
|
aReflowState.maxSize, eReflowReason_Incremental);
|
|
|
|
rv = ReflowChild(childFrame, aPresContext, aDesiredSize, childReflowState, aStatus);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
|
|
|
// the returned desired size is irrelevant, because we'll do a resize reflow in a moment
|
|
|
|
childFrame->GetNextSibling(childFrame);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-05-07 04:08:20 +04:00
|
|
|
NS_METHOD
|
1998-07-15 07:23:23 +04:00
|
|
|
nsTableCellFrame::CreateContinuingFrame(nsIPresContext& aPresContext,
|
1998-05-07 04:08:20 +04:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aStyleContext,
|
|
|
|
nsIFrame*& aContinuingFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-06 03:56:50 +04:00
|
|
|
nsTableCellFrame* cf = new nsTableCellFrame(mContent, aParent);
|
1998-05-07 04:08:20 +04:00
|
|
|
if (nsnull == cf) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf);
|
1998-04-17 05:41:24 +04:00
|
|
|
aContinuingFrame = cf;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-02 00:44:55 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Update the border style to map to the HTML border style
|
|
|
|
*
|
|
|
|
*/
|
1998-11-11 22:56:02 +03:00
|
|
|
void nsTableCellFrame::MapHTMLBorderStyle(nsIPresContext* aPresContext,
|
|
|
|
nsStyleSpacing& aSpacingStyle,
|
|
|
|
nscoord aBorderWidth,
|
|
|
|
nsTableFrame *aTableFrame)
|
1998-05-02 00:44:55 +04:00
|
|
|
{
|
1998-05-13 02:28:01 +04:00
|
|
|
nsStyleCoord width;
|
|
|
|
width.SetCoordValue(aBorderWidth);
|
|
|
|
aSpacingStyle.mBorder.SetTop(width);
|
|
|
|
aSpacingStyle.mBorder.SetLeft(width);
|
|
|
|
aSpacingStyle.mBorder.SetBottom(width);
|
|
|
|
aSpacingStyle.mBorder.SetRight(width);
|
|
|
|
|
1998-07-21 11:47:46 +04:00
|
|
|
// XXX This should come from the default style sheet (ua.css), and
|
|
|
|
// not be hardcoded. Using solid causes the borders not to show up...
|
1998-10-13 23:17:57 +04:00
|
|
|
#if 1
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_TOP] = NS_STYLE_BORDER_STYLE_INSET;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_LEFT] = NS_STYLE_BORDER_STYLE_INSET;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_BOTTOM] = NS_STYLE_BORDER_STYLE_INSET;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_RIGHT] = NS_STYLE_BORDER_STYLE_INSET;
|
1998-07-21 11:47:46 +04:00
|
|
|
#endif
|
1998-05-02 00:44:55 +04:00
|
|
|
|
1998-09-24 20:37:22 +04:00
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
1998-05-27 00:57:24 +04:00
|
|
|
nsIStyleContext* styleContext = nsnull;
|
|
|
|
|
1998-11-03 23:33:43 +03:00
|
|
|
tableFrame->GetStyleContext(styleContext);
|
1998-05-27 00:57:24 +04:00
|
|
|
|
1998-07-23 22:05:03 +04:00
|
|
|
const nsStyleColor* colorData =
|
|
|
|
nsStyleUtil::FindNonTransparentBackground(styleContext);
|
|
|
|
NS_IF_RELEASE(styleContext);
|
1998-05-27 00:57:24 +04:00
|
|
|
|
|
|
|
// Yaahoo, we found a style context which has a background color
|
|
|
|
nscolor borderColor = 0xFFC0C0C0;
|
|
|
|
|
1998-07-23 22:05:03 +04:00
|
|
|
if (colorData != nsnull)
|
1998-05-27 00:57:24 +04:00
|
|
|
borderColor = colorData->mBackgroundColor;
|
|
|
|
|
|
|
|
// if the border color is white, then shift to grey
|
|
|
|
if (borderColor == 0xFFFFFFFF)
|
|
|
|
borderColor = 0xFFC0C0C0;
|
|
|
|
|
|
|
|
aSpacingStyle.mBorderColor[NS_SIDE_TOP] =
|
|
|
|
aSpacingStyle.mBorderColor[NS_SIDE_LEFT] =
|
|
|
|
aSpacingStyle.mBorderColor[NS_SIDE_BOTTOM] =
|
|
|
|
aSpacingStyle.mBorderColor[NS_SIDE_RIGHT] = borderColor;
|
1998-11-11 22:56:02 +03:00
|
|
|
|
|
|
|
//adjust the border style based on the table rules attribute
|
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
tableFrame->GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
|
|
|
|
|
|
|
switch (tableStyle->mRules)
|
|
|
|
{
|
|
|
|
case NS_STYLE_TABLE_RULES_NONE:
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_TOP] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_RIGHT] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_BOTTOM] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_LEFT] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
break;
|
|
|
|
case NS_STYLE_TABLE_RULES_GROUPS:
|
|
|
|
// XXX: it depends on which cell this is!
|
|
|
|
/*
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_TOP] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_RIGHT] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_BOTTOM] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_LEFT] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
case NS_STYLE_TABLE_RULES_COLS:
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_TOP] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_BOTTOM] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_TABLE_RULES_ROWS:
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_RIGHT] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
aSpacingStyle.mBorderStyle[NS_SIDE_LEFT] = NS_STYLE_BORDER_STYLE_NONE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// do nothing for "ALL" or for any illegal value
|
|
|
|
}
|
1998-05-02 00:44:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
PRBool nsTableCellFrame::ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult)
|
1998-05-02 01:55:36 +04:00
|
|
|
{
|
|
|
|
PRInt32 result = 0;
|
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
if (aValue.GetUnit() == eHTMLUnit_Pixel)
|
1998-05-02 01:55:36 +04:00
|
|
|
aResult = aValue.GetPixelValue();
|
|
|
|
else if (aValue.GetUnit() == eHTMLUnit_Empty)
|
|
|
|
aResult = aDefault;
|
|
|
|
else
|
1998-05-22 03:43:18 +04:00
|
|
|
{
|
|
|
|
NS_ERROR("Unit must be pixel or empty");
|
1998-05-02 01:55:36 +04:00
|
|
|
return PR_FALSE;
|
1998-05-22 03:43:18 +04:00
|
|
|
}
|
1998-05-02 01:55:36 +04:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
1998-05-02 00:44:55 +04:00
|
|
|
|
|
|
|
void nsTableCellFrame::MapBorderMarginPadding(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
// Check to see if the table has either cell padding or
|
|
|
|
// Cell spacing defined for the table. If true, then
|
|
|
|
// this setting overrides any specific border, margin or
|
|
|
|
// padding information in the cell. If these attributes
|
|
|
|
// are not defined, the the cells attributes are used
|
|
|
|
|
|
|
|
nscoord padding = 0;
|
|
|
|
nscoord spacing = 0;
|
|
|
|
nscoord border = 1;
|
|
|
|
|
1998-09-24 20:37:22 +04:00
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
1998-09-15 21:58:24 +04:00
|
|
|
//tableFrame->GetGeometricParent((nsIFrame *&)tableFrame); // get the outer frame
|
1998-06-11 19:46:37 +04:00
|
|
|
NS_ASSERTION(tableFrame,"Table Must not be null");
|
|
|
|
if (!tableFrame)
|
1998-05-02 00:44:55 +04:00
|
|
|
return;
|
|
|
|
|
1998-06-11 19:46:37 +04:00
|
|
|
// get the table frame style context, and from it get cellpadding, cellspacing, and border info
|
1998-11-11 22:56:02 +03:00
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
tableFrame->GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
1998-07-17 03:23:31 +04:00
|
|
|
nsStyleSpacing* tableSpacingStyle;
|
|
|
|
tableFrame->GetStyleData(eStyleStruct_Spacing,(nsStyleStruct *&)tableSpacingStyle);
|
1998-06-05 10:09:09 +04:00
|
|
|
nsStyleSpacing* spacingData = (nsStyleSpacing*)mStyleContext->GetMutableStyleData(eStyleStruct_Spacing);
|
1998-05-13 02:28:01 +04:00
|
|
|
|
1998-05-02 00:44:55 +04:00
|
|
|
// check to see if cellpadding or cellspacing is defined
|
1998-06-11 19:46:37 +04:00
|
|
|
if (tableStyle->mCellPadding.GetUnit() != eStyleUnit_Null ||
|
|
|
|
tableStyle->mCellSpacing.GetUnit() != eStyleUnit_Null)
|
1998-05-02 00:44:55 +04:00
|
|
|
{
|
1998-06-11 19:46:37 +04:00
|
|
|
spacingData->mMargin.SetTop(tableStyle->mCellSpacing);
|
|
|
|
spacingData->mMargin.SetLeft(tableStyle->mCellSpacing);
|
|
|
|
spacingData->mMargin.SetBottom(tableStyle->mCellSpacing);
|
|
|
|
spacingData->mMargin.SetRight(tableStyle->mCellSpacing);
|
|
|
|
spacingData->mPadding.SetTop(tableStyle->mCellPadding);
|
|
|
|
spacingData->mPadding.SetLeft(tableStyle->mCellPadding);
|
|
|
|
spacingData->mPadding.SetBottom(tableStyle->mCellPadding);
|
|
|
|
spacingData->mPadding.SetRight(tableStyle->mCellPadding);
|
1998-05-02 00:44:55 +04:00
|
|
|
}
|
1998-05-02 01:55:36 +04:00
|
|
|
|
1998-06-11 19:46:37 +04:00
|
|
|
// get border information from the table
|
1998-11-11 22:56:02 +03:00
|
|
|
if (tableStyle->mRules!= NS_STYLE_TABLE_RULES_NONE)
|
1998-06-11 19:46:37 +04:00
|
|
|
{
|
1998-11-11 22:56:02 +03:00
|
|
|
// XXX: need to get border width here
|
|
|
|
// in HTML, cell borders are always 1 pixel by default
|
|
|
|
border = NSIntPixelsToTwips(1, aPresContext->GetPixelsToTwips());
|
|
|
|
MapHTMLBorderStyle(aPresContext, *spacingData, border, tableFrame);
|
1998-05-02 00:44:55 +04:00
|
|
|
}
|
1998-06-24 03:23:21 +04:00
|
|
|
|
1998-05-02 00:44:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Subclass hook for style post processing
|
|
|
|
NS_METHOD nsTableCellFrame::DidSetStyleContext(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
#ifdef NOISY_STYLE
|
|
|
|
printf("nsTableCellFrame::DidSetStyleContext \n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
MapBorderMarginPadding(aPresContext);
|
1998-05-13 02:28:01 +04:00
|
|
|
mStyleContext->RecalcAutomaticData(aPresContext);
|
1998-05-02 00:44:55 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
NS_METHOD
|
|
|
|
nsTableCellFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
return nsContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
nsresult
|
|
|
|
NS_NewTableCellFrame( nsIContent* aContent,
|
|
|
|
nsIFrame* aParentFrame,
|
|
|
|
nsIFrame*& aResult)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-09-15 21:58:24 +04:00
|
|
|
nsIFrame* it = new nsTableCellFrame(aContent, aParentFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1998-09-15 21:58:24 +04:00
|
|
|
aResult = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
/* ----- methods from CellLayoutData ----- */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a frame and an edge, find the margin
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
nscoord nsTableCellFrame::GetMargin(nsIFrame* aFrame, PRUint8 aEdge) const
|
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
|
|
|
|
if (aFrame)
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
|
|
|
|
nsMargin margin;
|
|
|
|
spacing->CalcMarginFor(aFrame, margin);
|
|
|
|
switch (aEdge)
|
|
|
|
{
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
result = margin.top;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
result = margin.right;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
result = margin.bottom;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
result = margin.left;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a style context and an edge, find the border width
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
nscoord nsTableCellFrame::GetBorderWidth(nsIFrame* aFrame, PRUint8 aEdge) const
|
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
|
|
|
|
if (aFrame)
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
|
|
|
|
nsMargin border;
|
|
|
|
spacing->CalcBorderFor(aFrame, border);
|
|
|
|
switch (aEdge)
|
|
|
|
{
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
result = border.top;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
result = border.right;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
result = border.bottom;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
result = border.left;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a style context and an edge, find the padding
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
nscoord nsTableCellFrame::GetPadding(nsIFrame* aFrame, PRUint8 aEdge) const
|
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
|
|
|
|
if (aFrame)
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
aFrame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
|
|
|
|
nsMargin padding;
|
|
|
|
spacing->CalcPaddingFor(aFrame, padding);
|
|
|
|
switch (aEdge)
|
|
|
|
{
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
result = padding.top;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
result = padding.right;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
result = padding.bottom;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
result = padding.left;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given an Edge, find the opposing edge (top<-->bottom, left<-->right)
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
PRUint8 nsTableCellFrame::GetOpposingEdge(PRUint8 aEdge)
|
|
|
|
{
|
|
|
|
PRUint8 result;
|
|
|
|
|
|
|
|
switch (aEdge)
|
|
|
|
{
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
result = NS_SIDE_RIGHT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
result = NS_SIDE_LEFT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
result = NS_SIDE_BOTTOM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
result = NS_SIDE_TOP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
result = NS_SIDE_TOP;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Determine border style for two cells.
|
|
|
|
*
|
|
|
|
1.If the adjacent elements are of the same type, the wider of the two borders is used.
|
|
|
|
"Wider" takes into account the border-style of 'none', so a "1px solid" border
|
|
|
|
will take precedence over a "20px none" border.
|
|
|
|
|
|
|
|
2.If there are two or more with the same width, but different style,
|
|
|
|
then the one with a style near the start of the following list will be drawn:
|
|
|
|
|
|
|
|
'blank', 'double', 'solid', 'dashed', 'dotted', 'ridge', 'groove', 'none'
|
|
|
|
|
|
|
|
3.If the borders are of the same width, the border on the element occurring first is used.
|
|
|
|
|
|
|
|
First is defined as aStyle for this method.
|
|
|
|
|
|
|
|
NOTE: This assumes left-to-right, top-to-bottom bias. -- gpk
|
|
|
|
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
nsIFrame* nsTableCellFrame::CompareCellBorders(nsIFrame* aFrame1,
|
|
|
|
PRUint8 aEdge1,
|
|
|
|
nsIFrame* aFrame2,
|
|
|
|
PRUint8 aEdge2)
|
|
|
|
{
|
|
|
|
PRInt32 width1 = GetBorderWidth(aFrame1,aEdge1);
|
|
|
|
PRInt32 width2 = GetBorderWidth(aFrame2,aEdge2);
|
|
|
|
|
|
|
|
nsIFrame* result = nsnull;
|
|
|
|
|
|
|
|
if (width1 > width2)
|
|
|
|
result = aFrame1;
|
|
|
|
else if (width1 < width2)
|
|
|
|
result = aFrame2;
|
|
|
|
else // width1 == width2
|
|
|
|
{
|
|
|
|
const nsStyleSpacing* border1;
|
|
|
|
const nsStyleSpacing* border2;
|
|
|
|
aFrame1->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)border1);
|
|
|
|
aFrame2->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)border2);
|
|
|
|
if (border1->mBorderStyle[aEdge1] >= border2->mBorderStyle[aEdge2])
|
|
|
|
result = aFrame1;
|
|
|
|
else
|
|
|
|
result = aFrame2;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a List of cell layout data, compare the edges to see which has the
|
|
|
|
* border with the highest precidence.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
|
|
|
nsIFrame* nsTableCellFrame::FindHighestPrecedentBorder(nsVoidArray* aList,
|
|
|
|
PRUint8 aEdge)
|
|
|
|
{
|
|
|
|
nsIFrame* result = nsnull;
|
|
|
|
PRInt32 index = 0;
|
|
|
|
PRInt32 count = 0;
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSERTION(aList,"a List must be valid");
|
|
|
|
count = aList->Count();
|
|
|
|
if (count)
|
|
|
|
{
|
|
|
|
nsIFrame* frame1;
|
|
|
|
nsIFrame* frame2;
|
|
|
|
|
|
|
|
frame1 = (nsIFrame*)(aList->ElementAt(index++));
|
|
|
|
while (index < count)
|
|
|
|
{
|
|
|
|
frame2 = (nsIFrame*)(aList->ElementAt(index++));
|
|
|
|
if (GetMargin(frame2,aEdge) == 0) {
|
|
|
|
frame1 = CompareCellBorders(frame1, aEdge, frame2, aEdge);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((nsnull != frame1) && (GetMargin(frame1, aEdge) != 0))
|
|
|
|
result = frame1;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nsIFrame* nsTableCellFrame::FindInnerBorder(nsVoidArray* aList, PRUint8 aEdge)
|
|
|
|
{
|
|
|
|
nsIFrame* result = nsnull;
|
|
|
|
PRUint8 opposite = GetOpposingEdge(aEdge);
|
|
|
|
|
|
|
|
if (GetMargin(this, aEdge) == 0)
|
|
|
|
{
|
|
|
|
nsIFrame* altFrame = FindHighestPrecedentBorder(aList,opposite);
|
|
|
|
if (nsnull != altFrame)
|
|
|
|
result = CompareCellBorders(this, aEdge, altFrame, opposite);
|
|
|
|
else
|
|
|
|
result = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* FindRelevantBorder recursively searches up the frame hierarchy for the border
|
|
|
|
* style that is applicable to the cell. If at any point the frame has a margin
|
|
|
|
* or the parent frame has padding, then the outer frame for this object takes
|
|
|
|
* presendence over the inner frame.
|
|
|
|
|
|
|
|
1.Borders on 'table' elements take precedence over borders on any other table elements.
|
|
|
|
2.Borders on 'row-groups' take precedence over borders on 'rows',
|
|
|
|
and likewise borders on 'column-groups' take precedence over borders on 'columns'.
|
|
|
|
3.Borders on any other type of table element take precedence over 'table-cell' elements.
|
|
|
|
|
|
|
|
*
|
|
|
|
* NOTE: This method assumes that the table cell potentially shares a border.
|
|
|
|
* It should not be called for internal cells
|
|
|
|
*
|
|
|
|
* NOTE: COLUMNS AND COLGROUPS NEED TO BE FIGURED INTO THE ALGORITHM -- GPK!!!
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
nsIFrame* nsTableCellFrame::FindOuterBorder( nsTableFrame* aTableFrame,
|
|
|
|
PRUint8 aEdge)
|
|
|
|
{
|
|
|
|
nsIFrame* frame = this; // By default, return our frame
|
|
|
|
PRBool done = PR_FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
// The table frame is the outer most frame we test against
|
|
|
|
while (done == PR_FALSE)
|
|
|
|
{
|
|
|
|
done = PR_TRUE; // where done unless the frame's margin is zero
|
|
|
|
// and the parent's padding is zero
|
|
|
|
|
|
|
|
nscoord margin = GetMargin(frame,aEdge);
|
|
|
|
|
|
|
|
// if the margin for this style is zero then check to see if the paddding
|
|
|
|
// for the parent frame is also zero
|
|
|
|
if (margin == 0)
|
|
|
|
{
|
|
|
|
nsIFrame* parentFrame;
|
|
|
|
|
|
|
|
frame->GetGeometricParent(parentFrame);
|
|
|
|
|
|
|
|
// if the padding for the parent style is zero just
|
|
|
|
// recursively call this routine
|
|
|
|
PRInt32 padding = GetPadding(parentFrame,aEdge);
|
|
|
|
if ((nsnull != parentFrame) && (padding == 0))
|
|
|
|
{
|
|
|
|
frame = parentFrame;
|
|
|
|
// If this frame represents the table frame then
|
|
|
|
// the table style is used
|
|
|
|
done = PRBool(frame != (nsIFrame*)aTableFrame);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Border Resolution
|
|
|
|
1.Borders on 'table' elements take precedence over borders on any other table elements.
|
|
|
|
2.Borders on 'row-groups' take precedence over borders on 'rows', and likewise borders on 'column-groups' take
|
|
|
|
precedence over borders on 'columns'.
|
|
|
|
3.Borders on any other type of table element take precedence over 'table-cell' elements.
|
|
|
|
4.If the adjacent elements are of the same type, the wider of the two borders is used. "Wider" takes into account
|
|
|
|
the border-style of 'none', so a "1px solid" border will take precedence over a "20px none" border.
|
|
|
|
5.If the borders are of the same width, the border on the element occurring first is used.
|
|
|
|
|
|
|
|
|
|
|
|
How to compare
|
|
|
|
1.Those of the one or two cells that have an edge here.
|
|
|
|
Less than two can occur at the edge of the table, but also
|
|
|
|
at the edges of "holes" (unoccupied grid cells).
|
|
|
|
2.Those of the columns that have an edge here.
|
|
|
|
3.Those of the column groups that have an edge here.
|
|
|
|
4.Those of the rows that have an edge here.
|
|
|
|
5.Those of the row groups that have an edge here.
|
|
|
|
6.Those of the table, if this is the edge of the table.
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param aIsFirst -- TRUE if this is the first cell in the row
|
|
|
|
* @param aIsLast -- TRUE if this is the last cell in the row
|
|
|
|
* @param aIsTop -- TRUE if this is the top cell in the column
|
|
|
|
* @param aIsBottom -- TRUE if this is the last cell in the column
|
|
|
|
*/
|
|
|
|
|
|
|
|
nsIFrame* nsTableCellFrame::FindBorderFrame(nsTableFrame* aTableFrame,
|
|
|
|
nsVoidArray* aList,
|
|
|
|
PRUint8 aEdge)
|
|
|
|
{
|
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
|
|
|
|
if (aList && aList->Count() == 0)
|
|
|
|
frame = FindOuterBorder(aTableFrame, aEdge);
|
|
|
|
else
|
|
|
|
frame = FindInnerBorder(aList, aEdge);
|
|
|
|
|
|
|
|
if (! frame)
|
|
|
|
frame = this;
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a List of cell layout data, compare the edges to see which has the
|
|
|
|
* border with the highest precidence.
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
nscoord nsTableCellFrame::FindLargestMargin(nsVoidArray* aList,PRUint8 aEdge)
|
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
PRInt32 index = 0;
|
|
|
|
PRInt32 count = 0;
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSERTION(aList,"a List must be valid");
|
|
|
|
count = aList->Count();
|
|
|
|
if (count)
|
|
|
|
{
|
|
|
|
nsIFrame* frame;
|
|
|
|
|
|
|
|
nscoord value = 0;
|
|
|
|
while (index < count)
|
|
|
|
{
|
|
|
|
frame = (nsIFrame*)(aList->ElementAt(index++));
|
|
|
|
value = GetMargin(frame, aEdge);
|
|
|
|
if (value > result)
|
|
|
|
result = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void nsTableCellFrame::CalculateMargins(nsTableFrame* aTableFrame,
|
|
|
|
nsVoidArray* aBoundaryCells[4])
|
|
|
|
{
|
|
|
|
// By default the margin is just the margin found in the
|
|
|
|
// table cells style
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
|
|
|
|
spacing->CalcMarginFor(this, mMargin);
|
|
|
|
|
|
|
|
// Left and Top Margins are collapsed with their neightbors
|
|
|
|
// Right and Bottom Margins are simple left as they are
|
|
|
|
nscoord value;
|
|
|
|
|
|
|
|
// The left and top sides margins are the difference between
|
|
|
|
// their inherint value and the value of the margin of the
|
|
|
|
// object to the left or right of them.
|
|
|
|
|
|
|
|
value = FindLargestMargin(aBoundaryCells[NS_SIDE_LEFT],NS_SIDE_RIGHT);
|
|
|
|
if (value > mMargin.left)
|
|
|
|
mMargin.left = 0;
|
|
|
|
else
|
|
|
|
mMargin.left -= value;
|
|
|
|
|
|
|
|
value = FindLargestMargin(aBoundaryCells[NS_SIDE_TOP],NS_SIDE_BOTTOM);
|
|
|
|
if (value > mMargin.top)
|
|
|
|
mMargin.top = 0;
|
|
|
|
else
|
|
|
|
mMargin.top -= value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nsTableCellFrame::RecalcLayoutData(nsTableFrame* aTableFrame,
|
|
|
|
nsVoidArray* aBoundaryCells[4])
|
|
|
|
|
|
|
|
{
|
|
|
|
CalculateBorders(aTableFrame, aBoundaryCells);
|
|
|
|
CalculateMargins(aTableFrame, aBoundaryCells);
|
|
|
|
mCalculated = NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-03 01:59:54 +04:00
|
|
|
/* ----- debugging methods ----- */
|
|
|
|
NS_METHOD nsTableCellFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const
|
|
|
|
{
|
|
|
|
// if a filter is present, only output this frame if the filter says we should
|
|
|
|
// since this could be any "tag" with the right display type, we'll
|
|
|
|
// just pretend it's a cell
|
|
|
|
if (nsnull==aFilter)
|
|
|
|
return nsContainerFrame::List(out, aIndent, aFilter);
|
|
|
|
|
|
|
|
nsAutoString tagString("td");
|
|
|
|
PRBool outputMe = aFilter->OutputTag(&tagString);
|
|
|
|
if (PR_TRUE==outputMe)
|
|
|
|
{
|
|
|
|
// Indent
|
|
|
|
for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
|
|
|
|
// Output the tag and rect
|
|
|
|
nsIAtom* tag;
|
|
|
|
mContent->GetTag(tag);
|
|
|
|
if (tag != nsnull) {
|
|
|
|
nsAutoString buf;
|
|
|
|
tag->ToString(buf);
|
|
|
|
fputs(buf, out);
|
|
|
|
NS_RELEASE(tag);
|
|
|
|
}
|
|
|
|
|
1998-10-09 00:35:16 +04:00
|
|
|
fprintf(out, "(%d)", ContentIndexInContainer(this));
|
1998-09-03 01:59:54 +04:00
|
|
|
out << mRect;
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
|
|
|
}
|
|
|
|
fputs("\n", out);
|
|
|
|
}
|
|
|
|
// Output the children
|
1998-09-21 07:40:32 +04:00
|
|
|
if (nsnull != mFirstChild) {
|
1998-09-03 01:59:54 +04:00
|
|
|
if (PR_TRUE==outputMe)
|
|
|
|
{
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]\n", mState);
|
|
|
|
}
|
|
|
|
}
|
1998-09-19 07:24:26 +04:00
|
|
|
for (nsIFrame* child = mFirstChild; child; child->GetNextSibling(child)) {
|
1998-09-03 01:59:54 +04:00
|
|
|
child->List(out, aIndent + 1, aFilter);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (PR_TRUE==outputMe)
|
|
|
|
{
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]\n", mState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
#if 0 //QQQ
|
1998-09-01 21:49:05 +04:00
|
|
|
void nsTableCellFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
1998-09-03 01:59:54 +04:00
|
|
|
// if a filter is present, only output this frame if the filter says we should
|
|
|
|
nsIAtom* tag;
|
|
|
|
nsAutoString tagString;
|
|
|
|
mContent->GetTag(tag);
|
|
|
|
if (tag != nsnull)
|
|
|
|
tag->ToString(tagString);
|
|
|
|
if ((nsnull==aFilter) || (PR_TRUE==aFilter->OutputTag(&tagString)))
|
|
|
|
{
|
|
|
|
PRInt32 indent;
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-09-03 01:59:54 +04:00
|
|
|
nsIContent* cell;
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-09-03 01:59:54 +04:00
|
|
|
this->GetContent(cell);
|
|
|
|
if (cell != nsnull)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
|
|
|
|
fprintf(out,"RowSpan = %d ColSpan = %d \n",cell->GetRowSpan(),cell->GetColSpan());
|
|
|
|
*/
|
|
|
|
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
|
|
|
|
fprintf(out,"Margin -- Top: %d Left: %d Bottom: %d Right: %d \n",
|
|
|
|
NSTwipsToIntPoints(mMargin.top),
|
|
|
|
NSTwipsToIntPoints(mMargin.left),
|
|
|
|
NSTwipsToIntPoints(mMargin.bottom),
|
|
|
|
NSTwipsToIntPoints(mMargin.right));
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
|
1998-09-03 01:59:54 +04:00
|
|
|
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-09-03 01:59:54 +04:00
|
|
|
nscoord top,left,bottom,right;
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-09-03 01:59:54 +04:00
|
|
|
top = (mBorderFrame[NS_SIDE_TOP] ? GetBorderWidth((nsIFrame*)mBorderFrame[NS_SIDE_TOP], NS_SIDE_TOP) : 0);
|
|
|
|
left = (mBorderFrame[NS_SIDE_LEFT] ? GetBorderWidth((nsIFrame*)mBorderFrame[NS_SIDE_LEFT], NS_SIDE_LEFT) : 0);
|
|
|
|
bottom = (mBorderFrame[NS_SIDE_BOTTOM] ? GetBorderWidth((nsIFrame*)mBorderFrame[NS_SIDE_BOTTOM], NS_SIDE_BOTTOM) : 0);
|
|
|
|
right = (mBorderFrame[NS_SIDE_RIGHT] ? GetBorderWidth((nsIFrame*)mBorderFrame[NS_SIDE_RIGHT], NS_SIDE_RIGHT) : 0);
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
|
1998-09-03 01:59:54 +04:00
|
|
|
fprintf(out,"Border -- Top: %d Left: %d Bottom: %d Right: %d \n",
|
|
|
|
NSTwipsToIntPoints(top),
|
|
|
|
NSTwipsToIntPoints(left),
|
|
|
|
NSTwipsToIntPoints(bottom),
|
|
|
|
NSTwipsToIntPoints(right));
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
1998-09-03 01:59:54 +04:00
|
|
|
cell->List(out,aIndent);
|
|
|
|
NS_RELEASE(cell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Output the children
|
1998-09-21 07:40:32 +04:00
|
|
|
if (nsnull != mFirstChild) {
|
1998-09-03 01:59:54 +04:00
|
|
|
if (PR_TRUE==outputMe)
|
|
|
|
{
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (nsIFrame* child = mFirstChild; child; NextChild(child, child)) {
|
|
|
|
child->List(out, aIndent + 1, aFilter);
|
|
|
|
}
|
|
|
|
if (PR_TRUE==outputMe)
|
|
|
|
{
|
|
|
|
for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (PR_TRUE==outputMe)
|
|
|
|
{
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
|
|
|
}
|
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|