2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04: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-14 00:24:54 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04: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-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
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"
|
1999-12-14 01:56:31 +03:00
|
|
|
#include "nsIDOMHTMLTableColElement.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
|
|
|
|
2001-11-30 18:05:51 +03:00
|
|
|
#define COL_GROUP_TYPE_BITS 0xC0000000 // uses bits 31-32 from mState
|
|
|
|
#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
|
|
|
{
|
|
|
|
PRUint32 type = aType - eColGroupContent;
|
|
|
|
mState |= (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,
|
2000-01-22 04:16:50 +03:00
|
|
|
PRInt32 aFirstColIndex,
|
|
|
|
nsIFrame* aStartColFrame)
|
1998-09-16 21:19:20 +04:00
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableColGroupFrame* colGroupFrame = (nsTableColGroupFrame*)aFirstColGroup;
|
|
|
|
PRInt32 colIndex = aFirstColIndex;
|
|
|
|
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
|
|
|
|
// the whole colgroup (aStartColFrame defaults to nsnull) 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)) {
|
2004-01-09 17:20:53 +03:00
|
|
|
colFrame = colGroupFrame->GetFirstChild(nsnull);
|
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:56 +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
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableColGroupFrame::AddColsToTable(PRInt32 aFirstColIndex,
|
1999-12-14 01:56:31 +03:00
|
|
|
PRBool aResetSubsequentColIndices,
|
|
|
|
nsIFrame* aFirstFrame,
|
|
|
|
nsIFrame* aLastFrame)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame || !aFirstFrame)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
// set the col indices of the col frames and and add col info to the table
|
|
|
|
PRInt32 colIndex = aFirstColIndex;
|
|
|
|
nsIFrame* kidFrame = aFirstFrame;
|
|
|
|
PRBool foundLastFrame = PR_FALSE;
|
|
|
|
while (kidFrame) {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::tableColFrame == kidFrame->GetType()) {
|
1999-12-14 01:56:31 +03:00
|
|
|
((nsTableColFrame*)kidFrame)->SetColIndex(colIndex);
|
|
|
|
if (!foundLastFrame) {
|
|
|
|
mColCount++;
|
2005-02-07 04:58:25 +03:00
|
|
|
tableFrame->InsertCol((nsTableColFrame &)*kidFrame, colIndex);
|
1998-10-14 20:32:45 +04:00
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
colIndex++;
|
|
|
|
}
|
|
|
|
if (kidFrame == aLastFrame) {
|
|
|
|
foundLastFrame = PR_TRUE;
|
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
kidFrame = kidFrame->GetNextSibling();
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
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
|
|
|
|
1998-09-24 01:48:26 +04:00
|
|
|
return rv;
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsTableColGroupFrame::GetLastRealColGroup(nsTableFrame* aTableFrame,
|
|
|
|
nsIFrame** aLastColGroup)
|
|
|
|
{
|
|
|
|
*aLastColGroup = nsnull;
|
|
|
|
nsFrameList colGroups = aTableFrame->GetColGroups();
|
|
|
|
|
|
|
|
nsIFrame* nextToLastColGroup = nsnull;
|
|
|
|
nsIFrame* lastColGroup = colGroups.FirstChild();
|
|
|
|
while(lastColGroup) {
|
2003-07-07 06:01:29 +04:00
|
|
|
nsIFrame* next = lastColGroup->GetNextSibling();
|
1999-12-14 01:56:31 +03:00
|
|
|
if (next) {
|
|
|
|
nextToLastColGroup = lastColGroup;
|
|
|
|
lastColGroup = next;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lastColGroup) return PR_TRUE; // there are no col group frames
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsTableColGroupType lastColGroupType =
|
|
|
|
((nsTableColGroupFrame *)lastColGroup)->GetColType();
|
1999-12-14 01:56:31 +03:00
|
|
|
if (eColGroupAnonymousCell == lastColGroupType) {
|
|
|
|
*aLastColGroup = nextToLastColGroup;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aLastColGroup = lastColGroup;
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
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
|
1998-09-16 21:19:20 +04:00
|
|
|
NS_IMETHODIMP
|
2006-04-10 04:16:29 +04:00
|
|
|
nsTableColGroupFrame::SetInitialChildList(nsIAtom* aListName,
|
1998-11-10 09:05:32 +03:00
|
|
|
nsIFrame* aChildList)
|
1998-09-16 21:19:20 +04:00
|
|
|
{
|
2006-04-09 22:43:46 +04: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 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2001-03-13 09:38:59 +03:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
if (!aChildList) {
|
|
|
|
nsIFrame* firstChild;
|
2005-02-07 04:58:25 +03:00
|
|
|
tableFrame->CreateAnonymousColFrames(this, GetSpan(), eColAnonymousColGroup,
|
1999-12-14 01:56:31 +03:00
|
|
|
PR_FALSE, nsnull, &firstChild);
|
|
|
|
if (firstChild) {
|
2006-04-10 04:16:29 +04:00
|
|
|
SetInitialChildList(aListName, firstChild);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
mFrames.AppendFrames(this, aChildList);
|
|
|
|
return NS_OK;
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
1999-08-06 18:34:56 +04:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableColGroupFrame::AppendFrames(nsIAtom* aListName,
|
1999-08-06 18:34:56 +04:00
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
|
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();
|
|
|
|
RemoveFrame(nsnull, col);
|
|
|
|
col = nextCol;
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
mFrames.AppendFrames(this, aFrameList);
|
2005-09-12 17:44:15 +04:00
|
|
|
InsertColsReflow(GetStartColumnIndex() + mColCount, aFrameList);
|
1999-08-06 18:34:56 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableColGroupFrame::InsertFrames(nsIAtom* aListName,
|
2006-06-29 06:32:36 +04:00
|
|
|
nsIFrame* aPrevFrame,
|
1999-08-06 18:34:56 +04:00
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
nsFrameList frames(aFrameList); // convience for getting last frame
|
|
|
|
nsIFrame* lastFrame = frames.LastChild();
|
1999-08-06 18:34:56 +04:00
|
|
|
|
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.
|
2007-12-03 10:45:07 +03:00
|
|
|
NS_ASSERTION(col != aPrevFrame, "Bad aPrevFrame");
|
2005-09-12 17:44:15 +04:00
|
|
|
nextCol = col->GetNextCol();
|
|
|
|
RemoveFrame(nsnull, col);
|
|
|
|
col = nextCol;
|
|
|
|
}
|
|
|
|
|
2007-12-03 10:45:07 +03: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 07:29:40 +03:00
|
|
|
|
2006-06-29 06:32:36 +04:00
|
|
|
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
|
|
|
|
nsIFrame* prevFrame = nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame,
|
2006-12-26 20:47:52 +03:00
|
|
|
nsGkAtoms::tableColFrame);
|
1999-08-06 18:34:56 +04:00
|
|
|
|
2005-09-12 17:44:15 +04:00
|
|
|
PRInt32 colIndex = (prevFrame) ? ((nsTableColFrame*)prevFrame)->GetColIndex() + 1 : GetStartColumnIndex();
|
2005-02-07 04:58:25 +03:00
|
|
|
InsertColsReflow(colIndex, aFrameList, lastFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableColGroupFrame::InsertColsReflow(PRInt32 aColIndex,
|
1999-12-14 01:56:31 +03:00
|
|
|
nsIFrame* aFirstFrame,
|
|
|
|
nsIFrame* aLastFrame)
|
|
|
|
{
|
2005-02-07 04:58:25 +03:00
|
|
|
AddColsToTable(aColIndex, PR_TRUE, aFirstFrame, aLastFrame);
|
1999-08-06 18:34:56 +04:00
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return;
|
2001-03-13 09:38:59 +03:00
|
|
|
|
2007-03-31 01:11:47 +04:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(tableFrame,
|
2007-05-06 23:16:52 +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,
|
2004-05-03 22:31:34 +04:00
|
|
|
PRBool aResetSubsequentColIndices)
|
1999-12-14 01:56:31 +03:00
|
|
|
{
|
|
|
|
PRInt32 colIndex = 0;
|
|
|
|
nsIFrame* nextChild = nsnull;
|
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
|
|
|
}
|
2006-04-10 04:16:29 +04:00
|
|
|
if (mFrames.DestroyFrame((nsIFrame*)&aChild)) {
|
1999-12-14 01:56:31 +03:00
|
|
|
mColCount--;
|
2004-05-03 22:31:34 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return;
|
2001-03-13 09:38:59 +03:00
|
|
|
|
2007-03-31 01:11:47 +04:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(tableFrame,
|
2007-05-06 23:16:52 +04:00
|
|
|
nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-08-06 18:34:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableColGroupFrame::RemoveFrame(nsIAtom* aListName,
|
1999-08-06 18:34:56 +04:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(!aListName, "unexpected child list");
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
if (!aOldFrame) return NS_OK;
|
|
|
|
|
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) {
|
|
|
|
// Remove any anonymous column frames this <col> produced via a colspan
|
|
|
|
nsTableColFrame* col = colFrame->GetNextCol();
|
|
|
|
nsTableColFrame* nextCol;
|
|
|
|
while (col && col->GetColType() == eColAnonymousCol) {
|
|
|
|
NS_ASSERTION(col->GetStyleContext() == colFrame->GetStyleContext() &&
|
|
|
|
col->GetContent() == colFrame->GetContent(),
|
|
|
|
"How did that happen??");
|
|
|
|
nextCol = col->GetNextCol();
|
|
|
|
RemoveFrame(nsnull, col);
|
|
|
|
col = nextCol;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
PRInt32 colIndex = colFrame->GetColIndex();
|
2005-02-07 04:58:25 +03:00
|
|
|
RemoveChild(*colFrame, PR_TRUE);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2001-03-13 09:38:59 +03:00
|
|
|
|
2005-02-07 04:58:25 +03:00
|
|
|
tableFrame->RemoveCol(this, colIndex, PR_TRUE, PR_TRUE);
|
1999-08-06 18:34:56 +04:00
|
|
|
|
2007-03-31 01:11:47 +04:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(tableFrame,
|
2007-05-06 23:16:52 +04:00
|
|
|
nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
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
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
PRIntn
|
|
|
|
nsTableColGroupFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
2006-02-22 00:33:47 +03:00
|
|
|
if (nsnull != GetPrevInFlow()) {
|
1998-10-20 21:45:07 +04:00
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
2006-02-22 00:33:47 +03:00
|
|
|
if (nsnull != GetNextInFlow()) {
|
1998-10-20 21:45:07 +04:00
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_METHOD nsTableColGroupFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +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
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableColGroupFrame");
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1998-05-29 01:39:22 +04:00
|
|
|
NS_ASSERTION(nsnull!=mContent, "bad state -- null content for frame");
|
1998-10-16 01:07:37 +04:00
|
|
|
nsresult rv=NS_OK;
|
2004-04-28 20:42:59 +04:00
|
|
|
|
|
|
|
const nsStyleVisibility* groupVis = GetStyleVisibility();
|
|
|
|
PRBool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
|
|
|
|
if (collapseGroup) {
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2004-04-28 20:42:59 +04:00
|
|
|
if (tableFrame) {
|
2006-03-04 08:26:57 +03:00
|
|
|
tableFrame->SetNeedToCollapse(PR_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
|
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
|
|
|
nsHTMLReflowMetrics kidSize;
|
1999-03-05 07:19:09 +03: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 08:38:33 +03:00
|
|
|
nsSize(0,0));
|
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);
|
2001-12-07 17:51:12 +03:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, nsnull, kidSize, 0, 0, 0);
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
1998-09-17 03:24:39 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
aDesiredSize.width=0;
|
|
|
|
aDesiredSize.height=0;
|
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
|
|
|
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 08:38:33 +03:00
|
|
|
/* virtual */ PRBool
|
|
|
|
nsTableColGroupFrame::IsContainingBlock() const
|
1998-10-16 01:07:37 +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
|
|
|
return PR_TRUE;
|
1998-05-29 01:39:22 +04:00
|
|
|
}
|
|
|
|
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableColFrame * nsTableColGroupFrame::GetFirstColumn()
|
|
|
|
{
|
|
|
|
return GetNextColumn(nsnull);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableColFrame * nsTableColGroupFrame::GetNextColumn(nsIFrame *aChildFrame)
|
|
|
|
{
|
|
|
|
nsTableColFrame *result = nsnull;
|
|
|
|
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 ==
|
|
|
|
childFrame->GetStyleDisplay()->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;
|
|
|
|
}
|
|
|
|
|
1998-09-24 01:48:26 +04:00
|
|
|
PRInt32 nsTableColGroupFrame::GetSpan()
|
|
|
|
{
|
2008-02-15 07:19:29 +03:00
|
|
|
return GetStyleTable()->mSpan;
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
|
|
|
|
2004-03-09 09:48:35 +03: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 10:46:44 +03:00
|
|
|
void nsTableColGroupFrame::GetContinuousBCBorderWidth(nsMargin& aBorder)
|
2004-03-09 09:48:35 +03:00
|
|
|
{
|
2007-02-07 10:46:44 +03:00
|
|
|
PRInt32 aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* table = nsTableFrame::GetTableFrame(this);
|
2004-03-09 09:48:35 +03:00
|
|
|
nsTableColFrame* col = table->GetColFrame(mStartColIndex + mColCount - 1);
|
2007-02-07 10:46:44 +03:00
|
|
|
col->GetContinuousBCBorderWidth(aBorder);
|
2004-03-09 09:48:35 +03:00
|
|
|
aBorder.top = BC_BORDER_BOTTOM_HALF_COORD(aPixelsToTwips,
|
|
|
|
mTopContBorderWidth);
|
|
|
|
aBorder.bottom = BC_BORDER_TOP_HALF_COORD(aPixelsToTwips,
|
|
|
|
mBottomContBorderWidth);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
1998-06-17 20:38:24 +04:00
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
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
|
|
|
|
2001-02-23 15:35:34 +03:00
|
|
|
NS_IMETHODIMP
|
2006-03-09 21:55:21 +03:00
|
|
|
nsTableColGroupFrame::Init(nsIContent* aContent,
|
2001-02-23 15:35:34 +03:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Let the base class do its processing
|
2006-03-27 01:30:36 +04:00
|
|
|
rv = nsHTMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2001-02-23 15:35:34 +03:00
|
|
|
|
|
|
|
// record that children that are ignorable whitespace should be excluded
|
|
|
|
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
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
|
|
|
|
|
|
|
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 17:44:15 +04: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 20:02:50 +04:00
|
|
|
printf("\n%s**END COLGROUP DUMP** ", indent);
|
|
|
|
delete [] indent;
|
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|