2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
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
|
|
|
{
|
|
|
|
PRUint32 type = aType - eColGroupContent;
|
|
|
|
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,
|
2000-01-22 01:16:50 +00:00
|
|
|
PRInt32 aFirstColIndex,
|
|
|
|
nsIFrame* aStartColFrame)
|
1998-09-16 17:19:20 +00:00
|
|
|
{
|
1999-12-13 22:56:31 +00:00
|
|
|
nsTableColGroupFrame* colGroupFrame = (nsTableColGroupFrame*)aFirstColGroup;
|
|
|
|
PRInt32 colIndex = aFirstColIndex;
|
|
|
|
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
|
|
|
|
// the whole colgroup (aStartColFrame defaults to nsnull) 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)) {
|
2004-01-09 14:20:53 +00:00
|
|
|
colFrame = colGroupFrame->GetFirstChild(nsnull);
|
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
|
2009-07-30 17:23:32 +00:00
|
|
|
nsTableColGroupFrame::AddColsToTable(PRInt32 aFirstColIndex,
|
|
|
|
PRBool aResetSubsequentColIndices,
|
|
|
|
const nsFrameList::Slice& aCols)
|
1999-12-13 22:56:31 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2009-07-30 17:23:32 +00:00
|
|
|
if (!tableFrame)
|
2006-03-04 05:26:57 +00:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-12-13 22:56:31 +00:00
|
|
|
|
|
|
|
// set the col indices of the col frames and and add col info to the table
|
|
|
|
PRInt32 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
|
|
|
|
1998-09-23 21:48:26 +00:00
|
|
|
return rv;
|
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();
|
|
|
|
|
|
|
|
nsIFrame* nextToLastColGroup = nsnull;
|
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()) {
|
|
|
|
return nsnull; // there are no col group frames
|
|
|
|
}
|
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
|
2006-04-10 00:16:29 +00:00
|
|
|
nsTableColGroupFrame::SetInitialChildList(nsIAtom* aListName,
|
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;
|
|
|
|
}
|
|
|
|
if (aListName) {
|
|
|
|
// All we know about is the unnamed principal child list
|
|
|
|
NS_NOTREACHED("unknown frame list");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2001-03-13 06:38:59 +00:00
|
|
|
|
2009-07-28 12:53:20 +00:00
|
|
|
if (aChildList.IsEmpty()) {
|
2009-07-28 12:53:18 +00:00
|
|
|
tableFrame->AppendAnonymousColFrames(this, GetSpan(), eColAnonymousColGroup,
|
|
|
|
PR_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)
|
|
|
|
{
|
|
|
|
if (!aOldStyleContext) //avoid this on init
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2008-11-03 18:30:38 +00:00
|
|
|
|
2008-10-26 10:11:34 +00:00
|
|
|
if (tableFrame->IsBorderCollapse() &&
|
|
|
|
tableFrame->BCRecalcNeeded(aOldStyleContext, GetStyleContext())) {
|
2008-11-03 18:30:38 +00:00
|
|
|
PRInt32 colCount = GetColCount();
|
|
|
|
if (!colCount)
|
|
|
|
return; // this is a degenerated colgroup
|
|
|
|
nsRect damageArea(GetFirstColumn()->GetColIndex(), 0, colCount,
|
2008-10-26 10:11:34 +00:00
|
|
|
tableFrame->GetRowCount());
|
|
|
|
tableFrame->SetBCDamageArea(damageArea);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-08-06 14:34:56 +00:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsTableColGroupFrame::AppendFrames(nsIAtom* aListName,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-08-06 14:34:56 +00:00
|
|
|
{
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
|
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();
|
|
|
|
RemoveFrame(nsnull, col);
|
|
|
|
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
|
2005-02-07 01:58:25 +00:00
|
|
|
nsTableColGroupFrame::InsertFrames(nsIAtom* aListName,
|
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
|
|
|
{
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
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
|
|
|
|
aPrevFrame = nsnull;
|
|
|
|
}
|
2005-09-12 13:44:15 +00:00
|
|
|
RemoveFrame(nsnull, col);
|
|
|
|
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
|
|
|
|
2005-09-12 13:44:15 +00:00
|
|
|
PRInt32 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
|
2009-07-30 17:23:32 +00:00
|
|
|
nsTableColGroupFrame::InsertColsReflow(PRInt32 aColIndex,
|
|
|
|
const nsFrameList::Slice& aCols)
|
1999-12-13 22:56:31 +00:00
|
|
|
{
|
2009-07-30 17:23:32 +00:00
|
|
|
AddColsToTable(aColIndex, PR_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,
|
2004-05-03 18:31:34 +00:00
|
|
|
PRBool aResetSubsequentColIndices)
|
1999-12-13 22:56:31 +00:00
|
|
|
{
|
|
|
|
PRInt32 colIndex = 0;
|
|
|
|
nsIFrame* nextChild = nsnull;
|
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
|
2005-02-07 01:58:25 +00:00
|
|
|
nsTableColGroupFrame::RemoveFrame(nsIAtom* aListName,
|
1999-08-06 14:34:56 +00:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
if (!aOldFrame) return NS_OK;
|
2010-03-06 09:53:02 +00:00
|
|
|
PRBool contentRemoval = PR_FALSE;
|
|
|
|
|
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) {
|
2010-03-06 09:53:02 +00:00
|
|
|
contentRemoval = PR_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
|
|
|
|
nsIFrame* providerFrame;
|
|
|
|
PRBool isChild;
|
|
|
|
colFrame->GetParentStyleContextFrame(PresContext(), &providerFrame,
|
|
|
|
&isChild);
|
|
|
|
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();
|
|
|
|
RemoveFrame(nsnull, col);
|
|
|
|
col = nextCol;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
PRInt32 colIndex = colFrame->GetColIndex();
|
2009-05-11 13:17:25 +00:00
|
|
|
// The RemoveChild call handles calling FrameNeedsReflow on us.
|
2005-02-07 01:58:25 +00:00
|
|
|
RemoveChild(*colFrame, PR_TRUE);
|
1999-12-13 22:56:31 +00:00
|
|
|
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2001-03-13 06:38:59 +00:00
|
|
|
|
2005-02-07 01:58:25 +00:00
|
|
|
tableFrame->RemoveCol(this, colIndex, PR_TRUE, PR_TRUE);
|
2010-03-06 09:53:02 +00:00
|
|
|
if (mFrames.IsEmpty() && contentRemoval &&
|
|
|
|
GetColType() == eColGroupContent) {
|
|
|
|
tableFrame->AppendAnonymousColFrames(this, GetSpan(),
|
|
|
|
eColAnonymousColGroup, PR_TRUE);
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
1998-10-20 17:45:07 +00:00
|
|
|
PRIntn
|
|
|
|
nsTableColGroupFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
2006-02-21 21:33:47 +00:00
|
|
|
if (nsnull != GetPrevInFlow()) {
|
1998-10-20 17:45:07 +00:00
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
2006-02-21 21:33:47 +00:00
|
|
|
if (nsnull != 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);
|
1998-05-28 21:39:22 +00:00
|
|
|
NS_ASSERTION(nsnull!=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();
|
|
|
|
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
|
|
|
|
if (collapseGroup) {
|
2006-03-04 05:26:57 +00:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2004-04-28 16:42:59 +00:00
|
|
|
if (tableFrame) {
|
2006-03-04 05:26:57 +00:00
|
|
|
tableFrame->SetNeedToCollapse(PR_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);
|
2001-12-07 14:51:12 +00:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, nsnull, 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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* virtual */ PRBool
|
|
|
|
nsTableColGroupFrame::IsContainingBlock() const
|
1998-10-15 21:07:37 +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
|
|
|
return PR_TRUE;
|
1998-05-28 21:39:22 +00:00
|
|
|
}
|
|
|
|
|
1998-10-14 22:51:50 +00:00
|
|
|
nsTableColFrame * nsTableColGroupFrame::GetFirstColumn()
|
|
|
|
{
|
|
|
|
return GetNextColumn(nsnull);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableColFrame * nsTableColGroupFrame::GetNextColumn(nsIFrame *aChildFrame)
|
|
|
|
{
|
|
|
|
nsTableColFrame *result = nsnull;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1998-09-23 21:48:26 +00:00
|
|
|
PRInt32 nsTableColGroupFrame::GetSpan()
|
|
|
|
{
|
2008-02-15 04:19:28 +00:00
|
|
|
return GetStyleTable()->mSpan;
|
1998-09-23 21:48:26 +00:00
|
|
|
}
|
|
|
|
|
2004-03-09 06:48:35 +00:00
|
|
|
void nsTableColGroupFrame::SetContinuousBCBorderWidth(PRUint8 aForSide,
|
|
|
|
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
|
|
|
{
|
2007-02-07 07:46:44 +00:00
|
|
|
PRInt32 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);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
void nsTableColGroupFrame::Dump(PRInt32 aIndent)
|
|
|
|
{
|
|
|
|
char* indent = new char[aIndent + 1];
|
|
|
|
if (!indent) return;
|
|
|
|
for (PRInt32 i = 0; i < aIndent + 1; i++) {
|
|
|
|
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
|
|
|
|
PRInt32 j = GetStartColumnIndex();
|
|
|
|
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
|