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"
|
2002-05-10 22:22:41 +04:00
|
|
|
#include "nsReflowPath.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"
|
1998-05-29 01:39:22 +04:00
|
|
|
#include "nsHTMLAtoms.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"
|
1999-10-02 04:02:54 +04:00
|
|
|
#include "nsLayoutAtoms.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) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableColGroupFrame == colGroupFrame->GetType()) {
|
2000-04-04 08:28:18 +04:00
|
|
|
// reset the starting col index for the first cg only if
|
|
|
|
// aFirstColIndex is smaller than the existing starting col index
|
|
|
|
if ((colIndex != aFirstColIndex) ||
|
|
|
|
(colIndex < colGroupFrame->GetStartColumnIndex())) {
|
|
|
|
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) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::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
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
colGroupFrame = NS_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;
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
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) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableColGroupFrame::SetInitialChildList(nsPresContext* aPresContext,
|
1998-11-10 09:05:32 +03:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-09-16 21:19:20 +04:00
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (!tableFrame) return NS_ERROR_NULL_POINTER;
|
|
|
|
|
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) {
|
|
|
|
SetInitialChildList(aPresContext, aListName, firstChild);
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
mFrames.AppendFrames(this, aFrameList);
|
2005-02-07 04:58:25 +03:00
|
|
|
InsertColsReflow(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,
|
1999-12-14 01:56:31 +03:00
|
|
|
nsIFrame* aPrevFrameIn,
|
1999-08-06 18:34:56 +04:00
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
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
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
mFrames.InsertFrames(this, aPrevFrameIn, aFrameList);
|
2004-01-18 13:28:40 +03:00
|
|
|
nsIFrame* prevFrame = nsTableFrame::GetFrameAtOrBefore(this, aPrevFrameIn,
|
1999-12-14 01:56:31 +03:00
|
|
|
nsLayoutAtoms::tableColFrame);
|
1999-08-06 18:34:56 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
PRInt32 colIndex = (prevFrame) ? ((nsTableColFrame*)prevFrame)->GetColIndex() + 1 : 0;
|
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
|
|
|
|
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (!tableFrame) return;
|
|
|
|
|
|
|
|
// XXX this could be optimized with much effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-08-06 18:34:56 +04:00
|
|
|
|
|
|
|
// Generate a reflow command so we reflow the table
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableFrame::AppendDirtyReflowCommand(tableFrame);
|
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
|
|
|
}
|
2005-02-07 04:58:25 +03:00
|
|
|
if (mFrames.DestroyFrame(GetPresContext(), (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
|
|
|
}
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (!tableFrame) return;
|
|
|
|
|
|
|
|
// XXX this could be optimized with much effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
|
|
|
// Generate a reflow command so we reflow the table
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableFrame::AppendDirtyReflowCommand(tableFrame);
|
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)
|
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
if (!aOldFrame) return NS_OK;
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableColFrame == aOldFrame->GetType()) {
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableColFrame* colFrame = (nsTableColFrame*)aOldFrame;
|
|
|
|
PRInt32 colIndex = colFrame->GetColIndex();
|
2005-02-07 04:58:25 +03:00
|
|
|
RemoveChild(*colFrame, PR_TRUE);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (!tableFrame) return NS_ERROR_NULL_POINTER;
|
|
|
|
|
2005-02-07 04:58:25 +03:00
|
|
|
tableFrame->RemoveCol(this, colIndex, PR_TRUE, PR_TRUE);
|
1999-08-06 18:34:56 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// XXX This could probably be optimized with much effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-12-14 01:56:31 +03:00
|
|
|
// Generate a reflow command so we reflow the table
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableFrame::AppendDirtyReflowCommand(tableFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
else {
|
2005-02-07 04:58:25 +03:00
|
|
|
mFrames.DestroyFrame(GetPresContext(), aOldFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
1999-08-06 18:34:56 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-09-19 16:35:19 +04:00
|
|
|
NS_METHOD
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableColGroupFrame::Paint(nsPresContext* aPresContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2001-01-27 17:09:34 +03:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-02-21 08:36:16 +03:00
|
|
|
|
1998-12-18 18:54:23 +03:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
PRIntn
|
|
|
|
nsTableColGroupFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
2000-03-22 05:43:08 +03:00
|
|
|
NS_IMETHODIMP
|
2005-01-01 20:26:29 +03:00
|
|
|
nsTableColGroupFrame::GetFrameForPoint(const nsPoint& aPoint,
|
2000-03-22 05:43:08 +03:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
nsIFrame** aFrame)
|
|
|
|
{
|
|
|
|
// this should act like a block, so we need to override
|
2005-01-01 20:26:29 +03:00
|
|
|
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, PR_FALSE, aFrame);
|
2000-03-22 05:43:08 +03:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2000-04-22 01:36:33 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableColGroupFrame", aReflowState.reason);
|
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) {
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (tableFrame) {
|
|
|
|
tableFrame->SetNeedToCollapseColumns(PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
nsIFrame* kidFrame = nsnull;
|
2004-04-28 20:42:59 +04:00
|
|
|
|
|
|
|
|
1998-09-24 01:48:26 +04:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
2005-02-07 04:58:25 +03:00
|
|
|
rv = IncrementalReflow(aDesiredSize, aReflowState, aStatus);
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
2003-07-07 06:01:29 +04:00
|
|
|
for (kidFrame = mFrames.FirstChild(); kidFrame;
|
|
|
|
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
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics kidSize(nsnull);
|
1998-09-16 21:19:20 +04:00
|
|
|
// XXX Use a valid reason...
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
|
1998-10-12 18:48:02 +04:00
|
|
|
nsSize(0,0), eReflowReason_Initial);
|
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-10-08 19:34:48 +04:00
|
|
|
aDesiredSize.ascent=aDesiredSize.height;
|
|
|
|
aDesiredSize.descent=0;
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2003-01-09 17:26:32 +03:00
|
|
|
aDesiredSize.mMaxElementWidth=0;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2005-02-07 04:58:25 +03:00
|
|
|
NS_METHOD nsTableColGroupFrame::IncrementalReflow(nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-16 01:07:37 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
|
2002-05-10 22:22:41 +04:00
|
|
|
// the col group is a target if its path has a reflow command
|
|
|
|
nsHTMLReflowCommand* command = aReflowState.path->mReflowCommand;
|
|
|
|
if (command)
|
2005-02-07 04:58:25 +03:00
|
|
|
IR_TargetIsMe(aDesiredSize, aReflowState, aStatus);
|
2002-05-10 22:22:41 +04:00
|
|
|
|
|
|
|
// see if the chidren are targets as well
|
|
|
|
nsReflowPath::iterator iter = aReflowState.path->FirstChild();
|
|
|
|
nsReflowPath::iterator end = aReflowState.path->EndChildren();
|
|
|
|
for (; iter != end; ++iter)
|
2005-02-07 04:58:25 +03:00
|
|
|
IR_TargetIsChild(aDesiredSize, aReflowState, aStatus, *iter);
|
2002-05-10 22:22:41 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-10-16 01:07:37 +04:00
|
|
|
}
|
|
|
|
|
2005-02-07 04:58:25 +03:00
|
|
|
NS_METHOD nsTableColGroupFrame::IR_TargetIsMe(nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-16 01:07:37 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2001-12-18 01:39:59 +03:00
|
|
|
nsReflowType type;
|
2002-05-10 22:22:41 +04:00
|
|
|
aReflowState.path->mReflowCommand->GetType(type);
|
1998-10-16 01:07:37 +04:00
|
|
|
nsIFrame *objectFrame;
|
2002-05-10 22:22:41 +04:00
|
|
|
aReflowState.path->mReflowCommand->GetChildFrame(objectFrame);
|
1998-10-16 01:07:37 +04:00
|
|
|
switch (type)
|
|
|
|
{
|
2001-12-18 01:39:59 +03:00
|
|
|
case eReflowType_StyleChanged :
|
2005-02-07 04:58:25 +03:00
|
|
|
rv = IR_StyleChanged(aDesiredSize, aReflowState, aStatus);
|
1998-10-16 01:07:37 +04:00
|
|
|
break;
|
|
|
|
|
2001-12-18 01:39:59 +03:00
|
|
|
case eReflowType_ContentChanged :
|
1998-10-16 01:07:37 +04:00
|
|
|
NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
break;
|
|
|
|
|
1999-08-06 18:34:56 +04:00
|
|
|
default:
|
|
|
|
NS_NOTYETIMPLEMENTED("unexpected reflow command type");
|
1998-10-16 01:07:37 +04:00
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2005-02-07 04:58:25 +03:00
|
|
|
NS_METHOD nsTableColGroupFrame::IR_StyleChanged(nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-30 10:57:44 +03:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// we presume that all the easy optimizations were done in the nsHTMLStyleSheet before we were called here
|
|
|
|
// XXX: we can optimize this when we know which style attribute changed
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
1998-10-30 10:57:44 +03:00
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (tableFrame) {
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1998-10-30 10:57:44 +03:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2005-02-07 04:58:25 +03:00
|
|
|
NS_METHOD nsTableColGroupFrame::IR_TargetIsChild(nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-16 01:07:37 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame * aNextFrame)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
1999-08-19 23:52:37 +04:00
|
|
|
|
1998-10-16 01:07:37 +04:00
|
|
|
// Pass along the reflow command
|
|
|
|
nsHTMLReflowMetrics desiredSize(nsnull);
|
2005-02-07 04:58:25 +03:00
|
|
|
nsPresContext* presContext = GetPresContext();
|
|
|
|
nsHTMLReflowState kidReflowState(presContext, aReflowState, aNextFrame,
|
1999-03-05 07:19:09 +03:00
|
|
|
nsSize(aReflowState.availableWidth,
|
|
|
|
aReflowState.availableHeight));
|
2005-02-07 04:58:25 +03:00
|
|
|
rv = ReflowChild(aNextFrame, presContext, desiredSize, kidReflowState, 0, 0, 0, aStatus);
|
|
|
|
aNextFrame->DidReflow(presContext, nsnull, NS_FRAME_REFLOW_FINISHED);
|
1998-10-16 01:07:37 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
nsTableFrame *tableFrame=nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (tableFrame) {
|
1998-10-16 01:07:37 +04:00
|
|
|
// compare the new col count to the old col count.
|
|
|
|
// If they are the same, we just need to rebalance column widths
|
|
|
|
// If they differ, we need to fix up other column groups and the column cache
|
2001-03-13 09:38:59 +03:00
|
|
|
// XXX for now assume the worse
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1998-05-30 02:08:19 +04:00
|
|
|
}
|
1998-10-14 20:32:45 +04:00
|
|
|
return rv;
|
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;
|
|
|
|
if (nsnull==childFrame)
|
1999-01-16 01:52:05 +03:00
|
|
|
childFrame = mFrames.FirstChild();
|
1998-10-15 02:51:50 +04:00
|
|
|
while (nsnull!=childFrame)
|
|
|
|
{
|
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()
|
|
|
|
{
|
1999-12-14 01:56:31 +03:00
|
|
|
PRInt32 span = 1;
|
2003-07-07 06:01:29 +04:00
|
|
|
nsIContent* iContent = GetContent();
|
|
|
|
if (!iContent) return NS_OK;
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
// col group element derives from col element
|
|
|
|
nsIDOMHTMLTableColElement* cgContent = nsnull;
|
2003-07-07 06:01:29 +04:00
|
|
|
nsresult rv = iContent->QueryInterface(NS_GET_IID(nsIDOMHTMLTableColElement),
|
|
|
|
(void **)&cgContent);
|
1999-12-14 01:56:31 +03:00
|
|
|
if (cgContent && NS_SUCCEEDED(rv)) {
|
|
|
|
cgContent->GetSpan(&span);
|
|
|
|
// XXX why does this work!!
|
|
|
|
if (span == -1) {
|
|
|
|
span = 1;
|
|
|
|
}
|
|
|
|
NS_RELEASE(cgContent);
|
1998-09-24 01:48:26 +04:00
|
|
|
}
|
|
|
|
return span;
|
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableColGroupFrame::GetContinuousBCBorderWidth(float aPixelsToTwips,
|
|
|
|
nsMargin& aBorder)
|
|
|
|
{
|
|
|
|
nsTableFrame* table;
|
|
|
|
nsTableFrame::GetTableFrame(this, table);
|
|
|
|
nsTableColFrame* col = table->GetColFrame(mStartColIndex + mColCount - 1);
|
|
|
|
col->GetContinuousBCBorderWidth(aPixelsToTwips, aBorder);
|
|
|
|
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
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewTableColGroupFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsTableColGroupFrame* it = new (aPresShell) nsTableColGroupFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-06-17 20:38:24 +04:00
|
|
|
|
2001-02-23 15:35:34 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableColGroupFrame::Init(nsPresContext* aPresContext,
|
2001-02-23 15:35:34 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-02-23 15:35:34 +03:00
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Let the base class do its processing
|
|
|
|
rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext,
|
|
|
|
aPrevInFlow);
|
|
|
|
|
|
|
|
// 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
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::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;
|
|
|
|
}
|
|
|
|
printf("\n%s**END COLGROUP DUMP** ", indent);
|
|
|
|
delete [] indent;
|
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|