2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* 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/
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* 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"),
|
|
|
|
* 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 MPL, 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 MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
#include "nsTableFrame.h"
|
|
|
|
#include "nsTableColFrame.h"
|
|
|
|
#include "nsTableCellFrame.h"
|
|
|
|
#include "nsTableFrame.h"
|
|
|
|
#include "nsTableRowGroupFrame.h"
|
|
|
|
#include "nsTablePainter.h"
|
|
|
|
#include "nsStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIDOMHTMLTableCellElement.h"
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsIAccessibilityService.h"
|
|
|
|
#endif
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsDisplayList.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
2008-09-13 07:38:29 -07:00
|
|
|
#include "nsTextFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//TABLECELL SELECTION
|
|
|
|
#include "nsFrameSelection.h"
|
|
|
|
#include "nsILookAndFeel.h"
|
|
|
|
|
|
|
|
|
|
|
|
nsTableCellFrame::nsTableCellFrame(nsStyleContext* aContext) :
|
|
|
|
nsHTMLContainerFrame(aContext)
|
|
|
|
{
|
|
|
|
mColIndex = 0;
|
|
|
|
mPriorAvailWidth = 0;
|
|
|
|
|
|
|
|
SetContentEmpty(PR_FALSE);
|
|
|
|
SetHasPctOverHeight(PR_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableCellFrame::~nsTableCellFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableCellFrame)
|
|
|
|
|
|
|
|
nsTableCellFrame*
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTableCellFrame::GetNextCell() const
|
|
|
|
{
|
|
|
|
nsIFrame* childFrame = GetNextSibling();
|
|
|
|
while (childFrame) {
|
2009-03-24 15:10:06 -07:00
|
|
|
nsTableCellFrame *cellFrame = do_QueryFrame(childFrame);
|
|
|
|
if (cellFrame) {
|
|
|
|
return cellFrame;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
childFrame = childFrame->GetNextSibling();
|
|
|
|
}
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
// Let the base class do its initialization
|
|
|
|
nsresult rv = nsHTMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
|
|
|
|
|
|
|
if (aPrevInFlow) {
|
|
|
|
// Set the column index
|
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)aPrevInFlow;
|
|
|
|
PRInt32 colIndex;
|
|
|
|
cellFrame->GetColIndex(colIndex);
|
|
|
|
SetColIndex(colIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsIPercentHeightObserver methods
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableCellFrame::NotifyPercentHeight(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
// nsHTMLReflowState ensures the mCBReflowState of blocks inside a
|
|
|
|
// cell is the cell frame, not the inner-cell block, and that the
|
|
|
|
// containing block of an inner table is the containing block of its
|
|
|
|
// outer table.
|
|
|
|
// XXXldb Given the now-stricter |NeedsToObserve|, many if not all of
|
|
|
|
// these tests are probably unnecessary.
|
|
|
|
|
|
|
|
// Maybe the cell reflow state; we sure if we're inside the |if|.
|
|
|
|
const nsHTMLReflowState *cellRS = aReflowState.mCBReflowState;
|
|
|
|
|
|
|
|
if (cellRS && cellRS->frame == this &&
|
2007-08-02 11:08:05 -07:00
|
|
|
(cellRS->ComputedHeight() == NS_UNCONSTRAINEDSIZE ||
|
|
|
|
cellRS->ComputedHeight() == 0)) { // XXXldb Why 0?
|
2007-03-22 10:30:00 -07:00
|
|
|
// This is a percentage height on a frame whose percentage heights
|
|
|
|
// are based on the height of the cell, since its containing block
|
|
|
|
// is the inner cell frame.
|
|
|
|
|
2007-06-25 13:34:35 -07:00
|
|
|
// We'll only honor the percent height if sibling-cells/ancestors
|
|
|
|
// have specified/pct height. (Also, siblings only count for this if
|
|
|
|
// both this cell and the sibling cell span exactly 1 row.)
|
|
|
|
|
|
|
|
if (nsTableFrame::AncestorsHaveStyleHeight(*cellRS) ||
|
|
|
|
(nsTableFrame::GetTableFrame(this)->GetEffectiveRowSpan(*this) == 1 &&
|
|
|
|
(cellRS->parentReflowState->frame->GetStateBits() &
|
|
|
|
NS_ROW_HAS_CELL_WITH_STYLE_HEIGHT))) {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-06-25 13:34:35 -07:00
|
|
|
for (const nsHTMLReflowState *rs = aReflowState.parentReflowState;
|
|
|
|
rs != cellRS;
|
|
|
|
rs = rs->parentReflowState) {
|
|
|
|
rs->frame->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_HEIGHT);
|
|
|
|
}
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2007-06-25 13:34:35 -07:00
|
|
|
nsTableFrame::RequestSpecialHeightReflow(*cellRS);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The cell needs to observe its block and things inside its block but nothing below that
|
2010-04-27 09:15:01 -07:00
|
|
|
PRBool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTableCellFrame::NeedsToObserve(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
const nsHTMLReflowState *rs = aReflowState.parentReflowState;
|
|
|
|
if (!rs)
|
|
|
|
return PR_FALSE;
|
|
|
|
if (rs->frame == this) {
|
|
|
|
// We always observe the child block. It will never send any
|
|
|
|
// notifications, but we need this so that the observer gets
|
|
|
|
// propagated to its kids.
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
rs = rs->parentReflowState;
|
|
|
|
if (!rs) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We always need to let the percent height observer be propagated
|
|
|
|
// from an outer table frame to an inner table frame.
|
|
|
|
nsIAtom *fType = aReflowState.frame->GetType();
|
|
|
|
if (fType == nsGkAtoms::tableFrame) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We need the observer to be propagated to all children of the cell
|
|
|
|
// (i.e., children of the child block) in quirks mode, but only to
|
|
|
|
// tables in standards mode.
|
|
|
|
return rs->frame == this &&
|
2007-03-30 14:11:41 -07:00
|
|
|
(PresContext()->CompatibilityMode() == eCompatibility_NavQuirks ||
|
2007-03-22 10:30:00 -07:00
|
|
|
fType == nsGkAtoms::tableOuterFrame);
|
|
|
|
}
|
|
|
|
|
2010-04-27 09:15:01 -07:00
|
|
|
nsresult
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTableCellFrame::GetRowIndex(PRInt32 &aRowIndex) const
|
|
|
|
{
|
|
|
|
nsresult result;
|
2007-07-08 00:08:04 -07:00
|
|
|
nsTableRowFrame* row = static_cast<nsTableRowFrame*>(GetParent());
|
2007-03-22 10:30:00 -07:00
|
|
|
if (row) {
|
|
|
|
aRowIndex = row->GetRowIndex();
|
|
|
|
result = NS_OK;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aRowIndex = 0;
|
|
|
|
result = NS_ERROR_NOT_INITIALIZED;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-04-27 09:15:01 -07:00
|
|
|
nsresult
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTableCellFrame::GetColIndex(PRInt32 &aColIndex) const
|
2010-04-27 09:15:01 -07:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
if (GetPrevInFlow()) {
|
|
|
|
return ((nsTableCellFrame*)GetFirstInFlow())->GetColIndex(aColIndex);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aColIndex = mColIndex;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aModType)
|
|
|
|
{
|
2007-07-01 11:42:18 -07:00
|
|
|
// We need to recalculate in this case because of the nowrap quirk in
|
|
|
|
// BasicTableLayoutStrategy
|
|
|
|
if (aNameSpaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::nowrap &&
|
|
|
|
PresContext()->CompatibilityMode() == eCompatibility_NavQuirks) {
|
|
|
|
PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_IS_DIRTY);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
// let the table frame decide what to do
|
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (tableFrame) {
|
2010-04-27 09:15:01 -07:00
|
|
|
tableFrame->AttributeChangedFor(this, mContent, aAttribute);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-10-26 03:11:34 -07:00
|
|
|
/* virtual */ void
|
|
|
|
nsTableCellFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
|
|
|
{
|
|
|
|
if (!aOldStyleContext) //avoid this on init
|
|
|
|
return;
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2008-10-26 03:11:34 -07:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2008-10-26 03:11:34 -07:00
|
|
|
if (tableFrame->IsBorderCollapse() &&
|
|
|
|
tableFrame->BCRecalcNeeded(aOldStyleContext, GetStyleContext())) {
|
|
|
|
PRInt32 colIndex, rowIndex;
|
|
|
|
GetColIndex(colIndex);
|
|
|
|
GetRowIndex(rowIndex);
|
|
|
|
nsRect damageArea(colIndex, rowIndex, GetColSpan(), GetRowSpan());
|
|
|
|
tableFrame->SetBCDamageArea(damageArea);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::AppendFrames(nsIAtom* aListName,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unsupported operation");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::InsertFrames(nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unsupported operation");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::RemoveFrame(nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unsupported operation");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableCellFrame::SetColIndex(PRInt32 aColIndex)
|
2010-04-27 09:15:01 -07:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
mColIndex = aColIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsTableCellFrame::GetUsedMargin() const
|
|
|
|
{
|
|
|
|
return nsMargin(0,0,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableCellFrame::DecorateForSelection(nsIRenderingContext& aRenderingContext,
|
|
|
|
nsPoint aPt)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(GetStateBits() & NS_FRAME_SELECTED_CONTENT,
|
|
|
|
"Should only be called for selected cells");
|
|
|
|
PRInt16 displaySelection;
|
2007-03-30 14:11:41 -07:00
|
|
|
nsPresContext* presContext = PresContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
displaySelection = DisplaySelection(presContext);
|
|
|
|
if (displaySelection) {
|
2007-11-22 12:47:33 -08:00
|
|
|
nsCOMPtr<nsFrameSelection> frameSelection =
|
|
|
|
presContext->PresShell()->FrameSelection();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (frameSelection->GetTableCellSelection()) {
|
|
|
|
nscolor bordercolor;
|
|
|
|
if (displaySelection == nsISelectionController::SELECTION_DISABLED) {
|
|
|
|
bordercolor = NS_RGB(176,176,176);// disabled color
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
presContext->LookAndFeel()->
|
|
|
|
GetColor(nsILookAndFeel::eColor_TextSelectBackground,
|
|
|
|
bordercolor);
|
|
|
|
}
|
|
|
|
nscoord threePx = nsPresContext::CSSPixelsToAppUnits(3);
|
|
|
|
if ((mRect.width > threePx) && (mRect.height > threePx))
|
|
|
|
{
|
|
|
|
//compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor)
|
|
|
|
bordercolor = EnsureDifferentColors(bordercolor,
|
|
|
|
GetStyleBackground()->mBackgroundColor);
|
|
|
|
nsIRenderingContext::AutoPushTranslation
|
|
|
|
translate(&aRenderingContext, aPt.x, aPt.y);
|
|
|
|
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
|
|
|
|
|
|
|
aRenderingContext.SetColor(bordercolor);
|
|
|
|
aRenderingContext.DrawLine(onePixel, 0, mRect.width, 0);
|
|
|
|
aRenderingContext.DrawLine(0, onePixel, 0, mRect.height);
|
|
|
|
aRenderingContext.DrawLine(onePixel, mRect.height, mRect.width, mRect.height);
|
|
|
|
aRenderingContext.DrawLine(mRect.width, onePixel, mRect.width, mRect.height);
|
|
|
|
//middle
|
|
|
|
aRenderingContext.DrawRect(onePixel, onePixel, mRect.width-onePixel,
|
|
|
|
mRect.height-onePixel);
|
|
|
|
//shading
|
|
|
|
aRenderingContext.DrawLine(2*onePixel, mRect.height-2*onePixel,
|
|
|
|
mRect.width-onePixel, mRect.height- (2*onePixel));
|
|
|
|
aRenderingContext.DrawLine(mRect.width - (2*onePixel), 2*onePixel,
|
|
|
|
mRect.width - (2*onePixel), mRect.height-onePixel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableCellFrame::PaintBackground(nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
2009-09-12 15:44:18 -07:00
|
|
|
nsPoint aPt,
|
|
|
|
PRUint32 aFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsRect rect(aPt, GetSize());
|
2007-03-30 14:11:41 -07:00
|
|
|
nsCSSRendering::PaintBackground(PresContext(), aRenderingContext, this,
|
2009-09-12 15:44:18 -07:00
|
|
|
aDirtyRect, rect, aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Called by nsTablePainter
|
|
|
|
void
|
|
|
|
nsTableCellFrame::PaintCellBackground(nsIRenderingContext& aRenderingContext,
|
2009-09-12 15:44:18 -07:00
|
|
|
const nsRect& aDirtyRect, nsPoint aPt,
|
|
|
|
PRUint32 aFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (!GetStyleVisibility()->IsVisible())
|
|
|
|
return;
|
|
|
|
|
2009-09-12 15:44:18 -07:00
|
|
|
PaintBackground(aRenderingContext, aDirtyRect, aPt, aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-04-06 04:34:14 -07:00
|
|
|
class nsDisplayTableCellBackground : public nsDisplayTableItem {
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayTableCellBackground(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsTableCellFrame* aFrame) :
|
|
|
|
nsDisplayTableItem(aBuilder, aFrame) {
|
2007-03-22 10:30:00 -07:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayTableCellBackground);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayTableCellBackground() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayTableCellBackground);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-07 17:31:26 -07:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) {
|
|
|
|
aOutFrames->AppendElement(mFrame);
|
|
|
|
}
|
2009-09-06 17:35:14 -07:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIRenderingContext* aCtx);
|
2008-04-06 04:34:14 -07:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder);
|
|
|
|
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("TableCellBackground", TYPE_TABLE_CELL_BACKGROUND)
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
void nsDisplayTableCellBackground::Paint(nsDisplayListBuilder* aBuilder,
|
2009-09-06 17:35:14 -07:00
|
|
|
nsIRenderingContext* aCtx)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<nsTableCellFrame*>(mFrame)->
|
2010-08-13 03:01:58 -07:00
|
|
|
PaintBackground(*aCtx, mVisibleRect, ToReferenceFrame(),
|
2009-09-12 15:44:18 -07:00
|
|
|
aBuilder->GetBackgroundPaintFlags());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-04-06 04:34:14 -07:00
|
|
|
nsRect
|
|
|
|
nsDisplayTableCellBackground::GetBounds(nsDisplayListBuilder* aBuilder)
|
|
|
|
{
|
|
|
|
// revert from nsDisplayTableItem's implementation ... cell backgrounds
|
|
|
|
// don't overflow the cell
|
|
|
|
return nsDisplayItem::GetBounds(aBuilder);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static void
|
|
|
|
PaintTableCellSelection(nsIFrame* aFrame, nsIRenderingContext* aCtx,
|
|
|
|
const nsRect& aRect, nsPoint aPt)
|
|
|
|
{
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<nsTableCellFrame*>(aFrame)->DecorateForSelection(*aCtx, aPt);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
if (!IsVisibleInSelection(aBuilder))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsTableCellFrame");
|
2008-08-26 00:59:34 -07:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2008-08-26 00:59:34 -07:00
|
|
|
PRInt32 emptyCellStyle = GetContentEmpty() && !tableFrame->IsBorderCollapse() ?
|
|
|
|
GetStyleTableBorder()->mEmptyCells
|
|
|
|
: NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
|
2007-03-22 10:30:00 -07:00
|
|
|
// take account of 'empty-cells'
|
|
|
|
if (GetStyleVisibility()->IsVisible() &&
|
|
|
|
(NS_STYLE_TABLE_EMPTY_CELLS_HIDE != emptyCellStyle)) {
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-04-06 04:34:14 -07:00
|
|
|
PRBool isRoot = aBuilder->IsAtRootOfPseudoStackingContext();
|
|
|
|
if (!isRoot) {
|
|
|
|
nsDisplayTableItem* currentItem = aBuilder->GetCurrentTableItem();
|
2009-12-12 10:50:30 -08:00
|
|
|
if (currentItem) {
|
|
|
|
currentItem->UpdateForFrameBackground(this);
|
|
|
|
}
|
2008-04-06 04:34:14 -07:00
|
|
|
}
|
|
|
|
|
2009-02-10 00:45:13 -08:00
|
|
|
// display outset box-shadows if we need to.
|
|
|
|
PRBool hasBoxShadow = !!(GetStyleBorder()->mBoxShadow);
|
|
|
|
if (hasBoxShadow) {
|
2010-08-13 03:01:13 -07:00
|
|
|
nsresult rv = aLists.BorderBackground()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayBoxShadowOuter(aBuilder, this));
|
2008-12-02 17:20:21 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// display background if we need to.
|
|
|
|
if (aBuilder->IsForEventDelivery() ||
|
2008-04-06 04:34:14 -07:00
|
|
|
(((!tableFrame->IsBorderCollapse() || isRoot) &&
|
2007-03-22 10:30:00 -07:00
|
|
|
(!GetStyleBackground()->IsTransparent() || GetStyleDisplay()->mAppearance)))) {
|
|
|
|
// The cell background was not painted by the nsTablePainter,
|
|
|
|
// so we need to do it. We have special background processing here
|
|
|
|
// so we need to duplicate some code from nsFrame::DisplayBorderBackgroundOutline
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayTableItem* item =
|
|
|
|
new (aBuilder) nsDisplayTableCellBackground(aBuilder, this);
|
2008-04-06 04:34:14 -07:00
|
|
|
nsresult rv = aLists.BorderBackground()->AppendNewToTop(item);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2008-04-06 04:34:14 -07:00
|
|
|
item->UpdateForFrameBackground(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-02-10 00:45:13 -08:00
|
|
|
|
|
|
|
// display inset box-shadows if we need to.
|
|
|
|
if (hasBoxShadow) {
|
2010-08-13 03:01:13 -07:00
|
|
|
nsresult rv = aLists.BorderBackground()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayBoxShadowInner(aBuilder, this));
|
2009-02-10 00:45:13 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// display borders if we need to
|
|
|
|
if (!tableFrame->IsBorderCollapse() && HasBorder() &&
|
|
|
|
emptyCellStyle == NS_STYLE_TABLE_EMPTY_CELLS_SHOW) {
|
|
|
|
nsresult rv = aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayBorder(aBuilder, this));
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
// and display the selection border if we need to
|
|
|
|
PRBool isSelected =
|
|
|
|
(GetStateBits() & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
|
|
|
|
if (isSelected) {
|
|
|
|
nsresult rv = aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayGeneric(aBuilder, this, ::PaintTableCellSelection,
|
|
|
|
"TableCellSelection",
|
2010-07-15 14:07:49 -07:00
|
|
|
nsDisplayItem::TYPE_TABLE_CELL_SELECTION));
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// the 'empty-cells' property has no effect on 'outline'
|
|
|
|
nsresult rv = DisplayOutline(aBuilder, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2009-12-12 10:50:25 -08:00
|
|
|
// Push a null 'current table item' so that descendant tables can't
|
|
|
|
// accidentally mess with our table
|
|
|
|
nsAutoPushCurrentTableItem pushTableItem;
|
|
|
|
pushTableItem.Push(aBuilder, nsnull);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
NS_ASSERTION(kid && !kid->GetNextSibling(), "Table cells should have just one child");
|
2008-11-02 17:01:49 -08:00
|
|
|
// The child's background will go in our BorderBackground() list.
|
|
|
|
// This isn't a problem since it won't have a real background except for
|
|
|
|
// event handling. We do not call BuildDisplayListForNonBlockChildren
|
|
|
|
// because that/ would put the child's background in the Content() list
|
|
|
|
// which isn't right (e.g., would end up on top of our child floats for
|
|
|
|
// event handling).
|
|
|
|
return BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
PRIntn
|
|
|
|
nsTableCellFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
|
|
|
if (nsnull != GetPrevInFlow()) {
|
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
|
|
|
}
|
|
|
|
if (nsnull != GetNextInFlow()) {
|
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsTableCellFrame::GetSelfOverflow(nsRect& aOverflowArea)
|
|
|
|
{
|
|
|
|
aOverflowArea = nsRect(nsPoint(0,0), GetSize());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Align the cell's child frame within the cell
|
|
|
|
|
|
|
|
void nsTableCellFrame::VerticallyAlignChild(nscoord aMaxAscent)
|
|
|
|
{
|
|
|
|
const nsStyleTextReset* textStyle = GetStyleTextReset();
|
|
|
|
/* It's the 'border-collapse' on the table that matters */
|
|
|
|
nsMargin borderPadding = GetUsedBorderAndPadding();
|
|
|
|
|
|
|
|
nscoord topInset = borderPadding.top;
|
|
|
|
nscoord bottomInset = borderPadding.bottom;
|
|
|
|
|
2010-08-31 09:05:12 -07:00
|
|
|
PRUint8 verticalAlignFlags = GetVerticalAlign();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nscoord height = mRect.height;
|
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
|
|
|
NS_ASSERTION(firstKid, "Frame construction error, a table cell always has an inner cell frame");
|
|
|
|
nsRect kidRect = firstKid->GetRect();
|
|
|
|
nscoord childHeight = kidRect.height;
|
|
|
|
|
|
|
|
// Vertically align the child
|
|
|
|
nscoord kidYTop = 0;
|
2010-04-27 09:15:01 -07:00
|
|
|
switch (verticalAlignFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BASELINE:
|
2010-04-27 09:15:01 -07:00
|
|
|
// Align the baselines of the child frame with the baselines of
|
2007-03-22 10:30:00 -07:00
|
|
|
// other children in the same row which have 'vertical-align: baseline'
|
|
|
|
kidYTop = topInset + aMaxAscent - GetCellBaseline();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_TOP:
|
2010-04-27 09:15:01 -07:00
|
|
|
// Align the top of the child frame with the top of the content area,
|
2007-03-22 10:30:00 -07:00
|
|
|
kidYTop = topInset;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
2010-04-27 09:15:01 -07:00
|
|
|
// Align the bottom of the child frame with the bottom of the content area,
|
2007-03-22 10:30:00 -07:00
|
|
|
kidYTop = height - childHeight - bottomInset;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
|
2010-04-27 09:15:01 -07:00
|
|
|
// Align the middle of the child frame with the middle of the content area,
|
2007-03-22 10:30:00 -07:00
|
|
|
kidYTop = (height - childHeight - bottomInset + topInset) / 2;
|
|
|
|
}
|
|
|
|
// if the content is larger than the cell height align from top
|
2009-09-16 08:01:36 -07:00
|
|
|
kidYTop = NS_MAX(0, kidYTop);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-08 01:36:32 -08:00
|
|
|
if (kidYTop != kidRect.y) {
|
|
|
|
// Invalidate at the old position first
|
2010-08-30 17:49:12 -07:00
|
|
|
firstKid->InvalidateFrameSubtree();
|
2008-02-08 01:36:32 -08:00
|
|
|
}
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
firstKid->SetPosition(nsPoint(kidRect.x, kidYTop));
|
|
|
|
nsHTMLReflowMetrics desiredSize;
|
|
|
|
desiredSize.width = mRect.width;
|
|
|
|
desiredSize.height = mRect.height;
|
|
|
|
GetSelfOverflow(desiredSize.mOverflowArea);
|
|
|
|
ConsiderChildOverflow(desiredSize.mOverflowArea, firstKid);
|
|
|
|
FinishAndStoreOverflow(&desiredSize);
|
|
|
|
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(firstKid);
|
2008-02-08 01:36:32 -08:00
|
|
|
|
|
|
|
// Invalidate new overflow rect
|
2010-08-30 17:49:12 -07:00
|
|
|
firstKid->InvalidateFrameSubtree();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (HasView()) {
|
2007-03-30 14:11:41 -07:00
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(PresContext(), this,
|
2007-03-22 10:30:00 -07:00
|
|
|
GetView(),
|
|
|
|
&desiredSize.mOverflowArea, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-31 09:05:12 -07:00
|
|
|
// Per CSS 2.1, we map 'sub', 'super', 'text-top', 'text-bottom',
|
|
|
|
// length, percentage, and calc() values to 'baseline'.
|
|
|
|
PRUint8
|
|
|
|
nsTableCellFrame::GetVerticalAlign() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-08-31 09:05:12 -07:00
|
|
|
const nsStyleCoord& verticalAlign = GetStyleTextReset()->mVerticalAlign;
|
|
|
|
if (verticalAlign.GetUnit() == eStyleUnit_Enumerated) {
|
|
|
|
PRUint8 value = verticalAlign.GetIntValue();
|
|
|
|
if (value == NS_STYLE_VERTICAL_ALIGN_TOP ||
|
|
|
|
value == NS_STYLE_VERTICAL_ALIGN_MIDDLE ||
|
|
|
|
value == NS_STYLE_VERTICAL_ALIGN_BOTTOM) {
|
|
|
|
return value;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2010-08-31 09:05:12 -07:00
|
|
|
return NS_STYLE_VERTICAL_ALIGN_BASELINE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-04-27 09:15:01 -07:00
|
|
|
PRBool
|
2008-09-13 07:38:29 -07:00
|
|
|
nsTableCellFrame::CellHasVisibleContent(nscoord height,
|
|
|
|
nsTableFrame* tableFrame,
|
2009-01-14 21:06:03 -08:00
|
|
|
nsIFrame* kidFrame)
|
2008-09-13 07:38:29 -07:00
|
|
|
{
|
2008-09-27 04:25:28 -07:00
|
|
|
// see http://www.w3.org/TR/CSS21/tables.html#empty-cells
|
2008-09-13 07:38:29 -07:00
|
|
|
if (height > 0)
|
|
|
|
return PR_TRUE;
|
|
|
|
if (tableFrame->IsBorderCollapse())
|
|
|
|
return PR_TRUE;
|
|
|
|
nsIFrame* innerFrame = kidFrame->GetFirstChild(nsnull);
|
|
|
|
while(innerFrame) {
|
|
|
|
nsIAtom* frameType = innerFrame->GetType();
|
|
|
|
if (nsGkAtoms::textFrame == frameType) {
|
|
|
|
nsTextFrame* textFrame = static_cast<nsTextFrame*>(innerFrame);
|
|
|
|
if (textFrame->HasNoncollapsedCharacters())
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (nsGkAtoms::placeholderFrame != frameType) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsIFrame *floatFrame = nsLayoutUtils::GetFloatFromPlaceholder(innerFrame);
|
|
|
|
if (floatFrame)
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
innerFrame = innerFrame->GetNextSibling();
|
2010-04-27 09:15:01 -07:00
|
|
|
}
|
2008-09-13 07:38:29 -07:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord
|
|
|
|
nsTableCellFrame::GetCellBaseline() const
|
|
|
|
{
|
|
|
|
// Ignore the position of the inner frame relative to the cell frame
|
|
|
|
// since we want the position as though the inner were top-aligned.
|
|
|
|
nsIFrame *inner = mFrames.FirstChild();
|
|
|
|
nscoord borderPadding = GetUsedBorderAndPadding().top;
|
|
|
|
nscoord result;
|
|
|
|
if (nsLayoutUtils::GetFirstLineBaseline(inner, &result))
|
|
|
|
return result + borderPadding;
|
|
|
|
return inner->GetContentRect().YMost() - inner->GetPosition().y +
|
|
|
|
borderPadding;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 nsTableCellFrame::GetRowSpan()
|
2010-04-27 09:15:01 -07:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
PRInt32 rowSpan=1;
|
|
|
|
nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent);
|
|
|
|
|
|
|
|
// Don't look at the content's rowspan if we're a pseudo cell
|
2009-10-29 14:17:56 -07:00
|
|
|
if (hc && !GetStyleContext()->GetPseudo()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsAttrValue* attr = hc->GetParsedAttr(nsGkAtoms::rowspan);
|
|
|
|
// Note that we don't need to check the tag name, because only table cells
|
|
|
|
// and table headers parse the "rowspan" attribute into an integer.
|
2010-04-27 09:15:01 -07:00
|
|
|
if (attr && attr->Type() == nsAttrValue::eInteger) {
|
|
|
|
rowSpan = attr->GetIntegerValue();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return rowSpan;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 nsTableCellFrame::GetColSpan()
|
2010-04-27 09:15:01 -07:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
PRInt32 colSpan=1;
|
|
|
|
nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent);
|
|
|
|
|
|
|
|
// Don't look at the content's colspan if we're a pseudo cell
|
2009-10-29 14:17:56 -07:00
|
|
|
if (hc && !GetStyleContext()->GetPseudo()) {
|
2010-04-27 09:15:01 -07:00
|
|
|
const nsAttrValue* attr = hc->GetParsedAttr(nsGkAtoms::colspan);
|
2007-03-22 10:30:00 -07:00
|
|
|
// Note that we don't need to check the tag name, because only table cells
|
|
|
|
// and table headers parse the "colspan" attribute into an integer.
|
2010-04-27 09:15:01 -07:00
|
|
|
if (attr && attr->Type() == nsAttrValue::eInteger) {
|
|
|
|
colSpan = attr->GetIntegerValue();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return colSpan;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
|
|
|
nsTableCellFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
|
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
|
|
|
|
nsIFrame *inner = mFrames.FirstChild();
|
|
|
|
result = nsLayoutUtils::IntrinsicForContainer(aRenderingContext, inner,
|
|
|
|
nsLayoutUtils::MIN_WIDTH);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
|
|
|
nsTableCellFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext)
|
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
|
|
|
|
nsIFrame *inner = mFrames.FirstChild();
|
|
|
|
result = nsLayoutUtils::IntrinsicForContainer(aRenderingContext, inner,
|
|
|
|
nsLayoutUtils::PREF_WIDTH);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsIFrame::IntrinsicWidthOffsetData
|
|
|
|
nsTableCellFrame::IntrinsicWidthOffsets(nsIRenderingContext* aRenderingContext)
|
|
|
|
{
|
|
|
|
IntrinsicWidthOffsetData result =
|
|
|
|
nsHTMLContainerFrame::IntrinsicWidthOffsets(aRenderingContext);
|
|
|
|
|
|
|
|
result.hMargin = 0;
|
|
|
|
result.hPctMargin = 0;
|
|
|
|
|
|
|
|
nsMargin border;
|
|
|
|
GetBorderWidth(border);
|
|
|
|
result.hBorder = border.LeftRight();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define PROBABLY_TOO_LARGE 1000000
|
|
|
|
static
|
2010-04-27 09:15:01 -07:00
|
|
|
void DebugCheckChildSize(nsIFrame* aChild,
|
|
|
|
nsHTMLReflowMetrics& aMet,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize& aAvailSize)
|
|
|
|
{
|
|
|
|
if ((aMet.width < 0) || (aMet.width > PROBABLY_TOO_LARGE)) {
|
2009-07-21 13:05:49 -07:00
|
|
|
printf("WARNING: cell content %p has large width %d \n",
|
|
|
|
static_cast<void*>(aChild), aMet.width);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// the computed height for the cell, which descendants use for percent height calculations
|
2010-04-27 09:15:01 -07:00
|
|
|
// it is the height (minus border, padding) of the cell's first in flow during its final
|
2007-03-22 10:30:00 -07:00
|
|
|
// reflow without an unconstrained height.
|
|
|
|
static nscoord
|
2009-02-16 16:02:21 -08:00
|
|
|
CalcUnpaginagedHeight(nsPresContext* aPresContext,
|
2010-04-27 09:15:01 -07:00
|
|
|
nsTableCellFrame& aCellFrame,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nscoord aVerticalBorderPadding)
|
|
|
|
{
|
|
|
|
const nsTableCellFrame* firstCellInFlow = (nsTableCellFrame*)aCellFrame.GetFirstInFlow();
|
|
|
|
nsTableFrame* firstTableInFlow = (nsTableFrame*)aTableFrame.GetFirstInFlow();
|
|
|
|
nsTableRowFrame* row
|
2007-07-08 00:08:04 -07:00
|
|
|
= static_cast<nsTableRowFrame*>(firstCellInFlow->GetParent());
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTableRowGroupFrame* firstRGInFlow
|
2007-07-08 00:08:04 -07:00
|
|
|
= static_cast<nsTableRowGroupFrame*>(row->GetParent());
|
2007-03-22 10:30:00 -07: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;
|
|
|
|
}
|
|
|
|
|
2009-01-14 21:06:03 -08:00
|
|
|
NS_METHOD nsTableCellFrame::Reflow(nsPresContext* aPresContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableCellFrame");
|
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
|
|
|
|
2007-06-18 16:19:39 -07:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
|
|
|
GetFirstInFlow()->AddStateBits(NS_TABLE_CELL_HAD_SPECIAL_REFLOW);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// see if a special height reflow needs to occur due to having a pct height
|
|
|
|
nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState);
|
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2009-02-16 16:02:21 -08:00
|
|
|
nsSize availSize(aReflowState.availableWidth, aReflowState.availableHeight);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* It's the 'border-collapse' on the table that matters */
|
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (!tableFrame)
|
|
|
|
ABORT1(NS_ERROR_NULL_POINTER);
|
|
|
|
|
|
|
|
nsMargin borderPadding = aReflowState.mComputedPadding;
|
|
|
|
nsMargin border;
|
|
|
|
GetBorderWidth(border);
|
|
|
|
borderPadding += border;
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord topInset = borderPadding.top;
|
|
|
|
nscoord rightInset = borderPadding.right;
|
|
|
|
nscoord bottomInset = borderPadding.bottom;
|
|
|
|
nscoord leftInset = borderPadding.left;
|
|
|
|
|
|
|
|
// reduce available space by insets, if we're in a constrained situation
|
2009-02-16 16:02:21 -08:00
|
|
|
availSize.width -= leftInset + rightInset;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != availSize.height)
|
|
|
|
availSize.height -= topInset + bottomInset;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Try to reflow the child into the available space. It might not
|
|
|
|
// fit or might need continuing.
|
|
|
|
if (availSize.height < 0)
|
|
|
|
availSize.height = 1;
|
|
|
|
|
|
|
|
nsHTMLReflowMetrics kidSize(aDesiredSize.mFlags);
|
|
|
|
kidSize.width = kidSize.height = 0;
|
|
|
|
SetPriorAvailWidth(aReflowState.availableWidth);
|
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
|
|
|
NS_ASSERTION(firstKid, "Frame construction error, a table cell always has an inner cell frame");
|
|
|
|
|
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
2007-08-02 11:08:05 -07:00
|
|
|
const_cast<nsHTMLReflowState&>(aReflowState).SetComputedHeight(mRect.height - topInset - bottomInset);
|
2007-03-22 10:30:00 -07:00
|
|
|
DISPLAY_REFLOW_CHANGE();
|
|
|
|
}
|
|
|
|
else if (aPresContext->IsPaginated()) {
|
2009-07-21 13:05:49 -07:00
|
|
|
nscoord computedUnpaginatedHeight =
|
|
|
|
CalcUnpaginagedHeight(aPresContext, (nsTableCellFrame&)*this,
|
|
|
|
*tableFrame, topInset + bottomInset);
|
|
|
|
if (computedUnpaginatedHeight > 0) {
|
|
|
|
const_cast<nsHTMLReflowState&>(aReflowState).SetComputedHeight(computedUnpaginatedHeight);
|
2007-03-22 10:30:00 -07:00
|
|
|
DISPLAY_REFLOW_CHANGE();
|
|
|
|
}
|
2010-04-27 09:15:01 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
else {
|
|
|
|
SetHasPctOverHeight(PR_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, firstKid,
|
|
|
|
availSize);
|
2007-11-06 14:47:29 -08:00
|
|
|
|
|
|
|
// Don't be a percent height observer if we're in the middle of
|
|
|
|
// special-height reflow, in case we get an accidental NotifyPercentHeight()
|
|
|
|
// call (which we shouldn't honor during special-height reflow)
|
|
|
|
if (!aReflowState.mFlags.mSpecialHeightReflow) {
|
|
|
|
// mPercentHeightObserver is for children of cells in quirks mode,
|
|
|
|
// but only those than are tables in standards mode. NeedsToObserve
|
|
|
|
// will determine how far this is propagated to descendants.
|
|
|
|
kidReflowState.mPercentHeightObserver = this;
|
|
|
|
}
|
2007-10-08 19:39:06 -07:00
|
|
|
// Don't propagate special height reflow state to our kids
|
|
|
|
kidReflowState.mFlags.mSpecialHeightReflow = PR_FALSE;
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2007-06-18 16:19:39 -07:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow ||
|
|
|
|
(GetFirstInFlow()->GetStateBits() & NS_TABLE_CELL_HAD_SPECIAL_REFLOW)) {
|
|
|
|
// We need to force the kid to have mVResize set if we've had a
|
|
|
|
// special reflow in the past, since the non-special reflow needs to
|
|
|
|
// resize back to what it was without the special height reflow.
|
2007-03-22 10:30:00 -07:00
|
|
|
kidReflowState.mFlags.mVResize = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint kidOrigin(leftInset, topInset);
|
2008-02-08 01:36:32 -08:00
|
|
|
nsRect origRect = firstKid->GetRect();
|
2008-03-16 13:32:48 -07:00
|
|
|
nsRect origOverflowRect = firstKid->GetOverflowRect();
|
2008-02-08 01:36:32 -08:00
|
|
|
PRBool firstReflow = (firstKid->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
ReflowChild(firstKid, aPresContext, kidSize, kidReflowState,
|
2008-02-08 01:36:32 -08:00
|
|
|
kidOrigin.x, kidOrigin.y, NS_FRAME_INVALIDATE_ON_MOVE, aStatus);
|
2007-07-25 21:03:29 -07:00
|
|
|
if (NS_FRAME_OVERFLOW_IS_INCOMPLETE(aStatus)) {
|
|
|
|
// Don't pass OVERFLOW_INCOMPLETE through tables until they can actually handle it
|
|
|
|
//XXX should paginate overflow as overflow, but not in this patch (bug 379349)
|
|
|
|
NS_FRAME_SET_INCOMPLETE(aStatus);
|
2009-07-21 13:05:49 -07:00
|
|
|
printf("Set table cell incomplete %p\n", static_cast<void*>(this));
|
2007-07-25 21:03:29 -07:00
|
|
|
}
|
2008-02-08 01:36:32 -08:00
|
|
|
|
|
|
|
// XXXbz is this invalidate actually needed, really?
|
2007-03-22 10:30:00 -07:00
|
|
|
if (GetStateBits() & NS_FRAME_IS_DIRTY) {
|
2010-08-30 17:49:12 -07:00
|
|
|
InvalidateFrameSubtree();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
DebugCheckChildSize(firstKid, kidSize, availSize);
|
|
|
|
#endif
|
|
|
|
|
2010-04-27 09:15:01 -07:00
|
|
|
// 0 dimensioned cells need to be treated specially in Standard/NavQuirks mode
|
2007-03-22 10:30:00 -07:00
|
|
|
// see testcase "emptyCells.html"
|
2008-04-08 05:28:34 -07:00
|
|
|
nsIFrame* prevInFlow = GetPrevInFlow();
|
|
|
|
PRBool isEmpty;
|
|
|
|
if (prevInFlow) {
|
|
|
|
isEmpty = static_cast<nsTableCellFrame*>(prevInFlow)->GetContentEmpty();
|
|
|
|
} else {
|
2008-09-13 07:38:29 -07:00
|
|
|
isEmpty = !CellHasVisibleContent(kidSize.height, tableFrame, firstKid);
|
2008-04-08 05:28:34 -07:00
|
|
|
}
|
|
|
|
SetContentEmpty(isEmpty);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Place the child
|
|
|
|
FinishReflowChild(firstKid, aPresContext, &kidReflowState, kidSize,
|
|
|
|
kidOrigin.x, kidOrigin.y, 0);
|
2008-02-08 01:36:32 -08:00
|
|
|
|
2008-03-16 13:32:48 -07:00
|
|
|
nsTableFrame::InvalidateFrame(firstKid, origRect, origOverflowRect,
|
|
|
|
firstReflow);
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// first, compute the height which can be set w/o being restricted by aMaxSize.height
|
|
|
|
nscoord cellHeight = kidSize.height;
|
|
|
|
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != cellHeight) {
|
|
|
|
cellHeight += topInset + bottomInset;
|
|
|
|
}
|
|
|
|
|
|
|
|
// next determine the cell's width
|
|
|
|
nscoord cellWidth = kidSize.width; // at this point, we've factored in the cell's style attributes
|
|
|
|
|
|
|
|
// factor in border and padding
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != cellWidth) {
|
2010-04-27 09:15:01 -07:00
|
|
|
cellWidth += leftInset + rightInset;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// set the cell's desired size and max element size
|
|
|
|
aDesiredSize.width = cellWidth;
|
|
|
|
aDesiredSize.height = cellHeight;
|
|
|
|
|
|
|
|
// the overflow area will be computed when the child will be vertically aligned
|
|
|
|
|
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
|
|
|
if (aDesiredSize.height > mRect.height) {
|
2010-04-27 09:15:01 -07:00
|
|
|
// set a bit indicating that the pct height contents exceeded
|
2007-03-22 10:30:00 -07:00
|
|
|
// the height that they could honor in the pass 2 reflow
|
|
|
|
SetHasPctOverHeight(PR_TRUE);
|
|
|
|
}
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
|
|
|
|
aDesiredSize.height = mRect.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-01 14:53:19 -07:00
|
|
|
// If our parent is in initial reflow, it'll handle invalidating our
|
|
|
|
// entire overflow rect.
|
|
|
|
if (!(GetParent()->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
2008-08-19 23:45:29 -07:00
|
|
|
CheckInvalidateSizeChange(aDesiredSize);
|
2008-04-01 14:53:19 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// remember the desired size for this reflow
|
|
|
|
SetDesiredSize(aDesiredSize);
|
|
|
|
|
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_HEAD(nsTableCellFrame)
|
2009-03-24 15:10:06 -07:00
|
|
|
NS_QUERYFRAME_ENTRY(nsTableCellFrame)
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_ENTRY(nsITableCellLayout)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIPercentHeightObserver)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 05:02:03 -07:00
|
|
|
already_AddRefed<nsAccessible>
|
|
|
|
nsTableCellFrame::CreateAccessible()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
|
|
|
|
if (accService) {
|
2010-06-28 05:02:03 -07:00
|
|
|
return accService->CreateHTMLTableCellAccessible(mContent,
|
|
|
|
PresContext()->PresShell());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-06-28 05:02:03 -07:00
|
|
|
return nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* This is primarily for editor access via nsITableLayout */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::GetCellIndexes(PRInt32 &aRowIndex, PRInt32 &aColIndex)
|
|
|
|
{
|
|
|
|
nsresult res = GetRowIndex(aRowIndex);
|
|
|
|
if (NS_FAILED(res))
|
|
|
|
{
|
|
|
|
aColIndex = 0;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
aColIndex = mColIndex;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
NS_NewTableCellFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext,
|
|
|
|
PRBool aIsBorderCollapse)
|
|
|
|
{
|
|
|
|
if (aIsBorderCollapse)
|
|
|
|
return new (aPresShell) nsBCTableCellFrame(aContext);
|
|
|
|
else
|
|
|
|
return new (aPresShell) nsTableCellFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsBCTableCellFrame)
|
|
|
|
|
2010-04-27 09:15:01 -07:00
|
|
|
nsMargin*
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTableCellFrame::GetBorderWidth(nsMargin& aBorder) const
|
|
|
|
{
|
2008-07-16 23:30:25 -07:00
|
|
|
aBorder = GetStyleBorder()->GetActualBorder();
|
2007-03-22 10:30:00 -07:00
|
|
|
return &aBorder;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsTableCellFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::tableCellFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ PRBool
|
|
|
|
nsTableCellFrame::IsContainingBlock() const
|
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCellFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableCell"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// nsBCTableCellFrame
|
|
|
|
|
|
|
|
nsBCTableCellFrame::nsBCTableCellFrame(nsStyleContext* aContext)
|
|
|
|
:nsTableCellFrame(aContext)
|
|
|
|
{
|
|
|
|
mTopBorder = mRightBorder = mBottomBorder = mLeftBorder = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBCTableCellFrame::~nsBCTableCellFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsBCTableCellFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::bcTableCellFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsBCTableCellFrame::GetUsedBorder() const
|
|
|
|
{
|
|
|
|
nsMargin result;
|
|
|
|
GetBorderWidth(result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-09-07 15:20:35 -07:00
|
|
|
/* virtual */ PRBool
|
|
|
|
nsBCTableCellFrame::GetBorderRadii(nscoord aRadii[8]) const
|
|
|
|
{
|
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
aRadii[corner] = 0;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBCTableCellFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("BCTableCell"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-27 09:15:01 -07:00
|
|
|
nsMargin*
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBCTableCellFrame::GetBorderWidth(nsMargin& aBorder) const
|
|
|
|
{
|
|
|
|
PRInt32 aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
|
|
|
|
aBorder.top = BC_BORDER_BOTTOM_HALF_COORD(aPixelsToTwips, mTopBorder);
|
|
|
|
aBorder.right = BC_BORDER_LEFT_HALF_COORD(aPixelsToTwips, mRightBorder);
|
|
|
|
aBorder.bottom = BC_BORDER_TOP_HALF_COORD(aPixelsToTwips, mBottomBorder);
|
|
|
|
aBorder.left = BC_BORDER_RIGHT_HALF_COORD(aPixelsToTwips, mLeftBorder);
|
|
|
|
return &aBorder;
|
|
|
|
}
|
|
|
|
|
|
|
|
BCPixelSize
|
2010-04-27 09:15:02 -07:00
|
|
|
nsBCTableCellFrame::GetBorderWidth(mozilla::css::Side aSide) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
switch(aSide) {
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
return BC_BORDER_BOTTOM_HALF(mTopBorder);
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
return BC_BORDER_LEFT_HALF(mRightBorder);
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
return BC_BORDER_TOP_HALF(mBottomBorder);
|
|
|
|
default:
|
|
|
|
return BC_BORDER_RIGHT_HALF(mLeftBorder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-27 09:15:01 -07:00
|
|
|
void
|
2010-04-27 09:15:02 -07:00
|
|
|
nsBCTableCellFrame::SetBorderWidth(mozilla::css::Side aSide,
|
2007-03-22 10:30:00 -07:00
|
|
|
BCPixelSize 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsBCTableCellFrame::GetSelfOverflow(nsRect& aOverflowArea)
|
|
|
|
{
|
|
|
|
nsMargin halfBorder;
|
|
|
|
PRInt32 p2t = nsPresContext::AppUnitsPerCSSPixel();
|
|
|
|
halfBorder.top = BC_BORDER_TOP_HALF_COORD(p2t, mTopBorder);
|
|
|
|
halfBorder.right = BC_BORDER_RIGHT_HALF_COORD(p2t, mRightBorder);
|
|
|
|
halfBorder.bottom = BC_BORDER_BOTTOM_HALF_COORD(p2t, mBottomBorder);
|
|
|
|
halfBorder.left = BC_BORDER_LEFT_HALF_COORD(p2t, mLeftBorder);
|
|
|
|
|
|
|
|
nsRect overflow(nsPoint(0,0), GetSize());
|
|
|
|
overflow.Inflate(halfBorder);
|
|
|
|
aOverflowArea = overflow;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBCTableCellFrame::PaintBackground(nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
2009-09-12 15:44:18 -07:00
|
|
|
nsPoint aPt,
|
|
|
|
PRUint32 aFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// make border-width reflect the half of the border-collapse
|
|
|
|
// assigned border that's inside the cell
|
|
|
|
nsMargin borderWidth;
|
|
|
|
GetBorderWidth(borderWidth);
|
|
|
|
|
|
|
|
nsStyleBorder myBorder(*GetStyleBorder());
|
2010-09-07 17:30:40 -07:00
|
|
|
// We're making an ephemeral stack copy here, so just copy this debug-only
|
|
|
|
// member to prevent assertions.
|
|
|
|
#ifdef DEBUG
|
|
|
|
myBorder.mImageTracked = GetStyleBorder()->mImageTracked;
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
|
|
|
myBorder.SetBorderWidth(side, borderWidth.side(side));
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect rect(aPt, GetSize());
|
2008-09-23 21:07:22 -07:00
|
|
|
// bypassing nsCSSRendering::PaintBackground is safe because this kind
|
|
|
|
// of frame cannot be used for the root element
|
|
|
|
nsCSSRendering::PaintBackgroundWithSC(PresContext(), aRenderingContext, this,
|
|
|
|
aDirtyRect, rect,
|
2010-04-02 18:58:26 -07:00
|
|
|
GetStyleContext(), myBorder,
|
2009-09-12 15:44:18 -07:00
|
|
|
aFlags, nsnull);
|
2010-09-07 17:30:40 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
myBorder.mImageTracked = false;
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|