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"
|
|
|
|
#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"
|
2019-04-16 07:24:49 +00:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
|
|
|
#include "mozilla/PresShell.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;
|
|
|
|
|
2019-02-05 16:45:54 +00:00
|
|
|
nsTableColFrame::nsTableColFrame(ComputedStyle* aStyle,
|
|
|
|
nsPresContext* aPresContext)
|
|
|
|
: nsSplittableFrame(aStyle, aPresContext, kClassID),
|
2016-12-01 08:06:50 +00:00
|
|
|
mMinCoord(0),
|
|
|
|
mPrefCoord(0),
|
|
|
|
mSpanMinCoord(0),
|
|
|
|
mSpanPrefCoord(0),
|
|
|
|
mPrefPercent(0.0f),
|
|
|
|
mSpanPrefPercent(0.0f),
|
|
|
|
mFinalISize(0),
|
|
|
|
mColIndex(0),
|
|
|
|
mIStartBorderWidth(0),
|
|
|
|
mIEndBorderWidth(0),
|
|
|
|
mBStartContBorderWidth(0),
|
|
|
|
mIEndContBorderWidth(0),
|
|
|
|
mBEndContBorderWidth(0),
|
|
|
|
mHasSpecifiedCoord(false) {
|
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) {
|
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
|
|
|
}
|
|
|
|
|
2019-02-25 22:09:24 +00:00
|
|
|
/* virtual */
|
|
|
|
void nsTableColFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) {
|
2018-03-22 18:20:41 +00:00
|
|
|
nsSplittableFrame::DidSetComputedStyle(aOldComputedStyle);
|
2012-08-13 21:13:34 +00:00
|
|
|
|
2018-03-22 18:20:41 +00:00
|
|
|
if (!aOldComputedStyle) // avoid this on init
|
2008-10-26 10:11:34 +00:00
|
|
|
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() &&
|
2018-03-22 18:20:41 +00:00
|
|
|
tableFrame->BCRecalcNeeded(aOldComputedStyle, Style())) {
|
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) {
|
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);
|
2017-09-13 10:00:25 +00:00
|
|
|
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
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
|
|
|
}
|
2016-07-21 10:36:39 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
1998-07-11 00:00:31 +00:00
|
|
|
}
|
|
|
|
|
2017-05-05 06:30:15 +00:00
|
|
|
void nsTableColFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) {
|
2019-05-20 23:15:19 +00:00
|
|
|
// Per https://drafts.csswg.org/css-tables-3/#global-style-overrides:
|
|
|
|
// "All css properties of table-column and table-column-group boxes are
|
|
|
|
// ignored, except when explicitly specified by this specification."
|
|
|
|
// CSS outlines and box-shadows fall into this category, so we skip them
|
|
|
|
// on these boxes.
|
2019-05-20 23:16:09 +00:00
|
|
|
MOZ_ASSERT_UNREACHABLE("Cols don't paint themselves");
|
2017-05-05 06:30:15 +00:00
|
|
|
}
|
|
|
|
|
2019-08-21 20:02:13 +00:00
|
|
|
int32_t nsTableColFrame::GetSpan() { return StyleTable()->mXSpan; }
|
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) {
|
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", int32_t(mMinCoord),
|
2012-01-22 22:48:34 +00:00
|
|
|
int32_t(mPrefCoord), mHasSpecifiedCoord ? 's' : 'u', mPrefPercent,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t(mSpanMinCoord), int32_t(mSpanPrefCoord), 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
|
|
|
|
2019-04-16 07:24:49 +00:00
|
|
|
nsTableColFrame* NS_NewTableColFrame(PresShell* aPresShell,
|
2018-03-22 18:20:41 +00:00
|
|
|
ComputedStyle* aStyle) {
|
2019-02-05 16:45:54 +00:00
|
|
|
return new (aPresShell) nsTableColFrame(aStyle, aPresShell->GetPresContext());
|
1998-07-11 00:00:31 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableColFrame)
|
|
|
|
|
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) {
|
2017-04-30 15:30:08 +00:00
|
|
|
if (childFrame->IsTableColFrame()) {
|
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
|
|
|
}
|
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsresult nsTableColFrame::GetFrameName(nsAString& aResult) const {
|
|
|
|
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
|
|
|
|
2018-04-04 04:15:49 +00:00
|
|
|
void nsTableColFrame::InvalidateFrame(uint32_t aDisplayItemKey,
|
|
|
|
bool aRebuildDisplayItems) {
|
|
|
|
nsIFrame::InvalidateFrame(aDisplayItemKey, aRebuildDisplayItems);
|
2018-06-07 08:31:38 +00:00
|
|
|
if (GetTableFrame()->IsBorderCollapse()) {
|
2018-04-04 04:15:49 +00:00
|
|
|
GetParent()->InvalidateFrameWithRect(
|
|
|
|
GetVisualOverflowRect() + GetPosition(), aDisplayItemKey, false);
|
2017-11-07 05:47:13 +00:00
|
|
|
}
|
2012-08-29 05:48:45 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 04:15:49 +00:00
|
|
|
void nsTableColFrame::InvalidateFrameWithRect(const nsRect& aRect,
|
|
|
|
uint32_t aDisplayItemKey,
|
|
|
|
bool aRebuildDisplayItems) {
|
|
|
|
nsIFrame::InvalidateFrameWithRect(aRect, aDisplayItemKey,
|
|
|
|
aRebuildDisplayItems);
|
2012-08-29 05:48:45 +00:00
|
|
|
|
|
|
|
// If we have filters applied that would affects our bounds, then
|
|
|
|
// we get an inactive layer created and this is computed
|
|
|
|
// within FrameLayerBuilder
|
2018-04-04 04:15:49 +00:00
|
|
|
GetParent()->InvalidateFrameWithRect(aRect + GetPosition(), aDisplayItemKey,
|
|
|
|
false);
|
2012-08-29 05:39:31 +00:00
|
|
|
}
|