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/. */
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsTableColGroupFrame.h"
|
1998-06-17 16:38:24 +00:00
|
|
|
#include "nsTableColFrame.h"
|
1998-08-31 21:23:28 +00:00
|
|
|
#include "nsTableFrame.h"
|
1999-12-13 22:56:31 +00:00
|
|
|
#include "nsIDOMHTMLTableColElement.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsStyleConsts.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
1998-09-23 21:48:26 +00:00
|
|
|
#include "nsHTMLParts.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1999-02-11 15:56:23 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-06-07 21:10:25 +00:00
|
|
|
#include "nsCSSRendering.h"
|
1999-08-06 14:34:56 +00:00
|
|
|
#include "nsIPresShell.h"
|
1998-05-28 21:39:22 +00:00
|
|
|
|
2010-06-09 05:28:14 +00:00
|
|
|
#define COL_GROUP_TYPE_BITS (NS_FRAME_STATE_BIT(30) | \
|
|
|
|
NS_FRAME_STATE_BIT(31))
|
2001-11-30 15:05:51 +00:00
|
|
|
#define COL_GROUP_TYPE_OFFSET 30
|
1999-12-13 22:56:31 +00:00
|
|
|
|
2001-11-30 15:05:51 +00:00
|
|
|
nsTableColGroupType
|
2003-10-31 20:19:18 +00:00
|
|
|
nsTableColGroupFrame::GetColType() const
|
2001-11-30 15:05:51 +00:00
|
|
|
{
|
|
|
|
return (nsTableColGroupType)((mState & COL_GROUP_TYPE_BITS) >> COL_GROUP_TYPE_OFFSET);
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
1998-09-15 17:58:24 +00:00
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
void nsTableColGroupFrame::SetColType(nsTableColGroupType aType)
|
2001-11-30 15:05:51 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t type = aType - eColGroupContent;
|
2001-11-30 15:05:51 +00:00
|
|
|
mState |= (type << COL_GROUP_TYPE_OFFSET);
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
|
|
|
|
2004-01-18 10:28:40 +00:00
|
|
|
void nsTableColGroupFrame::ResetColIndices(nsIFrame* aFirstColGroup,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aFirstColIndex,
|
2000-01-22 01:16:50 +00:00
|
|
|
nsIFrame* aStartColFrame)
|
1998-09-16 17:19:20 +00:00
|
|
|
{
|
1999-12-13 22:56:31 +00:00
|
|
|
nsTableColGroupFrame* colGroupFrame = (nsTableColGroupFrame*)aFirstColGroup;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t colIndex = aFirstColIndex;
|
1999-12-13 22:56:31 +00:00
|
|
|
while (colGroupFrame) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (nsGkAtoms::tableColGroupFrame == colGroupFrame->GetType()) {
|
2006-06-24 05:42:38 +00:00
|
|
|
// reset the starting col index for the first cg only if we should reset
|
2012-07-30 14:20:58 +00:00
|
|
|
// the whole colgroup (aStartColFrame defaults to nullptr) or if
|
2000-04-04 04:28:18 +00:00
|
|
|
// aFirstColIndex is smaller than the existing starting col index
|
|
|
|
if ((colIndex != aFirstColIndex) ||
|
2006-06-24 05:42:38 +00:00
|
|
|
(colIndex < colGroupFrame->GetStartColumnIndex()) ||
|
|
|
|
!aStartColFrame) {
|
2000-04-04 04:28:18 +00:00
|
|
|
colGroupFrame->SetStartColumnIndex(colIndex);
|
|
|
|
}
|
1999-12-13 22:56:31 +00:00
|
|
|
nsIFrame* colFrame = aStartColFrame;
|
|
|
|
if (!colFrame || (colIndex != aFirstColIndex)) {
|
2011-08-24 20:54:30 +00:00
|
|
|
colFrame = colGroupFrame->GetFirstPrincipalChild();
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
|
|
|
while (colFrame) {
|
2006-12-26 17:47:52 +00:00
|
|
|
if (nsGkAtoms::tableColFrame == colFrame->GetType()) {
|
1999-12-13 22:56:31 +00:00
|
|
|
((nsTableColFrame*)colFrame)->SetColIndex(colIndex);
|
|
|
|
colIndex++;
|
1999-08-10 02:45:18 +00:00
|
|
|
}
|
2003-07-07 02:01:29 +00:00
|
|
|
colFrame = colFrame->GetNextSibling();
|
1998-10-14 16:32:45 +00:00
|
|
|
}
|
1998-09-23 21:48:26 +00:00
|
|
|
}
|
2007-07-08 07:08:04 +00:00
|
|
|
colGroupFrame = static_cast<nsTableColGroupFrame*>
|
|
|
|
(colGroupFrame->GetNextSibling());
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-03 18:31:34 +00:00
|
|
|
nsresult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsTableColGroupFrame::AddColsToTable(int32_t aFirstColIndex,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aResetSubsequentColIndices,
|
2009-07-30 17:23:32 +00:00
|
|
|
const nsFrameList::Slice& aCols)
|
1999-12-13 22:56:31 +00:00
|
|
|
{
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
1999-12-13 22:56:31 +00:00
|
|
|
|
2012-08-29 05:39:31 +00:00
|
|
|
tableFrame->InvalidateFrameSubtree();
|
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
// set the col indices of the col frames and and add col info to the table
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t colIndex = aFirstColIndex;
|
2009-07-30 17:23:32 +00: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-13 22:56:31 +00:00
|
|
|
}
|
2009-07-30 17:23:32 +00:00
|
|
|
|
|
|
|
for (nsFrameList::Enumerator eTail = e.GetUnlimitedEnumerator();
|
|
|
|
!eTail.AtEnd();
|
|
|
|
eTail.Next()) {
|
|
|
|
((nsTableColFrame*)eTail.get())->SetColIndex(colIndex);
|
|
|
|
colIndex++;
|
|
|
|
}
|
|
|
|
|
2004-05-03 18:31:34 +00: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 02:01:29 +00:00
|
|
|
if (aResetSubsequentColIndices && GetNextSibling()) {
|
2004-01-18 10:28:40 +00:00
|
|
|
ResetColIndices(GetNextSibling(), colIndex);
|
1998-09-23 21:48:26 +00:00
|
|
|
}
|
1999-12-13 22:56:31 +00:00
|
|
|
|
2012-01-16 23:38:10 +00:00
|
|
|
return NS_OK;
|
1998-09-16 17:19:20 +00:00
|
|
|
}
|
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
|
2009-07-30 17:23:32 +00:00
|
|
|
nsTableColGroupFrame*
|
|
|
|
nsTableColGroupFrame::GetLastRealColGroup(nsTableFrame* aTableFrame)
|
1999-12-13 22:56:31 +00:00
|
|
|
{
|
|
|
|
nsFrameList colGroups = aTableFrame->GetColGroups();
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIFrame* nextToLastColGroup = nullptr;
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList::FrameLinkEnumerator link(colGroups);
|
|
|
|
for ( ; !link.AtEnd(); link.Next()) {
|
|
|
|
nextToLastColGroup = link.PrevFrame();
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
|
|
|
|
2009-07-30 17:23:32 +00:00
|
|
|
if (!link.PrevFrame()) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr; // there are no col group frames
|
2009-07-30 17:23:32 +00:00
|
|
|
}
|
1999-12-13 22:56:31 +00:00
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsTableColGroupType lastColGroupType =
|
2009-07-30 17:23:32 +00:00
|
|
|
static_cast<nsTableColGroupFrame*>(link.PrevFrame())->GetColType();
|
1999-12-13 22:56:31 +00:00
|
|
|
if (eColGroupAnonymousCell == lastColGroupType) {
|
2009-07-30 17:23:32 +00:00
|
|
|
return static_cast<nsTableColGroupFrame*>(nextToLastColGroup);
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
2009-07-30 17:23:32 +00:00
|
|
|
|
|
|
|
return static_cast<nsTableColGroupFrame*>(link.PrevFrame());
|
1998-09-16 23:24:39 +00:00
|
|
|
}
|
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
// don't set mColCount here, it is done in AddColsToTable
|
1998-09-16 17:19:20 +00:00
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsTableColGroupFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList)
|
1998-09-16 17:19:20 +00:00
|
|
|
{
|
2006-04-09 18:43:46 +00:00
|
|
|
if (!mFrames.IsEmpty()) {
|
|
|
|
// We already have child frames which means we've already been
|
|
|
|
// initialized
|
|
|
|
NS_NOTREACHED("unexpected second call to SetInitialChildList");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2011-08-24 20:54:30 +00:00
|
|
|
if (aListID != kPrincipalList) {
|
|
|
|
// All we know about is the principal child list.
|
2006-04-09 18:43:46 +00:00
|
|
|
NS_NOTREACHED("unknown frame list");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2009-07-28 12:53:20 +00:00
|
|
|
if (aChildList.IsEmpty()) {
|
2009-07-28 12:53:18 +00:00
|
|
|
tableFrame->AppendAnonymousColFrames(this, GetSpan(), eColAnonymousColGroup,
|
2011-10-17 14:59:28 +00:00
|
|
|
false);
|
1999-12-13 22:56:31 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
mFrames.AppendFrames(this, aChildList);
|
|
|
|
return NS_OK;
|
1998-09-16 17:19:20 +00:00
|
|
|
}
|
|
|
|
|
2008-10-26 10:11:34 +00:00
|
|
|
/* virtual */ void
|
|
|
|
nsTableColGroupFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
|
|
|
{
|
2012-08-13 21:13:34 +00:00
|
|
|
nsContainerFrame::DidSetStyleContext(aOldStyleContext);
|
|
|
|
|
2008-10-26 10:11:34 +00:00
|
|
|
if (!aOldStyleContext) //avoid this on init
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (tableFrame->IsBorderCollapse() &&
|
|
|
|
tableFrame->BCRecalcNeeded(aOldStyleContext, GetStyleContext())) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t colCount = GetColCount();
|
2008-11-03 18:30:38 +00:00
|
|
|
if (!colCount)
|
|
|
|
return; // this is a degenerated colgroup
|
2012-01-22 22:48:34 +00:00
|
|
|
nsIntRect damageArea(GetFirstColumn()->GetColIndex(), 0, colCount,
|
|
|
|
tableFrame->GetRowCount());
|
2011-10-27 13:58:44 +00:00
|
|
|
tableFrame->AddBCDamageArea(damageArea);
|
2008-10-26 10:11:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-06 14:34:56 +00:00
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsTableColGroupFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-08-06 14:34:56 +00:00
|
|
|
{
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2006-06-29 02:32:36 +00:00
|
|
|
|
2005-09-12 13:44:15 +00: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 04:29:40 +00: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 13:44:15 +00:00
|
|
|
nextCol = col->GetNextCol();
|
2011-08-24 20:54:30 +00:00
|
|
|
RemoveFrame(kPrincipalList, col);
|
2005-09-12 13:44:15 +00:00
|
|
|
col = nextCol;
|
|
|
|
}
|
|
|
|
|
2009-07-30 17:23:32 +00:00
|
|
|
const nsFrameList::Slice& newFrames =
|
|
|
|
mFrames.AppendFrames(this, aFrameList);
|
|
|
|
InsertColsReflow(GetStartColumnIndex() + mColCount, newFrames);
|
1999-08-06 14:34:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsTableColGroupFrame::InsertFrames(ChildListID aListID,
|
2006-06-29 02:32:36 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-08-06 14:34:56 +00:00
|
|
|
{
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
2005-09-12 13:44:15 +00:00
|
|
|
nsTableColFrame* col = GetFirstColumn();
|
|
|
|
nsTableColFrame* nextCol;
|
|
|
|
while (col && col->GetColType() == eColAnonymousColGroup) {
|
2007-11-20 04:29:40 +00: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 13:44:15 +00:00
|
|
|
nextCol = col->GetNextCol();
|
2009-04-15 21:44:53 +00: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 14:20:58 +00:00
|
|
|
aPrevFrame = nullptr;
|
2009-04-15 21:44:53 +00:00
|
|
|
}
|
2011-08-24 20:54:30 +00:00
|
|
|
RemoveFrame(kPrincipalList, col);
|
2005-09-12 13:44:15 +00:00
|
|
|
col = nextCol;
|
|
|
|
}
|
|
|
|
|
2007-12-03 07:45:06 +00:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame == aPrevFrame->GetLastContinuation(),
|
|
|
|
"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 04:29:40 +00:00
|
|
|
|
2009-07-30 17:23:32 +00:00
|
|
|
const nsFrameList::Slice& newFrames =
|
|
|
|
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
|
2006-06-29 02:32:36 +00:00
|
|
|
nsIFrame* prevFrame = nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::tableColFrame);
|
1999-08-06 14:34:56 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t colIndex = (prevFrame) ? ((nsTableColFrame*)prevFrame)->GetColIndex() + 1 : GetStartColumnIndex();
|
2009-07-30 17:23:32 +00:00
|
|
|
InsertColsReflow(colIndex, newFrames);
|
1999-12-13 22:56:31 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsTableColGroupFrame::InsertColsReflow(int32_t aColIndex,
|
2009-07-30 17:23:32 +00:00
|
|
|
const nsFrameList::Slice& aCols)
|
1999-12-13 22:56:31 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
AddColsToTable(aColIndex, true, aCols);
|
1999-08-06 14:34:56 +00:00
|
|
|
|
2009-05-11 13:17:25 +00:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(this,
|
2007-05-06 19:16:51 +00:00
|
|
|
nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-02-07 01:58:25 +00:00
|
|
|
nsTableColGroupFrame::RemoveChild(nsTableColFrame& aChild,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aResetSubsequentColIndices)
|
1999-12-13 22:56:31 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t colIndex = 0;
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIFrame* nextChild = nullptr;
|
2004-05-03 18:31:34 +00:00
|
|
|
if (aResetSubsequentColIndices) {
|
1999-12-13 22:56:31 +00:00
|
|
|
colIndex = aChild.GetColIndex();
|
2003-07-07 02:01:29 +00:00
|
|
|
nextChild = aChild.GetNextSibling();
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
2009-09-18 11:09:36 +00: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-13 22:56:31 +00:00
|
|
|
}
|
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
|
2009-05-11 13:17:25 +00:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(this,
|
2007-05-06 19:16:51 +00:00
|
|
|
nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-08-06 14:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsTableColGroupFrame::RemoveFrame(ChildListID aListID,
|
1999-08-06 14:34:56 +00:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2006-06-29 02:32:36 +00:00
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
if (!aOldFrame) return NS_OK;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool contentRemoval = false;
|
2010-03-06 09:53:02 +00:00
|
|
|
|
2006-12-26 17:47:52 +00:00
|
|
|
if (nsGkAtoms::tableColFrame == aOldFrame->GetType()) {
|
1999-12-13 22:56:31 +00:00
|
|
|
nsTableColFrame* colFrame = (nsTableColFrame*)aOldFrame;
|
2007-11-09 06:05:19 +00:00
|
|
|
if (colFrame->GetColType() == eColContent) {
|
2011-10-17 14:59:28 +00:00
|
|
|
contentRemoval = true;
|
2007-11-09 06:05:19 +00: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-02 20:56:09 +00:00
|
|
|
#ifdef DEBUG
|
2011-09-12 16:08:07 +00:00
|
|
|
nsIFrame* providerFrame = colFrame->GetParentStyleContextFrame();
|
2010-07-02 20:56:09 +00:00
|
|
|
if (colFrame->GetStyleContext()->GetParent() ==
|
|
|
|
providerFrame->GetStyleContext()) {
|
|
|
|
NS_ASSERTION(col->GetStyleContext() == colFrame->GetStyleContext() &&
|
|
|
|
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 06:05:19 +00:00
|
|
|
nextCol = col->GetNextCol();
|
2011-08-24 20:54:30 +00:00
|
|
|
RemoveFrame(kPrincipalList, col);
|
2007-11-09 06:05:19 +00:00
|
|
|
col = nextCol;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t colIndex = colFrame->GetColIndex();
|
2009-05-11 13:17:25 +00:00
|
|
|
// The RemoveChild call handles calling FrameNeedsReflow on us.
|
2011-10-17 14:59:28 +00:00
|
|
|
RemoveChild(*colFrame, true);
|
1999-12-13 22:56:31 +00:00
|
|
|
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2011-10-17 14:59:28 +00:00
|
|
|
tableFrame->RemoveCol(this, colIndex, true, true);
|
2010-03-06 09:53:02 +00:00
|
|
|
if (mFrames.IsEmpty() && contentRemoval &&
|
|
|
|
GetColType() == eColGroupContent) {
|
|
|
|
tableFrame->AppendAnonymousColFrames(this, GetSpan(),
|
2011-10-17 14:59:28 +00:00
|
|
|
eColAnonymousColGroup, true);
|
2010-03-06 09:53:02 +00:00
|
|
|
}
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-04-10 00:16:29 +00:00
|
|
|
mFrames.DestroyFrame(aOldFrame);
|
1999-12-13 22:56:31 +00:00
|
|
|
}
|
1999-08-06 14:34:56 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-09 07:09:40 +00:00
|
|
|
int
|
1998-10-20 17:45:07 +00:00
|
|
|
nsTableColGroupFrame::GetSkipSides() const
|
|
|
|
{
|
2012-08-09 07:09:40 +00:00
|
|
|
int skip = 0;
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr != GetPrevInFlow()) {
|
1998-10-20 17:45:07 +00:00
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr != GetNextInFlow()) {
|
1998-10-20 17:45:07 +00:00
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_METHOD nsTableColGroupFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 04:10:00 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-13 20:24:54 +00: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 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableColGroupFrame");
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(nullptr!=mContent, "bad state -- null content for frame");
|
1998-10-15 21:07:37 +00:00
|
|
|
nsresult rv=NS_OK;
|
2004-04-28 16:42:59 +00:00
|
|
|
|
|
|
|
const nsStyleVisibility* groupVis = GetStyleVisibility();
|
2011-09-29 06:19:26 +00:00
|
|
|
bool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
|
2004-04-28 16:42:59 +00:00
|
|
|
if (collapseGroup) {
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2012-01-16 23:38:10 +00:00
|
|
|
tableFrame->SetNeedToCollapse(true);
|
2004-04-28 16:42:59 +00:00
|
|
|
}
|
1998-08-26 17:26:38 +00: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 16:42:59 +00: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 05:38:33 +00:00
|
|
|
for (nsIFrame *kidFrame = mFrames.FirstChild(); kidFrame;
|
2003-07-07 02:01:29 +00:00
|
|
|
kidFrame = kidFrame->GetNextSibling()) {
|
1998-09-16 17:19:20 +00:00
|
|
|
// Give the child frame a chance to reflow, even though we know it'll have 0 size
|
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
|
|
|
nsHTMLReflowMetrics kidSize;
|
1999-03-05 04:19:09 +00:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
|
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
|
|
|
nsSize(0,0));
|
1998-10-06 00:27:22 +00:00
|
|
|
|
|
|
|
nsReflowStatus status;
|
1999-11-19 15:33:29 +00:00
|
|
|
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, 0, 0, 0, status);
|
2012-07-30 14:20:58 +00:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, nullptr, kidSize, 0, 0, 0);
|
1998-09-16 17:19:20 +00:00
|
|
|
}
|
1998-09-16 23:24:39 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
aDesiredSize.width=0;
|
|
|
|
aDesiredSize.height=0;
|
1998-05-12 04:17:56 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-10-15 21:07:37 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-14 22:51:50 +00:00
|
|
|
nsTableColFrame * nsTableColGroupFrame::GetFirstColumn()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return GetNextColumn(nullptr);
|
1998-10-14 22:51:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableColFrame * nsTableColGroupFrame::GetNextColumn(nsIFrame *aChildFrame)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
nsTableColFrame *result = nullptr;
|
1998-10-14 22:51:50 +00:00
|
|
|
nsIFrame *childFrame = aChildFrame;
|
2006-03-04 05:26:57 +00:00
|
|
|
if (!childFrame) {
|
1999-01-15 22:52:05 +00:00
|
|
|
childFrame = mFrames.FirstChild();
|
2006-03-04 05:26:57 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
childFrame = childFrame->GetNextSibling();
|
|
|
|
}
|
|
|
|
while (childFrame)
|
1998-10-14 22:51:50 +00:00
|
|
|
{
|
2003-05-15 03:42:21 +00:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_COLUMN ==
|
|
|
|
childFrame->GetStyleDisplay()->mDisplay)
|
1998-10-14 22:51:50 +00:00
|
|
|
{
|
|
|
|
result = (nsTableColFrame *)childFrame;
|
|
|
|
break;
|
|
|
|
}
|
2003-07-07 02:01:29 +00:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
1998-10-14 22:51:50 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t nsTableColGroupFrame::GetSpan()
|
1998-09-23 21:48:26 +00:00
|
|
|
{
|
2008-02-15 04:19:28 +00:00
|
|
|
return GetStyleTable()->mSpan;
|
1998-09-23 21:48:26 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsTableColGroupFrame::SetContinuousBCBorderWidth(uint8_t aForSide,
|
2004-03-09 06:48:35 +00:00
|
|
|
BCPixelSize aPixelValue)
|
|
|
|
{
|
|
|
|
switch (aForSide) {
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
mTopContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
mBottomContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
NS_ERROR("invalid side arg");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-07 07:46:44 +00:00
|
|
|
void nsTableColGroupFrame::GetContinuousBCBorderWidth(nsMargin& aBorder)
|
2004-03-09 06:48:35 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* table = nsTableFrame::GetTableFrame(this);
|
2004-03-09 06:48:35 +00:00
|
|
|
nsTableColFrame* col = table->GetColFrame(mStartColIndex + mColCount - 1);
|
2007-02-07 07:46:44 +00:00
|
|
|
col->GetContinuousBCBorderWidth(aBorder);
|
2004-03-09 06:48:35 +00:00
|
|
|
aBorder.top = BC_BORDER_BOTTOM_HALF_COORD(aPixelsToTwips,
|
|
|
|
mTopContBorderWidth);
|
|
|
|
aBorder.bottom = BC_BORDER_TOP_HALF_COORD(aPixelsToTwips,
|
|
|
|
mBottomContBorderWidth);
|
|
|
|
}
|
|
|
|
|
1998-09-15 17:58:24 +00:00
|
|
|
/* ----- global methods ----- */
|
1998-06-17 16:38:24 +00:00
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewTableColGroupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsTableColGroupFrame(aContext);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-06-17 16:38:24 +00:00
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableColGroupFrame)
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsTableColGroupFrame::GetType() const
|
1999-10-02 00:02:54 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::tableColGroupFrame;
|
1999-10-02 00:02:54 +00:00
|
|
|
}
|
2012-08-29 05:39:31 +00:00
|
|
|
|
|
|
|
void
|
2012-08-29 05:48:45 +00:00
|
|
|
nsTableColGroupFrame::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
|
|
|
|
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 05:39:31 +00:00
|
|
|
}
|
1999-10-02 00:02:54 +00:00
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsTableColGroupFrame::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("TableColGroup"), aResult);
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
2004-09-04 16:02:50 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void nsTableColGroupFrame::Dump(int32_t aIndent)
|
2004-09-04 16:02:50 +00:00
|
|
|
{
|
|
|
|
char* indent = new char[aIndent + 1];
|
|
|
|
if (!indent) return;
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t i = 0; i < aIndent + 1; i++) {
|
2004-09-04 16:02:50 +00: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 13:44:15 +00:00
|
|
|
// verify the colindices
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t j = GetStartColumnIndex();
|
2005-09-12 13:44:15 +00: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 16:02:50 +00:00
|
|
|
printf("\n%s**END COLGROUP DUMP** ", indent);
|
|
|
|
delete [] indent;
|
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|