2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
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"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsCSSRendering.h"
|
1999-12-16 04:51:06 +03:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIDOMHTMLTableColElement.h"
|
1998-07-11 04:00:31 +04:00
|
|
|
|
2010-06-09 09:28:14 +04:00
|
|
|
#define COL_TYPE_BITS (NS_FRAME_STATE_BIT(28) | \
|
|
|
|
NS_FRAME_STATE_BIT(29) | \
|
|
|
|
NS_FRAME_STATE_BIT(30) | \
|
|
|
|
NS_FRAME_STATE_BIT(31))
|
2001-11-30 18:05:51 +03:00
|
|
|
#define COL_TYPE_OFFSET 28
|
2004-09-04 20:02:50 +04:00
|
|
|
|
2007-12-03 10:45:06 +03:00
|
|
|
nsTableColFrame::nsTableColFrame(nsStyleContext* aContext) :
|
|
|
|
nsSplittableFrame(aContext)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
SetColType(eColContent);
|
2007-03-19 23:26:36 +03: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 08:38:33 +03:00
|
|
|
ResetFinalWidth();
|
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
|
|
|
{
|
2007-12-03 10:45:06 +03:00
|
|
|
NS_ASSERTION(aType != eColAnonymousCol ||
|
|
|
|
(GetPrevContinuation() &&
|
|
|
|
GetPrevContinuation()->GetNextContinuation() == this &&
|
|
|
|
GetPrevContinuation()->GetNextSibling() == this),
|
|
|
|
"spanned content cols must be continuations");
|
2001-11-30 18:05:51 +03:00
|
|
|
PRUint32 type = aType - eColContent;
|
|
|
|
mState |= (type << COL_TYPE_OFFSET);
|
|
|
|
}
|
|
|
|
|
2008-10-26 13:11:34 +03:00
|
|
|
/* virtual */ void
|
|
|
|
nsTableColFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
|
|
|
{
|
|
|
|
if (!aOldStyleContext) //avoid this on init
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (tableFrame->IsBorderCollapse() &&
|
|
|
|
tableFrame->BCRecalcNeeded(aOldStyleContext, GetStyleContext())) {
|
2012-01-23 02:48:34 +04:00
|
|
|
nsIntRect damageArea(GetColIndex(), 0, 1, tableFrame->GetRowCount());
|
2011-10-27 17:58:44 +04:00
|
|
|
tableFrame->AddBCDamageArea(damageArea);
|
2008-10-26 13:11:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
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 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableColFrame");
|
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();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
|
2004-04-28 20:42:59 +04:00
|
|
|
if (collapseCol) {
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2012-01-17 03:38:10 +04:00
|
|
|
tableFrame->SetNeedToCollapse(true);
|
2004-04-28 20:42:59 +04:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
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 08:38:33 +03:00
|
|
|
printf("%s**START COL DUMP**\n%s colIndex=%d coltype=",
|
|
|
|
indent, indent, mColIndex);
|
2004-09-04 20:02:50 +04: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 07:18:21 +03:00
|
|
|
printf("\nm:%d c:%d(%c) p:%f sm:%d sc:%d sp:%f f:%d",
|
2012-01-23 02:48:34 +04:00
|
|
|
PRInt32(mMinCoord), PRInt32(mPrefCoord),
|
|
|
|
mHasSpecifiedCoord ? 's' : 'u', mPrefPercent,
|
|
|
|
PRInt32(mSpanMinCoord), PRInt32(mSpanPrefCoord),
|
2007-03-19 23:26:36 +03:00
|
|
|
mSpanPrefPercent,
|
2012-01-23 02:48:34 +04:00
|
|
|
PRInt32(GetFinalWidth()));
|
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
|
|
|
|
2007-11-18 21:56:49 +03:00
|
|
|
nsTableColFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewTableColFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsTableColFrame(aContext);
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableColFrame)
|
|
|
|
|
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) {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::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
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::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
|
2007-12-03 10:45:06 +03:00
|
|
|
|
|
|
|
nsSplittableType
|
|
|
|
nsTableColFrame::GetSplittableType() const
|
|
|
|
{
|
|
|
|
return NS_FRAME_NOT_SPLITTABLE;
|
|
|
|
}
|
|
|
|
|
2012-06-30 07:06:11 +04:00
|
|
|
void
|
|
|
|
nsTableColFrame::InvalidateFrame(PRUint32 aFlags)
|
|
|
|
{
|
|
|
|
nsIFrame::InvalidateFrame(aFlags);
|
|
|
|
nsTableFrame *tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
tableFrame->InvalidateFrame(aFlags | INVALIDATE_DONT_SCHEDULE_PAINT);
|
|
|
|
}
|
|
|
|
|