2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
2000-02-02 22:24:56 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-12-14 00:24:33 +00:00
|
|
|
#include "nsTableFrame.h"
|
1999-01-03 19:22:40 +00:00
|
|
|
#include "nsTableColFrame.h"
|
1999-12-14 00:24:33 +00:00
|
|
|
#include "nsTableCellFrame.h"
|
1998-11-11 19:56:02 +00:00
|
|
|
#include "nsTableFrame.h"
|
2001-11-29 15:41:07 +00:00
|
|
|
#include "nsTableRowGroupFrame.h"
|
2004-03-09 06:48:35 +00:00
|
|
|
#include "nsTablePainter.h"
|
2002-05-10 18:22:41 +00:00
|
|
|
#include "nsReflowPath.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsStyleConsts.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
2005-01-12 19:45:38 +00:00
|
|
|
#include "nsGenericHTMLElement.h"
|
1998-10-06 00:44:35 +00:00
|
|
|
#include "nsHTMLParts.h"
|
1998-05-01 20:44:55 +00:00
|
|
|
#include "nsHTMLAtoms.h"
|
1998-10-06 00:44:35 +00:00
|
|
|
#include "nsVoidArray.h"
|
1998-05-21 23:43:18 +00:00
|
|
|
#include "nsIView.h"
|
1999-02-24 05:54:31 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-10-22 02:06:22 +00:00
|
|
|
#include "nsIPresShell.h"
|
1999-07-28 08:09:02 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-09-30 14:11:16 +00:00
|
|
|
#include "nsIDOMHTMLTableCellElement.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-04-01 01:01:33 +00:00
|
|
|
#include "nsIAccessibilityService.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-04-01 01:01:33 +00:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
2001-09-21 13:43:18 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
2001-04-01 01:01:33 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2000-04-13 20:21:32 +00:00
|
|
|
//TABLECELL SELECTION
|
|
|
|
#include "nsIFrameSelection.h"
|
2000-04-13 22:39:39 +00:00
|
|
|
#include "nsILookAndFeel.h"
|
2000-04-13 20:21:32 +00:00
|
|
|
|
1998-06-23 23:23:21 +00:00
|
|
|
|
2000-01-04 05:31:56 +00:00
|
|
|
nsTableCellFrame::nsTableCellFrame()
|
|
|
|
{
|
2002-03-16 21:46:29 +00:00
|
|
|
mBits.mColIndex = 0;
|
2000-01-04 05:31:56 +00:00
|
|
|
mPriorAvailWidth = 0;
|
2002-03-16 21:46:29 +00:00
|
|
|
|
|
|
|
SetContentEmpty(PR_FALSE);
|
|
|
|
SetNeedSpecialReflow(PR_FALSE);
|
|
|
|
SetHadSpecialReflow(PR_FALSE);
|
|
|
|
SetHasPctOverHeight(PR_FALSE);
|
2002-05-09 14:44:02 +00:00
|
|
|
SetNeedPass2Reflow(PR_TRUE);
|
2002-03-16 21:46:29 +00:00
|
|
|
|
2001-01-25 15:55:51 +00:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
mTimer = new nsReflowTimer(this);
|
|
|
|
mBlockTimer = new nsReflowTimer(this);
|
|
|
|
#endif
|
2000-01-04 05:31:56 +00:00
|
|
|
}
|
|
|
|
|
1999-10-17 03:30:11 +00:00
|
|
|
nsTableCellFrame::~nsTableCellFrame()
|
|
|
|
{
|
2001-01-25 15:55:51 +00:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflowDone(this);
|
|
|
|
#endif
|
1999-10-17 03:30:11 +00:00
|
|
|
}
|
|
|
|
|
2001-11-05 00:15:51 +00:00
|
|
|
nsTableCellFrame*
|
|
|
|
nsTableCellFrame::GetNextCell() const
|
|
|
|
{
|
2003-07-07 02:01:29 +00:00
|
|
|
nsIFrame* childFrame = GetNextSibling();
|
2001-11-05 00:15:51 +00:00
|
|
|
while (childFrame) {
|
2003-10-31 20:19:18 +00:00
|
|
|
if (IS_TABLE_CELL(childFrame->GetType())) {
|
2001-11-05 00:15:51 +00:00
|
|
|
return (nsTableCellFrame*)childFrame;
|
|
|
|
}
|
2003-07-07 02:01:29 +00:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2001-11-05 00:15:51 +00:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
1999-02-25 05:31:15 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableCellFrame::Init(nsPresContext* aPresContext,
|
1999-02-25 05:31:15 +00:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aContext,
|
1999-02-25 05:31:15 +00:00
|
|
|
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-13 22:56:31 +00:00
|
|
|
PRInt32 colIndex;
|
|
|
|
cellFrame->GetColIndex(colIndex);
|
2004-04-21 15:49:29 +00:00
|
|
|
SetColIndex(colIndex);
|
1999-02-25 05:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2001-12-07 14:51:12 +00:00
|
|
|
|
|
|
|
// nsIPercentHeightObserver methods
|
|
|
|
|
2002-04-10 21:32:41 +00:00
|
|
|
void
|
2001-12-07 14:51:12 +00:00
|
|
|
nsTableCellFrame::NotifyPercentHeight(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
2002-04-06 22:42:39 +00:00
|
|
|
if (!NeedSpecialReflow()) {
|
2001-12-07 14:51:12 +00:00
|
|
|
// Only initiate a special reflow if we will be able to construct a computed height
|
|
|
|
// on the cell that will result in the frame getting a computed height. This can only
|
2002-04-01 06:46:17 +00:00
|
|
|
// happen (but not sufficient) if there is no computed height already set between the
|
2001-12-07 14:51:12 +00:00
|
|
|
// initiating frame and the cell.
|
|
|
|
for (const nsHTMLReflowState* rs = aReflowState.parentReflowState; rs; rs = rs->parentReflowState) {
|
|
|
|
if ((NS_UNCONSTRAINEDSIZE != rs->mComputedHeight) && (0 != rs->mComputedHeight)) {
|
2002-04-10 21:32:41 +00:00
|
|
|
return;
|
2001-12-07 14:51:12 +00:00
|
|
|
}
|
|
|
|
// stop when we reach the cell frame
|
|
|
|
if (rs->frame == this) {
|
2002-04-01 06:46:17 +00:00
|
|
|
nsTableFrame::RequestSpecialHeightReflow(*rs);
|
2002-04-10 21:32:41 +00:00
|
|
|
return;
|
2001-12-07 14:51:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_ASSERTION(PR_FALSE, "program error in NotifyPercentHeight");
|
|
|
|
}
|
2002-04-10 21:32:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The cell needs to observe its block and things inside its block but nothing below that
|
|
|
|
PRBool
|
|
|
|
nsTableCellFrame::NeedsToObserve(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
const nsHTMLReflowState* parentRS = aReflowState.parentReflowState;
|
|
|
|
if (parentRS && (parentRS->mPercentHeightObserver == this)) { // cell observes the parent
|
|
|
|
result = PR_TRUE;
|
|
|
|
parentRS = parentRS->parentReflowState;
|
|
|
|
if (parentRS && (parentRS->mPercentHeightObserver == this)) { // cell observers the grand parent
|
|
|
|
parentRS = parentRS->parentReflowState;
|
|
|
|
if (parentRS && (parentRS->mPercentHeightObserver == this)) {
|
|
|
|
// cell observes the great grand parent, so we have gone too deep
|
|
|
|
result = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
2001-12-07 14:51:12 +00:00
|
|
|
}
|
1999-02-25 05:31:15 +00:00
|
|
|
|
2001-04-16 14:51:52 +00:00
|
|
|
nsresult
|
|
|
|
nsTableCellFrame::GetRowIndex(PRInt32 &aRowIndex) const
|
|
|
|
{
|
|
|
|
nsresult result;
|
2003-07-07 02:01:29 +00:00
|
|
|
nsTableRowFrame* row = NS_STATIC_CAST(nsTableRowFrame*, GetParent());
|
2001-04-16 14:51:52 +00:00
|
|
|
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 {
|
2001-12-07 14:51:12 +00:00
|
|
|
aColIndex = mBits.mColIndex;
|
2001-04-16 14:51:52 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-04 05:31:56 +00:00
|
|
|
NS_IMETHODIMP
|
2004-12-31 01:13:27 +00:00
|
|
|
nsTableCellFrame::AttributeChanged(nsIContent* aChild,
|
2000-01-04 05:31:56 +00:00
|
|
|
PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
2003-07-11 21:16:12 +00:00
|
|
|
PRInt32 aModType)
|
2000-01-04 05:31:56 +00:00
|
|
|
{
|
|
|
|
// let the table frame decide what to do
|
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
nsresult rv = nsTableFrame::GetTableFrame(this, tableFrame);
|
|
|
|
if ((NS_SUCCEEDED(rv)) && (tableFrame)) {
|
2005-02-07 01:58:25 +00:00
|
|
|
tableFrame->AttributeChangedFor(this, aChild, aAttribute);
|
2000-01-04 05:31:56 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-11-30 15:05:51 +00:00
|
|
|
void nsTableCellFrame::SetPass1MaxElementWidth(nscoord aMaxWidth,
|
|
|
|
nscoord aMaxElementWidth)
|
1999-09-30 14:11:16 +00:00
|
|
|
{
|
2001-11-30 15:05:51 +00:00
|
|
|
nscoord maxElemWidth = aMaxElementWidth;
|
2001-09-21 13:43:18 +00:00
|
|
|
// check for fixed width and not nowrap and not pre
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStylePosition* stylePosition = GetStylePosition();
|
|
|
|
const nsStyleText* styleText = GetStyleText();
|
2001-09-21 13:43:18 +00:00
|
|
|
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
|
2004-12-31 00:41:58 +00:00
|
|
|
if (GetContent()->HasAttr(kNameSpaceID_None, nsHTMLAtoms::nowrap)) {
|
2001-09-21 13:43:18 +00:00
|
|
|
// 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-02 21:29:26 +00:00
|
|
|
maxElemWidth = NS_MAX(maxElemWidth, stylePosition->mWidth.GetCoordValue());
|
2001-09-21 13:43:18 +00:00
|
|
|
}
|
|
|
|
}
|
2001-11-30 15:05:51 +00:00
|
|
|
mPass1MaxElementWidth = maxElemWidth;
|
1999-09-30 14:11:16 +00:00
|
|
|
}
|
|
|
|
|
1999-08-01 22:21:03 +00:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsTableCellFrame::AppendFrames(nsIAtom* aListName,
|
1999-08-01 22:21:03 +00:00
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unsupported operation");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsTableCellFrame::InsertFrames(nsIAtom* aListName,
|
1999-08-01 22:21:03 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unsupported operation");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsTableCellFrame::RemoveFrame(nsIAtom* aListName,
|
1999-08-01 22:21:03 +00:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unsupported operation");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2004-04-21 15:49:29 +00:00
|
|
|
void nsTableCellFrame::SetColIndex(PRInt32 aColIndex)
|
1999-07-28 08:09:02 +00:00
|
|
|
{
|
2001-12-07 14:51:12 +00:00
|
|
|
mBits.mColIndex = aColIndex;
|
1999-07-28 08:09:02 +00:00
|
|
|
}
|
|
|
|
|
2001-05-03 23:57:08 +00: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
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableCellFrame::DecorateForSelection(nsPresContext* aPresContext,
|
2001-05-03 23:57:08 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-05-31 22:19:43 +00:00
|
|
|
const nsStyleBackground *aStyleColor)
|
2001-05-03 23:57:08 +00:00
|
|
|
{
|
|
|
|
PRInt16 displaySelection;
|
|
|
|
displaySelection = DisplaySelection(aPresContext);
|
|
|
|
if (displaySelection) {
|
2003-07-07 02:01:29 +00:00
|
|
|
PRBool isSelected =
|
|
|
|
(GetStateBits() & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
|
2001-05-03 23:57:08 +00:00
|
|
|
if (isSelected) {
|
2004-08-29 03:08:44 +00:00
|
|
|
nsIFrameSelection *frameSelection =
|
|
|
|
aPresContext->PresShell()->FrameSelection();
|
|
|
|
|
|
|
|
PRBool tableCellSelectionMode;
|
|
|
|
nsresult 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 {
|
|
|
|
aPresContext->LookAndFeel()->
|
|
|
|
GetColor(nsILookAndFeel::eColor_TextSelectBackground,
|
|
|
|
bordercolor);
|
|
|
|
}
|
|
|
|
PRInt16 t2p = (PRInt16) aPresContext->PixelsToTwips();
|
|
|
|
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);
|
2001-05-03 23:57:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-03-07 15:23:08 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableCellFrame::PaintUnderlay(nsPresContext& aPresContext,
|
2002-03-07 15:23:08 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
PRUint32& aFlags,
|
|
|
|
const nsStyleBorder& aStyleBorder,
|
2002-10-08 10:24:53 +00:00
|
|
|
const nsStylePadding& aStylePadding,
|
2004-03-09 06:48:35 +00:00
|
|
|
const nsStyleTableBorder& aCellTableStyle)
|
2002-03-07 15:23:08 +00:00
|
|
|
{
|
2004-03-09 06:48:35 +00:00
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
nsCSSRendering::PaintBackground(&aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, aStyleBorder, aStylePadding,
|
|
|
|
PR_TRUE);
|
|
|
|
PRIntn skipSides = GetSkipSides();
|
|
|
|
if (NS_STYLE_TABLE_EMPTY_CELLS_SHOW == aCellTableStyle.mEmptyCells ||
|
|
|
|
!GetContentEmpty()) {
|
|
|
|
nsCSSRendering::PaintBorder(&aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, aStyleBorder, mStyleContext, skipSides);
|
2002-03-07 15:23:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-09 06:48:35 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableCellFrame::Paint(nsPresContext* aPresContext,
|
2001-09-19 12:35:19 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2002-03-07 15:23:08 +00:00
|
|
|
NS_ENSURE_TRUE(aPresContext, NS_ERROR_NULL_POINTER);
|
2001-01-27 14:09:34 +00:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-02-26 00:27:42 +00:00
|
|
|
|
2004-03-09 06:48:35 +00:00
|
|
|
PRBool paintChildren = PR_TRUE;
|
2002-03-07 15:23:08 +00:00
|
|
|
|
1999-08-27 21:53:04 +00:00
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
2002-03-07 15:23:08 +00:00
|
|
|
const nsStyleBorder* myBorder = nsnull;
|
2002-10-08 10:24:53 +00:00
|
|
|
const nsStylePadding* myPadding = nsnull;
|
2002-03-07 15:23:08 +00:00
|
|
|
const nsStyleTableBorder* cellTableStyle = nsnull;
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleVisibility* vis = GetStyleVisibility();
|
2002-12-14 17:52:27 +00:00
|
|
|
if (vis->IsVisible()) {
|
2003-05-15 03:42:21 +00:00
|
|
|
myBorder = GetStyleBorder();
|
|
|
|
myPadding = GetStylePadding();
|
|
|
|
cellTableStyle = GetStyleTableBorder();
|
1998-05-26 23:17:29 +00:00
|
|
|
|
2004-03-09 06:48:35 +00:00
|
|
|
// draw the border & background only when there is content or showing empty cells
|
|
|
|
if (NS_STYLE_TABLE_EMPTY_CELLS_HIDE != cellTableStyle->mEmptyCells ||
|
|
|
|
!GetContentEmpty()) {
|
|
|
|
PaintUnderlay(*aPresContext, aRenderingContext, aDirtyRect, aFlags,
|
|
|
|
*myBorder, *myPadding, *cellTableStyle);
|
|
|
|
}
|
2002-02-26 00:27:42 +00:00
|
|
|
|
2004-11-11 15:07:22 +00:00
|
|
|
// Paint outline
|
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
const nsStyleOutline* myOutline = GetStyleOutline();
|
|
|
|
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, *myBorder, *myOutline,
|
|
|
|
mStyleContext, 0);
|
|
|
|
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleBackground* myColor = GetStyleBackground();
|
2001-05-03 23:57:08 +00:00
|
|
|
DecorateForSelection(aPresContext, aRenderingContext,myColor); //ignore return value
|
1998-07-27 07:37:57 +00:00
|
|
|
}
|
2004-03-09 06:48:35 +00:00
|
|
|
|
|
|
|
paintChildren = !(aFlags & NS_PAINT_FLAG_TABLE_CELL_BG_PASS);
|
|
|
|
//flags were for us; remove them for our children
|
|
|
|
aFlags &= ~ (NS_PAINT_FLAG_TABLE_CELL_BG_PASS | NS_PAINT_FLAG_TABLE_BG_PAINT);
|
1998-05-26 23:17:29 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1998-04-13 20:24:54 +00:00
|
|
|
// for debug...
|
1999-03-26 00:39:35 +00:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
|
1998-12-23 15:47:43 +00:00
|
|
|
aRenderingContext.SetColor(NS_RGB(0, 0, 128));
|
1998-04-13 20:24:54 +00:00
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2002-03-07 15:23:08 +00:00
|
|
|
// paint the children unless we've been told not to
|
|
|
|
if (paintChildren) {
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleDisplay* disp = GetStyleDisplay();
|
2002-02-26 00:27:42 +00: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.
|
|
|
|
nsPoint offset;
|
2005-02-07 01:58:25 +00:00
|
|
|
GetCollapseOffset(offset);
|
2003-10-13 21:58:12 +00:00
|
|
|
PRBool pushed = PR_FALSE;
|
2002-02-26 00:27:42 +00:00
|
|
|
if ((0 != offset.x) || (0 != offset.y)) {
|
2001-02-24 14:30:12 +00:00
|
|
|
aRenderingContext.PushState();
|
2003-10-13 21:58:12 +00:00
|
|
|
pushed = PR_TRUE;
|
2002-02-26 00:27:42 +00:00
|
|
|
aRenderingContext.Translate(offset.x, offset.y);
|
|
|
|
aRenderingContext.SetClipRect(nsRect(-offset.x, -offset.y, mRect.width, mRect.height),
|
2004-04-23 15:21:24 +00:00
|
|
|
nsClipCombine_kIntersect);
|
2002-02-26 00:27:42 +00:00
|
|
|
}
|
|
|
|
else {
|
2004-09-02 23:27:23 +00:00
|
|
|
// XXXldb HIDDEN should really create a scrollframe,
|
|
|
|
// but use |IsTableClip| here since it doesn't.
|
|
|
|
if (disp->IsTableClip() ||
|
2004-10-10 07:31:35 +00:00
|
|
|
(HasPctOverHeight() && eCompatibility_NavQuirks == aPresContext->CompatibilityMode())) {
|
2002-02-26 00:27:42 +00:00
|
|
|
aRenderingContext.PushState();
|
2003-10-13 21:58:12 +00:00
|
|
|
pushed = PR_TRUE;
|
2002-02-26 00:27:42 +00:00
|
|
|
SetOverflowClipRect(aRenderingContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
|
|
|
|
|
2003-10-13 21:58:12 +00:00
|
|
|
if (pushed) {
|
2004-04-18 13:13:35 +00:00
|
|
|
aRenderingContext.PopState();
|
2002-02-26 00:27:42 +00:00
|
|
|
}
|
2001-02-24 14:30:12 +00:00
|
|
|
}
|
1999-02-11 06:22:33 +00:00
|
|
|
|
2001-03-13 01:47:22 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP_J("nsTableCellFrame", &aRenderingContext, 0);
|
1999-09-17 23:33:39 +00:00
|
|
|
return NS_OK;
|
|
|
|
/*nsFrame::Paint(aPresContext,
|
1999-06-01 23:04:13 +00:00
|
|
|
aRenderingContext,
|
|
|
|
aDirtyRect,
|
1999-09-17 23:33:39 +00:00
|
|
|
aWhichLayer);*/
|
1999-06-01 23:04:13 +00:00
|
|
|
}
|
|
|
|
|
2000-03-22 02:43:08 +00:00
|
|
|
NS_IMETHODIMP
|
2005-01-01 17:26:29 +00:00
|
|
|
nsTableCellFrame::GetFrameForPoint(const nsPoint& aPoint,
|
2000-03-22 02:43:08 +00:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
2001-03-13 06:38:59 +00:00
|
|
|
nsIFrame** aFrame)
|
2000-03-22 02:43:08 +00:00
|
|
|
{
|
|
|
|
// this should act like a block, so we need to override
|
2005-01-01 17:26:29 +00:00
|
|
|
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
|
2000-03-22 02:43:08 +00:00
|
|
|
}
|
|
|
|
|
1999-06-01 23:04:13 +00:00
|
|
|
//null range means the whole thing
|
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableCellFrame::SetSelected(nsPresContext* aPresContext,
|
2001-03-13 06:38:59 +00:00
|
|
|
nsIDOMRange* aRange,
|
|
|
|
PRBool aSelected,
|
|
|
|
nsSpread aSpread)
|
1999-06-01 23:04:13 +00:00
|
|
|
{
|
|
|
|
//traverse through children unselect tables
|
1999-09-21 22:58:14 +00:00
|
|
|
#if 0
|
1999-09-17 23:33:39 +00:00
|
|
|
if ((aSpread == eSpreadDown)){
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIFrame* kid = GetFirstChild(nsnull);
|
1999-06-01 23:04:13 +00:00
|
|
|
while (nsnull != kid) {
|
2003-07-07 02:01:29 +00:00
|
|
|
kid->SetSelected(nsnull, aSelected, eSpreadDown);
|
|
|
|
kid = kid->GetNextSibling();
|
1999-06-01 23:04:13 +00:00
|
|
|
}
|
|
|
|
}
|
1999-09-21 22:58:14 +00:00
|
|
|
//return nsFrame::SetSelected(aRange,aSelected,eSpreadNone);
|
|
|
|
#endif
|
2000-03-21 06:04:02 +00: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 18:56:26 +00:00
|
|
|
|
2004-08-29 03:08:44 +00:00
|
|
|
PRBool tableCellSelectionMode;
|
|
|
|
nsresult result = aPresContext->PresShell()->FrameSelection()->GetTableCellSelection(&tableCellSelectionMode);
|
|
|
|
if (NS_SUCCEEDED(result) && tableCellSelectionMode) {
|
|
|
|
// Selection can affect content, border and outline
|
|
|
|
Invalidate(GetOverflowRect(), PR_FALSE);
|
2000-04-30 18:56:26 +00:00
|
|
|
}
|
1999-09-21 22:58:14 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-20 17:45:07 +00: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-13 20:24:54 +00:00
|
|
|
|
1999-06-01 23:04:13 +00: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 06:38:18 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
// Align the cell's child frame within the cell
|
2001-04-01 01:01:33 +00:00
|
|
|
|
2005-02-07 01:58:25 +00:00
|
|
|
void nsTableCellFrame::VerticallyAlignChild(const nsHTMLReflowState& aReflowState,
|
2000-06-05 08:25:11 +00:00
|
|
|
nscoord aMaxAscent)
|
1998-04-25 18:48:48 +00:00
|
|
|
{
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleTextReset* textStyle = GetStyleTextReset();
|
1998-12-23 15:47:43 +00:00
|
|
|
/* XXX: remove tableFrame when border-collapse inherits */
|
2005-02-07 01:58:25 +00:00
|
|
|
nsPresContext* presContext = GetPresContext();
|
|
|
|
GET_PIXELS_TO_TWIPS(presContext, p2t);
|
2003-03-21 19:35:36 +00:00
|
|
|
nsMargin borderPadding = nsTableFrame::GetBorderPadding(aReflowState, p2t, this);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-07-28 08:09:02 +00:00
|
|
|
nscoord topInset = borderPadding.top;
|
|
|
|
nscoord bottomInset = borderPadding.bottom;
|
2000-07-28 09:19:26 +00:00
|
|
|
|
2000-06-05 08:25:11 +00: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 09:19:26 +00:00
|
|
|
}
|
2000-06-05 08:25:11 +00:00
|
|
|
|
1999-07-28 08:09:02 +00:00
|
|
|
nscoord height = mRect.height;
|
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
2004-11-06 07:07:43 +00:00
|
|
|
NS_ASSERTION(firstKid, "Frame construction error, a table cell always has an inner cell frame");
|
2003-07-07 02:01:29 +00:00
|
|
|
nsRect kidRect = firstKid->GetRect();
|
1999-07-28 08:09:02 +00:00
|
|
|
nscoord childHeight = kidRect.height;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-07-28 08:09:02 +00:00
|
|
|
// Vertically align the child
|
|
|
|
nscoord kidYTop = 0;
|
|
|
|
switch (verticalAlignFlags)
|
|
|
|
{
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BASELINE:
|
1999-08-27 04:29:05 +00:00
|
|
|
// Align the baselines of the child frame with the baselines of
|
2000-06-05 08:25:11 +00:00
|
|
|
// other children in the same row which have 'vertical-align: baseline'
|
|
|
|
kidYTop = topInset + aMaxAscent - GetDesiredAscent();
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-07-28 08:09:02 +00:00
|
|
|
case NS_STYLE_VERTICAL_ALIGN_TOP:
|
1999-08-27 04:29:05 +00:00
|
|
|
// Align the top of the child frame with the top of the content area,
|
1999-07-28 08:09:02 +00:00
|
|
|
kidYTop = topInset;
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-07-28 08:09:02 +00:00
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
1999-08-27 04:29:05 +00:00
|
|
|
// Align the bottom of the child frame with the bottom of the content area,
|
1999-07-28 08:09:02 +00:00
|
|
|
kidYTop = height - childHeight - bottomInset;
|
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-07-28 08:09:02 +00:00
|
|
|
default:
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
|
1999-08-27 04:29:05 +00:00
|
|
|
// Align the middle of the child frame with the middle of the content area,
|
|
|
|
kidYTop = (height - childHeight - bottomInset + topInset) / 2;
|
2004-07-29 19:41:39 +00:00
|
|
|
kidYTop = nsTableFrame::RoundToPixel(kidYTop,
|
2005-02-07 01:58:25 +00:00
|
|
|
presContext->ScaledPixelsToTwips(),
|
2004-07-29 19:41:39 +00:00
|
|
|
eAlwaysRoundDown);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
2004-09-18 19:04:13 +00:00
|
|
|
// if the content is larger than the cell height align from top
|
|
|
|
kidYTop = PR_MAX(0, kidYTop);
|
|
|
|
|
2003-07-07 02:01:29 +00:00
|
|
|
firstKid->SetPosition(nsPoint(kidRect.x, kidYTop));
|
2003-09-13 16:26:30 +00:00
|
|
|
nsHTMLReflowMetrics desiredSize(PR_FALSE);
|
|
|
|
desiredSize.width = mRect.width;
|
|
|
|
desiredSize.height = mRect.height;
|
|
|
|
desiredSize.mOverflowArea = nsRect(0, 0, mRect.width, mRect.height);
|
2004-12-27 15:05:18 +00:00
|
|
|
ConsiderChildOverflow(desiredSize.mOverflowArea, firstKid);
|
2004-07-16 16:56:21 +00:00
|
|
|
FinishAndStoreOverflow(&desiredSize);
|
1999-11-19 15:33:29 +00:00
|
|
|
if (kidYTop != kidRect.y) {
|
|
|
|
// Make sure any child views are correctly positioned. We know the inner table
|
|
|
|
// cell won't have a view
|
2004-12-27 15:05:18 +00:00
|
|
|
nsContainerFrame::PositionChildViews(firstKid);
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
2004-03-28 06:31:03 +00:00
|
|
|
if (HasView()) {
|
2005-02-07 01:58:25 +00:00
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(presContext, this,
|
|
|
|
GetView(),
|
|
|
|
&desiredSize.mOverflowArea, 0);
|
2004-03-28 06:31:03 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-06-05 08:25:11 +00: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()
|
|
|
|
{
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleTextReset* textStyle = GetStyleTextReset();
|
2000-06-05 08:25:11 +00: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 17:58:24 +00:00
|
|
|
PRInt32 nsTableCellFrame::GetRowSpan()
|
|
|
|
{
|
|
|
|
PRInt32 rowSpan=1;
|
2005-01-12 19:45:38 +00:00
|
|
|
nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent);
|
2002-05-23 00:00:34 +00:00
|
|
|
|
|
|
|
if (hc) {
|
2005-01-25 00:02:58 +00:00
|
|
|
const nsAttrValue* attr = hc->GetParsedAttr(nsHTMLAtoms::rowspan);
|
|
|
|
if (attr && attr->Type() == nsAttrValue::eInteger) {
|
|
|
|
rowSpan = attr->GetIntegerValue();
|
1998-09-15 17:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return rowSpan;
|
|
|
|
}
|
1998-05-21 23:43:18 +00:00
|
|
|
|
1998-09-15 17:58:24 +00:00
|
|
|
PRInt32 nsTableCellFrame::GetColSpan()
|
|
|
|
{
|
|
|
|
PRInt32 colSpan=1;
|
2005-01-12 19:45:38 +00:00
|
|
|
nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent);
|
2002-05-23 00:00:34 +00:00
|
|
|
|
|
|
|
if (hc) {
|
2005-01-25 00:02:58 +00:00
|
|
|
const nsAttrValue* attr = hc->GetParsedAttr(nsHTMLAtoms::colspan);
|
|
|
|
if (attr && attr->Type() == nsAttrValue::eInteger) {
|
|
|
|
colSpan = attr->GetIntegerValue();
|
1998-09-15 17:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return colSpan;
|
|
|
|
}
|
1998-05-21 23:43:18 +00:00
|
|
|
|
2003-04-05 15:36:31 +00:00
|
|
|
#ifdef DEBUG
|
2001-02-07 04:31:38 +00:00
|
|
|
#define PROBABLY_TOO_LARGE 1000000
|
1999-08-20 13:32:23 +00:00
|
|
|
static
|
1999-04-29 17:43:41 +00:00
|
|
|
void DebugCheckChildSize(nsIFrame* aChild,
|
|
|
|
nsHTMLReflowMetrics& aMet,
|
|
|
|
nsSize& aAvailSize,
|
|
|
|
PRBool aIsPass2Reflow)
|
1999-03-13 12:49:37 +00:00
|
|
|
{
|
1999-04-29 17:43:41 +00:00
|
|
|
if (aIsPass2Reflow) {
|
2001-02-07 04:31:38 +00:00
|
|
|
if ((aMet.width < 0) || (aMet.width > PROBABLY_TOO_LARGE)) {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("WARNING: cell content %p has large width %d \n", aChild, aMet.width);
|
1999-04-29 17:43:41 +00:00
|
|
|
}
|
1999-03-13 12:49:37 +00:00
|
|
|
}
|
2003-01-09 14:26:32 +00:00
|
|
|
if (aMet.mComputeMEW) {
|
|
|
|
nscoord tmp = aMet.mMaxElementWidth;
|
2001-02-07 04:31:38 +00:00
|
|
|
if ((tmp < 0) || (tmp > PROBABLY_TOO_LARGE)) {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("WARNING: cell content %p has large max element width %d \n", aChild, tmp);
|
1999-03-13 12:49:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-04-05 15:36:31 +00:00
|
|
|
#endif
|
1999-03-13 12:49:37 +00:00
|
|
|
|
2001-11-29 15:41:07 +00:00
|
|
|
// the computed height for the cell, which descendents use for percent height calculations
|
|
|
|
// it is the height (minus border, padding) of the cell's first in flow during its final
|
|
|
|
// reflow without an unconstrained height.
|
|
|
|
static nscoord
|
2004-07-31 23:15:21 +00:00
|
|
|
CalcUnpaginagedHeight(nsPresContext* aPresContext,
|
2001-11-29 15:41:07 +00:00
|
|
|
nsTableCellFrame& aCellFrame,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nscoord aVerticalBorderPadding)
|
|
|
|
{
|
|
|
|
const nsTableCellFrame* firstCellInFlow = (nsTableCellFrame*)aCellFrame.GetFirstInFlow();
|
|
|
|
nsTableFrame* firstTableInFlow = (nsTableFrame*)aTableFrame.GetFirstInFlow();
|
2003-07-07 02:01:29 +00:00
|
|
|
nsTableRowFrame* row
|
|
|
|
= NS_STATIC_CAST(nsTableRowFrame*, firstCellInFlow->GetParent());
|
|
|
|
nsTableRowGroupFrame* firstRGInFlow
|
|
|
|
= NS_STATIC_CAST(nsTableRowGroupFrame*, row->GetParent());
|
2001-11-29 15:41:07 +00:00
|
|
|
|
|
|
|
PRInt32 rowIndex;
|
|
|
|
firstCellInFlow->GetRowIndex(rowIndex);
|
|
|
|
PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan(*firstCellInFlow);
|
|
|
|
nscoord cellSpacing = firstTableInFlow->GetCellSpacingX();
|
|
|
|
|
|
|
|
nscoord computedHeight = ((rowSpan - 1) * cellSpacing) - aVerticalBorderPadding;
|
|
|
|
PRInt32 rowX;
|
|
|
|
for (row = firstRGInFlow->GetFirstRow(), rowX = 0; row; row = row->GetNextRow(), rowX++) {
|
|
|
|
if (rowX > rowIndex + rowSpan - 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (rowX >= rowIndex) {
|
|
|
|
computedHeight += row->GetUnpaginatedHeight(aPresContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return computedHeight;
|
|
|
|
}
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_METHOD nsTableCellFrame::Reflow(nsPresContext* aPresContext,
|
1999-04-29 17:43:41 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 04:10:00 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-04-29 17:43:41 +00:00
|
|
|
nsReflowStatus& aStatus)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-04-21 21:36:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableCellFrame", aReflowState.reason);
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2001-10-29 01:43:59 +00:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 15:55:51 +00:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState);
|
|
|
|
#endif
|
2004-07-29 19:41:39 +00:00
|
|
|
float p2t = aPresContext->ScaledPixelsToTwips();
|
2001-11-01 15:31:13 +00:00
|
|
|
|
|
|
|
// work around pixel rounding errors, round down to ensure we don't exceed the avail height in
|
|
|
|
nscoord availHeight = aReflowState.availableHeight;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != availHeight) {
|
|
|
|
availHeight = nsTableFrame::RoundToPixel(availHeight, p2t, eAlwaysRoundDown);
|
|
|
|
}
|
|
|
|
|
1998-10-30 07:57:44 +00:00
|
|
|
nsresult rv = NS_OK;
|
2001-11-05 00:15:51 +00:00
|
|
|
|
2002-04-01 06:46:17 +00:00
|
|
|
// see if a special height reflow needs to occur due to having a pct height
|
2002-04-10 21:32:41 +00:00
|
|
|
if (!NeedSpecialReflow())
|
|
|
|
nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState);
|
2002-04-01 06:46:17 +00:00
|
|
|
|
1999-04-09 21:09:52 +00:00
|
|
|
// this should probably be cached somewhere
|
2003-12-24 21:51:50 +00:00
|
|
|
nsCompatibility compatMode = aPresContext->CompatibilityMode();
|
1998-10-30 07:57:44 +00:00
|
|
|
|
1998-06-03 00:43:53 +00:00
|
|
|
// Initialize out parameter
|
2003-01-09 14:26:32 +00:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaxElementWidth = 0;
|
1998-06-03 00:43:53 +00:00
|
|
|
}
|
|
|
|
|
1998-05-12 04:17:56 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2001-11-01 15:31:13 +00:00
|
|
|
nsSize availSize(aReflowState.availableWidth, availHeight);
|
1999-05-11 22:03:29 +00:00
|
|
|
|
2004-12-01 03:50:03 +00:00
|
|
|
PRBool noBorderBeforeReflow = GetContentEmpty() &&
|
|
|
|
GetStyleTableBorder()->mEmptyCells != NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
|
1998-12-23 15:47:43 +00:00
|
|
|
/* XXX: remove tableFrame when border-collapse inherits */
|
2002-02-19 15:48:28 +00:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame); if (!tableFrame) ABORT1(NS_ERROR_NULL_POINTER);
|
2001-11-05 00:15:51 +00:00
|
|
|
|
2000-02-12 01:55:40 +00:00
|
|
|
nsMargin borderPadding = aReflowState.mComputedPadding;
|
1999-04-09 21:09:52 +00:00
|
|
|
nsMargin border;
|
2002-02-19 15:48:28 +00:00
|
|
|
GetBorderWidth(p2t, border);
|
2004-12-01 03:50:03 +00:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE == availSize.width) || !noBorderBeforeReflow) {
|
1999-04-09 21:09:52 +00:00
|
|
|
borderPadding += border;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord topInset = borderPadding.top;
|
|
|
|
nscoord rightInset = borderPadding.right;
|
1998-05-12 22:28:01 +00:00
|
|
|
nscoord bottomInset = borderPadding.bottom;
|
1999-04-09 21:09:52 +00:00
|
|
|
nscoord leftInset = borderPadding.left;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-07-06 21:00:11 +00:00
|
|
|
// reduce available space by insets, if we're in a constrained situation
|
1998-06-26 00:48:44 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE!=availSize.width)
|
1998-07-06 21:00:11 +00:00
|
|
|
availSize.width -= leftInset+rightInset;
|
1998-06-26 00:48:44 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE!=availSize.height)
|
1998-11-22 08:56:19 +00:00
|
|
|
availSize.height -= topInset+bottomInset;
|
1998-06-26 00:48:44 +00:00
|
|
|
|
1999-08-29 04:18:00 +00:00
|
|
|
PRBool isStyleChanged = PR_FALSE;
|
2001-03-13 06:38:59 +00:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
2002-05-10 18:22:41 +00:00
|
|
|
// if the path has a reflow command then the cell must be the target of a style change
|
|
|
|
nsHTMLReflowCommand* command = aReflowState.path->mReflowCommand;
|
|
|
|
if (command) {
|
|
|
|
// if there are other reflow commands targeted at the cell's block, these will
|
|
|
|
// be subsumed by the style change reflow
|
|
|
|
nsReflowType type;
|
|
|
|
command->GetType(type);
|
|
|
|
if (eReflowType_StyleChanged == type) {
|
|
|
|
isStyleChanged = PR_TRUE;
|
1998-10-30 07:57:44 +00:00
|
|
|
}
|
2002-05-10 18:22:41 +00:00
|
|
|
else NS_ASSERTION(PR_FALSE, "table cell target of illegal incremental reflow type");
|
1998-10-30 07:57:44 +00:00
|
|
|
}
|
2002-05-10 18:22:41 +00:00
|
|
|
// else the reflow command will be passed down to the child
|
1998-07-16 22:15:02 +00:00
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Try to reflow the child into the available space. It might not
|
|
|
|
// fit or might need continuing.
|
1998-04-23 17:29:07 +00:00
|
|
|
if (availSize.height < 0)
|
|
|
|
availSize.height = 1;
|
1998-09-24 16:37:22 +00:00
|
|
|
|
2003-01-09 14:26:32 +00:00
|
|
|
nsHTMLReflowMetrics kidSize(NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth ||
|
|
|
|
aDesiredSize.mComputeMEW,
|
|
|
|
aDesiredSize.mFlags);
|
1998-06-03 00:43:53 +00:00
|
|
|
kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0;
|
1999-01-05 23:31:18 +00:00
|
|
|
SetPriorAvailWidth(aReflowState.availableWidth);
|
1999-01-15 22:52:05 +00:00
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
2004-11-06 07:07:43 +00:00
|
|
|
NS_ASSERTION(firstKid, "Frame construction error, a table cell always has an inner cell frame");
|
2001-11-05 00:15:51 +00:00
|
|
|
|
2001-11-29 15:41:07 +00:00
|
|
|
nscoord computedPaginatedHeight = 0;
|
|
|
|
|
2001-12-07 14:51:12 +00:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow ||
|
2002-04-10 21:32:41 +00:00
|
|
|
(HadSpecialReflow() && (eReflowReason_Incremental == aReflowState.reason))) {
|
2001-11-05 00:15:51 +00:00
|
|
|
((nsHTMLReflowState&)aReflowState).mComputedHeight = mRect.height - topInset - bottomInset;
|
2001-11-27 01:45:46 +00:00
|
|
|
DISPLAY_REFLOW_CHANGE();
|
2001-11-05 00:15:51 +00:00
|
|
|
}
|
2004-03-03 18:24:20 +00:00
|
|
|
else if (aPresContext->IsPaginated()) {
|
2001-11-29 15:41:07 +00:00
|
|
|
computedPaginatedHeight = CalcUnpaginagedHeight(aPresContext, (nsTableCellFrame&)*this, *tableFrame, topInset + bottomInset);
|
|
|
|
if (computedPaginatedHeight > 0) {
|
|
|
|
((nsHTMLReflowState&)aReflowState).mComputedHeight = computedPaginatedHeight;
|
|
|
|
DISPLAY_REFLOW_CHANGE();
|
|
|
|
}
|
|
|
|
}
|
2001-11-28 00:50:08 +00:00
|
|
|
else {
|
|
|
|
SetHasPctOverHeight(PR_FALSE);
|
|
|
|
}
|
1998-10-01 04:46:11 +00:00
|
|
|
|
2002-05-10 18:22:41 +00:00
|
|
|
// If it was a style change targeted at us, then reflow the child with a style change reason
|
|
|
|
nsReflowReason reason = aReflowState.reason;
|
1999-08-29 04:18:00 +00:00
|
|
|
if (isStyleChanged) {
|
2002-05-10 18:22:41 +00:00
|
|
|
reason = eReflowReason_StyleChange;
|
2001-03-26 06:13:56 +00:00
|
|
|
// the following could be optimized with a fair amount of effort
|
|
|
|
tableFrame->SetNeedStrategyInit(PR_TRUE);
|
1999-08-29 04:18:00 +00:00
|
|
|
}
|
|
|
|
|
2002-05-10 18:22:41 +00:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, firstKid, availSize, reason);
|
|
|
|
// mIPercentHeightObserver is for non table related frames inside cells
|
|
|
|
kidReflowState.mPercentHeightObserver = (nsIPercentHeightObserver *)this;
|
|
|
|
|
1999-11-19 15:33:29 +00: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-11-22 19:34:59 +00:00
|
|
|
if (isStyleChanged ||
|
|
|
|
(eReflowReason_Initial == aReflowState.reason) ||
|
|
|
|
(eReflowReason_StyleChange == aReflowState.reason)) {
|
1999-11-19 15:33:29 +00:00
|
|
|
kidOrigin.MoveTo(leftInset, topInset);
|
|
|
|
} else {
|
2000-02-12 01:55:40 +00:00
|
|
|
// handle percent padding-left which was 0 during initial reflow
|
2001-02-07 09:57:26 +00:00
|
|
|
if (eStyleUnit_Percent == aReflowState.mStylePadding->mPadding.GetLeftUnit()) {
|
2003-07-07 02:01:29 +00:00
|
|
|
nsRect kidRect = firstKid->GetRect();
|
2000-02-12 01:55:40 +00:00
|
|
|
// only move in the x direction for the same reason as above
|
|
|
|
kidOrigin.MoveTo(leftInset, kidRect.y);
|
2003-07-07 02:01:29 +00:00
|
|
|
firstKid->SetPosition(nsPoint(leftInset, kidRect.y));
|
2000-02-12 01:55:40 +00:00
|
|
|
}
|
2003-07-07 02:01:29 +00:00
|
|
|
kidOrigin = firstKid->GetPosition();
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
2000-05-25 22:40:21 +00:00
|
|
|
|
2001-10-29 01:43:59 +00:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 15:55:51 +00:00
|
|
|
nsTableFrame::DebugReflow(firstKid, (nsHTMLReflowState&)kidReflowState);
|
|
|
|
#endif
|
2001-12-07 14:51:12 +00:00
|
|
|
nscoord priorBlockHeight = GetLastBlockHeight();
|
1999-11-19 15:33:29 +00:00
|
|
|
ReflowChild(firstKid, aPresContext, kidSize, kidReflowState,
|
|
|
|
kidOrigin.x, kidOrigin.y, 0, aStatus);
|
2001-12-07 14:51:12 +00:00
|
|
|
SetLastBlockHeight(kidSize.height);
|
2000-09-11 02:47:02 +00:00
|
|
|
if (isStyleChanged) {
|
2004-08-26 00:07:56 +00:00
|
|
|
Invalidate(GetOverflowRect(), PR_FALSE);
|
2000-09-11 02:47:02 +00:00
|
|
|
}
|
2001-11-28 00:50:08 +00:00
|
|
|
|
2001-10-29 01:43:59 +00:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 15:55:51 +00:00
|
|
|
nsTableFrame::DebugReflow(firstKid, (nsHTMLReflowState&)kidReflowState, &kidSize, aStatus);
|
|
|
|
#endif
|
1999-08-21 06:38:07 +00:00
|
|
|
|
1998-09-09 20:00:40 +00:00
|
|
|
#ifdef NS_DEBUG
|
1999-04-29 17:43:41 +00:00
|
|
|
DebugCheckChildSize(firstKid, kidSize, availSize, (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth));
|
1998-12-08 19:18:33 +00:00
|
|
|
#endif
|
|
|
|
|
1999-04-09 21:09:52 +00:00
|
|
|
// 0 dimensioned cells need to be treated specially in Standard/NavQuirks mode
|
1999-09-10 18:55:46 +00:00
|
|
|
// see testcase "emptyCells.html"
|
2000-01-28 02:19:45 +00:00
|
|
|
if ((0 == kidSize.width) || (0 == kidSize.height)) { // XXX why was this &&
|
|
|
|
SetContentEmpty(PR_TRUE);
|
2004-12-01 03:50:03 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == kidReflowState.availableWidth &&
|
|
|
|
GetStyleTableBorder()->mEmptyCells != NS_STYLE_TABLE_EMPTY_CELLS_SHOW) {
|
1999-04-09 21:09:52 +00: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 02:19:45 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetContentEmpty(PR_FALSE);
|
2004-12-01 03:50:03 +00:00
|
|
|
if ((eReflowReason_Incremental == aReflowState.reason) && noBorderBeforeReflow) {
|
2001-11-06 23:05:32 +00:00
|
|
|
// need to consider borders, since they were factored out above
|
|
|
|
leftInset += border.left;
|
|
|
|
rightInset += border.right;
|
|
|
|
topInset += border.top;
|
|
|
|
bottomInset += border.bottom;
|
|
|
|
kidOrigin.MoveTo(leftInset, topInset);
|
|
|
|
}
|
1998-12-10 19:57:42 +00:00
|
|
|
}
|
1999-09-10 18:55:46 +00:00
|
|
|
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStylePosition* pos = GetStylePosition();
|
1999-09-10 18:55:46 +00:00
|
|
|
|
|
|
|
// calculate the min cell width
|
2004-03-09 06:48:35 +00:00
|
|
|
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
|
2001-09-26 13:49:26 +00:00
|
|
|
nscoord smallestMinWidth = 0;
|
1999-09-10 18:55:46 +00:00
|
|
|
if (eCompatibility_NavQuirks == compatMode) {
|
|
|
|
if ((pos->mWidth.GetUnit() != eStyleUnit_Coord) &&
|
|
|
|
(pos->mWidth.GetUnit() != eStyleUnit_Percent)) {
|
1999-10-18 13:45:41 +00:00
|
|
|
if (PR_TRUE == GetContentEmpty()) {
|
|
|
|
if (border.left > 0)
|
|
|
|
smallestMinWidth += onePixel;
|
|
|
|
if (border.right > 0)
|
|
|
|
smallestMinWidth += onePixel;
|
|
|
|
}
|
1999-09-10 18:55:46 +00:00
|
|
|
}
|
1999-10-05 04:21:00 +00:00
|
|
|
}
|
2000-02-01 03:23:29 +00:00
|
|
|
PRInt32 colspan = tableFrame->GetEffectiveColSpan(*this);
|
1999-10-05 04:21:00 +00:00
|
|
|
if (colspan > 1) {
|
|
|
|
smallestMinWidth = PR_MAX(smallestMinWidth, colspan * onePixel);
|
|
|
|
nscoord spacingX = tableFrame->GetCellSpacingX();
|
|
|
|
nscoord spacingExtra = spacingX * (colspan - 1);
|
|
|
|
smallestMinWidth += spacingExtra;
|
2000-02-12 01:55:40 +00:00
|
|
|
if (aReflowState.mComputedPadding.left > 0) {
|
1999-10-05 04:21:00 +00:00
|
|
|
smallestMinWidth -= onePixel;
|
1999-09-10 18:55:46 +00:00
|
|
|
}
|
|
|
|
}
|
1999-10-05 04:21:00 +00:00
|
|
|
|
1999-09-13 14:35:00 +00: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 18:43:56 +00:00
|
|
|
}
|
1999-04-09 21:09:52 +00:00
|
|
|
if (0 == kidSize.height) {
|
|
|
|
if ((pos->mHeight.GetUnit() != eStyleUnit_Coord) &&
|
|
|
|
(pos->mHeight.GetUnit() != eStyleUnit_Percent)) {
|
2002-11-13 15:38:48 +00:00
|
|
|
PRInt32 pixHeight = (eCompatibility_NavQuirks == compatMode) ? 1 : 0;
|
1999-04-09 21:09:52 +00:00
|
|
|
kidSize.height = NSIntPixelsToTwips(pixHeight, p2t);
|
|
|
|
}
|
1998-12-05 05:27:21 +00:00
|
|
|
}
|
1999-04-09 21:09:52 +00:00
|
|
|
// end 0 dimensioned cells
|
1998-12-08 19:18:33 +00:00
|
|
|
|
1999-09-10 18:55:46 +00:00
|
|
|
kidSize.width = PR_MAX(kidSize.width, smallestMinWidth);
|
2001-01-25 22:57:53 +00:00
|
|
|
if (!tableFrame->IsAutoLayout()) {
|
|
|
|
// a cell in a fixed layout table is constrained to the avail width
|
2004-11-14 14:47:59 +00:00
|
|
|
// if we need to shorten the cell the previous non overflowing block
|
|
|
|
// will get some overflow area
|
|
|
|
if (kidSize.width > availSize.width) {
|
|
|
|
kidSize.width = availSize.width;
|
|
|
|
firstKid->FinishAndStoreOverflow(&kidSize);
|
|
|
|
}
|
2001-01-25 22:57:53 +00:00
|
|
|
}
|
2001-01-11 23:22:44 +00:00
|
|
|
//if (eReflowReason_Resize == aReflowState.reason) {
|
|
|
|
// NS_ASSERTION(kidSize.width <= availSize.width, "child needed more space during resize reflow");
|
|
|
|
//}
|
1998-06-05 02:36:25 +00:00
|
|
|
// Place the child
|
2001-12-07 14:51:12 +00:00
|
|
|
FinishReflowChild(firstKid, aPresContext, &kidReflowState, kidSize,
|
1999-11-19 15:33:29 +00:00
|
|
|
kidOrigin.x, kidOrigin.y, 0);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-04-09 21:09:52 +00:00
|
|
|
// first, compute the height which can be set w/o being restricted by aMaxSize.height
|
1999-09-13 14:35:00 +00:00
|
|
|
nscoord cellHeight = kidSize.height;
|
2001-08-08 01:13:35 +00:00
|
|
|
|
1999-09-13 14:35:00 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != cellHeight) {
|
|
|
|
cellHeight += topInset + bottomInset;
|
2001-11-01 15:31:13 +00:00
|
|
|
// work around block rounding errors, round down to ensure we don't exceed the avail height in
|
|
|
|
nsPixelRound roundMethod = (NS_UNCONSTRAINEDSIZE == availHeight) ? eAlwaysRoundUp : eAlwaysRoundDown;
|
|
|
|
cellHeight = nsTableFrame::RoundToPixel(cellHeight, p2t, roundMethod);
|
1999-09-13 14:35:00 +00:00
|
|
|
}
|
1999-08-19 19:52:37 +00:00
|
|
|
|
1998-06-05 02:36:25 +00:00
|
|
|
// next determine the cell's width
|
1998-07-06 21:00:11 +00:00
|
|
|
nscoord cellWidth = kidSize.width; // at this point, we've factored in the cell's style attributes
|
1998-07-02 17:40:56 +00:00
|
|
|
|
1999-09-13 14:35:00 +00:00
|
|
|
// factor in border and padding
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != cellWidth) {
|
|
|
|
cellWidth += leftInset + rightInset;
|
|
|
|
}
|
2001-03-25 23:06:08 +00:00
|
|
|
cellWidth = nsTableFrame::RoundToPixel(cellWidth, p2t); // work around block rounding errors
|
1998-07-31 00:32:27 +00:00
|
|
|
|
1998-06-05 02:36:25 +00:00
|
|
|
// set the cell's desired size and max element size
|
1999-09-13 14:35:00 +00:00
|
|
|
aDesiredSize.width = cellWidth;
|
|
|
|
aDesiredSize.height = cellHeight;
|
|
|
|
aDesiredSize.ascent = topInset;
|
1998-04-13 20:24:54 +00:00
|
|
|
aDesiredSize.descent = bottomInset;
|
2000-07-28 09:19:26 +00:00
|
|
|
|
2000-06-05 08:25:11 +00:00
|
|
|
aDesiredSize.ascent += kidSize.ascent;
|
|
|
|
aDesiredSize.descent += kidSize.descent;
|
2003-09-13 16:26:30 +00:00
|
|
|
|
|
|
|
// the overflow area will be computed when the child will be vertically aligned
|
2000-07-28 09:19:26 +00:00
|
|
|
|
2003-01-09 14:26:32 +00:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaxElementWidth =
|
|
|
|
PR_MAX(smallestMinWidth, kidSize.mMaxElementWidth);
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aDesiredSize.mMaxElementWidth) {
|
|
|
|
aDesiredSize.mMaxElementWidth = nsTableFrame::RoundToPixel(
|
|
|
|
aDesiredSize.mMaxElementWidth + leftInset + rightInset, p2t);
|
2001-03-13 06:38:59 +00:00
|
|
|
}
|
1998-04-20 22:49:15 +00:00
|
|
|
}
|
2002-06-19 23:16:33 +00:00
|
|
|
if (aDesiredSize.mFlags & NS_REFLOW_CALC_MAX_WIDTH) {
|
|
|
|
aDesiredSize.mMaximumWidth = kidSize.mMaximumWidth;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aDesiredSize.mMaximumWidth) {
|
|
|
|
aDesiredSize.mMaximumWidth += leftInset + rightInset;
|
|
|
|
aDesiredSize.mMaximumWidth = nsTableFrame::RoundToPixel(aDesiredSize.mMaximumWidth, p2t);
|
|
|
|
}
|
|
|
|
// make sure the preferred width is at least as big as the max element width
|
2003-01-09 14:26:32 +00:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaximumWidth = PR_MAX(aDesiredSize.mMaximumWidth, aDesiredSize.mMaxElementWidth);
|
2002-06-19 23:16:33 +00:00
|
|
|
}
|
|
|
|
}
|
1998-10-02 20:36:35 +00:00
|
|
|
|
2001-12-07 14:51:12 +00:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
2001-11-28 00:50:08 +00:00
|
|
|
if (aDesiredSize.height > mRect.height) {
|
2001-12-07 14:51:12 +00:00
|
|
|
// set a bit indicating that the pct height contents exceeded
|
2001-11-28 00:50:08 +00:00
|
|
|
// the height that they could honor in the pass 2 reflow
|
|
|
|
SetHasPctOverHeight(PR_TRUE);
|
|
|
|
}
|
2002-03-16 21:46:29 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
|
|
|
|
aDesiredSize.height = mRect.height;
|
|
|
|
}
|
2001-11-05 00:15:51 +00:00
|
|
|
SetNeedSpecialReflow(PR_FALSE);
|
2001-12-07 14:51:12 +00:00
|
|
|
SetHadSpecialReflow(PR_TRUE);
|
2001-11-05 00:15:51 +00:00
|
|
|
}
|
2002-04-06 22:42:39 +00:00
|
|
|
else if (HadSpecialReflow()) {
|
2002-06-19 22:42:41 +00:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
2002-04-06 22:42:39 +00:00
|
|
|
// with an unconstrained height, if the block height value hasn't changed,
|
|
|
|
// use the last height of the cell.
|
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) &&
|
|
|
|
(GetLastBlockHeight() == priorBlockHeight)) {
|
|
|
|
aDesiredSize.height = mRect.height;
|
|
|
|
}
|
2001-12-11 15:02:36 +00:00
|
|
|
}
|
2002-04-06 22:42:39 +00:00
|
|
|
// XXX should probably call SetHadSpecialReflow(PR_FALSE) when things change so that
|
|
|
|
// nothing inside the cell has a percent height, but it is not easy determining this
|
2001-11-28 00:50:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// remember the desired size for this reflow
|
|
|
|
SetDesiredSize(aDesiredSize);
|
2001-11-05 00:15:51 +00:00
|
|
|
|
2001-10-29 01:43:59 +00:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 15:55:51 +00:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState, &aDesiredSize, aStatus);
|
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2002-05-09 14:44:02 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth) {
|
|
|
|
SetNeedPass2Reflow(PR_TRUE);
|
|
|
|
}
|
|
|
|
else if ((eReflowReason_Initial == aReflowState.reason) ||
|
|
|
|
(eReflowReason_Resize == aReflowState.reason)) {
|
|
|
|
SetNeedPass2Reflow(PR_FALSE);
|
|
|
|
}
|
|
|
|
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-09-15 17:58:24 +00:00
|
|
|
/* ----- global methods ----- */
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-08-01 18:26:45 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsTableCellFrame, nsHTMLContainerFrame)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsTableCellFrame, nsHTMLContainerFrame)
|
1999-07-31 22:11:50 +00:00
|
|
|
|
1999-08-01 18:26:45 +00:00
|
|
|
nsresult nsTableCellFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2001-04-01 01:01:33 +00:00
|
|
|
|
2000-02-02 22:24:56 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsITableCellLayout))) {
|
1999-08-04 02:04:45 +00:00
|
|
|
*aInstancePtr = (void*) (nsITableCellLayout *)this;
|
1999-08-01 18:26:45 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-12-07 14:51:12 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIPercentHeightObserver))) {
|
|
|
|
*aInstancePtr = (void*) (nsIPercentHeightObserver *)this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-05-17 23:52:32 +00:00
|
|
|
|
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-17 23:52:32 +00:00
|
|
|
NS_IMETHODIMP nsTableCellFrame::GetAccessible(nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
|
|
|
|
if (accService) {
|
|
|
|
return accService->CreateHTMLTableCellAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-08-01 18:26:45 +00:00
|
|
|
}
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
1999-07-31 22:11:50 +00:00
|
|
|
|
1999-08-04 02:04:45 +00: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;
|
|
|
|
}
|
2001-12-07 14:51:12 +00:00
|
|
|
aColIndex = mBits.mColIndex;
|
1999-08-04 02:04:45 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-23 04:24:58 +00: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);
|
2002-11-13 15:38:48 +00:00
|
|
|
if (!cellFrame) return NS_ERROR_FAILURE;
|
|
|
|
return CallQueryInterface(cellFrame, aCellLayout);
|
2000-03-23 04:24:58 +00:00
|
|
|
}
|
2002-11-13 15:38:48 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2000-03-23 04:24:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2002-11-13 15:38:48 +00:00
|
|
|
if (!cellFrame) return NS_ERROR_FAILURE;
|
|
|
|
return CallQueryInterface(cellFrame, aCellLayout);
|
2000-03-23 04:24:58 +00:00
|
|
|
}
|
|
|
|
|
1998-09-15 17:58:24 +00:00
|
|
|
nsresult
|
2002-02-19 15:48:28 +00:00
|
|
|
NS_NewTableCellFrame(nsIPresShell* aPresShell,
|
|
|
|
PRBool aIsBorderCollapse,
|
|
|
|
nsIFrame** aNewFrame)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-05-11 22:03:29 +00:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2002-02-19 15:48:28 +00:00
|
|
|
nsTableCellFrame* it = (aIsBorderCollapse) ? new (aPresShell) nsBCTableCellFrame
|
|
|
|
: new (aPresShell) nsTableCellFrame;
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-11 22:03:29 +00:00
|
|
|
*aNewFrame = it;
|
1998-04-13 20:24:54 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-05-21 23:43:18 +00:00
|
|
|
|
2002-02-19 15:48:28 +00:00
|
|
|
nsMargin*
|
|
|
|
nsTableCellFrame::GetBorderWidth(float aPixelsToTwips,
|
|
|
|
nsMargin& aBorder) const
|
1998-12-23 15:47:43 +00:00
|
|
|
{
|
|
|
|
aBorder.left = aBorder.right = aBorder.top = aBorder.bottom = 0;
|
1998-07-11 00:00:31 +00:00
|
|
|
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleBorder* borderData = GetStyleBorder();
|
2002-02-19 15:48:28 +00:00
|
|
|
borderData->GetBorder(aBorder);
|
|
|
|
return &aBorder;
|
1998-12-23 15:47:43 +00:00
|
|
|
}
|
1998-07-11 00:00:31 +00:00
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsTableCellFrame::GetType() const
|
1999-02-24 05:54:31 +00:00
|
|
|
{
|
2003-10-31 20:19:18 +00:00
|
|
|
return nsLayoutAtoms::tableCellFrame;
|
1999-02-24 05:54:31 +00:00
|
|
|
}
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsTableCellFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 17:22:29 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableCell"), aResult);
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1999-02-11 06:22:33 +00:00
|
|
|
|
2005-02-07 01:58:25 +00:00
|
|
|
void nsTableCellFrame::SetCollapseOffsetX(nscoord aXOffset)
|
1999-10-22 02:06:22 +00:00
|
|
|
{
|
|
|
|
// Get the frame property (creating a point struct if necessary)
|
2005-02-07 01:58:25 +00:00
|
|
|
nsPoint* offset = (nsPoint*)nsTableFrame::GetProperty(this, nsLayoutAtoms::collapseOffsetProperty, aXOffset != 0);
|
1999-10-22 02:06:22 +00:00
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
offset->x = aXOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-07 01:58:25 +00:00
|
|
|
void nsTableCellFrame::SetCollapseOffsetY(nscoord aYOffset)
|
1999-10-22 02:06:22 +00:00
|
|
|
{
|
|
|
|
// Get the property (creating a point struct if necessary)
|
2005-02-07 01:58:25 +00:00
|
|
|
nsPoint* offset = (nsPoint*)nsTableFrame::GetProperty(this, nsLayoutAtoms::collapseOffsetProperty, aYOffset != 0);
|
1999-10-22 02:06:22 +00:00
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
offset->y = aYOffset;
|
|
|
|
}
|
1999-02-11 06:22:33 +00:00
|
|
|
}
|
|
|
|
|
2005-02-07 01:58:25 +00:00
|
|
|
void nsTableCellFrame::GetCollapseOffset(nsPoint& aOffset)
|
1999-02-11 06:22:33 +00:00
|
|
|
{
|
1999-10-22 02:06:22 +00:00
|
|
|
// See if the property is set
|
2005-02-07 01:58:25 +00:00
|
|
|
nsPoint* offset = (nsPoint*)nsTableFrame::GetProperty(this, nsLayoutAtoms::collapseOffsetProperty);
|
1999-10-22 02:06:22 +00:00
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
aOffset = *offset;
|
|
|
|
} else {
|
|
|
|
aOffset.MoveTo(0, 0);
|
|
|
|
}
|
1999-02-11 06:22:33 +00:00
|
|
|
}
|
|
|
|
|
2002-02-19 15:48:28 +00:00
|
|
|
// nsBCTableCellFrame
|
|
|
|
|
|
|
|
nsBCTableCellFrame::nsBCTableCellFrame()
|
|
|
|
:nsTableCellFrame()
|
|
|
|
{
|
|
|
|
mTopBorder = mRightBorder = mBottomBorder = mLeftBorder = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBCTableCellFrame::~nsBCTableCellFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsBCTableCellFrame::GetType() const
|
2002-02-19 15:48:28 +00:00
|
|
|
{
|
2003-10-31 20:19:18 +00:00
|
|
|
return nsLayoutAtoms::bcTableCellFrame;
|
2002-02-19 15:48:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBCTableCellFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("BCTableCell"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBCTableCellFrame::SetBorderWidth(const nsMargin& aBorder)
|
|
|
|
{
|
|
|
|
mTopBorder = aBorder.top;
|
|
|
|
mRightBorder = aBorder.right;
|
|
|
|
mBottomBorder = aBorder.bottom;
|
|
|
|
mLeftBorder = aBorder.left;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsMargin*
|
|
|
|
nsBCTableCellFrame::GetBorderWidth(float aPixelsToTwips,
|
|
|
|
nsMargin& aBorder) const
|
|
|
|
{
|
|
|
|
aBorder.top = (aPixelsToTwips) ? NSToCoordRound(aPixelsToTwips * mTopBorder) : mTopBorder;
|
|
|
|
aBorder.right = (aPixelsToTwips) ? NSToCoordRound(aPixelsToTwips * mRightBorder) : mRightBorder;
|
|
|
|
aBorder.bottom = (aPixelsToTwips) ? NSToCoordRound(aPixelsToTwips * mBottomBorder): mBottomBorder;
|
|
|
|
aBorder.left = (aPixelsToTwips) ? NSToCoordRound(aPixelsToTwips * mLeftBorder): mLeftBorder;
|
|
|
|
return &aBorder;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsBCTableCellFrame::GetBorderWidth(PRUint8 aSide) const
|
|
|
|
{
|
|
|
|
switch(aSide) {
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
return (PRUint8)mTopBorder;
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
return (PRUint8)mRightBorder;
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
return (PRUint8)mBottomBorder;
|
|
|
|
default:
|
|
|
|
return (PRUint8)mLeftBorder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBCTableCellFrame::SetBorderWidth(PRUint8 aSide,
|
|
|
|
nscoord aValue)
|
|
|
|
{
|
|
|
|
switch(aSide) {
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
mTopBorder = aValue;
|
|
|
|
break;
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
mRightBorder = aValue;
|
|
|
|
break;
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
mBottomBorder = aValue;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mLeftBorder = aValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-07 15:23:08 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsBCTableCellFrame::PaintUnderlay(nsPresContext& aPresContext,
|
2002-03-07 15:23:08 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
PRUint32& aFlags,
|
|
|
|
const nsStyleBorder& aStyleBorder,
|
2002-10-08 10:24:53 +00:00
|
|
|
const nsStylePadding& aStylePadding,
|
2004-03-09 06:48:35 +00:00
|
|
|
const nsStyleTableBorder& aCellTableStyle)
|
2002-03-07 15:23:08 +00:00
|
|
|
{
|
2004-03-09 06:48:35 +00:00
|
|
|
if (!(aFlags & NS_PAINT_FLAG_TABLE_BG_PAINT)
|
|
|
|
/*direct call; not table-based paint*/ ||
|
|
|
|
(aFlags & NS_PAINT_FLAG_TABLE_CELL_BG_PASS)
|
|
|
|
/*table cell background only pass*/) {
|
2002-03-07 15:23:08 +00:00
|
|
|
// make border-width reflect border-collapse assigned border
|
|
|
|
GET_PIXELS_TO_TWIPS(&aPresContext, p2t);
|
|
|
|
nsMargin borderWidth;
|
|
|
|
GetBorderWidth(p2t, borderWidth);
|
|
|
|
|
|
|
|
nsStyleBorder myBorder = aStyleBorder;
|
|
|
|
|
|
|
|
nsStyleCoord coord(borderWidth.top);
|
|
|
|
myBorder.mBorder.SetTop(coord);
|
|
|
|
coord.SetCoordValue(borderWidth.right);
|
|
|
|
myBorder.mBorder.SetRight(coord);
|
|
|
|
coord.SetCoordValue(borderWidth.bottom);
|
|
|
|
myBorder.mBorder.SetBottom(coord);
|
|
|
|
coord.SetCoordValue(borderWidth.left);
|
|
|
|
myBorder.mBorder.SetLeft(coord);
|
2004-11-26 18:40:58 +00:00
|
|
|
myBorder.RecalcData(&aPresContext);
|
2002-03-07 15:23:08 +00:00
|
|
|
|
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
nsCSSRendering::PaintBackground(&aPresContext, aRenderingContext, this,
|
2002-10-08 10:24:53 +00:00
|
|
|
aDirtyRect, rect, myBorder, aStylePadding,
|
2003-02-23 02:49:22 +00:00
|
|
|
PR_TRUE);
|
2002-03-07 15:23:08 +00:00
|
|
|
// borders are painted by nsTableFrame
|
|
|
|
}
|
|
|
|
}
|