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/. */
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsTableColGroupFrame.h"
|
2019-04-06 09:02:28 +03:00
|
|
|
|
|
|
|
#include "mozilla/ComputedStyle.h"
|
|
|
|
#include "mozilla/PresShell.h"
|
1998-06-17 20:38:24 +04:00
|
|
|
#include "nsTableColFrame.h"
|
1998-09-01 01:23:28 +04:00
|
|
|
#include "nsTableFrame.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1998-09-24 01:48:26 +04:00
|
|
|
#include "nsHTMLParts.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1999-02-11 18:56:23 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1999-06-08 01:10:25 +04:00
|
|
|
#include "nsCSSRendering.h"
|
1998-05-29 01:39:22 +04:00
|
|
|
|
2014-06-28 14:13:14 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2017-09-01 23:30:57 +03:00
|
|
|
#define COLGROUP_SYNTHETIC_BIT NS_FRAME_STATE_BIT(30)
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2017-09-01 23:30:57 +03:00
|
|
|
bool nsTableColGroupFrame::IsSynthetic() const {
|
|
|
|
return HasAnyStateBits(COLGROUP_SYNTHETIC_BIT);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
1998-09-15 21:58:24 +04:00
|
|
|
|
2017-09-01 23:30:57 +03:00
|
|
|
void nsTableColGroupFrame::SetIsSynthetic() {
|
|
|
|
AddStateBits(COLGROUP_SYNTHETIC_BIT);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
2004-01-18 13:28:40 +03:00
|
|
|
void nsTableColGroupFrame::ResetColIndices(nsIFrame* aFirstColGroup,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aFirstColIndex,
|
2000-01-22 04:16:50 +03:00
|
|
|
nsIFrame* aStartColFrame) {
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableColGroupFrame* colGroupFrame = (nsTableColGroupFrame*)aFirstColGroup;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colIndex = aFirstColIndex;
|
1999-12-14 01:56:31 +03:00
|
|
|
while (colGroupFrame) {
|
2017-04-30 18:30:08 +03:00
|
|
|
if (colGroupFrame->IsTableColGroupFrame()) {
|
2006-06-24 09:42:38 +04:00
|
|
|
// reset the starting col index for the first cg only if we should reset
|
2012-07-30 18:20:58 +04:00
|
|
|
// the whole colgroup (aStartColFrame defaults to nullptr) or if
|
2000-04-04 08:28:18 +04:00
|
|
|
// aFirstColIndex is smaller than the existing starting col index
|
|
|
|
if ((colIndex != aFirstColIndex) ||
|
2006-06-24 09:42:38 +04:00
|
|
|
(colIndex < colGroupFrame->GetStartColumnIndex()) ||
|
|
|
|
!aStartColFrame) {
|
2000-04-04 08:28:18 +04:00
|
|
|
colGroupFrame->SetStartColumnIndex(colIndex);
|
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
nsIFrame* colFrame = aStartColFrame;
|
1999-12-14 01:56:31 +03:00
|
|
|
if (!colFrame || (colIndex != aFirstColIndex)) {
|
2016-01-29 17:42:14 +03:00
|
|
|
colFrame = colGroupFrame->PrincipalChildList().FirstChild();
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
while (colFrame) {
|
2017-04-30 18:30:08 +03:00
|
|
|
if (colFrame->IsTableColFrame()) {
|
1999-12-14 01:56:31 +03:00
|
|
|
((nsTableColFrame*)colFrame)->SetColIndex(colIndex);
|
|
|
|
colIndex++;
|
1999-08-10 06:45:18 +04:00
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
colFrame = colFrame->GetNextSibling();
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
2007-07-08 11:08:04 +04:00
|
|
|
colGroupFrame =
|
|
|
|
static_cast<nsTableColGroupFrame*>(colGroupFrame->GetNextSibling());
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult nsTableColGroupFrame::AddColsToTable(int32_t aFirstColIndex,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aResetSubsequentColIndices,
|
2009-07-30 21:23:32 +04:00
|
|
|
const nsFrameList::Slice& aCols) {
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2012-08-29 09:39:31 +04:00
|
|
|
tableFrame->InvalidateFrameSubtree();
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// set the col indices of the col frames and and add col info to the table
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colIndex = aFirstColIndex;
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList::Enumerator e(aCols);
|
|
|
|
for (; !e.AtEnd(); e.Next()) {
|
|
|
|
((nsTableColFrame*)e.get())->SetColIndex(colIndex);
|
|
|
|
mColCount++;
|
|
|
|
tableFrame->InsertCol((nsTableColFrame&)*e.get(), colIndex);
|
|
|
|
colIndex++;
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
2009-07-30 21:23:32 +04:00
|
|
|
|
|
|
|
for (nsFrameList::Enumerator eTail = e.GetUnlimitedEnumerator();
|
|
|
|
!eTail.AtEnd(); eTail.Next()) {
|
|
|
|
((nsTableColFrame*)eTail.get())->SetColIndex(colIndex);
|
|
|
|
colIndex++;
|
|
|
|
}
|
|
|
|
|
2004-05-03 22:31:34 +04:00
|
|
|
// We have already set the colindex for all the colframes in this
|
|
|
|
// colgroup that come after the first inserted colframe, but there could
|
|
|
|
// be other colgroups following this one and their colframes need
|
|
|
|
// correct colindices too.
|
2003-07-07 06:01:29 +04:00
|
|
|
if (aResetSubsequentColIndices && GetNextSibling()) {
|
2004-01-18 13:28:40 +03:00
|
|
|
ResetColIndices(GetNextSibling(), colIndex);
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2012-01-17 03:38:10 +04:00
|
|
|
return NS_OK;
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
2009-07-30 21:23:32 +04:00
|
|
|
nsTableColGroupFrame* nsTableColGroupFrame::GetLastRealColGroup(
|
|
|
|
nsTableFrame* aTableFrame) {
|
1999-12-14 01:56:31 +03:00
|
|
|
nsFrameList colGroups = aTableFrame->GetColGroups();
|
|
|
|
|
2017-09-01 23:30:57 +03:00
|
|
|
auto lastColGroup = static_cast<nsTableColGroupFrame*>(colGroups.LastChild());
|
|
|
|
if (!lastColGroup) {
|
|
|
|
return nullptr;
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
2017-09-01 23:30:57 +03:00
|
|
|
if (!lastColGroup->IsSynthetic()) {
|
|
|
|
return lastColGroup;
|
2009-07-30 21:23:32 +04:00
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2017-09-01 23:30:57 +03:00
|
|
|
return static_cast<nsTableColGroupFrame*>(lastColGroup->GetPrevSibling());
|
1998-09-17 03:24:39 +04:00
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// don't set mColCount here, it is done in AddColsToTable
|
2011-08-25 00:54:30 +04:00
|
|
|
void nsTableColGroupFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList) {
|
2014-05-28 23:36:58 +04:00
|
|
|
MOZ_ASSERT(mFrames.IsEmpty(),
|
|
|
|
"unexpected second call to SetInitialChildList");
|
|
|
|
MOZ_ASSERT(aListID == kPrincipalList, "unexpected child list");
|
2019-03-29 20:34:17 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
for (nsIFrame* f : aChildList) {
|
|
|
|
MOZ_ASSERT(f->GetParent() == this, "Unexpected parent");
|
|
|
|
}
|
|
|
|
#endif
|
2017-07-06 15:00:35 +03:00
|
|
|
if (aChildList.IsEmpty()) {
|
2015-04-30 07:24:59 +03:00
|
|
|
GetTableFrame()->AppendAnonymousColFrames(this, GetSpan(),
|
|
|
|
eColAnonymousColGroup, false);
|
2017-07-06 15:00:35 +03:00
|
|
|
return;
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mFrames.AppendFrames(this, aChildList);
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
void nsTableColGroupFrame::DidSetComputedStyle(
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aOldComputedStyle) {
|
|
|
|
nsContainerFrame::DidSetComputedStyle(aOldComputedStyle);
|
2012-08-14 01:13:34 +04:00
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
if (!aOldComputedStyle) // avoid this on init
|
2008-10-26 13:11:34 +03:00
|
|
|
return;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2008-10-26 13:11:34 +03:00
|
|
|
if (tableFrame->IsBorderCollapse() &&
|
2018-03-22 21:20:41 +03:00
|
|
|
tableFrame->BCRecalcNeeded(aOldComputedStyle, Style())) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colCount = GetColCount();
|
2017-07-06 15:00:35 +03:00
|
|
|
if (!colCount) return; // this is a degenerated colgroup
|
2015-05-01 00:46:59 +03:00
|
|
|
TableArea damageArea(GetFirstColumn()->GetColIndex(), 0, colCount,
|
2012-01-23 02:48:34 +04:00
|
|
|
tableFrame->GetRowCount());
|
2011-10-27 17:58:44 +04:00
|
|
|
tableFrame->AddBCDamageArea(damageArea);
|
2008-10-26 13:11:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
void nsTableColGroupFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList) {
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2006-06-29 06:32:36 +04:00
|
|
|
|
2005-09-12 17:44:15 +04:00
|
|
|
nsTableColFrame* col = GetFirstColumn();
|
|
|
|
nsTableColFrame* nextCol;
|
|
|
|
while (col && col->GetColType() == eColAnonymousColGroup) {
|
|
|
|
// this colgroup spans one or more columns but now that there is a
|
2007-11-20 07:29:40 +03:00
|
|
|
// real column below, spanned anonymous columns should be removed,
|
|
|
|
// since the HTML spec says to ignore the span of a colgroup if it
|
|
|
|
// has content columns in it.
|
2005-09-12 17:44:15 +04:00
|
|
|
nextCol = col->GetNextCol();
|
2011-08-25 00:54:30 +04:00
|
|
|
RemoveFrame(kPrincipalList, col);
|
2005-09-12 17:44:15 +04:00
|
|
|
col = nextCol;
|
|
|
|
}
|
|
|
|
|
2017-08-10 19:43:05 +03:00
|
|
|
// Our next colframe should be an eColContent. We've removed all the
|
|
|
|
// eColAnonymousColGroup colframes, eColAnonymousCol colframes always follow
|
2017-09-01 23:30:57 +03:00
|
|
|
// eColContent ones, and eColAnonymousCell colframes only appear in a
|
|
|
|
// synthetic colgroup, which never gets AppendFrames() called on it.
|
2017-08-10 19:43:05 +03:00
|
|
|
MOZ_ASSERT(!col || col->GetColType() == eColContent,
|
|
|
|
"What's going on with our columns?");
|
|
|
|
|
2009-07-30 21:23:32 +04:00
|
|
|
const nsFrameList::Slice& newFrames = mFrames.AppendFrames(this, aFrameList);
|
|
|
|
InsertColsReflow(GetStartColumnIndex() + mColCount, newFrames);
|
1999-08-06 18:34:56 +04:00
|
|
|
}
|
|
|
|
|
2019-07-18 02:34:45 +03:00
|
|
|
void nsTableColGroupFrame::InsertFrames(
|
|
|
|
ChildListID aListID, nsIFrame* aPrevFrame,
|
|
|
|
const nsLineList::iterator* aPrevFrameLine, nsFrameList& aFrameList) {
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
2005-09-12 17:44:15 +04:00
|
|
|
nsTableColFrame* col = GetFirstColumn();
|
|
|
|
nsTableColFrame* nextCol;
|
|
|
|
while (col && col->GetColType() == eColAnonymousColGroup) {
|
2007-11-20 07:29:40 +03:00
|
|
|
// this colgroup spans one or more columns but now that there is a
|
|
|
|
// real column below, spanned anonymous columns should be removed,
|
|
|
|
// since the HTML spec says to ignore the span of a colgroup if it
|
|
|
|
// has content columns in it.
|
2005-09-12 17:44:15 +04:00
|
|
|
nextCol = col->GetNextCol();
|
2009-04-16 01:44:53 +04:00
|
|
|
if (col == aPrevFrame) {
|
|
|
|
// This can happen when we're being appended to
|
|
|
|
NS_ASSERTION(!nextCol || nextCol->GetColType() != eColAnonymousColGroup,
|
|
|
|
"Inserting in the middle of our anonymous cols?");
|
|
|
|
// We'll want to insert at the beginning
|
2012-07-30 18:20:58 +04:00
|
|
|
aPrevFrame = nullptr;
|
2009-04-16 01:44:53 +04:00
|
|
|
}
|
2011-08-25 00:54:30 +04:00
|
|
|
RemoveFrame(kPrincipalList, col);
|
2005-09-12 17:44:15 +04:00
|
|
|
col = nextCol;
|
|
|
|
}
|
|
|
|
|
2017-08-10 19:43:05 +03:00
|
|
|
// Our next colframe should be an eColContent. We've removed all the
|
|
|
|
// eColAnonymousColGroup colframes, eColAnonymousCol colframes always follow
|
2017-09-01 23:30:57 +03:00
|
|
|
// eColContent ones, and eColAnonymousCell colframes only appear in a
|
|
|
|
// synthetic colgroup, which never gets InsertFrames() called on it.
|
2017-08-10 19:43:05 +03:00
|
|
|
MOZ_ASSERT(!col || col->GetColType() == eColContent,
|
|
|
|
"What's going on with our columns?");
|
|
|
|
|
2013-09-25 15:42:34 +04:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame == aPrevFrame->LastContinuation(),
|
2007-12-03 10:45:06 +03:00
|
|
|
"Prev frame should be last in continuation chain");
|
|
|
|
NS_ASSERTION(!aPrevFrame || !GetNextColumn(aPrevFrame) ||
|
|
|
|
GetNextColumn(aPrevFrame)->GetColType() != eColAnonymousCol,
|
|
|
|
"Shouldn't be inserting before a spanned colframe");
|
2007-11-20 07:29:40 +03:00
|
|
|
|
2009-07-30 21:23:32 +04:00
|
|
|
const nsFrameList::Slice& newFrames =
|
|
|
|
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
|
2017-05-01 20:32:52 +03:00
|
|
|
nsIFrame* prevFrame = nsTableFrame::GetFrameAtOrBefore(
|
|
|
|
this, aPrevFrame, LayoutFrameType::TableCol);
|
1999-08-06 18:34:56 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colIndex = (prevFrame)
|
|
|
|
? ((nsTableColFrame*)prevFrame)->GetColIndex() + 1
|
|
|
|
: GetStartColumnIndex();
|
2009-07-30 21:23:32 +04:00
|
|
|
InsertColsReflow(colIndex, newFrames);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsTableColGroupFrame::InsertColsReflow(int32_t aColIndex,
|
2009-07-30 21:23:32 +04:00
|
|
|
const nsFrameList::Slice& aCols) {
|
2011-10-17 18:59:28 +04:00
|
|
|
AddColsToTable(aColIndex, true, aCols);
|
1999-08-06 18:34:56 +04:00
|
|
|
|
2019-04-25 08:04:15 +03:00
|
|
|
PresShell()->FrameNeedsReflow(this, IntrinsicDirty::TreeChange,
|
2007-05-06 23:16:51 +04:00
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
2005-02-07 04:58:25 +03:00
|
|
|
void nsTableColGroupFrame::RemoveChild(nsTableColFrame& aChild,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aResetSubsequentColIndices) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colIndex = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIFrame* nextChild = nullptr;
|
2004-05-03 22:31:34 +04:00
|
|
|
if (aResetSubsequentColIndices) {
|
1999-12-14 01:56:31 +03:00
|
|
|
colIndex = aChild.GetColIndex();
|
2003-07-07 06:01:29 +04:00
|
|
|
nextChild = aChild.GetNextSibling();
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
2009-09-18 15:09:36 +04:00
|
|
|
mFrames.DestroyFrame(&aChild);
|
|
|
|
mColCount--;
|
|
|
|
if (aResetSubsequentColIndices) {
|
|
|
|
if (nextChild) { // reset inside this and all following colgroups
|
|
|
|
ResetColIndices(this, colIndex, nextChild);
|
|
|
|
} else {
|
|
|
|
nsIFrame* nextGroup = GetNextSibling();
|
|
|
|
if (nextGroup) // reset next and all following colgroups
|
|
|
|
ResetColIndices(nextGroup, colIndex);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
|
2019-04-25 08:04:15 +03:00
|
|
|
PresShell()->FrameNeedsReflow(this, IntrinsicDirty::TreeChange,
|
2017-11-09 05:00:48 +03:00
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-08-06 18:34:56 +04:00
|
|
|
}
|
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
void nsTableColGroupFrame::RemoveFrame(ChildListID aListID,
|
1999-08-06 18:34:56 +04:00
|
|
|
nsIFrame* aOldFrame) {
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2006-06-29 06:32:36 +04:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
if (!aOldFrame) {
|
|
|
|
return;
|
|
|
|
}
|
2011-09-29 10:19:26 +04:00
|
|
|
bool contentRemoval = false;
|
2017-04-30 18:30:08 +03:00
|
|
|
|
|
|
|
if (aOldFrame->IsTableColFrame()) {
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableColFrame* colFrame = (nsTableColFrame*)aOldFrame;
|
2007-11-09 09:05:19 +03:00
|
|
|
if (colFrame->GetColType() == eColContent) {
|
2011-10-17 18:59:28 +04:00
|
|
|
contentRemoval = true;
|
2007-11-09 09:05:19 +03:00
|
|
|
// Remove any anonymous column frames this <col> produced via a colspan
|
|
|
|
nsTableColFrame* col = colFrame->GetNextCol();
|
|
|
|
nsTableColFrame* nextCol;
|
|
|
|
while (col && col->GetColType() == eColAnonymousCol) {
|
2010-07-03 00:56:09 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
#endif
|
2007-11-09 09:05:19 +03:00
|
|
|
nextCol = col->GetNextCol();
|
2011-08-25 00:54:30 +04:00
|
|
|
RemoveFrame(kPrincipalList, col);
|
2007-11-09 09:05:19 +03:00
|
|
|
col = nextCol;
|
|
|
|
}
|
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colIndex = colFrame->GetColIndex();
|
2009-05-11 17:17:25 +04:00
|
|
|
// The RemoveChild call handles calling FrameNeedsReflow on us.
|
2011-10-17 18:59:28 +04:00
|
|
|
RemoveChild(*colFrame, true);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2011-10-17 18:59:28 +04:00
|
|
|
tableFrame->RemoveCol(this, colIndex, true, true);
|
2017-09-01 23:30:57 +03:00
|
|
|
if (mFrames.IsEmpty() && contentRemoval && !IsSynthetic()) {
|
2010-03-06 12:53:02 +03:00
|
|
|
tableFrame->AppendAnonymousColFrames(this, GetSpan(),
|
2011-10-17 18:59:28 +04:00
|
|
|
eColAnonymousColGroup, true);
|
2010-03-06 12:53:02 +03:00
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
} else {
|
2006-04-10 04:16:29 +04:00
|
|
|
mFrames.DestroyFrame(aOldFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
1999-08-06 18:34:56 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
nsIFrame::LogicalSides nsTableColGroupFrame::GetLogicalSkipSides(
|
|
|
|
const ReflowInput* aReflowInput) const {
|
2014-05-05 21:55:54 +04:00
|
|
|
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
|
2016-08-26 10:14:32 +03:00
|
|
|
StyleBoxDecorationBreak::Clone)) {
|
2014-06-28 14:13:13 +04:00
|
|
|
return LogicalSides();
|
2014-05-05 21:55:54 +04:00
|
|
|
}
|
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
LogicalSides skip;
|
2012-07-30 18:20:58 +04:00
|
|
|
if (nullptr != GetPrevInFlow()) {
|
2014-06-28 14:13:14 +04:00
|
|
|
skip |= eLogicalSideBitsBStart;
|
1998-10-20 21:45:07 +04:00
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
if (nullptr != GetNextInFlow()) {
|
2014-06-28 14:13:14 +04:00
|
|
|
skip |= eLogicalSideBitsBEnd;
|
1998-10-20 21:45:07 +04:00
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void nsTableColGroupFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2015-03-30 01:38:40 +03:00
|
|
|
nsReflowStatus& aStatus) {
|
2015-03-30 01:38:40 +03: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 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableColGroupFrame");
|
2016-07-21 13:36:39 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
2017-09-13 13:00:25 +03:00
|
|
|
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ASSERTION(nullptr != mContent, "bad state -- null content for frame");
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleVisibility* groupVis = StyleVisibility();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
|
2004-04-28 20:42:59 +04:00
|
|
|
if (collapseGroup) {
|
2015-04-30 07:24:59 +03:00
|
|
|
GetTableFrame()->SetNeedToCollapse(true);
|
2004-04-28 20:42:59 +04:00
|
|
|
}
|
1998-08-26 21:26:38 +04:00
|
|
|
// for every content child that (is a column thingy and does not already have
|
|
|
|
// a frame) create a frame and adjust it's style
|
2017-07-06 15:00:35 +03: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
|
|
|
for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame;
|
2003-07-07 06:01:29 +04:00
|
|
|
kidFrame = kidFrame->GetNextSibling()) {
|
1998-09-16 21:19:20 +04:00
|
|
|
// Give the child frame a chance to reflow, even though we know it'll have 0
|
|
|
|
// size
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowOutput kidSize(aReflowInput);
|
|
|
|
ReflowInput kidReflowInput(aPresContext, aReflowInput, kidFrame,
|
2014-07-24 12:28:46 +04:00
|
|
|
LogicalSize(kidFrame->GetWritingMode()));
|
1998-10-06 04:27:22 +04:00
|
|
|
|
|
|
|
nsReflowStatus status;
|
2019-08-08 22:48:19 +03:00
|
|
|
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowInput, 0, 0,
|
|
|
|
ReflowChildFlags::Default, status);
|
Bug 1547759 - Pass ReflowInput to FinishReflowChild in almost all cases. r=jfkthame
At first glance, it might look like this would change behavior, since
FinishReflowChild passes aReflowInput to DidReflow, which in turn
notifies aReflowInput's mPercentBSizeObserver. However, if you examine
how the mPercentBSizeObserver is propagated, it can only be set for the
anonymous block wrapping the children of table cells, the children of
table cells, or additionally a child of a table wrapper frame that has
it set (i.e., a table or its caption, when logically a child of a table
cell). Since all of the frames for which this is being changed are
either internal table elements that are inside of the table, or are
things that can never be a descendant of a table at all, there should be
no change in behavior.
Differential Revision: https://phabricator.services.mozilla.com/D40565
--HG--
extra : moz-landing-system : lando
2019-08-05 14:52:19 +03:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, kidSize, &kidReflowInput, 0, 0,
|
2019-08-08 22:48:19 +03:00
|
|
|
ReflowChildFlags::Default);
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
1998-09-17 03:24:39 +04:00
|
|
|
|
2014-07-24 12:30:07 +04:00
|
|
|
aDesiredSize.ClearSize();
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
1998-10-16 01:07:37 +04:00
|
|
|
}
|
|
|
|
|
2017-05-05 09:30:15 +03:00
|
|
|
void nsTableColGroupFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) {
|
2019-05-21 02:15:19 +03: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-21 02:16:09 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("Colgroups don't paint themselves");
|
2017-05-05 09:30:15 +03:00
|
|
|
}
|
|
|
|
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableColFrame* nsTableColGroupFrame::GetFirstColumn() {
|
2012-07-30 18:20:58 +04:00
|
|
|
return GetNextColumn(nullptr);
|
1998-10-15 02:51:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableColFrame* nsTableColGroupFrame::GetNextColumn(nsIFrame* aChildFrame) {
|
2012-07-30 18:20:58 +04:00
|
|
|
nsTableColFrame* result = nullptr;
|
1998-10-15 02:51:50 +04:00
|
|
|
nsIFrame* childFrame = aChildFrame;
|
2006-03-04 08:26:57 +03:00
|
|
|
if (!childFrame) {
|
1999-01-16 01:52:05 +03:00
|
|
|
childFrame = mFrames.FirstChild();
|
2006-03-04 08:26:57 +03:00
|
|
|
} else {
|
|
|
|
childFrame = childFrame->GetNextSibling();
|
|
|
|
}
|
|
|
|
while (childFrame) {
|
2016-08-28 05:31:50 +03:00
|
|
|
if (mozilla::StyleDisplay::TableColumn ==
|
2013-02-17 01:51:02 +04:00
|
|
|
childFrame->StyleDisplay()->mDisplay) {
|
1998-10-15 02:51:50 +04:00
|
|
|
result = (nsTableColFrame*)childFrame;
|
|
|
|
break;
|
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
1998-10-15 02:51:50 +04:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t nsTableColGroupFrame::GetSpan() { return StyleTable()->mSpan; }
|
1998-09-24 01:48:26 +04:00
|
|
|
|
2015-06-24 19:56:54 +03:00
|
|
|
void nsTableColGroupFrame::SetContinuousBCBorderWidth(LogicalSide aForSide,
|
2004-03-09 09:48:35 +03:00
|
|
|
BCPixelSize aPixelValue) {
|
|
|
|
switch (aForSide) {
|
2015-06-24 19:56:54 +03:00
|
|
|
case eLogicalSideBStart:
|
|
|
|
mBStartContBorderWidth = aPixelValue;
|
2004-03-09 09:48:35 +03:00
|
|
|
return;
|
2015-06-24 19:56:54 +03:00
|
|
|
case eLogicalSideBEnd:
|
|
|
|
mBEndContBorderWidth = aPixelValue;
|
2004-03-09 09:48:35 +03:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
NS_ERROR("invalid side arg");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-24 19:56:54 +03:00
|
|
|
void nsTableColGroupFrame::GetContinuousBCBorderWidth(WritingMode aWM,
|
|
|
|
LogicalMargin& aBorder) {
|
2017-09-13 02:48:00 +03:00
|
|
|
int32_t d2a = PresContext()->AppUnitsPerDevPixel();
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableColFrame* col =
|
|
|
|
GetTableFrame()->GetColFrame(mStartColIndex + mColCount - 1);
|
2015-06-24 19:56:54 +03:00
|
|
|
col->GetContinuousBCBorderWidth(aWM, aBorder);
|
2017-09-13 02:48:00 +03:00
|
|
|
aBorder.BStart(aWM) = BC_BORDER_END_HALF_COORD(d2a, mBStartContBorderWidth);
|
|
|
|
aBorder.BEnd(aWM) = BC_BORDER_START_HALF_COORD(d2a, mBEndContBorderWidth);
|
2004-03-09 09:48:35 +03:00
|
|
|
}
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
1998-06-17 20:38:24 +04:00
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
nsTableColGroupFrame* NS_NewTableColGroupFrame(PresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aStyle) {
|
2019-02-05 19:45:54 +03:00
|
|
|
return new (aPresShell)
|
|
|
|
nsTableColGroupFrame(aStyle, aPresShell->GetPresContext());
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-06-17 20:38:24 +04:00
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableColGroupFrame)
|
|
|
|
|
2018-04-04 07:15:49 +03:00
|
|
|
void nsTableColGroupFrame::InvalidateFrame(uint32_t aDisplayItemKey,
|
|
|
|
bool aRebuildDisplayItems) {
|
|
|
|
nsIFrame::InvalidateFrame(aDisplayItemKey, aRebuildDisplayItems);
|
2018-06-07 11:31:38 +03:00
|
|
|
if (GetTableFrame()->IsBorderCollapse()) {
|
2018-04-04 07:15:49 +03:00
|
|
|
GetParent()->InvalidateFrameWithRect(
|
|
|
|
GetVisualOverflowRect() + GetPosition(), aDisplayItemKey, false);
|
2017-11-07 08:47:13 +03:00
|
|
|
}
|
2012-08-29 09:48:45 +04:00
|
|
|
}
|
|
|
|
|
2017-04-30 18:30:08 +03:00
|
|
|
void nsTableColGroupFrame::InvalidateFrameWithRect(const nsRect& aRect,
|
2018-04-04 07:15:49 +03:00
|
|
|
uint32_t aDisplayItemKey,
|
|
|
|
bool aRebuildDisplayItems) {
|
|
|
|
nsIFrame::InvalidateFrameWithRect(aRect, aDisplayItemKey,
|
|
|
|
aRebuildDisplayItems);
|
2012-08-29 09:48:45 +04: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 07:15:49 +03:00
|
|
|
GetParent()->InvalidateFrameWithRect(aRect + GetPosition(), aDisplayItemKey,
|
|
|
|
false);
|
2012-08-29 09:39:31 +04:00
|
|
|
}
|
1999-10-02 04:02:54 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsresult nsTableColGroupFrame::GetFrameName(nsAString& aResult) const {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableColGroup"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
2004-09-04 20:02:50 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsTableColGroupFrame::Dump(int32_t aIndent) {
|
2004-09-04 20:02:50 +04:00
|
|
|
char* indent = new char[aIndent + 1];
|
|
|
|
if (!indent) return;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = 0; i < aIndent + 1; i++) {
|
2004-09-04 20:02:50 +04:00
|
|
|
indent[i] = ' ';
|
|
|
|
}
|
|
|
|
indent[aIndent] = 0;
|
|
|
|
|
2017-09-01 23:30:57 +03:00
|
|
|
printf(
|
|
|
|
"%s**START COLGROUP DUMP**\n%s startcolIndex=%d colcount=%d span=%d "
|
|
|
|
"isSynthetic=%s",
|
|
|
|
indent, indent, GetStartColumnIndex(), GetColCount(), GetSpan(),
|
|
|
|
IsSynthetic() ? "true" : "false");
|
|
|
|
|
2005-09-12 17:44:15 +04:00
|
|
|
// verify the colindices
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t j = GetStartColumnIndex();
|
2005-09-12 17:44:15 +04:00
|
|
|
nsTableColFrame* col = GetFirstColumn();
|
|
|
|
while (col) {
|
|
|
|
NS_ASSERTION(j == col->GetColIndex(), "wrong colindex on col frame");
|
|
|
|
col = col->GetNextCol();
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
NS_ASSERTION((j - GetStartColumnIndex()) == GetColCount(),
|
|
|
|
"number of cols out of sync");
|
2004-09-04 20:02:50 +04:00
|
|
|
printf("\n%s**END COLGROUP DUMP** ", indent);
|
|
|
|
delete[] indent;
|
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|