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"
|
2001-11-29 18:41:07 +03:00
|
|
|
#include "nsTableRowGroupFrame.h"
|
2002-05-10 22:22:41 +04:00
|
|
|
#include "nsReflowPath.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
1998-09-15 21:58:24 +04:00
|
|
|
#include "nsIHTMLContent.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-10-06 04:44:35 +04:00
|
|
|
#include "nsVoidArray.h"
|
1998-05-22 03:43:18 +04:00
|
|
|
#include "nsIView.h"
|
1999-02-24 08:54:31 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-10-22 06:06:22 +04:00
|
|
|
#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()
|
|
|
|
{
|
2002-03-17 00:46:29 +03:00
|
|
|
mBits.mColIndex = 0;
|
2000-01-04 08:31:56 +03:00
|
|
|
mPriorAvailWidth = 0;
|
2002-03-17 00:46:29 +03:00
|
|
|
|
|
|
|
SetContentEmpty(PR_FALSE);
|
|
|
|
SetNeedSpecialReflow(PR_FALSE);
|
|
|
|
SetHadSpecialReflow(PR_FALSE);
|
|
|
|
SetHasPctOverHeight(PR_FALSE);
|
2002-05-09 18:44:02 +04:00
|
|
|
SetNeedPass2Reflow(PR_TRUE);
|
2002-03-17 00:46:29 +03:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableCellFrame*
|
|
|
|
nsTableCellFrame::GetNextCell() const
|
|
|
|
{
|
2003-07-07 06:01:29 +04:00
|
|
|
nsIFrame* childFrame = GetNextSibling();
|
2001-11-05 03:15:51 +03:00
|
|
|
while (childFrame) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (IS_TABLE_CELL(childFrame->GetType())) {
|
2001-11-05 03:15:51 +03:00
|
|
|
return (nsTableCellFrame*)childFrame;
|
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
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,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
1999-02-25 08:31:15 +03: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-14 01:56:31 +03:00
|
|
|
PRInt32 colIndex;
|
|
|
|
cellFrame->GetColIndex(colIndex);
|
|
|
|
InitCellFrame(colIndex);
|
1999-02-25 08:31:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2001-12-07 17:51:12 +03:00
|
|
|
|
|
|
|
// nsIPercentHeightObserver methods
|
|
|
|
|
2002-04-11 01:32:41 +04:00
|
|
|
void
|
2001-12-07 17:51:12 +03:00
|
|
|
nsTableCellFrame::NotifyPercentHeight(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
2002-04-07 02:42:39 +04:00
|
|
|
if (!NeedSpecialReflow()) {
|
2001-12-07 17:51:12 +03: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 10:46:17 +04:00
|
|
|
// happen (but not sufficient) if there is no computed height already set between the
|
2001-12-07 17:51:12 +03: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-11 01:32:41 +04:00
|
|
|
return;
|
2001-12-07 17:51:12 +03:00
|
|
|
}
|
|
|
|
// stop when we reach the cell frame
|
|
|
|
if (rs->frame == this) {
|
2002-04-01 10:46:17 +04:00
|
|
|
nsTableFrame::RequestSpecialHeightReflow(*rs);
|
2002-04-11 01:32:41 +04:00
|
|
|
return;
|
2001-12-07 17:51:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_ASSERTION(PR_FALSE, "program error in NotifyPercentHeight");
|
|
|
|
}
|
2002-04-11 01:32:41 +04: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 17:51:12 +03:00
|
|
|
}
|
1999-02-25 08:31:15 +03:00
|
|
|
|
2001-04-16 18:51:52 +04:00
|
|
|
nsresult
|
|
|
|
nsTableCellFrame::GetRowIndex(PRInt32 &aRowIndex) const
|
|
|
|
{
|
|
|
|
nsresult result;
|
2003-07-07 06:01:29 +04:00
|
|
|
nsTableRowFrame* row = NS_STATIC_CAST(nsTableRowFrame*, GetParent());
|
2001-04-16 18:51:52 +04: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 17:51:12 +03:00
|
|
|
aColIndex = mBits.mColIndex;
|
2001-04-16 18:51:52 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-04 08:31:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
2003-07-12 01:16:12 +04:00
|
|
|
PRInt32 aModType)
|
2000-01-04 08:31:56 +03:00
|
|
|
{
|
|
|
|
// 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-11-30 18:05:51 +03:00
|
|
|
void nsTableCellFrame::SetPass1MaxElementWidth(nscoord aMaxWidth,
|
|
|
|
nscoord aMaxElementWidth)
|
1999-09-30 18:11:16 +04:00
|
|
|
{
|
2001-11-30 18:05:51 +03:00
|
|
|
nscoord maxElemWidth = aMaxElementWidth;
|
2001-09-21 17:43:18 +04:00
|
|
|
// check for fixed width and not nowrap and not pre
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStylePosition* stylePosition = GetStylePosition();
|
|
|
|
const nsStyleText* styleText = GetStyleText();
|
2001-09-21 17:43:18 +04: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
|
|
|
|
nsAutoString nowrap;
|
2003-07-07 06:01:29 +04:00
|
|
|
nsresult result = GetContent()->GetAttr(kNameSpaceID_None, nsHTMLAtoms::nowrap, nowrap);
|
2001-09-21 17:43:18 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2001-11-30 18:05:51 +03:00
|
|
|
mPass1MaxElementWidth = 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)
|
|
|
|
{
|
2001-12-07 17:51:12 +03:00
|
|
|
mBits.mColIndex = aColIndex;
|
1999-07-28 12:09:02 +04:00
|
|
|
// 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
|
|
|
|
|
2003-07-07 06:01:29 +04:00
|
|
|
//nsIContent* cell = kidFrame->GetContent();
|
|
|
|
nsIContent* cell = GetContent();
|
|
|
|
if (!cell)
|
|
|
|
return NS_OK;
|
1999-07-28 12:09:02 +04:00
|
|
|
|
|
|
|
nsIHTMLTableCellElement* cellContent = nsnull;
|
2003-07-07 06:01:29 +04:00
|
|
|
nsresult rv = CallQueryInterface(cell, &cellContent); // cellContent: REFCNT++
|
1999-07-28 12:09:02 +04:00
|
|
|
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) {
|
2003-07-07 06:01:29 +04:00
|
|
|
PRBool isSelected =
|
|
|
|
(GetStateBits() & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
|
2001-05-04 03:57:08 +04:00
|
|
|
if (isSelected) {
|
|
|
|
nsCOMPtr<nsIFrameSelection> frameSelection;
|
2003-12-21 08:36:36 +03:00
|
|
|
nsresult result = aPresContext->PresShell()->
|
|
|
|
GetFrameSelection(getter_AddRefs(frameSelection));
|
2001-05-04 03:57:08 +04:00
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
PRBool tableCellSelectionMode;
|
|
|
|
result = frameSelection->GetTableCellSelection(&tableCellSelectionMode);
|
|
|
|
if (NS_SUCCEEDED(result) && tableCellSelectionMode) {
|
|
|
|
nscolor bordercolor;
|
2003-09-13 20:26:30 +04:00
|
|
|
if (displaySelection == nsISelectionController::SELECTION_DISABLED) {
|
2001-05-04 03:57:08 +04:00
|
|
|
bordercolor = NS_RGB(176,176,176);// disabled color
|
|
|
|
}
|
|
|
|
else {
|
2004-01-21 12:35:59 +03:00
|
|
|
aPresContext->LookAndFeel()->
|
|
|
|
GetColor(nsILookAndFeel::eColor_TextSelectBackground,
|
|
|
|
bordercolor);
|
2001-05-04 03:57:08 +04:00
|
|
|
}
|
2004-02-11 07:57:07 +03:00
|
|
|
PRInt16 t2p = (PRInt16) aPresContext->PixelsToTwips();
|
|
|
|
if ((mRect.width >(3*t2p)) && (mRect.height > (3*t2p)))
|
2001-05-04 03:57:08 +04:00
|
|
|
{
|
2004-02-11 07:57:07 +03:00
|
|
|
//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-04 03:57:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-03-07 18:23:08 +03:00
|
|
|
void
|
|
|
|
nsTableCellFrame::PaintUnderlay(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
PRUint32& aFlags,
|
|
|
|
const nsStyleTableBorder& aCellTableStyle,
|
|
|
|
const nsStyleBorder& aStyleBorder,
|
2002-10-08 14:24:53 +04:00
|
|
|
const nsStylePadding& aStylePadding,
|
2002-03-07 18:23:08 +03:00
|
|
|
PRBool aVisibleBackground,
|
|
|
|
PRBool& aPaintChildren)
|
|
|
|
{
|
|
|
|
if (aVisibleBackground) {
|
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
nsCSSRendering::PaintBackground(&aPresContext, aRenderingContext, this,
|
2002-10-08 14:24:53 +04:00
|
|
|
aDirtyRect, rect, aStyleBorder, aStylePadding,
|
2003-02-23 05:49:22 +03:00
|
|
|
PR_TRUE);
|
2002-03-07 18:23:08 +03:00
|
|
|
// draw the border only when there is content or showing empty cells
|
|
|
|
if (!GetContentEmpty() || NS_STYLE_TABLE_EMPTY_CELLS_SHOW == aCellTableStyle.mEmptyCells) {
|
|
|
|
PRIntn skipSides = GetSkipSides();
|
|
|
|
nsCSSRendering::PaintBorder(&aPresContext, aRenderingContext, this,
|
|
|
|
aDirtyRect, rect, aStyleBorder, mStyleContext, skipSides);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// tell Paint to paint the children
|
|
|
|
aPaintChildren = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2002-03-07 18:23:08 +03:00
|
|
|
NS_ENSURE_TRUE(aPresContext, NS_ERROR_NULL_POINTER);
|
2001-01-27 17:09:34 +03:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-02-26 03:27:42 +03:00
|
|
|
|
2002-03-07 18:23:08 +03:00
|
|
|
PRBool paintChildren = PR_TRUE;
|
|
|
|
|
1999-08-28 01:53:04 +04:00
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
2002-03-07 18:23:08 +03:00
|
|
|
PRBool paintBackground = PR_FALSE;
|
|
|
|
const nsStyleBorder* myBorder = nsnull;
|
2002-10-08 14:24:53 +04:00
|
|
|
const nsStylePadding* myPadding = nsnull;
|
2002-03-07 18:23:08 +03:00
|
|
|
const nsStyleTableBorder* cellTableStyle = nsnull;
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleVisibility* vis = GetStyleVisibility();
|
2002-12-14 20:52:27 +03:00
|
|
|
if (vis->IsVisible()) {
|
2003-05-15 07:42:21 +04:00
|
|
|
myBorder = GetStyleBorder();
|
|
|
|
myPadding = GetStylePadding();
|
|
|
|
cellTableStyle = GetStyleTableBorder();
|
1998-05-27 03:17:29 +04:00
|
|
|
|
2002-03-07 18:23:08 +03:00
|
|
|
// paint the background when the cell is not empty or when showing empty cells or background
|
|
|
|
paintBackground = (!GetContentEmpty() ||
|
|
|
|
NS_STYLE_TABLE_EMPTY_CELLS_SHOW == cellTableStyle->mEmptyCells ||
|
|
|
|
NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND == cellTableStyle->mEmptyCells);
|
|
|
|
}
|
|
|
|
|
|
|
|
PaintUnderlay(*aPresContext, aRenderingContext, aDirtyRect, aFlags, *cellTableStyle,
|
2002-10-08 14:24:53 +04:00
|
|
|
*myBorder, *myPadding, paintBackground, paintChildren);
|
2002-02-26 03:27:42 +03:00
|
|
|
|
2002-12-14 20:52:27 +03:00
|
|
|
if (vis->IsVisible()) {
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleBackground* myColor = GetStyleBackground();
|
2001-05-04 03:57:08 +04:00
|
|
|
DecorateForSelection(aPresContext, aRenderingContext,myColor); //ignore return value
|
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
|
|
|
|
2002-03-07 18:23:08 +03:00
|
|
|
// paint the children unless we've been told not to
|
|
|
|
if (paintChildren) {
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleDisplay* disp = GetStyleDisplay();
|
2002-02-26 03:27:42 +03: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.
|
|
|
|
PRBool clipState;
|
|
|
|
nsPoint offset;
|
|
|
|
GetCollapseOffset(aPresContext, offset);
|
2003-10-14 01:58:12 +04:00
|
|
|
PRBool pushed = PR_FALSE;
|
2002-02-26 03:27:42 +03:00
|
|
|
if ((0 != offset.x) || (0 != offset.y)) {
|
2001-02-24 17:30:12 +03:00
|
|
|
aRenderingContext.PushState();
|
2003-10-14 01:58:12 +04:00
|
|
|
pushed = PR_TRUE;
|
2002-02-26 03:27:42 +03:00
|
|
|
aRenderingContext.Translate(offset.x, offset.y);
|
|
|
|
aRenderingContext.SetClipRect(nsRect(-offset.x, -offset.y, mRect.width, mRect.height),
|
|
|
|
nsClipCombine_kIntersect, clipState);
|
|
|
|
}
|
|
|
|
else {
|
2003-10-14 01:58:12 +04:00
|
|
|
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow ||
|
|
|
|
// XXXldb SCROLLBARS_NONE should really create a scrollframe,
|
|
|
|
// but test here since it doesn't.
|
|
|
|
NS_STYLE_OVERFLOW_SCROLLBARS_NONE == disp->mOverflow ||
|
|
|
|
HasPctOverHeight()) {
|
2002-02-26 03:27:42 +03:00
|
|
|
aRenderingContext.PushState();
|
2003-10-14 01:58:12 +04:00
|
|
|
pushed = PR_TRUE;
|
2002-02-26 03:27:42 +03:00
|
|
|
SetOverflowClipRect(aRenderingContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
|
|
|
|
|
2003-10-14 01:58:12 +04:00
|
|
|
if (pushed) {
|
2002-02-26 03:27:42 +03:00
|
|
|
aRenderingContext.PopState(clipState);
|
|
|
|
}
|
2001-02-24 17:30:12 +03:00
|
|
|
}
|
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)){
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame* kid = GetFirstChild(nsnull);
|
1999-06-02 03:04:13 +04:00
|
|
|
while (nsnull != kid) {
|
2003-07-07 06:01:29 +04:00
|
|
|
kid->SetSelected(nsnull, aSelected, eSpreadDown);
|
|
|
|
kid = kid->GetNextSibling();
|
1999-06-02 03:04:13 +04:00
|
|
|
}
|
|
|
|
}
|
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<nsIFrameSelection> frameSelection;
|
2003-12-21 08:36:36 +03:00
|
|
|
nsresult result = aPresContext->PresShell()->
|
|
|
|
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) {
|
2003-07-07 06:01:29 +04:00
|
|
|
nsRect frameRect = GetRect();
|
2000-04-30 22:56:26 +04:00
|
|
|
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
|
|
|
{
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleTextReset* textStyle = GetStyleTextReset();
|
1998-12-23 18:47:43 +03:00
|
|
|
/* XXX: remove tableFrame when border-collapse inherits */
|
2002-02-19 18:48:28 +03:00
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
2003-03-21 22:35:36 +03:00
|
|
|
nsMargin borderPadding = nsTableFrame::GetBorderPadding(aReflowState, p2t, this);
|
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;
|
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
2003-07-07 06:01:29 +04:00
|
|
|
nsRect kidRect = firstKid->GetRect();
|
1999-07-28 12:09:02 +04:00
|
|
|
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;
|
2001-11-16 17:54:11 +03:00
|
|
|
float p2t;
|
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
kidYTop = nsTableFrame::RoundToPixel(kidYTop, p2t, eAlwaysRoundDown);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
firstKid->SetPosition(nsPoint(kidRect.x, kidYTop));
|
2003-09-13 20:26:30 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(PR_FALSE);
|
|
|
|
desiredSize.width = mRect.width;
|
|
|
|
desiredSize.height = mRect.height;
|
|
|
|
desiredSize.mOverflowArea = nsRect(0, 0, mRect.width, mRect.height);
|
|
|
|
ConsiderChildOverflow(aPresContext, desiredSize.mOverflowArea, firstKid);
|
|
|
|
StoreOverflow(aPresContext, desiredSize);
|
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()
|
|
|
|
{
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleTextReset* textStyle = GetStyleTextReset();
|
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;
|
2002-05-23 04:00:34 +04:00
|
|
|
nsCOMPtr<nsIHTMLContent> hc(do_QueryInterface(mContent));
|
|
|
|
|
|
|
|
if (hc) {
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rowSpan;
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
PRInt32 nsTableCellFrame::GetColSpan()
|
|
|
|
{
|
|
|
|
PRInt32 colSpan=1;
|
2002-05-23 04:00:34 +04:00
|
|
|
nsCOMPtr<nsIHTMLContent> hc(do_QueryInterface(mContent));
|
|
|
|
|
|
|
|
if (hc) {
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return colSpan;
|
|
|
|
}
|
1998-05-22 03:43:18 +04:00
|
|
|
|
2003-04-05 19:36:31 +04:00
|
|
|
#ifdef DEBUG
|
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
|
|
|
}
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aMet.mComputeMEW) {
|
|
|
|
nscoord tmp = aMet.mMaxElementWidth;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-04-05 19:36:31 +04:00
|
|
|
#endif
|
1999-03-13 15:49:37 +03:00
|
|
|
|
2001-11-29 18:41:07 +03: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
|
|
|
|
CalcUnpaginagedHeight(nsIPresContext* aPresContext,
|
|
|
|
nsTableCellFrame& aCellFrame,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nscoord aVerticalBorderPadding)
|
|
|
|
{
|
|
|
|
const nsTableCellFrame* firstCellInFlow = (nsTableCellFrame*)aCellFrame.GetFirstInFlow();
|
|
|
|
nsTableFrame* firstTableInFlow = (nsTableFrame*)aTableFrame.GetFirstInFlow();
|
2003-07-07 06:01:29 +04:00
|
|
|
nsTableRowFrame* row
|
|
|
|
= NS_STATIC_CAST(nsTableRowFrame*, firstCellInFlow->GetParent());
|
|
|
|
nsTableRowGroupFrame* firstRGInFlow
|
|
|
|
= NS_STATIC_CAST(nsTableRowGroupFrame*, row->GetParent());
|
2001-11-29 18:41:07 +03: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;
|
|
|
|
}
|
|
|
|
|
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-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
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);
|
|
|
|
#endif
|
2001-11-01 18:31:13 +03:00
|
|
|
float p2t;
|
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
|
|
|
|
// 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 10:57:44 +03:00
|
|
|
nsresult rv = NS_OK;
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2002-04-01 10:46:17 +04:00
|
|
|
// see if a special height reflow needs to occur due to having a pct height
|
2002-04-11 01:32:41 +04:00
|
|
|
if (!NeedSpecialReflow())
|
|
|
|
nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState);
|
2002-04-01 10:46:17 +04:00
|
|
|
|
1999-04-10 01:09:52 +04:00
|
|
|
// this should probably be cached somewhere
|
2003-12-25 00:51:50 +03:00
|
|
|
nsCompatibility compatMode = aPresContext->CompatibilityMode();
|
1998-10-30 10:57:44 +03:00
|
|
|
|
1998-06-03 04:43:53 +04:00
|
|
|
// Initialize out parameter
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaxElementWidth = 0;
|
1998-06-03 04:43:53 +04:00
|
|
|
}
|
|
|
|
|
1998-05-12 08:17:56 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2001-11-01 18:31:13 +03:00
|
|
|
nsSize availSize(aReflowState.availableWidth, availHeight);
|
1999-05-12 02:03:29 +04:00
|
|
|
|
2001-11-07 02:05:32 +03:00
|
|
|
PRBool contentEmptyBeforeReflow = GetContentEmpty();
|
1998-12-23 18:47:43 +03:00
|
|
|
/* XXX: remove tableFrame when border-collapse inherits */
|
2002-02-19 18:48:28 +03:00
|
|
|
nsTableFrame* tableFrame = nsnull;
|
|
|
|
rv = nsTableFrame::GetTableFrame(this, tableFrame); if (!tableFrame) ABORT1(NS_ERROR_NULL_POINTER);
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2000-02-12 04:55:40 +03:00
|
|
|
nsMargin borderPadding = aReflowState.mComputedPadding;
|
1999-04-10 01:09:52 +04:00
|
|
|
nsMargin border;
|
2002-02-19 18:48:28 +03:00
|
|
|
GetBorderWidth(p2t, border);
|
2001-11-07 02:05:32 +03:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE == availSize.width) || !contentEmptyBeforeReflow) {
|
1999-04-10 01:09:52 +04:00
|
|
|
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) {
|
2002-05-10 22:22:41 +04: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 10:57:44 +03:00
|
|
|
}
|
2002-05-10 22:22:41 +04:00
|
|
|
else NS_ASSERTION(PR_FALSE, "table cell target of illegal incremental reflow type");
|
1998-10-30 10:57:44 +03:00
|
|
|
}
|
2002-05-10 22:22:41 +04:00
|
|
|
// else the reflow command will be passed down to the child
|
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
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
nsHTMLReflowMetrics kidSize(NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth ||
|
|
|
|
aDesiredSize.mComputeMEW,
|
|
|
|
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();
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2001-11-29 18:41:07 +03:00
|
|
|
PRBool isPaginated;
|
|
|
|
aPresContext->IsPaginated(&isPaginated);
|
|
|
|
nscoord computedPaginatedHeight = 0;
|
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow ||
|
2002-04-11 01:32:41 +04:00
|
|
|
(HadSpecialReflow() && (eReflowReason_Incremental == aReflowState.reason))) {
|
2001-11-05 03:15:51 +03:00
|
|
|
((nsHTMLReflowState&)aReflowState).mComputedHeight = mRect.height - topInset - bottomInset;
|
2001-11-27 04:45:46 +03:00
|
|
|
DISPLAY_REFLOW_CHANGE();
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
2001-11-29 18:41:07 +03:00
|
|
|
else if (isPaginated) {
|
|
|
|
computedPaginatedHeight = CalcUnpaginagedHeight(aPresContext, (nsTableCellFrame&)*this, *tableFrame, topInset + bottomInset);
|
|
|
|
if (computedPaginatedHeight > 0) {
|
|
|
|
((nsHTMLReflowState&)aReflowState).mComputedHeight = computedPaginatedHeight;
|
|
|
|
DISPLAY_REFLOW_CHANGE();
|
|
|
|
}
|
|
|
|
}
|
2001-11-28 03:50:08 +03:00
|
|
|
else {
|
|
|
|
SetHasPctOverHeight(PR_FALSE);
|
|
|
|
}
|
1998-10-01 08:46:11 +04:00
|
|
|
|
2002-05-10 22:22:41 +04: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 08:18:00 +04:00
|
|
|
if (isStyleChanged) {
|
2002-05-10 22:22:41 +04:00
|
|
|
reason = eReflowReason_StyleChange;
|
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
|
|
|
}
|
|
|
|
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, firstKid, availSize, reason);
|
|
|
|
// mIPercentHeightObserver is for non table related frames inside cells
|
|
|
|
kidReflowState.mPercentHeightObserver = (nsIPercentHeightObserver *)this;
|
|
|
|
|
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-11-22 22:34:59 +03:00
|
|
|
if (isStyleChanged ||
|
|
|
|
(eReflowReason_Initial == aReflowState.reason) ||
|
|
|
|
(eReflowReason_StyleChange == 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()) {
|
2003-07-07 06:01:29 +04:00
|
|
|
nsRect kidRect = firstKid->GetRect();
|
2000-02-12 04:55:40 +03:00
|
|
|
// only move in the x direction for the same reason as above
|
|
|
|
kidOrigin.MoveTo(leftInset, kidRect.y);
|
2003-07-07 06:01:29 +04:00
|
|
|
firstKid->SetPosition(nsPoint(leftInset, kidRect.y));
|
2000-02-12 04:55:40 +03:00
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
kidOrigin = firstKid->GetPosition();
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
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
|
2001-12-07 17:51:12 +03:00
|
|
|
nscoord priorBlockHeight = GetLastBlockHeight();
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(firstKid, aPresContext, kidSize, kidReflowState,
|
|
|
|
kidOrigin.x, kidOrigin.y, 0, aStatus);
|
2001-12-07 17:51:12 +03:00
|
|
|
SetLastBlockHeight(kidSize.height);
|
2000-09-11 06:47:02 +04:00
|
|
|
if (isStyleChanged) {
|
|
|
|
Invalidate(aPresContext, mRect);
|
|
|
|
}
|
2001-11-28 03:50:08 +03: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, &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);
|
2001-11-07 02:05:32 +03:00
|
|
|
if ((eReflowReason_Incremental == aReflowState.reason) && contentEmptyBeforeReflow) {
|
|
|
|
// 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 22:57:42 +03:00
|
|
|
}
|
1999-09-10 22:55:46 +04:00
|
|
|
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStylePosition* pos = GetStylePosition();
|
1999-09-10 22:55:46 +04:00
|
|
|
|
|
|
|
// calculate the min cell width
|
|
|
|
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)) {
|
2002-11-13 18:38:48 +03:00
|
|
|
PRInt32 pixHeight = (eCompatibility_NavQuirks == compatMode) ? 1 : 0;
|
1999-04-10 01:09:52 +04:00
|
|
|
kidSize.height = NSIntPixelsToTwips(pixHeight, p2t);
|
|
|
|
}
|
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
|
2001-12-07 17:51:12 +03:00
|
|
|
FinishReflowChild(firstKid, aPresContext, &kidReflowState, kidSize,
|
1999-11-19 18:33:29 +03:00
|
|
|
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-11-01 18:31:13 +03: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 18:35:00 +04:00
|
|
|
}
|
1999-08-19 23:52:37 +04:00
|
|
|
|
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;
|
2003-09-13 20:26:30 +04:00
|
|
|
|
|
|
|
// the overflow area will be computed when the child will be vertically aligned
|
2000-07-28 13:19:26 +04:00
|
|
|
|
2003-01-09 17:26:32 +03: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 09:38:59 +03:00
|
|
|
}
|
1998-04-21 02:49:15 +04:00
|
|
|
}
|
2002-06-20 03:16:33 +04: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 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaximumWidth = PR_MAX(aDesiredSize.mMaximumWidth, aDesiredSize.mMaxElementWidth);
|
2002-06-20 03:16:33 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-03 00:36:35 +04:00
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
2001-11-28 03:50:08 +03:00
|
|
|
if (aDesiredSize.height > mRect.height) {
|
2001-12-07 17:51:12 +03:00
|
|
|
// set a bit indicating that the pct height contents exceeded
|
2001-11-28 03:50:08 +03:00
|
|
|
// the height that they could honor in the pass 2 reflow
|
|
|
|
SetHasPctOverHeight(PR_TRUE);
|
|
|
|
}
|
2002-03-17 00:46:29 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
|
|
|
|
aDesiredSize.height = mRect.height;
|
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
SetNeedSpecialReflow(PR_FALSE);
|
2001-12-07 17:51:12 +03:00
|
|
|
SetHadSpecialReflow(PR_TRUE);
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
2002-04-07 02:42:39 +04:00
|
|
|
else if (HadSpecialReflow()) {
|
2002-06-20 02:42:41 +04:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
2002-04-07 02:42:39 +04: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 18:02:36 +03:00
|
|
|
}
|
2002-04-07 02:42:39 +04: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 03:50:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// remember the desired size for this reflow
|
|
|
|
SetDesiredSize(aDesiredSize);
|
2001-11-05 03:15:51 +03: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
|
|
|
|
2002-05-09 18:44:02 +04:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth) {
|
|
|
|
SetNeedPass2Reflow(PR_TRUE);
|
|
|
|
}
|
|
|
|
else if ((eReflowReason_Initial == aReflowState.reason) ||
|
|
|
|
(eReflowReason_Resize == aReflowState.reason)) {
|
|
|
|
SetNeedPass2Reflow(PR_FALSE);
|
|
|
|
}
|
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +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-12-07 17:51:12 +03:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIPercentHeightObserver))) {
|
|
|
|
*aInstancePtr = (void*) (nsIPercentHeightObserver *)this;
|
|
|
|
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) {
|
|
|
|
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;
|
|
|
|
}
|
2001-12-07 17:51:12 +03:00
|
|
|
aColIndex = mBits.mColIndex;
|
1999-08-04 06:04:45 +04:00
|
|
|
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);
|
2002-11-13 18:38:48 +03:00
|
|
|
if (!cellFrame) return NS_ERROR_FAILURE;
|
|
|
|
return CallQueryInterface(cellFrame, aCellLayout);
|
2000-03-23 07:24:58 +03:00
|
|
|
}
|
2002-11-13 18:38:48 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
2000-03-23 07:24:58 +03: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 18:38:48 +03:00
|
|
|
if (!cellFrame) return NS_ERROR_FAILURE;
|
|
|
|
return CallQueryInterface(cellFrame, aCellLayout);
|
2000-03-23 07:24:58 +03:00
|
|
|
}
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
nsresult
|
2002-02-19 18:48:28 +03:00
|
|
|
NS_NewTableCellFrame(nsIPresShell* aPresShell,
|
|
|
|
PRBool aIsBorderCollapse,
|
|
|
|
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;
|
|
|
|
}
|
2002-02-19 18:48:28 +03:00
|
|
|
nsTableCellFrame* it = (aIsBorderCollapse) ? new (aPresShell) nsBCTableCellFrame
|
|
|
|
: 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
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
nsMargin*
|
|
|
|
nsTableCellFrame::GetBorderWidth(float aPixelsToTwips,
|
|
|
|
nsMargin& aBorder) const
|
1998-12-23 18:47:43 +03:00
|
|
|
{
|
|
|
|
aBorder.left = aBorder.right = aBorder.top = aBorder.bottom = 0;
|
1998-07-11 04:00:31 +04:00
|
|
|
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleBorder* borderData = GetStyleBorder();
|
2002-02-19 18:48:28 +03:00
|
|
|
borderData->GetBorder(aBorder);
|
|
|
|
return &aBorder;
|
1998-12-23 18:47:43 +03:00
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsTableCellFrame::GetType() const
|
1999-02-24 08:54:31 +03:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::tableCellFrame;
|
1999-02-24 08:54:31 +03:00
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsTableCellFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 20:22:29 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableCell"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
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
|
|
|
void nsTableCellFrame::SetCollapseOffsetX(nsIPresContext* aPresContext,
|
|
|
|
nscoord aXOffset)
|
|
|
|
{
|
|
|
|
// Get the frame property (creating a point struct if necessary)
|
2001-11-29 18:41:07 +03:00
|
|
|
nsPoint* offset = (nsPoint*)nsTableFrame::GetProperty(aPresContext, this, nsLayoutAtoms::collapseOffsetProperty, PR_TRUE);
|
1999-10-22 06:06:22 +04:00
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
offset->x = aXOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableCellFrame::SetCollapseOffsetY(nsIPresContext* aPresContext,
|
|
|
|
nscoord aYOffset)
|
|
|
|
{
|
|
|
|
// Get the property (creating a point struct if necessary)
|
2001-11-29 18:41:07 +03:00
|
|
|
nsPoint* offset = (nsPoint*)nsTableFrame::GetProperty(aPresContext, this, nsLayoutAtoms::collapseOffsetProperty, PR_TRUE);
|
1999-10-22 06:06:22 +04:00
|
|
|
|
|
|
|
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
|
2001-11-29 18:41:07 +03:00
|
|
|
nsPoint* offset = (nsPoint*)nsTableFrame::GetProperty(aPresContext, this, nsLayoutAtoms::collapseOffsetProperty);
|
1999-10-22 06:06:22 +04:00
|
|
|
|
|
|
|
if (offset) {
|
|
|
|
aOffset = *offset;
|
|
|
|
} else {
|
|
|
|
aOffset.MoveTo(0, 0);
|
|
|
|
}
|
1999-02-11 09:22:33 +03:00
|
|
|
}
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
// nsBCTableCellFrame
|
|
|
|
|
|
|
|
nsBCTableCellFrame::nsBCTableCellFrame()
|
|
|
|
:nsTableCellFrame()
|
|
|
|
{
|
|
|
|
mTopBorder = mRightBorder = mBottomBorder = mLeftBorder = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBCTableCellFrame::~nsBCTableCellFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsBCTableCellFrame::GetType() const
|
2002-02-19 18:48:28 +03:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::bcTableCellFrame;
|
2002-02-19 18:48:28 +03: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 18:23:08 +03:00
|
|
|
void
|
|
|
|
nsBCTableCellFrame::PaintUnderlay(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
PRUint32& aFlags,
|
|
|
|
const nsStyleTableBorder& aCellTableStyle,
|
|
|
|
const nsStyleBorder& aStyleBorder,
|
2002-10-08 14:24:53 +04:00
|
|
|
const nsStylePadding& aStylePadding,
|
2002-03-07 18:23:08 +03:00
|
|
|
PRBool aVisibleBackground,
|
|
|
|
PRBool& aPaintChildren)
|
|
|
|
{
|
|
|
|
// Draw the background only during pass1.
|
|
|
|
if (aVisibleBackground && !(aFlags & BORDER_COLLAPSE_BACKGROUNDS)) {
|
|
|
|
// 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);
|
|
|
|
myBorder.RecalcData();
|
|
|
|
|
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
nsCSSRendering::PaintBackground(&aPresContext, aRenderingContext, this,
|
2002-10-08 14:24:53 +04:00
|
|
|
aDirtyRect, rect, myBorder, aStylePadding,
|
2003-02-23 05:49:22 +03:00
|
|
|
PR_TRUE);
|
2002-03-07 18:23:08 +03:00
|
|
|
// borders are painted by nsTableFrame
|
|
|
|
}
|
|
|
|
|
|
|
|
// don't paint the children if it's pass1
|
|
|
|
aPaintChildren = (aFlags & BORDER_COLLAPSE_BACKGROUNDS);
|
|
|
|
}
|