2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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-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"
|
1998-07-11 00:00:31 +00:00
|
|
|
|
2015-05-04 07:09:25 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2010-06-09 05:28:14 +00: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 15:05:51 +00:00
|
|
|
#define COL_TYPE_OFFSET 28
|
2004-09-04 16:02:50 +00:00
|
|
|
|
2015-04-30 21:46:59 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
|
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();
|
2015-04-18 23:01:26 +00:00
|
|
|
ResetFinalISize();
|
1999-07-28 08:09:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableColFrame::~nsTableColFrame()
|
|
|
|
{
|
1998-07-11 00:00:31 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 18:42:05 +00:00
|
|
|
nsTableColType
|
|
|
|
nsTableColFrame::GetColType() const
|
2001-11-30 15:05:51 +00:00
|
|
|
{
|
|
|
|
return (nsTableColType)((mState & COL_TYPE_BITS) >> COL_TYPE_OFFSET);
|
|
|
|
}
|
|
|
|
|
2015-04-17 18:42:05 +00:00
|
|
|
void
|
|
|
|
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");
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t type = aType - eColContent;
|
2014-02-18 02:32:06 +00:00
|
|
|
RemoveStateBits(COL_TYPE_BITS);
|
|
|
|
AddStateBits(nsFrameState(type << COL_TYPE_OFFSET));
|
2001-11-30 15:05:51 +00:00
|
|
|
}
|
|
|
|
|
2008-10-26 10:11:34 +00:00
|
|
|
/* virtual */ void
|
|
|
|
nsTableColFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
|
|
|
{
|
2012-08-13 21:13:34 +00:00
|
|
|
nsSplittableFrame::DidSetStyleContext(aOldStyleContext);
|
|
|
|
|
2008-10-26 10:11:34 +00:00
|
|
|
if (!aOldStyleContext) //avoid this on init
|
|
|
|
return;
|
2015-04-17 18:42:05 +00:00
|
|
|
|
2015-04-30 04:24:59 +00:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2008-10-26 10:11:34 +00:00
|
|
|
if (tableFrame->IsBorderCollapse() &&
|
2013-02-16 05:38:33 +00:00
|
|
|
tableFrame->BCRecalcNeeded(aOldStyleContext, StyleContext())) {
|
2015-04-30 21:46:59 +00:00
|
|
|
TableArea damageArea(GetColIndex(), 0, 1, tableFrame->GetRowCount());
|
2011-10-27 13:58:44 +00:00
|
|
|
tableFrame->AddBCDamageArea(damageArea);
|
2008-10-26 10:11:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-04 07:09:25 +00:00
|
|
|
void nsTableColFrame::SetContinuousBCBorderWidth(LogicalSide aForSide,
|
2004-03-09 06:48:35 +00:00
|
|
|
BCPixelSize aPixelValue)
|
|
|
|
{
|
|
|
|
switch (aForSide) {
|
2015-05-04 07:09:25 +00:00
|
|
|
case eLogicalSideBStart:
|
|
|
|
mBStartContBorderWidth = aPixelValue;
|
2004-03-09 06:48:35 +00:00
|
|
|
return;
|
2015-05-04 07:09:25 +00:00
|
|
|
case eLogicalSideIEnd:
|
|
|
|
mIEndContBorderWidth = aPixelValue;
|
2004-03-09 06:48:35 +00:00
|
|
|
return;
|
2015-05-04 07:09:25 +00:00
|
|
|
case eLogicalSideBEnd:
|
|
|
|
mBEndContBorderWidth = aPixelValue;
|
2004-03-09 06:48:35 +00:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
NS_ERROR("invalid side arg");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
void
|
|
|
|
nsTableColFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 10:36:38 +00:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 10:36:39 +00:00
|
|
|
const ReflowInput& aReflowInput,
|
2001-10-29 01:43:59 +00:00
|
|
|
nsReflowStatus& aStatus)
|
1998-07-11 00:00:31 +00:00
|
|
|
{
|
2015-03-29 22:38:40 +00:00
|
|
|
MarkInReflow();
|
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");
|
2016-07-21 10:36:39 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
2014-07-24 08:30:07 +00:00
|
|
|
aDesiredSize.ClearSize();
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleVisibility* colVis = StyleVisibility();
|
2011-09-29 06:19:26 +00:00
|
|
|
bool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
|
2004-04-28 16:42:59 +00:00
|
|
|
if (collapseCol) {
|
2015-04-30 04:24:59 +00:00
|
|
|
GetTableFrame()->SetNeedToCollapse(true);
|
2004-04-28 16:42:59 +00:00
|
|
|
}
|
1998-07-11 00:00:31 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2016-07-21 10:36:39 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
1998-07-11 00:00:31 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t nsTableColFrame::GetSpan()
|
2003-05-15 03:42:21 +00:00
|
|
|
{
|
2013-02-16 21:51:02 +00:00
|
|
|
return StyleTable()->mSpan;
|
1998-11-12 18:37:28 +00:00
|
|
|
}
|
|
|
|
|
2004-09-04 16:02:50 +00:00
|
|
|
#ifdef DEBUG
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsTableColFrame::Dump(int32_t 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;
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t i = 0; i < aIndent + 1; i++) {
|
1999-07-28 08:09:02 +00:00
|
|
|
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;
|
2015-04-17 18:42:05 +00:00
|
|
|
case eColAnonymousCol:
|
2004-09-04 16:02:50 +00:00
|
|
|
printf(" anonymous-column ");
|
|
|
|
break;
|
|
|
|
case eColAnonymousColGroup:
|
|
|
|
printf(" anonymous-colgroup ");
|
|
|
|
break;
|
2015-04-17 18:42:05 +00:00
|
|
|
case eColAnonymousCell:
|
2004-09-04 16:02:50 +00:00
|
|
|
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",
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t(mMinCoord), int32_t(mPrefCoord),
|
2012-01-22 22:48:34 +00:00
|
|
|
mHasSpecifiedCoord ? 's' : 'u', mPrefPercent,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t(mSpanMinCoord), int32_t(mSpanPrefCoord),
|
2007-03-19 20:26:36 +00:00
|
|
|
mSpanPrefPercent,
|
2015-04-18 23:01:26 +00:00
|
|
|
int32_t(GetFinalISize()));
|
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
|
|
|
|
2015-04-17 18:42:05 +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
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableColFrame)
|
|
|
|
|
2015-04-17 18:42:05 +00:00
|
|
|
nsTableColFrame*
|
2002-02-19 15:48:28 +00:00
|
|
|
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
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2002-02-19 15:48:28 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
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;
|
|
|
|
}
|
|
|
|
|
2012-08-29 05:39:31 +00:00
|
|
|
void
|
2012-08-29 05:48:45 +00:00
|
|
|
nsTableColFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
2012-08-29 05:39:31 +00:00
|
|
|
{
|
2012-08-29 05:48:45 +00:00
|
|
|
nsIFrame::InvalidateFrame(aDisplayItemKey);
|
|
|
|
GetParent()->InvalidateFrameWithRect(GetVisualOverflowRect() + GetPosition(), aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableColFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
nsIFrame::InvalidateFrameWithRect(aRect, aDisplayItemKey);
|
|
|
|
|
|
|
|
// If we have filters applied that would affects our bounds, then
|
|
|
|
// we get an inactive layer created and this is computed
|
|
|
|
// within FrameLayerBuilder
|
|
|
|
GetParent()->InvalidateFrameWithRect(aRect + GetPosition(), aDisplayItemKey);
|
2012-08-29 05:39:31 +00:00
|
|
|
}
|
|
|
|
|