2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
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.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* 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):
|
2000-02-03 01:24:56 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either 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"),
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-12-14 03:24:33 +03:00
|
|
|
#include "nsTableFrame.h"
|
1999-01-03 22:22:40 +03:00
|
|
|
#include "nsTableColFrame.h"
|
1999-12-14 03:24:33 +03:00
|
|
|
#include "nsTableCellFrame.h"
|
1998-11-11 22:56:02 +03:00
|
|
|
#include "nsTableFrame.h"
|
1998-06-09 08:51:44 +04:00
|
|
|
#include "nsIReflowCommand.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
1998-09-15 21:58:24 +04:00
|
|
|
#include "nsIHTMLContent.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
1998-10-06 04:44:35 +04:00
|
|
|
#include "nsHTMLParts.h"
|
1998-06-11 04:13:18 +04:00
|
|
|
#include "nsHTMLValue.h"
|
1998-05-02 00:44:55 +04:00
|
|
|
#include "nsHTMLAtoms.h"
|
1998-06-05 06:36:25 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1998-10-06 04:44:35 +04:00
|
|
|
#include "nsVoidArray.h"
|
1998-05-22 03:43:18 +04:00
|
|
|
#include "nsIView.h"
|
1998-07-23 22:05:03 +04:00
|
|
|
#include "nsStyleUtil.h"
|
1999-02-24 08:54:31 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-10-22 06:06:22 +04:00
|
|
|
#include "nsIFrameManager.h"
|
|
|
|
#include "nsIPresShell.h"
|
1999-07-28 12:09:02 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIHTMLTableCellElement.h"
|
1999-09-30 18:11:16 +04:00
|
|
|
#include "nsIDOMHTMLTableCellElement.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-04-01 05:01:33 +04:00
|
|
|
#include "nsIAccessibilityService.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-04-01 05:01:33 +04:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
2001-09-21 17:43:18 +04:00
|
|
|
#include "nsINameSpaceManager.h"
|
2001-04-01 05:01:33 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-04-14 00:21:32 +04:00
|
|
|
//TABLECELL SELECTION
|
|
|
|
#include "nsIFrameSelection.h"
|
2000-04-14 02:39:39 +04:00
|
|
|
#include "nsILookAndFeel.h"
|
2000-04-14 00:21:32 +04:00
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
|
2000-01-04 08:31:56 +03:00
|
|
|
nsTableCellFrame::nsTableCellFrame()
|
|
|
|
{
|
|
|
|
mColIndex = 0;
|
|
|
|
mPriorAvailWidth = 0;
|
2001-01-25 18:55:51 +03:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
mTimer = new nsReflowTimer(this);
|
|
|
|
mBlockTimer = new nsReflowTimer(this);
|
|
|
|
#endif
|
2000-01-04 08:31:56 +03:00
|
|
|
}
|
|
|
|
|
1999-10-17 07:30:11 +04:00
|
|
|
nsTableCellFrame::~nsTableCellFrame()
|
|
|
|
{
|
2001-01-25 18:55:51 +03:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflowDone(this);
|
|
|
|
#endif
|
1999-10-17 07:30:11 +04:00
|
|
|
}
|
|
|
|
|
1999-02-25 08:31:15 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableCellFrame::Init(nsIPresContext* aPresContext,
|
1999-02-25 08:31:15 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Let the base class do its initialization
|
|
|
|
rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext,
|
|
|
|
aPrevInFlow);
|
|
|
|
|
|
|
|
if (aPrevInFlow) {
|
|
|
|
// Set the column index
|
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)aPrevInFlow;
|
1999-12-14 01:56:31 +03:00
|
|
|
PRInt32 colIndex;
|
|
|
|
cellFrame->GetColIndex(colIndex);
|
|
|
|
InitCellFrame(colIndex);
|
1999-02-25 08:31:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-04-16 18:51:52 +04:00
|
|
|
nsresult
|
|
|
|
nsTableCellFrame::GetRowIndex(PRInt32 &aRowIndex) const
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsTableRowFrame * row;
|
|
|
|
GetParent((nsIFrame **)&row);
|
|
|
|
if (row) {
|
|
|
|
aRowIndex = row->GetRowIndex();
|
|
|
|
result = NS_OK;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aRowIndex = 0;
|
|
|
|
result = NS_ERROR_NOT_INITIALIZED;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsTableCellFrame::GetColIndex(PRInt32 &aColIndex) const
|
|
|
|
{
|
|
|
|
if (mPrevInFlow) {
|
|
|
|
return ((nsTableCellFrame*)GetFirstInFlow())->GetColIndex(aColIndex);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aColIndex = mColIndex;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-04 08:31:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
2001-08-25 06:01:08 +04:00
|
|
|
PRInt32 aModType,
|
2000-01-04 08:31:56 +03:00
|
|
|
PRInt32 aHint)
|
|
|
|
{
|
|
|
|
// let the table frame decide what to do
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if ((NS_SUCCEEDED(rv)) && (tableFrame)) {
|
|
|
|
tableFrame->AttributeChangedFor(aPresContext, this, aChild, aAttribute);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-12 02:03:37 +03:00
|
|
|
void nsTableCellFrame::SetPass1MaxElementSize(nscoord aMaxWidth,
|
|
|
|
const nsSize& aMaxElementSize)
|
1999-09-30 18:11:16 +04:00
|
|
|
{
|
|
|
|
mPass1MaxElementSize.height = aMaxElementSize.height;
|
2001-09-21 17:43:18 +04:00
|
|
|
|
|
|
|
nscoord maxElemWidth = aMaxElementSize.width;
|
|
|
|
const nsStylePosition* stylePosition;
|
|
|
|
const nsStyleText* styleText;
|
|
|
|
// check for fixed width and not nowrap and not pre
|
|
|
|
GetStyleData(eStyleStruct_Position, ((const nsStyleStruct *&)stylePosition));
|
|
|
|
GetStyleData(eStyleStruct_Text, ((const nsStyleStruct *&)styleText));
|
|
|
|
if (stylePosition->mWidth.GetUnit() == eStyleUnit_Coord &&
|
|
|
|
styleText->mWhiteSpace != NS_STYLE_WHITESPACE_NOWRAP &&
|
|
|
|
styleText->mWhiteSpace != NS_STYLE_WHITESPACE_PRE) {
|
|
|
|
// has fixed width, check the content for nowrap
|
|
|
|
nsAutoString nowrap;
|
|
|
|
nsCOMPtr<nsIContent> cellContent;
|
|
|
|
GetContent(getter_AddRefs(cellContent));
|
|
|
|
nsresult result = cellContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::nowrap, nowrap);
|
|
|
|
if(NS_CONTENT_ATTR_NOT_THERE != result) {
|
|
|
|
// content has nowrap (is not mapped to style be cause it has width)
|
|
|
|
// set the max element size to the value of the fixed width (NAV/IE quirk)
|
2001-10-03 01:29:26 +04:00
|
|
|
maxElemWidth = NS_MAX(maxElemWidth, stylePosition->mWidth.GetCoordValue());
|
2001-09-21 17:43:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
mPass1MaxElementSize.width = maxElemWidth;
|
1999-09-30 18:11:16 +04:00
|
|
|
}
|
|
|
|
|
1999-08-02 02:21:03 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableCellFrame::AppendFrames(nsIPresContext* aPresContext,
|
1999-08-02 02:21:03 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unsupported operation");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableCellFrame::InsertFrames(nsIPresContext* aPresContext,
|
1999-08-02 02:21:03 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unsupported operation");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableCellFrame::RemoveFrame(nsIPresContext* aPresContext,
|
1999-08-02 02:21:03 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unsupported operation");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
void nsTableCellFrame::InitCellFrame(PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
nsTableFrame* tableFrame=nsnull; // I should be checking my own style context, but border-collapse isn't inheriting correctly
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
if ((NS_SUCCEEDED(rv)) && tableFrame) {
|
1999-12-14 01:56:31 +03:00
|
|
|
SetColIndex(aColIndex);
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
nsresult nsTableCellFrame::SetColIndex(PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
mColIndex = aColIndex;
|
|
|
|
// for style context optimization, set the content's column index if possible.
|
|
|
|
// this can only be done if we really have an nsTableCell.
|
|
|
|
// other tags mapped to table cell display won't benefit from this optimization
|
|
|
|
// see nsHTMLStyleSheet::RulesMatching
|
|
|
|
|
|
|
|
//nsIContent* cell;
|
|
|
|
//kidFrame->GetContent(&cell);
|
|
|
|
nsCOMPtr<nsIContent> cell;
|
|
|
|
nsresult rv = GetContent(getter_AddRefs(cell));
|
|
|
|
if (NS_FAILED(rv) || !cell)
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
nsIHTMLTableCellElement* cellContent = nsnull;
|
2001-01-04 23:44:42 +03:00
|
|
|
rv = cell->QueryInterface(NS_GET_IID(nsIHTMLTableCellElement),
|
1999-07-28 12:09:02 +04:00
|
|
|
(void **)&cellContent); // cellContent: REFCNT++
|
|
|
|
if (cellContent && NS_SUCCEEDED(rv)) { // it's a table cell
|
|
|
|
cellContent->SetColIndex(aColIndex);
|
|
|
|
NS_RELEASE(cellContent);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-05-04 03:57:08 +04:00
|
|
|
|
|
|
|
//ASSURE DIFFERENT COLORS for selection
|
|
|
|
inline nscolor EnsureDifferentColors(nscolor colorA, nscolor colorB)
|
|
|
|
{
|
|
|
|
if (colorA == colorB)
|
|
|
|
{
|
|
|
|
nscolor res;
|
|
|
|
res = NS_RGB(NS_GET_R(colorA) ^ 0xff,
|
|
|
|
NS_GET_G(colorA) ^ 0xff,
|
|
|
|
NS_GET_B(colorA) ^ 0xff);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
return colorA;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsTableCellFrame::DecorateForSelection(nsIPresContext* aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleBackground *aStyleColor)
|
2001-05-04 03:57:08 +04:00
|
|
|
{
|
|
|
|
PRInt16 displaySelection;
|
|
|
|
displaySelection = DisplaySelection(aPresContext);
|
|
|
|
if (displaySelection) {
|
|
|
|
nsFrameState frameState;
|
|
|
|
PRBool isSelected;
|
|
|
|
GetFrameState(&frameState);
|
|
|
|
isSelected = (frameState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
|
|
|
|
if (isSelected) {
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
nsresult result = aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
nsCOMPtr<nsIFrameSelection> frameSelection;
|
|
|
|
result = shell->GetFrameSelection(getter_AddRefs(frameSelection));
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
PRBool tableCellSelectionMode;
|
|
|
|
result = frameSelection->GetTableCellSelection(&tableCellSelectionMode);
|
|
|
|
if (NS_SUCCEEDED(result) && tableCellSelectionMode) {
|
|
|
|
nscolor bordercolor;
|
|
|
|
if(displaySelection == nsISelectionController::SELECTION_DISABLED) {
|
|
|
|
bordercolor = NS_RGB(176,176,176);// disabled color
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsILookAndFeel* look = nsnull;
|
|
|
|
if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(&look)) && look) {
|
|
|
|
look->GetColor(nsILookAndFeel::eColor_TextSelectBackground, bordercolor);
|
|
|
|
NS_RELEASE(look);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
float t2pfloat;
|
|
|
|
if (NS_SUCCEEDED(aPresContext->GetPixelsToTwips(&t2pfloat)))
|
|
|
|
{
|
|
|
|
PRInt16 t2p = (PRInt16)t2pfloat;
|
|
|
|
if ((mRect.width >(3*t2p)) && (mRect.height > (3*t2p)))
|
|
|
|
{
|
|
|
|
//compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor)
|
|
|
|
bordercolor = EnsureDifferentColors(bordercolor, aStyleColor->mBackgroundColor);
|
|
|
|
//outerrounded
|
|
|
|
aRenderingContext.SetColor(bordercolor);
|
|
|
|
aRenderingContext.DrawLine(t2p, 0, mRect.width, 0);
|
|
|
|
aRenderingContext.DrawLine(0, t2p, 0, mRect.height);
|
|
|
|
aRenderingContext.DrawLine(t2p, mRect.height, mRect.width, mRect.height);
|
|
|
|
aRenderingContext.DrawLine(mRect.width, t2p, mRect.width, mRect.height);
|
|
|
|
//middle
|
|
|
|
aRenderingContext.DrawRect(t2p, t2p, mRect.width-t2p, mRect.height-t2p);
|
|
|
|
//shading
|
|
|
|
aRenderingContext.DrawLine(2*t2p, mRect.height-2*t2p, mRect.width-t2p, mRect.height- (2*t2p));
|
|
|
|
aRenderingContext.DrawLine(mRect.width - (2*t2p), 2*t2p, mRect.width - (2*t2p), mRect.height-t2p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-09-19 16:35:19 +04:00
|
|
|
NS_METHOD
|
|
|
|
nsTableCellFrame::Paint(nsIPresContext* aPresContext,
|
|
|
|
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;
|
|
|
|
}
|
1999-08-28 01:53:04 +04:00
|
|
|
const nsStyleDisplay* disp =
|
|
|
|
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleVisibility* vis =
|
|
|
|
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
|
|
|
|
|
1999-08-28 01:53:04 +04:00
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
2001-06-01 02:19:43 +04:00
|
|
|
if (vis->IsVisibleOrCollapsed()) {
|
2001-05-04 03:57:08 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleBackground* myColor = (const nsStyleBackground*)mStyleContext->GetStyleData(eStyleStruct_Background);
|
2001-05-04 03:57:08 +04:00
|
|
|
#ifdef OLD_TABLE_SELECTION
|
|
|
|
myColor = GetColorStyleFromSelection(myColor);
|
|
|
|
#endif
|
2000-04-14 00:21:32 +04:00
|
|
|
|
2001-02-07 12:57:26 +03:00
|
|
|
const nsStyleBorder* myBorder =
|
|
|
|
(const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);
|
1998-12-18 18:54:23 +03:00
|
|
|
NS_ASSERTION(nsnull!=myColor, "bad style color");
|
2001-02-07 12:57:26 +03:00
|
|
|
NS_ASSERTION(nsnull!=myBorder, "bad style spacing");
|
1998-04-30 04:27:59 +04:00
|
|
|
|
2001-05-04 03:57:08 +04:00
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleTableBorder* cellTableStyle;
|
|
|
|
GetStyleData(eStyleStruct_TableBorder, ((const nsStyleStruct *&)cellTableStyle));
|
1998-12-18 18:54:23 +03:00
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
1998-05-27 03:17:29 +04:00
|
|
|
|
2001-04-17 18:58:34 +04:00
|
|
|
|
|
|
|
// bug #8113
|
|
|
|
// as of the CSS2-errata http://www.w3.org/Style/css2-updates/REC-CSS2-19980512-errata.html
|
|
|
|
// always draw the background and border except when the cell is empty and 'empty-cells: hide' is set
|
|
|
|
if ( !(GetContentEmpty() && NS_STYLE_TABLE_EMPTY_CELLS_HIDE == cellTableStyle->mEmptyCells) ) {
|
1999-06-08 09:04:22 +04:00
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
|
2001-02-07 12:57:26 +03:00
|
|
|
aDirtyRect, rect, *myColor, *myBorder, 0, 0);
|
2001-04-17 18:58:34 +04:00
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
PRIntn skipSides = GetSkipSides();
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull; // I should be checking my own style context, but border-collapse isn't inheriting correctly
|
1998-12-21 09:38:18 +03:00
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2001-03-13 09:38:59 +03:00
|
|
|
if ((NS_SUCCEEDED(rv)) && tableFrame) {
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleTableBorder* tableStyle;
|
|
|
|
tableFrame->GetStyleData(eStyleStruct_TableBorder, ((const nsStyleStruct *&)tableStyle));
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_STYLE_BORDER_SEPARATE == tableFrame->GetBorderCollapseStyle()) {
|
1998-12-21 09:38:18 +03:00
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
|
2001-02-07 12:57:26 +03:00
|
|
|
aDirtyRect, rect, *myBorder, mStyleContext, skipSides);
|
1998-12-21 09:38:18 +03:00
|
|
|
}
|
|
|
|
}
|
1998-12-18 18:54:23 +03:00
|
|
|
}
|
2001-05-04 03:57:08 +04:00
|
|
|
#ifndef OLD_TABLE_SELECTION
|
|
|
|
DecorateForSelection(aPresContext, aRenderingContext,myColor); //ignore return value
|
|
|
|
#endif //OLD_TABLE_SELECTION
|
1998-07-27 11:37:57 +04:00
|
|
|
}
|
1998-05-27 03:17:29 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-04-14 00:24:54 +04:00
|
|
|
// for debug...
|
1999-03-26 03:39:35 +03:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
|
1998-12-23 18:47:43 +03:00
|
|
|
aRenderingContext.SetColor(NS_RGB(0, 0, 128));
|
1998-04-14 00:24:54 +04:00
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-08-28 01:53:04 +04:00
|
|
|
// if the cell originates in a row and/or col that is collapsed, the
|
|
|
|
// bottom and/or right portion of the cell is painted by translating
|
|
|
|
// the rendering context.
|
1999-02-11 09:22:33 +03:00
|
|
|
PRBool clipState;
|
1999-10-22 06:06:22 +04:00
|
|
|
nsPoint offset;
|
1999-11-24 09:03:41 +03:00
|
|
|
GetCollapseOffset(aPresContext, offset);
|
1999-02-11 09:22:33 +03:00
|
|
|
if ((0 != offset.x) || (0 != offset.y)) {
|
1999-10-28 03:01:21 +04:00
|
|
|
aRenderingContext.PushState();
|
1999-02-11 09:22:33 +03:00
|
|
|
aRenderingContext.Translate(offset.x, offset.y);
|
1999-08-28 01:53:04 +04:00
|
|
|
aRenderingContext.SetClipRect(nsRect(-offset.x, -offset.y, mRect.width, mRect.height),
|
1999-02-11 09:22:33 +03:00
|
|
|
nsClipCombine_kIntersect, clipState);
|
1999-10-28 03:01:21 +04:00
|
|
|
}
|
2001-02-24 17:30:12 +03:00
|
|
|
else{
|
|
|
|
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
|
|
|
|
const nsStylePadding* myPadding =
|
|
|
|
(const nsStylePadding*)mStyleContext->GetStyleData(eStyleStruct_Padding);
|
|
|
|
nsMargin padding;
|
|
|
|
nsRect clipRect(0, 0, mRect.width, mRect.height);
|
|
|
|
if (myPadding->GetPadding(padding)) {
|
|
|
|
clipRect.Deflate(padding);
|
|
|
|
}
|
|
|
|
|
|
|
|
aRenderingContext.PushState();
|
|
|
|
aRenderingContext.SetClipRect(clipRect,nsClipCombine_kIntersect, clipState);
|
|
|
|
}
|
|
|
|
}
|
1998-12-18 18:54:23 +03:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1999-10-28 03:01:21 +04:00
|
|
|
if ((0 != offset.x) || (0 != offset.y)) {
|
|
|
|
aRenderingContext.PopState(clipState);
|
|
|
|
}
|
2001-02-24 17:30:12 +03:00
|
|
|
else {
|
|
|
|
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
|
|
|
|
aRenderingContext.PopState(clipState);
|
|
|
|
}
|
|
|
|
}
|
1999-02-11 09:22:33 +03:00
|
|
|
|
2001-03-13 04:47:22 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP_J("nsTableCellFrame", &aRenderingContext, 0);
|
1999-09-18 03:33:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
/*nsFrame::Paint(aPresContext,
|
1999-06-02 03:04:13 +04:00
|
|
|
aRenderingContext,
|
|
|
|
aDirtyRect,
|
1999-09-18 03:33:39 +04:00
|
|
|
aWhichLayer);*/
|
1999-06-02 03:04:13 +04:00
|
|
|
}
|
|
|
|
|
2000-03-22 05:43:08 +03:00
|
|
|
NS_IMETHODIMP
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableCellFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
2000-03-22 05:43:08 +03:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame** aFrame)
|
2000-03-22 05:43:08 +03:00
|
|
|
{
|
|
|
|
// this should act like a block, so we need to override
|
|
|
|
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
|
|
|
|
}
|
|
|
|
|
1999-06-02 03:04:13 +04:00
|
|
|
//null range means the whole thing
|
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsTableCellFrame::SetSelected(nsIPresContext* aPresContext,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIDOMRange* aRange,
|
|
|
|
PRBool aSelected,
|
|
|
|
nsSpread aSpread)
|
1999-06-02 03:04:13 +04:00
|
|
|
{
|
|
|
|
//traverse through children unselect tables
|
1999-09-22 02:58:14 +04:00
|
|
|
#if 0
|
1999-09-18 03:33:39 +04:00
|
|
|
if ((aSpread == eSpreadDown)){
|
1999-06-02 03:04:13 +04:00
|
|
|
nsIFrame* kid;
|
1999-08-28 01:53:04 +04:00
|
|
|
FirstChild(nsnull, &kid);
|
1999-06-02 03:04:13 +04:00
|
|
|
while (nsnull != kid) {
|
1999-09-18 03:33:39 +04:00
|
|
|
kid->SetSelected(nsnull,aSelected,eSpreadDown);
|
1999-06-02 03:04:13 +04:00
|
|
|
|
|
|
|
kid->GetNextSibling(&kid);
|
|
|
|
}
|
|
|
|
}
|
1999-09-22 02:58:14 +04:00
|
|
|
//return nsFrame::SetSelected(aRange,aSelected,eSpreadNone);
|
|
|
|
#endif
|
2000-03-21 09:04:02 +03:00
|
|
|
// Must call base class to set mSelected state and trigger repaint of frame
|
|
|
|
// Note that in current version, aRange and aSpread are ignored,
|
|
|
|
// only this frame is considered
|
|
|
|
nsFrame::SetSelected(aPresContext, aRange, aSelected, aSpread);
|
2000-04-30 22:56:26 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
nsresult result = aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
nsCOMPtr<nsIFrameSelection> frameSelection;
|
|
|
|
result = shell->GetFrameSelection(getter_AddRefs(frameSelection));
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_SUCCEEDED(result) && frameSelection) {
|
2000-04-30 22:56:26 +04:00
|
|
|
PRBool tableCellSelectionMode;
|
|
|
|
result = frameSelection->GetTableCellSelection(&tableCellSelectionMode);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_SUCCEEDED(result) && tableCellSelectionMode) {
|
2000-04-30 22:56:26 +04:00
|
|
|
nsRect frameRect;
|
|
|
|
GetRect(frameRect);
|
|
|
|
nsRect rect(0, 0, frameRect.width, frameRect.height);
|
|
|
|
Invalidate(aPresContext, rect, PR_FALSE);
|
|
|
|
}
|
|
|
|
}
|
1999-09-22 02:58:14 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
PRIntn
|
|
|
|
nsTableCellFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
|
|
|
if (nsnull != mPrevInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-06-02 03:04:13 +04:00
|
|
|
PRBool nsTableCellFrame::ParentDisablesSelection() const //override default behavior
|
|
|
|
{
|
|
|
|
PRBool returnval;
|
|
|
|
if (NS_FAILED(GetSelected(&returnval)))
|
|
|
|
return PR_FALSE;
|
|
|
|
if (returnval)
|
|
|
|
return PR_TRUE;
|
|
|
|
return nsFrame::ParentDisablesSelection();
|
|
|
|
}
|
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// Align the cell's child frame within the cell
|
2001-04-01 05:01:33 +04:00
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nscoord aMaxAscent)
|
1998-04-25 22:48:48 +04:00
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleTextReset* textStyle =
|
|
|
|
(const nsStyleTextReset*)mStyleContext->GetStyleData(eStyleStruct_TextReset);
|
1998-12-23 18:47:43 +03:00
|
|
|
/* XXX: remove tableFrame when border-collapse inherits */
|
2000-02-12 04:55:40 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
1999-08-28 01:53:04 +04:00
|
|
|
(void) nsTableFrame::GetTableFrame(this, tableFrame);
|
1999-07-28 12:09:02 +04:00
|
|
|
nsMargin borderPadding;
|
|
|
|
GetCellBorder (borderPadding, tableFrame);
|
2000-02-12 04:55:40 +03:00
|
|
|
nsMargin padding = nsTableFrame::GetPadding(aReflowState, this);
|
1999-07-28 12:09:02 +04:00
|
|
|
borderPadding += padding;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
nscoord topInset = borderPadding.top;
|
|
|
|
nscoord bottomInset = borderPadding.bottom;
|
2000-07-28 13:19:26 +04:00
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
// As per bug 10207, we map 'sub', 'super', 'text-top', 'text-bottom',
|
|
|
|
// length and percentage values to 'baseline'
|
|
|
|
// XXX It seems that we don't get to see length and percentage values here
|
|
|
|
// because the Style System has already fixed the error and mapped them
|
|
|
|
// to whatever is inherited from the parent, i.e, 'middle' in most cases.
|
|
|
|
PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_BASELINE;
|
|
|
|
if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
|
|
|
|
verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue();
|
|
|
|
if (verticalAlignFlags != NS_STYLE_VERTICAL_ALIGN_TOP &&
|
|
|
|
verticalAlignFlags != NS_STYLE_VERTICAL_ALIGN_MIDDLE &&
|
|
|
|
verticalAlignFlags != NS_STYLE_VERTICAL_ALIGN_BOTTOM)
|
|
|
|
{
|
|
|
|
verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_BASELINE;
|
|
|
|
}
|
2000-07-28 13:19:26 +04:00
|
|
|
}
|
2000-06-05 12:25:11 +04:00
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
nscoord height = mRect.height;
|
|
|
|
nsRect kidRect;
|
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
|
|
|
firstKid->GetRect(kidRect);
|
|
|
|
nscoord childHeight = kidRect.height;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
// Vertically align the child
|
|
|
|
nscoord kidYTop = 0;
|
|
|
|
switch (verticalAlignFlags)
|
|
|
|
{
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BASELINE:
|
1999-08-27 08:29:05 +04:00
|
|
|
// Align the baselines of the child frame with the baselines of
|
2000-06-05 12:25:11 +04:00
|
|
|
// other children in the same row which have 'vertical-align: baseline'
|
|
|
|
kidYTop = topInset + aMaxAscent - GetDesiredAscent();
|
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
case NS_STYLE_VERTICAL_ALIGN_TOP:
|
1999-08-27 08:29:05 +04:00
|
|
|
// Align the top of the child frame with the top of the content area,
|
1999-07-28 12:09:02 +04:00
|
|
|
kidYTop = topInset;
|
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
1999-08-27 08:29:05 +04:00
|
|
|
// Align the bottom of the child frame with the bottom of the content area,
|
1999-07-28 12:09:02 +04:00
|
|
|
kidYTop = height - childHeight - bottomInset;
|
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
default:
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
|
1999-08-27 08:29:05 +04:00
|
|
|
// Align the middle of the child frame with the middle of the content area,
|
|
|
|
kidYTop = (height - childHeight - bottomInset + topInset) / 2;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1999-10-26 08:44:41 +04:00
|
|
|
firstKid->MoveTo(aPresContext, kidRect.x, kidYTop);
|
1999-11-19 18:33:29 +03:00
|
|
|
if (kidYTop != kidRect.y) {
|
|
|
|
// Make sure any child views are correctly positioned. We know the inner table
|
|
|
|
// cell won't have a view
|
|
|
|
nsContainerFrame::PositionChildViews(aPresContext, firstKid);
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
// As per bug 10207, we map 'sub', 'super', 'text-top', 'text-bottom',
|
|
|
|
// length and percentage values to 'baseline'
|
|
|
|
// XXX It seems that we don't get to see length and percentage values here
|
|
|
|
// because the Style System has already fixed the error and mapped them
|
|
|
|
// to whatever is inherited from the parent, i.e, 'middle' in most cases.
|
|
|
|
PRBool
|
|
|
|
nsTableCellFrame::HasVerticalAlignBaseline()
|
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleTextReset* textStyle;
|
|
|
|
GetStyleData(eStyleStruct_TextReset, (const nsStyleStruct*&)textStyle);
|
2000-06-05 12:25:11 +04:00
|
|
|
if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
|
|
|
|
PRUint8 verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue();
|
|
|
|
if (verticalAlignFlags == NS_STYLE_VERTICAL_ALIGN_TOP ||
|
|
|
|
verticalAlignFlags == NS_STYLE_VERTICAL_ALIGN_MIDDLE ||
|
|
|
|
verticalAlignFlags == NS_STYLE_VERTICAL_ALIGN_BOTTOM)
|
|
|
|
{
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
PRInt32 nsTableCellFrame::GetRowSpan()
|
|
|
|
{
|
|
|
|
PRInt32 rowSpan=1;
|
|
|
|
nsIHTMLContent *hc=nsnull;
|
|
|
|
nsresult rv = mContent->QueryInterface(kIHTMLContentIID, (void**) &hc);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_OK==rv) {
|
1998-09-15 21:58:24 +04:00
|
|
|
nsHTMLValue val;
|
1998-12-20 04:21:23 +03:00
|
|
|
hc->GetHTMLAttribute(nsHTMLAtoms::rowspan, val);
|
1998-09-15 21:58:24 +04:00
|
|
|
if (eHTMLUnit_Integer == val.GetUnit()) {
|
|
|
|
rowSpan=val.GetIntValue();
|
|
|
|
}
|
|
|
|
NS_RELEASE(hc);
|
|
|
|
}
|
|
|
|
return rowSpan;
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
PRInt32 nsTableCellFrame::GetColSpan()
|
|
|
|
{
|
|
|
|
PRInt32 colSpan=1;
|
|
|
|
nsIHTMLContent *hc=nsnull;
|
|
|
|
nsresult rv = mContent->QueryInterface(kIHTMLContentIID, (void**) &hc);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_OK==rv) {
|
1998-09-15 21:58:24 +04:00
|
|
|
nsHTMLValue val;
|
1998-12-20 04:21:23 +03:00
|
|
|
hc->GetHTMLAttribute(nsHTMLAtoms::colspan, val);
|
1998-09-15 21:58:24 +04:00
|
|
|
if (eHTMLUnit_Integer == val.GetUnit()) {
|
|
|
|
colSpan=val.GetIntValue();
|
|
|
|
}
|
|
|
|
NS_RELEASE(hc);
|
|
|
|
}
|
|
|
|
return colSpan;
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
2001-02-07 07:31:38 +03:00
|
|
|
#define PROBABLY_TOO_LARGE 1000000
|
1999-08-20 17:32:23 +04:00
|
|
|
static
|
1999-04-29 21:43:41 +04:00
|
|
|
void DebugCheckChildSize(nsIFrame* aChild,
|
|
|
|
nsHTMLReflowMetrics& aMet,
|
|
|
|
nsSize& aAvailSize,
|
|
|
|
PRBool aIsPass2Reflow)
|
1999-03-13 15:49:37 +03:00
|
|
|
{
|
1999-04-29 21:43:41 +04:00
|
|
|
if (aIsPass2Reflow) {
|
2001-02-07 07:31:38 +03:00
|
|
|
if ((aMet.width < 0) || (aMet.width > PROBABLY_TOO_LARGE)) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("WARNING: cell content %p has large width %d \n", aChild, aMet.width);
|
1999-04-29 21:43:41 +04:00
|
|
|
}
|
1999-03-13 15:49:37 +03:00
|
|
|
}
|
|
|
|
if (aMet.maxElementSize) {
|
|
|
|
nscoord tmp = aMet.maxElementSize->width;
|
2001-02-07 07:31:38 +03:00
|
|
|
if ((tmp < 0) || (tmp > PROBABLY_TOO_LARGE)) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("WARNING: cell content %p has large max element width %d \n", aChild, tmp);
|
1999-03-13 15:49:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
|
1999-04-29 21:43:41 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-04-29 21:43:41 +04:00
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2000-04-22 01:36:33 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableCellFrame", aReflowState.reason);
|
2001-10-29 04:43:59 +03:00
|
|
|
DISPLAY_REFLOW(this, aReflowState, aDesiredSize, aStatus);
|
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 18:55:51 +03:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState);
|
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
nsresult rv = NS_OK;
|
1999-04-10 01:09:52 +04:00
|
|
|
// this should probably be cached somewhere
|
|
|
|
nsCompatibility compatMode;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetCompatibilityMode(&compatMode);
|
1998-10-30 10:57:44 +03:00
|
|
|
|
1998-06-03 04:43:53 +04:00
|
|
|
// Initialize out parameter
|
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
|
|
|
}
|
|
|
|
|
1998-05-12 08:17:56 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1999-01-06 02:31:18 +03:00
|
|
|
nsSize availSize(aReflowState.availableWidth, aReflowState.availableHeight);
|
1998-04-14 00:24:54 +04:00
|
|
|
nsSize maxElementSize;
|
2001-03-13 09:38:59 +03:00
|
|
|
nsSize* pMaxElementSize = aDesiredSize.maxElementSize;
|
1999-01-06 02:31:18 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE==aReflowState.availableWidth)
|
1998-04-14 00:24:54 +04:00
|
|
|
pMaxElementSize = &maxElementSize;
|
1999-05-12 02:03:29 +04:00
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
/* XXX: remove tableFrame when border-collapse inherits */
|
|
|
|
nsTableFrame* tableFrame=nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
2000-02-12 04:55:40 +03:00
|
|
|
nsMargin borderPadding = aReflowState.mComputedPadding;
|
1999-04-10 01:09:52 +04:00
|
|
|
nsMargin border;
|
|
|
|
GetCellBorder(border, tableFrame);
|
|
|
|
if ((NS_UNCONSTRAINEDSIZE == availSize.width) || !GetContentEmpty()) {
|
|
|
|
borderPadding += border;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord topInset = borderPadding.top;
|
|
|
|
nscoord rightInset = borderPadding.right;
|
1998-05-13 02:28:01 +04:00
|
|
|
nscoord bottomInset = borderPadding.bottom;
|
1999-04-10 01:09:52 +04:00
|
|
|
nscoord leftInset = borderPadding.left;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-07-07 01:00:11 +04:00
|
|
|
// reduce available space by insets, if we're in a constrained situation
|
1998-06-26 04:48:44 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE!=availSize.width)
|
1998-07-07 01:00:11 +04:00
|
|
|
availSize.width -= leftInset+rightInset;
|
1998-06-26 04:48:44 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE!=availSize.height)
|
1998-11-22 11:56:19 +03:00
|
|
|
availSize.height -= topInset+bottomInset;
|
1998-06-26 04:48:44 +04:00
|
|
|
|
1999-08-29 08:18:00 +04:00
|
|
|
PRBool isStyleChanged = PR_FALSE;
|
2001-03-13 09:38:59 +03:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
1999-03-13 15:49:37 +03:00
|
|
|
// We *must* do this otherwise incremental reflow that's
|
1998-07-17 02:15:02 +04:00
|
|
|
// passing through will not work right.
|
|
|
|
nsIFrame* next;
|
|
|
|
aReflowState.reflowCommand->GetNext(next);
|
1998-10-30 10:57:44 +03:00
|
|
|
|
|
|
|
// if it is a StyleChanged reflow targeted at this cell frame,
|
|
|
|
// handle that here
|
|
|
|
// first determine if this frame is the target or not
|
|
|
|
nsIFrame *target=nsnull;
|
|
|
|
rv = aReflowState.reflowCommand->GetTarget(target);
|
2001-03-13 09:38:59 +03:00
|
|
|
if ((PR_TRUE==NS_SUCCEEDED(rv)) && target) {
|
|
|
|
if (this == target) {
|
1998-10-30 10:57:44 +03:00
|
|
|
nsIReflowCommand::ReflowType type;
|
|
|
|
aReflowState.reflowCommand->GetType(type);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (nsIReflowCommand::StyleChanged == type) {
|
1999-08-29 08:18:00 +04:00
|
|
|
isStyleChanged = PR_TRUE;
|
1998-10-30 10:57:44 +03:00
|
|
|
}
|
1999-04-15 23:28:11 +04:00
|
|
|
else {
|
|
|
|
NS_ASSERTION(PR_FALSE, "table cell target of illegal incremental reflow type");
|
|
|
|
}
|
1998-10-30 10:57:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// if any of these conditions are not true, we just pass the reflow command down
|
1998-07-17 02:15:02 +04:00
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Try to reflow the child into the available space. It might not
|
|
|
|
// fit or might need continuing.
|
1998-04-23 21:29:07 +04:00
|
|
|
if (availSize.height < 0)
|
|
|
|
availSize.height = 1;
|
1998-09-24 20:37:22 +04:00
|
|
|
|
1999-12-30 07:15:45 +03:00
|
|
|
nsHTMLReflowMetrics kidSize(pMaxElementSize, aDesiredSize.mFlags);
|
1998-06-03 04:43:53 +04:00
|
|
|
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
1999-01-06 02:31:18 +03:00
|
|
|
SetPriorAvailWidth(aReflowState.availableWidth);
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
1999-03-05 07:19:09 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, firstKid,
|
1998-10-12 18:48:02 +04:00
|
|
|
availSize);
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1999-08-29 08:18:00 +04:00
|
|
|
// If it was a style change targeted at us, then reflow the child using
|
|
|
|
// the special reflow reason
|
|
|
|
if (isStyleChanged) {
|
|
|
|
kidReflowState.reason = eReflowReason_StyleChange;
|
|
|
|
kidReflowState.reflowCommand = nsnull;
|
2001-03-26 10:13:56 +04:00
|
|
|
// the following could be optimized with a fair amount of effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-08-29 08:18:00 +04:00
|
|
|
}
|
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
// Assume the inner child will stay positioned exactly where it is. Later in
|
|
|
|
// VerticallyAlignChild() we'll move it if it turns out to be wrong. This
|
|
|
|
// avoids excessive movement and is more stable
|
|
|
|
nsPoint kidOrigin;
|
2001-10-22 18:31:18 +04:00
|
|
|
if (isStyleChanged || (eReflowReason_Initial == aReflowState.reason)) {
|
1999-11-19 18:33:29 +03:00
|
|
|
kidOrigin.MoveTo(leftInset, topInset);
|
|
|
|
} else {
|
2000-02-12 04:55:40 +03:00
|
|
|
// handle percent padding-left which was 0 during initial reflow
|
2001-02-07 12:57:26 +03:00
|
|
|
if (eStyleUnit_Percent == aReflowState.mStylePadding->mPadding.GetLeftUnit()) {
|
2000-02-12 04:55:40 +03:00
|
|
|
nsRect kidRect;
|
|
|
|
firstKid->GetRect(kidRect);
|
|
|
|
// only move in the x direction for the same reason as above
|
|
|
|
kidOrigin.MoveTo(leftInset, kidRect.y);
|
|
|
|
firstKid->MoveTo(aPresContext, leftInset, kidRect.y);
|
|
|
|
}
|
1999-11-19 18:33:29 +03:00
|
|
|
firstKid->GetOrigin(kidOrigin);
|
|
|
|
}
|
2000-05-26 02:40:21 +04:00
|
|
|
|
2001-10-29 04:43:59 +03:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 18:55:51 +03:00
|
|
|
nsTableFrame::DebugReflow(firstKid, (nsHTMLReflowState&)kidReflowState);
|
|
|
|
#endif
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(firstKid, aPresContext, kidSize, kidReflowState,
|
|
|
|
kidOrigin.x, kidOrigin.y, 0, aStatus);
|
2000-09-11 06:47:02 +04:00
|
|
|
if (isStyleChanged) {
|
|
|
|
Invalidate(aPresContext, mRect);
|
|
|
|
}
|
2001-10-29 04:43:59 +03:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 18:55:51 +03:00
|
|
|
nsTableFrame::DebugReflow(firstKid, (nsHTMLReflowState&)kidReflowState, &kidSize, aStatus);
|
|
|
|
#endif
|
1999-08-21 10:38:07 +04:00
|
|
|
|
1998-09-10 00:00:40 +04:00
|
|
|
#ifdef NS_DEBUG
|
1999-04-29 21:43:41 +04:00
|
|
|
DebugCheckChildSize(firstKid, kidSize, availSize, (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth));
|
1998-12-08 22:18:33 +03:00
|
|
|
#endif
|
|
|
|
|
1999-04-10 01:09:52 +04:00
|
|
|
// 0 dimensioned cells need to be treated specially in Standard/NavQuirks mode
|
1999-09-10 22:55:46 +04:00
|
|
|
// see testcase "emptyCells.html"
|
2000-01-28 05:19:45 +03:00
|
|
|
if ((0 == kidSize.width) || (0 == kidSize.height)) { // XXX why was this &&
|
|
|
|
SetContentEmpty(PR_TRUE);
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == kidReflowState.availableWidth) {
|
1999-04-10 01:09:52 +04:00
|
|
|
// need to reduce the insets by border if the cell is empty
|
|
|
|
leftInset -= border.left;
|
|
|
|
rightInset -= border.right;
|
|
|
|
topInset -= border.top;
|
|
|
|
bottomInset -= border.bottom;
|
|
|
|
}
|
2000-01-28 05:19:45 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetContentEmpty(PR_FALSE);
|
1998-12-10 22:57:42 +03:00
|
|
|
}
|
1999-09-10 22:55:46 +04:00
|
|
|
|
|
|
|
const nsStylePosition* pos;
|
|
|
|
GetStyleData(eStyleStruct_Position, ((const nsStyleStruct *&)pos));
|
|
|
|
|
|
|
|
// calculate the min cell width
|
|
|
|
float p2t;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
1999-09-10 22:55:46 +04:00
|
|
|
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
|
2001-09-26 17:49:26 +04:00
|
|
|
nscoord smallestMinWidth = 0;
|
1999-09-10 22:55:46 +04:00
|
|
|
if (eCompatibility_NavQuirks == compatMode) {
|
|
|
|
if ((pos->mWidth.GetUnit() != eStyleUnit_Coord) &&
|
|
|
|
(pos->mWidth.GetUnit() != eStyleUnit_Percent)) {
|
1999-10-18 17:45:41 +04:00
|
|
|
if (PR_TRUE == GetContentEmpty()) {
|
|
|
|
if (border.left > 0)
|
|
|
|
smallestMinWidth += onePixel;
|
|
|
|
if (border.right > 0)
|
|
|
|
smallestMinWidth += onePixel;
|
|
|
|
}
|
1999-09-10 22:55:46 +04:00
|
|
|
}
|
1999-10-05 08:21:00 +04:00
|
|
|
}
|
2000-02-01 06:23:29 +03:00
|
|
|
PRInt32 colspan = tableFrame->GetEffectiveColSpan(*this);
|
1999-10-05 08:21:00 +04:00
|
|
|
if (colspan > 1) {
|
|
|
|
smallestMinWidth = PR_MAX(smallestMinWidth, colspan * onePixel);
|
|
|
|
nscoord spacingX = tableFrame->GetCellSpacingX();
|
|
|
|
nscoord spacingExtra = spacingX * (colspan - 1);
|
|
|
|
smallestMinWidth += spacingExtra;
|
2000-02-12 04:55:40 +03:00
|
|
|
if (aReflowState.mComputedPadding.left > 0) {
|
1999-10-05 08:21:00 +04:00
|
|
|
smallestMinWidth -= onePixel;
|
1999-09-10 22:55:46 +04:00
|
|
|
}
|
|
|
|
}
|
1999-10-05 08:21:00 +04:00
|
|
|
|
1999-09-13 18:35:00 +04:00
|
|
|
if ((0 == kidSize.width) && (NS_UNCONSTRAINEDSIZE != kidReflowState.availableWidth)) {
|
|
|
|
// empty content has to be forced to the assigned width for resize or incremental reflow
|
|
|
|
kidSize.width = kidReflowState.availableWidth;
|
1998-11-25 21:43:56 +03:00
|
|
|
}
|
1999-04-10 01:09:52 +04:00
|
|
|
if (0 == kidSize.height) {
|
|
|
|
if ((pos->mHeight.GetUnit() != eStyleUnit_Coord) &&
|
|
|
|
(pos->mHeight.GetUnit() != eStyleUnit_Percent)) {
|
|
|
|
// Standard mode should probably be 0 pixels high instead of 1
|
|
|
|
PRInt32 pixHeight = (eCompatibility_Standard == compatMode) ? 1 : 2;
|
|
|
|
kidSize.height = NSIntPixelsToTwips(pixHeight, p2t);
|
|
|
|
if ((nsnull != aDesiredSize.maxElementSize) && (0 == pMaxElementSize->height))
|
|
|
|
pMaxElementSize->height = kidSize.height;
|
|
|
|
}
|
1998-12-05 08:27:21 +03:00
|
|
|
}
|
1999-04-10 01:09:52 +04:00
|
|
|
// end 0 dimensioned cells
|
1998-12-08 22:18:33 +03:00
|
|
|
|
1999-09-10 22:55:46 +04:00
|
|
|
kidSize.width = PR_MAX(kidSize.width, smallestMinWidth);
|
2001-01-26 01:57:53 +03:00
|
|
|
if (!tableFrame->IsAutoLayout()) {
|
|
|
|
// a cell in a fixed layout table is constrained to the avail width
|
|
|
|
kidSize.width = PR_MIN(kidSize.width, availSize.width);
|
|
|
|
}
|
2001-01-12 02:22:44 +03:00
|
|
|
//if (eReflowReason_Resize == aReflowState.reason) {
|
|
|
|
// NS_ASSERTION(kidSize.width <= availSize.width, "child needed more space during resize reflow");
|
|
|
|
//}
|
1998-06-05 06:36:25 +04:00
|
|
|
// Place the child
|
1999-11-19 18:33:29 +03:00
|
|
|
FinishReflowChild(firstKid, aPresContext, kidSize,
|
|
|
|
kidOrigin.x, kidOrigin.y, 0);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-04-10 01:09:52 +04:00
|
|
|
// first, compute the height which can be set w/o being restricted by aMaxSize.height
|
1999-09-13 18:35:00 +04:00
|
|
|
nscoord cellHeight = kidSize.height;
|
2001-08-08 05:13:35 +04:00
|
|
|
|
1999-09-13 18:35:00 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != cellHeight) {
|
|
|
|
cellHeight += topInset + bottomInset;
|
|
|
|
}
|
2001-03-26 03:06:08 +04:00
|
|
|
cellHeight = nsTableFrame::RoundToPixel(cellHeight, p2t); // work around block rounding errors
|
1999-08-19 23:52:37 +04:00
|
|
|
|
2001-08-08 05:13:35 +04:00
|
|
|
// if the table allocated extra vertical space to row groups, rows, cells in pagination mode
|
|
|
|
// then use that height as the desired height unless the cell needs to split.
|
|
|
|
nsTableFrame* tableFrameFirstInFlow = (nsTableFrame*)tableFrame->GetFirstInFlow();
|
|
|
|
if ((NS_FRAME_COMPLETE == aStatus) && tableFrameFirstInFlow->IsThirdPassReflow()) {
|
|
|
|
cellHeight = PR_MAX(cellHeight, mRect.height);
|
|
|
|
}
|
1998-06-05 06:36:25 +04:00
|
|
|
// next determine the cell's width
|
1998-07-07 01:00:11 +04:00
|
|
|
nscoord cellWidth = kidSize.width; // at this point, we've factored in the cell's style attributes
|
1998-07-02 21:40:56 +04:00
|
|
|
|
1999-09-13 18:35:00 +04:00
|
|
|
// factor in border and padding
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != cellWidth) {
|
|
|
|
cellWidth += leftInset + rightInset;
|
|
|
|
}
|
2001-03-26 03:06:08 +04:00
|
|
|
cellWidth = nsTableFrame::RoundToPixel(cellWidth, p2t); // work around block rounding errors
|
1998-07-31 04:32:27 +04:00
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
// set the cell's desired size and max element size
|
1999-09-13 18:35:00 +04:00
|
|
|
aDesiredSize.width = cellWidth;
|
|
|
|
aDesiredSize.height = cellHeight;
|
|
|
|
aDesiredSize.ascent = topInset;
|
1998-04-14 00:24:54 +04:00
|
|
|
aDesiredSize.descent = bottomInset;
|
2000-07-28 13:19:26 +04:00
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
aDesiredSize.ascent += kidSize.ascent;
|
|
|
|
aDesiredSize.descent += kidSize.descent;
|
2000-07-28 13:19:26 +04:00
|
|
|
|
1999-12-30 07:15:45 +03:00
|
|
|
if (aDesiredSize.mFlags & NS_REFLOW_CALC_MAX_WIDTH) {
|
2001-03-13 09:38:59 +03:00
|
|
|
aDesiredSize.mMaximumWidth = kidSize.mMaximumWidth;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aDesiredSize.mMaximumWidth) {
|
|
|
|
aDesiredSize.mMaximumWidth += leftInset + rightInset;
|
2001-03-26 04:56:44 +04:00
|
|
|
aDesiredSize.mMaximumWidth = nsTableFrame::RoundToPixel(aDesiredSize.mMaximumWidth, p2t);
|
2001-03-13 09:38:59 +03:00
|
|
|
}
|
1999-12-30 07:15:45 +03:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
if (aDesiredSize.maxElementSize) {
|
1998-05-25 21:31:49 +04:00
|
|
|
*aDesiredSize.maxElementSize = *pMaxElementSize;
|
2001-03-26 04:56:44 +04:00
|
|
|
if ((0 != pMaxElementSize->height) && (NS_UNCONSTRAINEDSIZE != pMaxElementSize->height)) {
|
1998-07-14 00:41:38 +04:00
|
|
|
aDesiredSize.maxElementSize->height += topInset + bottomInset;
|
2001-03-26 04:56:44 +04:00
|
|
|
aDesiredSize.maxElementSize->height = nsTableFrame::RoundToPixel(aDesiredSize.maxElementSize->height, p2t);
|
1999-09-13 18:35:00 +04:00
|
|
|
}
|
1999-09-10 22:55:46 +04:00
|
|
|
aDesiredSize.maxElementSize->width = PR_MAX(smallestMinWidth, aDesiredSize.maxElementSize->width);
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aDesiredSize.maxElementSize->width) {
|
|
|
|
aDesiredSize.maxElementSize->width += leftInset + rightInset;
|
2001-03-26 04:56:44 +04:00
|
|
|
aDesiredSize.maxElementSize->width = nsTableFrame::RoundToPixel(aDesiredSize.maxElementSize->width, p2t);
|
2001-03-13 09:38:59 +03:00
|
|
|
}
|
1998-04-21 02:49:15 +04:00
|
|
|
}
|
1998-10-03 00:36:35 +04:00
|
|
|
// remember my desired size for this reflow
|
1998-07-11 04:00:31 +04:00
|
|
|
SetDesiredSize(aDesiredSize);
|
1998-10-03 00:36:35 +04:00
|
|
|
|
2001-10-29 04:43:59 +03:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 18:55:51 +03:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState, &aDesiredSize, aStatus);
|
|
|
|
#endif
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-05-02 00:44:55 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Update the border style to map to the HTML border style
|
|
|
|
*
|
|
|
|
*/
|
1998-11-11 22:56:02 +03:00
|
|
|
void nsTableCellFrame::MapHTMLBorderStyle(nsIPresContext* aPresContext,
|
2001-02-07 12:57:26 +03:00
|
|
|
nsStyleBorder& aBorderStyle,
|
1999-05-18 09:18:16 +04:00
|
|
|
nsTableFrame* aTableFrame)
|
1998-05-02 00:44:55 +04:00
|
|
|
{
|
1998-11-11 22:56:02 +03:00
|
|
|
//adjust the border style based on the table rules attribute
|
2000-10-06 03:49:25 +04:00
|
|
|
|
|
|
|
/* The RULES code below has been disabled because collapsing borders have been disabled
|
|
|
|
and RULES depend on collapsing borders
|
|
|
|
|
1998-11-11 22:56:02 +03:00
|
|
|
const nsStyleTable* tableStyle;
|
1999-09-02 04:07:14 +04:00
|
|
|
aTableFrame->GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
1998-11-11 22:56:02 +03:00
|
|
|
|
|
|
|
switch (tableStyle->mRules)
|
|
|
|
{
|
|
|
|
case NS_STYLE_TABLE_RULES_NONE:
|
2001-02-07 12:57:26 +03:00
|
|
|
aBorderStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
aBorderStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
aBorderStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
aBorderStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
|
1998-11-11 22:56:02 +03:00
|
|
|
break;
|
1999-09-02 04:07:14 +04:00
|
|
|
|
1998-11-11 22:56:02 +03:00
|
|
|
case NS_STYLE_TABLE_RULES_COLS:
|
2001-02-07 12:57:26 +03:00
|
|
|
aBorderStyle.SetBorderStyle(NS_SIDE_TOP, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
aBorderStyle.SetBorderStyle(NS_SIDE_BOTTOM, NS_STYLE_BORDER_STYLE_NONE);
|
1998-11-11 22:56:02 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_TABLE_RULES_ROWS:
|
2001-02-07 12:57:26 +03:00
|
|
|
aBorderStyle.SetBorderStyle(NS_SIDE_LEFT, NS_STYLE_BORDER_STYLE_NONE);
|
|
|
|
aBorderStyle.SetBorderStyle(NS_SIDE_RIGHT, NS_STYLE_BORDER_STYLE_NONE);
|
1998-11-11 22:56:02 +03:00
|
|
|
break;
|
|
|
|
|
1999-09-02 04:07:14 +04:00
|
|
|
default:
|
|
|
|
// do nothing for "GROUPS" or "ALL" or for any illegal value
|
|
|
|
// "GROUPS" will be handled in nsTableFrame::ProcessGroupRules
|
|
|
|
break;
|
1998-11-11 22:56:02 +03:00
|
|
|
}
|
2000-10-06 03:49:25 +04:00
|
|
|
*/
|
1998-05-02 00:44:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
PRBool nsTableCellFrame::ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult)
|
1998-05-02 01:55:36 +04:00
|
|
|
{
|
1998-05-22 03:43:18 +04:00
|
|
|
if (aValue.GetUnit() == eHTMLUnit_Pixel)
|
1998-05-02 01:55:36 +04:00
|
|
|
aResult = aValue.GetPixelValue();
|
|
|
|
else if (aValue.GetUnit() == eHTMLUnit_Empty)
|
|
|
|
aResult = aDefault;
|
2001-03-13 09:38:59 +03:00
|
|
|
else {
|
1998-05-22 03:43:18 +04:00
|
|
|
NS_ERROR("Unit must be pixel or empty");
|
1998-05-02 01:55:36 +04:00
|
|
|
return PR_FALSE;
|
1998-05-22 03:43:18 +04:00
|
|
|
}
|
1998-05-02 01:55:36 +04:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
1998-05-02 00:44:55 +04:00
|
|
|
|
1999-10-20 18:18:56 +04:00
|
|
|
void nsTableCellFrame::MapBorderPadding(nsIPresContext* aPresContext)
|
1998-05-02 00:44:55 +04:00
|
|
|
{
|
1999-10-20 18:18:56 +04:00
|
|
|
// Check to see if the table has cell padding or defined for the table. If true,
|
|
|
|
// then this setting overrides any specific border or padding information in the
|
|
|
|
// cell. If these attributes are not defined, the the cells attributes are used
|
1998-05-02 00:44:55 +04:00
|
|
|
|
1998-09-24 20:37:22 +04:00
|
|
|
nsTableFrame* tableFrame;
|
|
|
|
nsTableFrame::GetTableFrame(this, tableFrame);
|
1998-11-20 04:01:25 +03:00
|
|
|
NS_ASSERTION(tableFrame,"Table must not be null");
|
1998-06-11 19:46:37 +04:00
|
|
|
if (!tableFrame)
|
1998-05-02 00:44:55 +04:00
|
|
|
return;
|
|
|
|
|
1998-06-11 19:46:37 +04:00
|
|
|
// get the table frame style context, and from it get cellpadding, cellspacing, and border info
|
1998-11-11 22:56:02 +03:00
|
|
|
const nsStyleTable* tableStyle;
|
|
|
|
tableFrame->GetStyleData(eStyleStruct_Table, (const nsStyleStruct *&)tableStyle);
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
float p2t;
|
|
|
|
aPresContext->GetPixelsToTwips(&p2t);
|
2001-02-07 12:57:26 +03:00
|
|
|
|
1998-11-20 04:01:25 +03:00
|
|
|
|
1999-01-03 22:22:40 +03:00
|
|
|
MapVAlignAttribute(aPresContext, tableFrame);
|
|
|
|
MapHAlignAttribute(aPresContext, tableFrame);
|
1998-06-24 03:23:21 +04:00
|
|
|
|
1998-05-02 00:44:55 +04:00
|
|
|
}
|
|
|
|
|
1999-01-03 22:22:40 +03:00
|
|
|
/* XXX: this code will not work properly until the style and layout code has been updated
|
|
|
|
* as outlined in Bugzilla bug report 1802 and 915 */
|
|
|
|
void nsTableCellFrame::MapVAlignAttribute(nsIPresContext* aPresContext, nsTableFrame *aTableFrame)
|
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
#if 0
|
|
|
|
const nsStyleTextReset* textStyle;
|
|
|
|
GetStyleData(eStyleStruct_TextReset,(const nsStyleStruct *&)textStyle);
|
1999-01-03 22:22:40 +03:00
|
|
|
// check if valign is set on the cell
|
2000-02-16 04:08:54 +03:00
|
|
|
// this condition will also be true if we inherited valign from the row or rowgroup
|
|
|
|
if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
|
1999-01-03 22:22:40 +03:00
|
|
|
return; // valign is already set on this cell
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if valign is set on the cell's COL (or COLGROUP by inheritance)
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 colIndex;
|
|
|
|
GetColIndex(colIndex);
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableColFrame* colFrame = aTableFrame->GetColFrame(colIndex);
|
1999-08-10 22:15:46 +04:00
|
|
|
if (colFrame) {
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleTextReset* colTextStyle;
|
|
|
|
colFrame->GetStyleData(eStyleStruct_TextReset,(const nsStyleStruct *&)colTextStyle);
|
1999-08-10 22:15:46 +04:00
|
|
|
if (colTextStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleTextReset* cellTextStyle = (nsStyleTextReset*)mStyleContext->GetMutableStyleData(eStyleStruct_TextReset);
|
2000-02-16 04:08:54 +03:00
|
|
|
cellTextStyle->mVerticalAlign.SetIntValue(colTextStyle->mVerticalAlign.GetIntValue(), eStyleUnit_Enumerated);
|
1999-08-10 22:15:46 +04:00
|
|
|
return; // valign set from COL info
|
2000-02-16 04:08:54 +03:00
|
|
|
}
|
1999-01-03 22:22:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// otherwise, set the vertical align attribute to the HTML default
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleTextReset* cellTextStyle = (nsStyleTextReset*)mStyleContext->GetMutableStyleData(eStyleStruct_TextReset);
|
2000-02-16 04:08:54 +03:00
|
|
|
cellTextStyle->mVerticalAlign.SetIntValue(NS_STYLE_VERTICAL_ALIGN_MIDDLE, eStyleUnit_Enumerated);
|
2001-06-01 02:19:43 +04:00
|
|
|
#endif
|
1999-01-03 22:22:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: this code will not work properly until the style and layout code has been updated
|
|
|
|
* as outlined in Bugzilla bug report 1802 and 915.
|
|
|
|
* In particular, mTextAlign has to be an nsStyleCoord, not just an int */
|
2000-02-16 04:08:54 +03:00
|
|
|
void nsTableCellFrame::MapHAlignAttribute(nsIPresContext* aPresContext,
|
|
|
|
nsTableFrame* aTableFrame)
|
1999-01-03 22:22:40 +03:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
const nsStyleText* textStyle;
|
|
|
|
GetStyleData(eStyleStruct_Text,(const nsStyleStruct *&)textStyle);
|
|
|
|
// check if halign is set on the cell
|
2000-02-16 04:08:54 +03:00
|
|
|
// cells do not inherited halign from the row or rowgroup
|
|
|
|
if (NS_STYLE_TEXT_ALIGN_DEFAULT != textStyle->mTextAlign) {
|
|
|
|
return; // text align is already set on this cell
|
1999-01-03 22:22:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// check if halign is set on the cell's ROW (or ROWGROUP by inheritance)
|
2000-02-16 04:08:54 +03:00
|
|
|
nsIFrame* rowFrame;
|
|
|
|
GetParent(&rowFrame);
|
1999-01-03 22:22:40 +03:00
|
|
|
const nsStyleText* rowTextStyle;
|
|
|
|
rowFrame->GetStyleData(eStyleStruct_Text,(const nsStyleStruct *&)rowTextStyle);
|
2000-02-16 04:08:54 +03:00
|
|
|
if (NS_STYLE_TEXT_ALIGN_DEFAULT != rowTextStyle->mTextAlign) {
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleText* cellTextStyle = (nsStyleText*)mStyleContext->GetMutableStyleData(eStyleStruct_Text);
|
2000-02-16 04:08:54 +03:00
|
|
|
cellTextStyle->mTextAlign = rowTextStyle->mTextAlign;
|
1999-01-03 22:22:40 +03:00
|
|
|
return; // halign set from ROW info
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if halign is set on the cell's COL (or COLGROUP by inheritance)
|
1999-02-11 04:16:28 +03:00
|
|
|
PRInt32 colIndex;
|
|
|
|
GetColIndex(colIndex);
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableColFrame* colFrame = aTableFrame->GetColFrame(colIndex);
|
1999-08-10 22:15:46 +04:00
|
|
|
if (colFrame) {
|
|
|
|
const nsStyleText* colTextStyle;
|
|
|
|
colFrame->GetStyleData(eStyleStruct_Text,(const nsStyleStruct *&)colTextStyle);
|
2000-02-16 04:08:54 +03:00
|
|
|
if (NS_STYLE_TEXT_ALIGN_DEFAULT != colTextStyle->mTextAlign) {
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleText* cellTextStyle = (nsStyleText*)mStyleContext->GetMutableStyleData(eStyleStruct_Text);
|
2000-02-16 04:08:54 +03:00
|
|
|
cellTextStyle->mTextAlign = colTextStyle->mTextAlign;
|
1999-08-10 22:15:46 +04:00
|
|
|
return; // halign set from COL info
|
2000-02-16 04:08:54 +03:00
|
|
|
}
|
1999-01-03 22:22:40 +03:00
|
|
|
}
|
|
|
|
|
2000-02-16 04:08:54 +03:00
|
|
|
// otherwise, set the text align to the HTML default (center for TH, left for TD)
|
2001-06-01 02:19:43 +04:00
|
|
|
nsStyleText* cellTextStyle = (nsStyleText*)mStyleContext->GetMutableStyleData(eStyleStruct_Text);
|
2000-02-16 04:08:54 +03:00
|
|
|
nsIAtom* tag;
|
|
|
|
if (mContent) {
|
1999-01-03 22:22:40 +03:00
|
|
|
mContent->GetTag(tag);
|
2000-02-16 04:08:54 +03:00
|
|
|
if (tag) {
|
|
|
|
cellTextStyle->mTextAlign = (nsHTMLAtoms::th == tag)
|
|
|
|
? NS_STYLE_TEXT_ALIGN_CENTER
|
|
|
|
: NS_STYLE_TEXT_ALIGN_LEFT;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(tag);
|
|
|
|
}
|
1999-01-03 22:22:40 +03:00
|
|
|
#endif
|
|
|
|
}
|
1998-05-02 00:44:55 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-08-01 22:26:45 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsTableCellFrame, nsHTMLContainerFrame)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsTableCellFrame, nsHTMLContainerFrame)
|
1999-08-01 02:11:50 +04:00
|
|
|
|
1999-08-01 22:26:45 +04:00
|
|
|
nsresult nsTableCellFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2001-04-01 05:01:33 +04:00
|
|
|
|
2000-02-03 01:24:56 +03:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsITableCellLayout))) {
|
1999-08-04 06:04:45 +04:00
|
|
|
*aInstancePtr = (void*) (nsITableCellLayout *)this;
|
1999-08-01 22:26:45 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-05-18 03:52:32 +04:00
|
|
|
|
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-18 03:52:32 +04:00
|
|
|
NS_IMETHODIMP nsTableCellFrame::GetAccessible(nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
|
|
|
|
if (accService) {
|
|
|
|
nsIAccessible* acc = nsnull;
|
|
|
|
return accService->CreateHTMLTableCellAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-08-01 22:26:45 +04:00
|
|
|
}
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
1999-08-01 02:11:50 +04:00
|
|
|
|
1999-08-04 06:04:45 +04:00
|
|
|
/* This is primarily for editor access via nsITableLayout */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::GetCellIndexes(PRInt32 &aRowIndex, PRInt32 &aColIndex)
|
|
|
|
{
|
|
|
|
nsresult res = GetRowIndex(aRowIndex);
|
|
|
|
if (NS_FAILED(res))
|
|
|
|
{
|
|
|
|
aColIndex = 0;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
aColIndex = mColIndex;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-23 07:24:58 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::GetPreviousCellInColumn(nsITableCellLayout **aCellLayout)
|
|
|
|
{
|
|
|
|
if (!aCellLayout) return NS_ERROR_NULL_POINTER;
|
|
|
|
*aCellLayout = nsnull;
|
|
|
|
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
if (!tableFrame) return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// Get current cell location
|
|
|
|
PRInt32 rowIndex, colIndex;
|
|
|
|
GetCellIndexes(rowIndex, colIndex);
|
|
|
|
if (colIndex > 0)
|
|
|
|
{
|
|
|
|
// Get the cellframe at previous colIndex
|
|
|
|
nsTableCellFrame *cellFrame = tableFrame->GetCellFrameAt(rowIndex, colIndex-1);
|
|
|
|
if (cellFrame)
|
|
|
|
cellFrame->QueryInterface(NS_GET_IID(nsITableCellLayout), (void **)aCellLayout);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::GetNextCellInColumn(nsITableCellLayout **aCellLayout)
|
|
|
|
{
|
|
|
|
if (!aCellLayout) return NS_ERROR_NULL_POINTER;
|
|
|
|
*aCellLayout = nsnull;
|
|
|
|
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
if (!tableFrame) return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// Get current cell location
|
|
|
|
PRInt32 rowIndex, colIndex;
|
|
|
|
GetCellIndexes(rowIndex, colIndex);
|
|
|
|
|
|
|
|
// Get the cellframe at next colIndex
|
|
|
|
nsTableCellFrame *cellFrame = tableFrame->GetCellFrameAt(rowIndex, colIndex+1);
|
|
|
|
if (cellFrame)
|
|
|
|
cellFrame->QueryInterface(NS_GET_IID(nsITableCellLayout), (void **)aCellLayout);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewTableCellFrame(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
|
|
|
nsTableCellFrame* it = new (aPresShell) nsTableCellFrame;
|
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-05-22 03:43:18 +04:00
|
|
|
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
/* ----- methods from CellLayoutData ----- */
|
|
|
|
|
2000-02-12 04:55:40 +03:00
|
|
|
void
|
|
|
|
nsTableCellFrame::GetCellBorder(nsMargin& aBorder,
|
|
|
|
nsTableFrame* aTableFrame)
|
1998-12-23 18:47:43 +03:00
|
|
|
{
|
|
|
|
aBorder.left = aBorder.right = aBorder.top = aBorder.bottom = 0;
|
1999-03-14 20:36:10 +03:00
|
|
|
if (nsnull==aTableFrame) {
|
1998-12-23 18:47:43 +03:00
|
|
|
return;
|
1999-03-14 20:36:10 +03:00
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_STYLE_BORDER_SEPARATE == aTableFrame->GetBorderCollapseStyle()) {
|
2001-02-07 12:57:26 +03:00
|
|
|
const nsStyleBorder* borderData;
|
|
|
|
GetStyleData(eStyleStruct_Border, (const nsStyleStruct*&)borderData);
|
|
|
|
borderData->GetBorder(aBorder);
|
2001-03-13 09:38:59 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(PR_FALSE, "not implemented");
|
1998-12-23 18:47:43 +03:00
|
|
|
}
|
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1999-02-24 08:54:31 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::tableCellFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::GetFrameName(nsString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName("TableCell", aResult);
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-02-11 09:22:33 +03:00
|
|
|
|
1999-10-22 06:06:22 +04:00
|
|
|
// Destructor function for the collapse offset frame property
|
|
|
|
static void
|
|
|
|
DestroyPointFunc(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIAtom* aPropertyName,
|
|
|
|
void* aPropertyValue)
|
1999-02-11 09:22:33 +03:00
|
|
|
{
|
1999-10-22 06:06:22 +04:00
|
|
|
delete (nsPoint*)aPropertyValue;
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
|
|
|
|
1999-10-22 06:06:22 +04:00
|
|
|
static nsPoint*
|
|
|
|
GetCollapseOffsetProperty(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
PRBool aCreateIfNecessary = PR_FALSE)
|
1999-02-11 09:22:33 +03:00
|
|
|
{
|
1999-10-22 06:06:22 +04:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
|
|
|
|
if (presShell) {
|
|
|
|
nsCOMPtr<nsIFrameManager> frameManager;
|
|
|
|
presShell->GetFrameManager(getter_AddRefs(frameManager));
|
|
|
|
|
|
|
|
if (frameManager) {
|
|
|
|
void* value;
|
|
|
|
|
|
|
|
frameManager->GetFrameProperty(aFrame, nsLayoutAtoms::collapseOffsetProperty,
|
|
|
|
0, &value);
|
|
|
|
if (value) {
|
|
|
|
return (nsPoint*)value; // the property already exists
|
|
|
|
|
|
|
|
} else if (aCreateIfNecessary) {
|
|
|
|
// The property isn't set yet, so allocate a new point, set the property,
|
|
|
|
// and return the newly allocated point
|
|
|
|
nsPoint* offset = new nsPoint(0, 0);
|
2000-11-30 18:53:55 +03:00
|
|
|
if (!offset) return nsnull;
|
1999-10-22 06:06:22 +04:00
|
|
|
|
|
|
|
frameManager->SetFrameProperty(aFrame, nsLayoutAtoms::collapseOffsetProperty,
|
|
|
|
offset, DestroyPointFunc);
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableCellFrame::SetCollapseOffsetX(nsIPresContext* aPresContext,
|
|
|
|
nscoord aXOffset)
|
|
|
|
{
|
|
|
|
// Get the frame property (creating a point struct if necessary)
|
|
|
|
nsPoint* offset = ::GetCollapseOffsetProperty(aPresContext, this, PR_TRUE);
|
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
offset->x = aXOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableCellFrame::SetCollapseOffsetY(nsIPresContext* aPresContext,
|
|
|
|
nscoord aYOffset)
|
|
|
|
{
|
|
|
|
// Get the property (creating a point struct if necessary)
|
|
|
|
nsPoint* offset = ::GetCollapseOffsetProperty(aPresContext, this, PR_TRUE);
|
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
offset->y = aYOffset;
|
|
|
|
}
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
|
|
|
|
1999-10-22 06:06:22 +04:00
|
|
|
void nsTableCellFrame::GetCollapseOffset(nsIPresContext* aPresContext,
|
|
|
|
nsPoint& aOffset)
|
1999-02-11 09:22:33 +03:00
|
|
|
{
|
1999-10-22 06:06:22 +04:00
|
|
|
// See if the property is set
|
|
|
|
nsPoint* offset = ::GetCollapseOffsetProperty(aPresContext, this);
|
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
aOffset = *offset;
|
|
|
|
} else {
|
|
|
|
aOffset.MoveTo(0, 0);
|
|
|
|
}
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
|
|
|
|
1999-09-01 05:02:16 +04:00
|
|
|
#ifdef DEBUG
|
1999-08-31 07:09:40 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
|
|
|
{
|
1999-09-01 05:02:16 +04:00
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
PRUint32 sum = sizeof(*this);
|
|
|
|
*aResult = sum;
|
|
|
|
return NS_OK;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|