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"
|
1998-06-17 20:38:24 +04:00
|
|
|
#include "nsTableColFrame.h"
|
1998-09-01 01:23:28 +04:00
|
|
|
#include "nsTableFrame.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.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"
|
1999-08-06 18:34:56 +04:00
|
|
|
#include "nsIPresShell.h"
|
1998-05-29 01:39:22 +04:00
|
|
|
|
2014-06-28 14:13:14 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2010-06-09 09:28:14 +04:00
|
|
|
#define COL_GROUP_TYPE_BITS (NS_FRAME_STATE_BIT(30) | \
|
|
|
|
NS_FRAME_STATE_BIT(31))
|
2001-11-30 18:05:51 +03:00
|
|
|
#define COL_GROUP_TYPE_OFFSET 30
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2001-11-30 18:05:51 +03:00
|
|
|
nsTableColGroupType
|
2003-10-31 23:19:18 +03:00
|
|
|
nsTableColGroupFrame::GetColType() const
|
2001-11-30 18:05:51 +03:00
|
|
|
{
|
|
|
|
return (nsTableColGroupType)((mState & COL_GROUP_TYPE_BITS) >> COL_GROUP_TYPE_OFFSET);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
1998-09-15 21:58:24 +04:00
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
void nsTableColGroupFrame::SetColType(nsTableColGroupType aType)
|
2001-11-30 18:05:51 +03:00
|
|
|
{
|
2014-02-18 06:32:06 +04:00
|
|
|
NS_ASSERTION(GetColType() == eColGroupContent,
|
|
|
|
"should only call nsTableColGroupFrame::SetColType with aType "
|
|
|
|
"!= eColGroupContent once");
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t type = aType - eColGroupContent;
|
2014-02-18 06:32:06 +04:00
|
|
|
RemoveStateBits(COL_GROUP_TYPE_BITS);
|
|
|
|
AddStateBits(nsFrameState(type << COL_GROUP_TYPE_OFFSET));
|
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)
|
1998-09-16 21:19:20 +04:00
|
|
|
{
|
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) {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::tableColGroupFrame == colGroupFrame->GetType()) {
|
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);
|
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
nsIFrame* colFrame = aStartColFrame;
|
|
|
|
if (!colFrame || (colIndex != aFirstColIndex)) {
|
2011-08-25 00:54:30 +04:00
|
|
|
colFrame = colGroupFrame->GetFirstPrincipalChild();
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
while (colFrame) {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::tableColFrame == colFrame->GetType()) {
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-03 22:31:34 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
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)
|
1999-12-14 01:56:31 +03:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03: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();
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIFrame* nextToLastColGroup = nullptr;
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList::FrameLinkEnumerator link(colGroups);
|
|
|
|
for ( ; !link.AtEnd(); link.Next()) {
|
|
|
|
nextToLastColGroup = link.PrevFrame();
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
2009-07-30 21:23:32 +04:00
|
|
|
if (!link.PrevFrame()) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr; // there are no col group frames
|
2009-07-30 21:23:32 +04:00
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsTableColGroupType lastColGroupType =
|
2009-07-30 21:23:32 +04:00
|
|
|
static_cast<nsTableColGroupFrame*>(link.PrevFrame())->GetColType();
|
1999-12-14 01:56:31 +03:00
|
|
|
if (eColGroupAnonymousCell == lastColGroupType) {
|
2009-07-30 21:23:32 +04:00
|
|
|
return static_cast<nsTableColGroupFrame*>(nextToLastColGroup);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
2009-07-30 21:23:32 +04:00
|
|
|
|
|
|
|
return static_cast<nsTableColGroupFrame*>(link.PrevFrame());
|
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
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsTableColGroupFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
1998-09-16 21:19:20 +04:00
|
|
|
{
|
2014-05-28 23:36:58 +04:00
|
|
|
MOZ_ASSERT(mFrames.IsEmpty(),
|
|
|
|
"unexpected second call to SetInitialChildList");
|
|
|
|
MOZ_ASSERT(aListID == kPrincipalList, "unexpected child list");
|
|
|
|
if (aChildList.IsEmpty()) {
|
2015-04-30 07:24:59 +03:00
|
|
|
GetTableFrame()->AppendAnonymousColFrames(this, GetSpan(),
|
|
|
|
eColAnonymousColGroup, false);
|
2014-05-28 23:36:58 +04:00
|
|
|
return;
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
mFrames.AppendFrames(this, aChildList);
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
2008-10-26 13:11:34 +03:00
|
|
|
/* virtual */ void
|
|
|
|
nsTableColGroupFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
|
|
|
{
|
2012-08-14 01:13:34 +04:00
|
|
|
nsContainerFrame::DidSetStyleContext(aOldStyleContext);
|
|
|
|
|
2008-10-26 13:11:34 +03:00
|
|
|
if (!aOldStyleContext) //avoid this on init
|
|
|
|
return;
|
|
|
|
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2008-10-26 13:11:34 +03:00
|
|
|
if (tableFrame->IsBorderCollapse() &&
|
2013-02-16 09:38:33 +04:00
|
|
|
tableFrame->BCRecalcNeeded(aOldStyleContext, StyleContext())) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colCount = GetColCount();
|
2008-11-03 21:30:38 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsTableColGroupFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
1999-08-06 18:34:56 +04:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsTableColGroupFrame::InsertFrames(ChildListID aListID,
|
2006-06-29 06:32:36 +04:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
1999-08-06 18:34:56 +04:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
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);
|
2006-06-29 06:32:36 +04:00
|
|
|
nsIFrame* prevFrame = nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame,
|
2006-12-26 20:47:52 +03:00
|
|
|
nsGkAtoms::tableColFrame);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsTableColGroupFrame::InsertColsReflow(int32_t aColIndex,
|
2009-07-30 21:23:32 +04:00
|
|
|
const nsFrameList::Slice& aCols)
|
1999-12-14 01:56:31 +03:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
AddColsToTable(aColIndex, true, aCols);
|
1999-08-06 18:34:56 +04:00
|
|
|
|
2009-05-11 17:17:25 +04:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(this,
|
2007-05-06 23:16:51 +04:00
|
|
|
nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableColGroupFrame::RemoveChild(nsTableColFrame& aChild,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aResetSubsequentColIndices)
|
1999-12-14 01:56:31 +03:00
|
|
|
{
|
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
|
|
|
|
2009-05-11 17:17:25 +04:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(this,
|
2007-05-06 23:16:51 +04:00
|
|
|
nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-08-06 18:34:56 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
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;
|
2010-03-06 12:53:02 +03:00
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::tableColFrame == aOldFrame->GetType()) {
|
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
|
2014-11-20 21:24:10 +03:00
|
|
|
nsIFrame* providerFrame;
|
|
|
|
nsStyleContext* psc = colFrame->GetParentStyleContext(&providerFrame);
|
|
|
|
if (colFrame->StyleContext()->GetParent() == psc) {
|
2013-02-16 09:38:33 +04:00
|
|
|
NS_ASSERTION(col->StyleContext() == colFrame->StyleContext() &&
|
2010-07-03 00:56:09 +04:00
|
|
|
col->GetContent() == colFrame->GetContent(),
|
|
|
|
"How did that happen??");
|
|
|
|
}
|
|
|
|
// else colFrame is being removed because of a frame
|
|
|
|
// reconstruct on it, and its style context is still the old
|
|
|
|
// one, so we can't assert anything about how it compares to
|
|
|
|
// col's style context.
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
1999-12-14 01:56:31 +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);
|
2010-03-06 12:53:02 +03:00
|
|
|
if (mFrames.IsEmpty() && contentRemoval &&
|
|
|
|
GetColType() == eColGroupContent) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
nsIFrame::LogicalSides
|
2014-03-13 11:39:33 +04:00
|
|
|
nsTableColGroupFrame::GetLogicalSkipSides(const nsHTMLReflowState* aReflowState) const
|
1998-10-20 21:45:07 +04:00
|
|
|
{
|
2014-05-05 21:55:54 +04:00
|
|
|
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
|
|
|
|
NS_STYLE_BOX_DECORATION_BREAK_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,
|
2015-03-30 01:38:40 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
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");
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ASSERTION(nullptr!=mContent, "bad state -- null content for frame");
|
2004-04-28 20:42:59 +04: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
|
2004-04-28 20:42:59 +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
|
|
|
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
|
2013-12-31 17:50:31 +04:00
|
|
|
nsHTMLReflowMetrics kidSize(aReflowState);
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
|
2014-07-24 12:28:46 +04:00
|
|
|
LogicalSize(kidFrame->GetWritingMode()));
|
1998-10-06 04:27:22 +04:00
|
|
|
|
|
|
|
nsReflowStatus status;
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, 0, 0, 0, status);
|
2014-01-17 05:34:44 +04:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, kidSize, nullptr, 0, 0, 0);
|
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();
|
1998-05-12 08:17:56 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-10-16 01:07:37 +04: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)
|
1998-10-15 02:51:50 +04:00
|
|
|
{
|
2003-05-15 07:42:21 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN ==
|
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()
|
1998-09-24 01:48:26 +04:00
|
|
|
{
|
2013-02-17 01:51:02 +04:00
|
|
|
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)
|
2004-03-09 09:48:35 +03:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
|
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);
|
|
|
|
aBorder.BStart(aWM) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
|
|
|
|
mBStartContBorderWidth);
|
|
|
|
aBorder.BEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
|
|
|
|
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
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
nsTableColGroupFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewTableColGroupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsTableColGroupFrame(aContext);
|
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)
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsTableColGroupFrame::GetType() const
|
1999-10-02 04:02:54 +04:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::tableColGroupFrame;
|
1999-10-02 04:02:54 +04:00
|
|
|
}
|
2012-08-29 09:39:31 +04:00
|
|
|
|
|
|
|
void
|
2012-08-29 09:48:45 +04:00
|
|
|
nsTableColGroupFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
2012-08-29 09:39:31 +04:00
|
|
|
{
|
2012-08-29 09:48:45 +04:00
|
|
|
nsIFrame::InvalidateFrame(aDisplayItemKey);
|
|
|
|
GetParent()->InvalidateFrameWithRect(GetVisualOverflowRect() + GetPosition(), aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableColGroupFrame::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 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
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2001-11-14 04:33:42 +03:00
|
|
|
nsTableColGroupFrame::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("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;
|
|
|
|
|
|
|
|
printf("%s**START COLGROUP DUMP**\n%s startcolIndex=%d colcount=%d span=%d coltype=",
|
|
|
|
indent, indent, GetStartColumnIndex(), GetColCount(), GetSpan());
|
|
|
|
nsTableColGroupType colType = GetColType();
|
|
|
|
switch (colType) {
|
|
|
|
case eColGroupContent:
|
|
|
|
printf(" content ");
|
|
|
|
break;
|
|
|
|
case eColGroupAnonymousCol:
|
|
|
|
printf(" anonymous-column ");
|
|
|
|
break;
|
|
|
|
case eColGroupAnonymousCell:
|
|
|
|
printf(" anonymous-cell ");
|
|
|
|
break;
|
|
|
|
}
|
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
|
2014-07-24 12:28:46 +04:00
|
|
|
|