2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-07-11 04:00:31 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-07-11 04:00:31 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-07-11 04:00:31 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-12-14 01:56:31 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-07-11 04:00:31 +04:00
|
|
|
#include "nsTableColFrame.h"
|
2004-04-28 20:42:59 +04:00
|
|
|
#include "nsTableFrame.h"
|
1998-07-11 04:00:31 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-07-11 04:00:31 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1998-07-11 04:00:31 +04:00
|
|
|
#include "nsHTMLAtoms.h"
|
1999-06-08 01:10:25 +04:00
|
|
|
#include "nsCSSRendering.h"
|
1999-10-02 04:02:54 +04:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-12-16 04:51:06 +03:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIDOMHTMLTableColElement.h"
|
1998-07-11 04:00:31 +04:00
|
|
|
|
2001-11-30 18:05:51 +03:00
|
|
|
#define COL_TYPE_BITS 0xF0000000 // uses bits 29-32 from mState
|
|
|
|
#define COL_TYPE_OFFSET 28
|
2004-09-04 20:02:50 +04:00
|
|
|
|
2001-11-30 18:05:51 +03:00
|
|
|
#define COL_CONSTRAINT_BITS 0x07000000 // uses bits 25-27
|
|
|
|
#define COL_CONSTRAINT_OFFSET 24
|
1999-12-16 04:51:06 +03:00
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsTableColFrame::nsTableColFrame()
|
2001-03-13 09:38:59 +03:00
|
|
|
: nsFrame()
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
SetColType(eColContent);
|
2001-11-30 18:05:51 +03:00
|
|
|
ResetSizingInfo();
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableColFrame::~nsTableColFrame()
|
|
|
|
{
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
|
|
|
|
2001-11-30 18:05:51 +03:00
|
|
|
nsTableColType
|
2003-10-31 23:19:18 +03:00
|
|
|
nsTableColFrame::GetColType() const
|
2001-11-30 18:05:51 +03:00
|
|
|
{
|
|
|
|
return (nsTableColType)((mState & COL_TYPE_BITS) >> COL_TYPE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-10-31 23:19:18 +03:00
|
|
|
nsTableColFrame::SetColType(nsTableColType aType)
|
2001-11-30 18:05:51 +03:00
|
|
|
{
|
|
|
|
PRUint32 type = aType - eColContent;
|
|
|
|
mState |= (type << COL_TYPE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsColConstraint
|
|
|
|
nsTableColFrame::GetConstraint() const
|
|
|
|
{
|
|
|
|
return (nsColConstraint)((mState & COL_CONSTRAINT_BITS) >> COL_CONSTRAINT_OFFSET);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
2001-11-30 18:05:51 +03:00
|
|
|
void
|
|
|
|
nsTableColFrame::SetConstraint(nsColConstraint aConstraint)
|
|
|
|
{
|
|
|
|
PRUint32 con = aConstraint - eNoConstraint;
|
|
|
|
mState |= (con << COL_CONSTRAINT_OFFSET);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// XXX what about other style besides width
|
|
|
|
nsStyleCoord nsTableColFrame::GetStyleWidth() const
|
|
|
|
{
|
2003-11-24 22:46:25 +03:00
|
|
|
nsStyleCoord styleWidth = GetStylePosition()->mWidth;
|
|
|
|
if (eStyleUnit_Auto == styleWidth.GetUnit()) {
|
|
|
|
styleWidth = GetParent()->GetStylePosition()->mWidth;
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleCoord returnWidth;
|
|
|
|
returnWidth.mUnit = styleWidth.mUnit;
|
|
|
|
returnWidth.mValue = styleWidth.mValue;
|
|
|
|
return returnWidth;
|
|
|
|
}
|
|
|
|
|
2004-03-09 09:48:35 +03:00
|
|
|
void nsTableColFrame::SetContinuousBCBorderWidth(PRUint8 aForSide,
|
|
|
|
BCPixelSize aPixelValue)
|
|
|
|
{
|
|
|
|
switch (aForSide) {
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
mTopContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
mRightContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
mBottomContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
NS_ERROR("invalid side arg");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-21 10:38:07 +04:00
|
|
|
void nsTableColFrame::ResetSizingInfo()
|
|
|
|
{
|
2002-02-05 04:41:13 +03:00
|
|
|
memset(mWidths, WIDTH_NOT_SET, NUM_WIDTHS * sizeof(PRInt32));
|
2001-11-30 18:05:51 +03:00
|
|
|
SetConstraint(eNoConstraint);
|
1999-08-21 10:38:07 +04:00
|
|
|
}
|
|
|
|
|
2001-09-19 16:35:19 +04:00
|
|
|
NS_METHOD
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableColFrame::Paint(nsPresContext* aPresContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
2001-01-27 17:09:34 +03:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-02-21 08:36:16 +03:00
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-22 05:43:08 +03:00
|
|
|
// override, since we want to act like a block
|
2005-09-19 06:15:54 +04:00
|
|
|
nsIFrame*
|
2005-01-01 20:26:29 +03:00
|
|
|
nsTableColFrame::GetFrameForPoint(const nsPoint& aPoint,
|
2005-09-19 06:15:54 +04:00
|
|
|
nsFramePaintLayer aWhichLayer)
|
2000-03-22 05:43:08 +03:00
|
|
|
{
|
2005-09-19 06:15:54 +04:00
|
|
|
return nsnull;
|
2000-03-22 05:43:08 +03:00
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_METHOD nsTableColFrame::Reflow(nsPresContext* aPresContext,
|
2001-10-29 04:43:59 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2001-10-29 04:43:59 +03:00
|
|
|
nsReflowStatus& aStatus)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
2000-04-22 01:36:33 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableColFrame", aReflowState.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1998-07-11 04:00:31 +04:00
|
|
|
aDesiredSize.width=0;
|
|
|
|
aDesiredSize.height=0;
|
2004-04-28 20:42:59 +04:00
|
|
|
const nsStyleVisibility* colVis = GetStyleVisibility();
|
|
|
|
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
|
|
|
|
if (collapseCol) {
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (tableFrame) {
|
|
|
|
tableFrame->SetNeedToCollapseColumns(PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
2003-01-09 17:26:32 +03:00
|
|
|
aDesiredSize.mMaxElementWidth=0;
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-07-11 04:00:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-12 21:37:28 +03:00
|
|
|
PRInt32 nsTableColFrame::GetSpan()
|
2003-05-15 07:42:21 +04:00
|
|
|
{
|
|
|
|
return GetStyleTable()->mSpan;
|
1998-11-12 21:37:28 +03:00
|
|
|
}
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
nscoord nsTableColFrame::GetWidth(PRUint32 aWidthType)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aWidthType < NUM_WIDTHS, "GetWidth: bad width type");
|
|
|
|
return mWidths[aWidthType];
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableColFrame::SetWidth(PRUint32 aWidthType,
|
|
|
|
nscoord aWidth)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aWidthType < NUM_WIDTHS, "SetWidth: bad width type");
|
|
|
|
mWidths[aWidthType] = aWidth;
|
|
|
|
#ifdef MY_DEBUG
|
|
|
|
if (aWidth > 0) {
|
|
|
|
nscoord minWidth = GetMinWidth();
|
|
|
|
if ((MIN_CON != aWidthType) && (aWidth < minWidth)) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("non min width set to lower than min \n");
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord nsTableColFrame::GetMinWidth()
|
|
|
|
{
|
|
|
|
return PR_MAX(mWidths[MIN_CON], mWidths[MIN_ADJ]);
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord nsTableColFrame::GetDesWidth()
|
|
|
|
{
|
|
|
|
return PR_MAX(mWidths[DES_CON], mWidths[DES_ADJ]);
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord nsTableColFrame::GetFixWidth()
|
|
|
|
{
|
|
|
|
return PR_MAX(mWidths[FIX], mWidths[FIX_ADJ]);
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord nsTableColFrame::GetPctWidth()
|
|
|
|
{
|
|
|
|
return PR_MAX(mWidths[PCT], mWidths[PCT_ADJ]);
|
|
|
|
}
|
|
|
|
|
2004-09-04 20:02:50 +04:00
|
|
|
#ifdef DEBUG
|
1999-07-28 12:09:02 +04:00
|
|
|
void nsTableColFrame::Dump(PRInt32 aIndent)
|
1998-11-16 09:46:00 +03:00
|
|
|
{
|
1999-07-28 12:09:02 +04:00
|
|
|
char* indent = new char[aIndent + 1];
|
2000-11-30 18:53:55 +03:00
|
|
|
if (!indent) return;
|
1999-07-28 12:09:02 +04:00
|
|
|
for (PRInt32 i = 0; i < aIndent + 1; i++) {
|
|
|
|
indent[i] = ' ';
|
|
|
|
}
|
|
|
|
indent[aIndent] = 0;
|
|
|
|
|
2004-09-04 20:02:50 +04:00
|
|
|
printf("%s**START COL DUMP**\n%s colIndex=%d constraint=%d coltype=",
|
|
|
|
indent, indent, mColIndex, GetConstraint());
|
|
|
|
nsTableColType colType = GetColType();
|
|
|
|
switch (colType) {
|
|
|
|
case eColContent:
|
|
|
|
printf(" content ");
|
|
|
|
break;
|
|
|
|
case eColAnonymousCol:
|
|
|
|
printf(" anonymous-column ");
|
|
|
|
break;
|
|
|
|
case eColAnonymousColGroup:
|
|
|
|
printf(" anonymous-colgroup ");
|
|
|
|
break;
|
|
|
|
case eColAnonymousCell:
|
|
|
|
printf(" anonymous-cell ");
|
|
|
|
break;
|
|
|
|
}
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("\n%s widths=", indent);
|
1999-07-28 12:09:02 +04:00
|
|
|
for (PRInt32 widthX = 0; widthX < NUM_WIDTHS; widthX++) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("%d ", mWidths[widthX]);
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
2004-09-04 20:02:50 +04:00
|
|
|
printf("\n%s**END COL DUMP** ", indent);
|
1999-07-28 12:09:02 +04:00
|
|
|
delete [] indent;
|
1998-11-16 09:46:00 +03:00
|
|
|
}
|
2004-09-04 20:02:50 +04:00
|
|
|
#endif
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
1998-07-11 04:00:31 +04:00
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
|
|
|
NS_NewTableColFrame(nsIPresShell* aPresShell)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
2005-11-04 05:38:33 +03:00
|
|
|
return new (aPresShell) nsTableColFrame;
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
|
|
|
|
2001-02-23 15:35:34 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableColFrame::Init(nsPresContext* aPresContext,
|
2001-02-23 15:35:34 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-02-23 15:35:34 +03:00
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Let the the base class do its initialization
|
|
|
|
rv = nsFrame::Init(aPresContext, aContent, aParent, aContext,
|
|
|
|
aPrevInFlow);
|
|
|
|
|
|
|
|
// record that children that are ignorable whitespace should be excluded
|
|
|
|
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
nsTableColFrame*
|
|
|
|
nsTableColFrame::GetNextCol() const
|
|
|
|
{
|
2003-07-07 06:01:29 +04:00
|
|
|
nsIFrame* childFrame = GetNextSibling();
|
2002-02-19 18:48:28 +03:00
|
|
|
while (childFrame) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableColFrame == childFrame->GetType()) {
|
2002-02-19 18:48:28 +03:00
|
|
|
return (nsTableColFrame*)childFrame;
|
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2002-02-19 18:48:28 +03:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsTableColFrame::GetType() const
|
1999-10-02 04:02:54 +04:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::tableColFrame;
|
1999-10-02 04:02:54 +04:00
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsTableColFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 20:22:29 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableCol"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|