2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-07-11 00:00:31 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00: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 00:00:31 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00: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 00:00:31 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00: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-28 20:14:13 +00: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 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00: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 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-12-13 22:56:31 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1998-07-11 00:00:31 +00:00
|
|
|
#include "nsTableColFrame.h"
|
2004-04-28 16:42:59 +00:00
|
|
|
#include "nsTableFrame.h"
|
1998-07-11 00:00:31 +00:00
|
|
|
#include "nsContainerFrame.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1998-07-11 00:00:31 +00:00
|
|
|
#include "nsStyleConsts.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2006-12-26 17:47:52 +00:00
|
|
|
#include "nsCSSRendering.h"
|
1999-12-16 01:51:06 +00:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIDOMHTMLTableColElement.h"
|
1998-07-11 00:00:31 +00:00
|
|
|
|
2001-11-30 15:05:51 +00:00
|
|
|
#define COL_TYPE_BITS 0xF0000000 // uses bits 29-32 from mState
|
|
|
|
#define COL_TYPE_OFFSET 28
|
2004-09-04 16:02:50 +00:00
|
|
|
|
2001-11-30 15:05:51 +00:00
|
|
|
#define COL_CONSTRAINT_BITS 0x07000000 // uses bits 25-27
|
|
|
|
#define COL_CONSTRAINT_OFFSET 24
|
1999-12-16 01:51:06 +00:00
|
|
|
|
2007-12-03 07:45:06 +00:00
|
|
|
nsTableColFrame::nsTableColFrame(nsStyleContext* aContext) :
|
|
|
|
nsSplittableFrame(aContext)
|
1998-07-11 00:00:31 +00:00
|
|
|
{
|
2003-10-31 20:19:18 +00:00
|
|
|
SetColType(eColContent);
|
2007-03-19 20:26:36 +00:00
|
|
|
ResetIntrinsics();
|
|
|
|
ResetSpanIntrinsics();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
ResetFinalWidth();
|
1999-07-28 08:09:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableColFrame::~nsTableColFrame()
|
|
|
|
{
|
1998-07-11 00:00:31 +00:00
|
|
|
}
|
|
|
|
|
2001-11-30 15:05:51 +00:00
|
|
|
nsTableColType
|
2003-10-31 20:19:18 +00:00
|
|
|
nsTableColFrame::GetColType() const
|
2001-11-30 15:05:51 +00:00
|
|
|
{
|
|
|
|
return (nsTableColType)((mState & COL_TYPE_BITS) >> COL_TYPE_OFFSET);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-10-31 20:19:18 +00:00
|
|
|
nsTableColFrame::SetColType(nsTableColType aType)
|
2001-11-30 15:05:51 +00:00
|
|
|
{
|
2007-12-03 07:45:06 +00:00
|
|
|
NS_ASSERTION(aType != eColAnonymousCol ||
|
|
|
|
(GetPrevContinuation() &&
|
|
|
|
GetPrevContinuation()->GetNextContinuation() == this &&
|
|
|
|
GetPrevContinuation()->GetNextSibling() == this),
|
|
|
|
"spanned content cols must be continuations");
|
2001-11-30 15:05:51 +00:00
|
|
|
PRUint32 type = aType - eColContent;
|
|
|
|
mState |= (type << COL_TYPE_OFFSET);
|
|
|
|
}
|
|
|
|
|
2004-03-09 06:48:35 +00: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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_METHOD nsTableColFrame::Reflow(nsPresContext* aPresContext,
|
2001-10-29 01:43:59 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 04:10:00 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2001-10-29 01:43:59 +00:00
|
|
|
nsReflowStatus& aStatus)
|
1998-07-11 00:00:31 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableColFrame");
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1998-07-11 00:00:31 +00:00
|
|
|
aDesiredSize.width=0;
|
|
|
|
aDesiredSize.height=0;
|
2004-04-28 16:42:59 +00:00
|
|
|
const nsStyleVisibility* colVis = GetStyleVisibility();
|
|
|
|
PRBool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
|
|
|
|
if (collapseCol) {
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2004-04-28 16:42:59 +00:00
|
|
|
if (tableFrame) {
|
2006-03-04 05:26:57 +00:00
|
|
|
tableFrame->SetNeedToCollapse(PR_TRUE);
|
2004-04-28 16:42:59 +00:00
|
|
|
}
|
|
|
|
}
|
1998-07-11 00:00:31 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-07-11 00:00:31 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-12 18:37:28 +00:00
|
|
|
PRInt32 nsTableColFrame::GetSpan()
|
2003-05-15 03:42:21 +00:00
|
|
|
{
|
|
|
|
return GetStyleTable()->mSpan;
|
1998-11-12 18:37:28 +00:00
|
|
|
}
|
|
|
|
|
2004-09-04 16:02:50 +00:00
|
|
|
#ifdef DEBUG
|
1999-07-28 08:09:02 +00:00
|
|
|
void nsTableColFrame::Dump(PRInt32 aIndent)
|
1998-11-16 06:46:00 +00:00
|
|
|
{
|
1999-07-28 08:09:02 +00:00
|
|
|
char* indent = new char[aIndent + 1];
|
2000-11-30 15:53:55 +00:00
|
|
|
if (!indent) return;
|
1999-07-28 08:09:02 +00:00
|
|
|
for (PRInt32 i = 0; i < aIndent + 1; i++) {
|
|
|
|
indent[i] = ' ';
|
|
|
|
}
|
|
|
|
indent[aIndent] = 0;
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
printf("%s**START COL DUMP**\n%s colIndex=%d coltype=",
|
|
|
|
indent, indent, mColIndex);
|
2004-09-04 16:02:50 +00:00
|
|
|
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;
|
|
|
|
}
|
2008-01-18 04:18:21 +00:00
|
|
|
printf("\nm:%d c:%d(%c) p:%f sm:%d sc:%d sp:%f f:%d",
|
2007-03-19 20:26:36 +00:00
|
|
|
mMinCoord, mPrefCoord, mHasSpecifiedCoord ? 's' : 'u', mPrefPercent,
|
2008-01-18 04:18:21 +00:00
|
|
|
mSpanMinCoord, mSpanPrefCoord,
|
2007-03-19 20:26:36 +00:00
|
|
|
mSpanPrefPercent,
|
2007-01-13 01:08:18 +00:00
|
|
|
GetFinalWidth());
|
2004-09-04 16:02:50 +00:00
|
|
|
printf("\n%s**END COL DUMP** ", indent);
|
1999-07-28 08:09:02 +00:00
|
|
|
delete [] indent;
|
1998-11-16 06:46:00 +00:00
|
|
|
}
|
2004-09-04 16:02:50 +00:00
|
|
|
#endif
|
1998-09-15 17:58:24 +00:00
|
|
|
/* ----- global methods ----- */
|
1998-07-11 00:00:31 +00:00
|
|
|
|
2007-11-18 18:56:49 +00:00
|
|
|
nsTableColFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewTableColFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-07-11 00:00:31 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsTableColFrame(aContext);
|
1998-07-11 00:00:31 +00:00
|
|
|
}
|
|
|
|
|
2001-02-23 12:35:34 +00:00
|
|
|
NS_IMETHODIMP
|
2006-03-09 18:55:21 +00:00
|
|
|
nsTableColFrame::Init(nsIContent* aContent,
|
2001-02-23 12:35:34 +00:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2005-11-20 22:05:24 +00:00
|
|
|
// Let the base class do its initialization
|
2007-12-03 07:45:06 +00:00
|
|
|
nsresult rv = nsSplittableFrame::Init(aContent, aParent, aPrevInFlow);
|
2001-02-23 12:35:34 +00:00
|
|
|
|
|
|
|
// record that children that are ignorable whitespace should be excluded
|
|
|
|
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2002-02-19 15:48:28 +00:00
|
|
|
nsTableColFrame*
|
|
|
|
nsTableColFrame::GetNextCol() const
|
|
|
|
{
|
2003-07-07 02:01:29 +00:00
|
|
|
nsIFrame* childFrame = GetNextSibling();
|
2002-02-19 15:48:28 +00:00
|
|
|
while (childFrame) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (nsGkAtoms::tableColFrame == childFrame->GetType()) {
|
2002-02-19 15:48:28 +00:00
|
|
|
return (nsTableColFrame*)childFrame;
|
|
|
|
}
|
2003-07-07 02:01:29 +00:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2002-02-19 15:48:28 +00:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsTableColFrame::GetType() const
|
1999-10-02 00:02:54 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::tableColFrame;
|
1999-10-02 00:02:54 +00:00
|
|
|
}
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsTableColFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 17:22:29 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableCol"), aResult);
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|
2007-12-03 07:45:06 +00:00
|
|
|
|
|
|
|
nsSplittableType
|
|
|
|
nsTableColFrame::GetSplittableType() const
|
|
|
|
{
|
|
|
|
return NS_FRAME_NOT_SPLITTABLE;
|
|
|
|
}
|
|
|
|
|