2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsTableFrame.h"
|
|
|
|
#include "nsTableColFrame.h"
|
|
|
|
#include "nsTableCellFrame.h"
|
2012-08-08 06:05:17 -07:00
|
|
|
#include "nsTableRowFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsTableRowGroupFrame.h"
|
|
|
|
#include "nsTablePainter.h"
|
|
|
|
#include "nsStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsPresContext.h"
|
2011-04-07 18:04:40 -07:00
|
|
|
#include "nsRenderingContext.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-09-30 09:40:24 -07:00
|
|
|
#include "nsAttrValueInlines.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
2014-02-27 15:04:46 -08:00
|
|
|
#include "nsNameSpaceManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsDisplayList.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
2008-09-13 07:38:29 -07:00
|
|
|
#include "nsTextFrame.h"
|
2012-08-28 22:48:45 -07:00
|
|
|
#include "FrameLayerBuilder.h"
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//TABLECELL SELECTION
|
|
|
|
#include "nsFrameSelection.h"
|
2011-09-08 19:27:13 -07:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
|
|
|
|
nsTableCellFrame::nsTableCellFrame(nsStyleContext* aContext) :
|
2011-12-27 12:18:48 -08:00
|
|
|
nsContainerFrame(aContext)
|
2014-07-24 01:30:07 -07:00
|
|
|
, mDesiredSize(GetWritingMode())
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
mColIndex = 0;
|
|
|
|
mPriorAvailWidth = 0;
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
SetContentEmpty(false);
|
|
|
|
SetHasPctOverHeight(false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-03-19 18:47:48 -07:00
|
|
|
void
|
2014-05-24 15:20:40 -07:00
|
|
|
nsTableCellFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Let the base class do its initialization
|
2013-03-19 18:47:48 -07:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-04-16 15:32:12 -07:00
|
|
|
if (GetStateBits() & NS_FRAME_FONT_INFLATION_CONTAINER) {
|
|
|
|
AddStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aPrevInFlow) {
|
|
|
|
// Set the column index
|
|
|
|
nsTableCellFrame* cellFrame = (nsTableCellFrame*)aPrevInFlow;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t colIndex;
|
2007-03-22 10:30:00 -07:00
|
|
|
cellFrame->GetColIndex(colIndex);
|
|
|
|
SetColIndex(colIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-10 15:41:17 -07:00
|
|
|
void
|
|
|
|
nsTableCellFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
|
|
|
{
|
|
|
|
if (GetStateBits() & NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN) {
|
|
|
|
nsTableFrame::UnregisterPositionedTablePart(this, aDestructRoot);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsContainerFrame::DestroyFrom(aDestructRoot);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// 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
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTableCellFrame::NeedsToObserve(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
const nsHTMLReflowState *rs = aReflowState.parentReflowState;
|
|
|
|
if (!rs)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
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.
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
rs = rs->parentReflowState;
|
|
|
|
if (!rs) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2012-08-22 08:56:38 -07:00
|
|
|
nsTableCellFrame::GetRowIndex(int32_t &aRowIndex) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
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
|
2012-08-22 08:56:38 -07:00
|
|
|
nsTableCellFrame::GetColIndex(int32_t &aColIndex) const
|
2010-04-27 09:15:01 -07:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
if (GetPrevInFlow()) {
|
2013-09-25 04:42:35 -07:00
|
|
|
return static_cast<nsTableCellFrame*>(FirstInFlow())->GetColIndex(aColIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
aColIndex = mColIndex;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
nsTableCellFrame::AttributeChanged(int32_t aNameSpaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
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);
|
2012-01-16 15:38:10 -08: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)
|
|
|
|
{
|
2012-08-13 14:13:34 -07:00
|
|
|
nsContainerFrame::DidSetStyleContext(aOldStyleContext);
|
|
|
|
|
2008-10-26 03:11:34 -07:00
|
|
|
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);
|
|
|
|
if (tableFrame->IsBorderCollapse() &&
|
2013-02-15 21:38:33 -08:00
|
|
|
tableFrame->BCRecalcNeeded(aOldStyleContext, StyleContext())) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t colIndex, rowIndex;
|
2008-10-26 03:11:34 -07:00
|
|
|
GetColIndex(colIndex);
|
|
|
|
GetRowIndex(rowIndex);
|
2011-12-07 11:38:25 -08:00
|
|
|
// row span needs to be clamped as we do not create rows in the cellmap
|
|
|
|
// which do not have cells originating in them
|
2012-01-22 14:48:34 -08:00
|
|
|
nsIntRect damageArea(colIndex, rowIndex, GetColSpan(),
|
2013-01-15 04:22:03 -08:00
|
|
|
std::min(GetRowSpan(), tableFrame->GetRowCount() - rowIndex));
|
2011-10-27 06:58:44 -07:00
|
|
|
tableFrame->AddBCDamageArea(damageArea);
|
2008-10-26 03:11:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-28 12:36:59 -07:00
|
|
|
#ifdef DEBUG
|
2014-05-28 12:36:58 -07:00
|
|
|
void
|
2011-08-24 13:54:30 -07:00
|
|
|
nsTableCellFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-05-28 12:36:59 -07:00
|
|
|
MOZ_CRASH("unsupported operation");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-05-28 12:36:58 -07:00
|
|
|
void
|
2011-08-24 13:54:30 -07:00
|
|
|
nsTableCellFrame::InsertFrames(ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-05-28 12:36:59 -07:00
|
|
|
MOZ_CRASH("unsupported operation");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-05-28 12:36:58 -07:00
|
|
|
void
|
2011-08-24 13:54:30 -07:00
|
|
|
nsTableCellFrame::RemoveFrame(ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2014-05-28 12:36:59 -07:00
|
|
|
MOZ_CRASH("unsupported operation");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2014-05-28 12:36:59 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void nsTableCellFrame::SetColIndex(int32_t 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
|
2011-04-07 18:04:40 -07:00
|
|
|
nsTableCellFrame::DecorateForSelection(nsRenderingContext& aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsPoint aPt)
|
|
|
|
{
|
2011-12-20 01:15:41 -08:00
|
|
|
NS_ASSERTION(IsSelected(), "Should only be called for selected cells");
|
2012-08-22 08:56:38 -07:00
|
|
|
int16_t 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) {
|
2011-05-18 20:10:49 -07:00
|
|
|
nsRefPtr<nsFrameSelection> frameSelection =
|
2007-11-22 12:47:33 -08:00
|
|
|
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 {
|
2011-09-08 19:27:13 -07:00
|
|
|
bordercolor =
|
|
|
|
LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectBackground);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
nscoord threePx = nsPresContext::CSSPixelsToAppUnits(3);
|
|
|
|
if ((mRect.width > threePx) && (mRect.height > threePx))
|
|
|
|
{
|
|
|
|
//compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor)
|
|
|
|
bordercolor = EnsureDifferentColors(bordercolor,
|
2013-02-16 13:51:02 -08:00
|
|
|
StyleBackground()->mBackgroundColor);
|
2014-09-10 23:48:09 -07:00
|
|
|
|
|
|
|
gfxContext* ctx = aRenderingContext.ThebesContext();
|
|
|
|
|
|
|
|
gfxPoint devPixelOffset =
|
|
|
|
nsLayoutUtils::PointToGfxPoint(aPt,
|
|
|
|
PresContext()->AppUnitsPerDevPixel());
|
|
|
|
|
|
|
|
gfxContextMatrixAutoSaveRestore autoSR(ctx);
|
|
|
|
ctx->SetMatrix(ctx->CurrentMatrix().Translate(devPixelOffset));
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
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
|
2011-04-07 18:04:40 -07:00
|
|
|
nsTableCellFrame::PaintBackground(nsRenderingContext& aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRect& aDirtyRect,
|
2009-09-12 15:44:18 -07:00
|
|
|
nsPoint aPt,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t 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
|
2011-04-07 18:04:40 -07:00
|
|
|
nsTableCellFrame::PaintCellBackground(nsRenderingContext& aRenderingContext,
|
2009-09-12 15:44:18 -07:00
|
|
|
const nsRect& aDirtyRect, nsPoint aPt,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-16 13:51:02 -08:00
|
|
|
if (!StyleVisibility()->IsVisible())
|
2007-03-22 10:30:00 -07:00
|
|
|
return;
|
|
|
|
|
2009-09-12 15:44:18 -07:00
|
|
|
PaintBackground(aRenderingContext, aDirtyRect, aPt, aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-12-13 09:42:43 -08:00
|
|
|
nsresult
|
|
|
|
nsTableCellFrame::ProcessBorders(nsTableFrame* aFrame,
|
|
|
|
nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
const nsStyleBorder* borderStyle = StyleBorder();
|
|
|
|
if (aFrame->IsBorderCollapse() || !borderStyle->HasBorder())
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
if (!GetContentEmpty() ||
|
|
|
|
StyleTableBorder()->mEmptyCells == NS_STYLE_TABLE_EMPTY_CELLS_SHOW) {
|
|
|
|
aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayBorder(aBuilder, this));
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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,
|
2014-02-24 06:41:56 -08:00
|
|
|
HitTestState* aState,
|
|
|
|
nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE {
|
2010-04-07 17:31:26 -07:00
|
|
|
aOutFrames->AppendElement(mFrame);
|
|
|
|
}
|
2009-09-06 17:35:14 -07:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2014-02-24 06:41:56 -08:00
|
|
|
nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2014-02-24 06:41:56 -08:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
|
|
|
|
bool* aSnap) MOZ_OVERRIDE;
|
2013-06-26 09:43:26 -07:00
|
|
|
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion *aInvalidRegion) MOZ_OVERRIDE;
|
2008-04-06 04:34:14 -07:00
|
|
|
|
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,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* 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
|
2012-04-10 04:24:18 -07:00
|
|
|
nsDisplayTableCellBackground::GetBounds(nsDisplayListBuilder* aBuilder,
|
|
|
|
bool* aSnap)
|
2008-04-06 04:34:14 -07:00
|
|
|
{
|
|
|
|
// revert from nsDisplayTableItem's implementation ... cell backgrounds
|
|
|
|
// don't overflow the cell
|
2012-04-10 04:24:18 -07:00
|
|
|
return nsDisplayItem::GetBounds(aBuilder, aSnap);
|
2008-04-06 04:34:14 -07:00
|
|
|
}
|
|
|
|
|
2013-06-26 09:43:26 -07:00
|
|
|
void
|
|
|
|
nsDisplayTableCellBackground::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayItemGeometry* aGeometry,
|
|
|
|
nsRegion *aInvalidRegion)
|
|
|
|
{
|
|
|
|
if (aBuilder->ShouldSyncDecodeImages()) {
|
|
|
|
if (!nsCSSRendering::AreAllBackgroundImagesDecodedForFrame(mFrame)) {
|
|
|
|
bool snap;
|
|
|
|
aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDisplayTableItem::ComputeInvalidationRegion(aBuilder, aGeometry, aInvalidRegion);
|
|
|
|
}
|
|
|
|
|
2012-08-28 22:48:45 -07:00
|
|
|
void nsTableCellFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
nsIFrame::InvalidateFrame(aDisplayItemKey);
|
|
|
|
GetParent()->InvalidateFrameWithRect(GetVisualOverflowRect() + GetPosition(), aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsTableCellFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
nsIFrame::InvalidateFrameWithRect(aRect, aDisplayItemKey);
|
|
|
|
// If we have filters applied that would affects our bounds, then
|
|
|
|
// we get an inactive layer created and this is computed
|
|
|
|
// within FrameLayerBuilder
|
|
|
|
GetParent()->InvalidateFrameWithRect(aRect + GetPosition(), aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static void
|
2011-04-07 18:04:40 -07:00
|
|
|
PaintTableCellSelection(nsIFrame* aFrame, nsRenderingContext* aCtx,
|
2007-03-22 10:30:00 -07:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsTableCellFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
DO_GLOBAL_REFLOW_COUNT_DSP("nsTableCellFrame");
|
2012-04-02 17:30:45 -07:00
|
|
|
if (IsVisibleInSelection(aBuilder)) {
|
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t emptyCellStyle = GetContentEmpty() && !tableFrame->IsBorderCollapse() ?
|
2013-02-16 13:51:02 -08:00
|
|
|
StyleTableBorder()->mEmptyCells
|
2012-04-02 17:30:45 -07:00
|
|
|
: NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
|
|
|
|
// take account of 'empty-cells'
|
2013-02-16 13:51:02 -08:00
|
|
|
if (StyleVisibility()->IsVisible() &&
|
2012-04-02 17:30:45 -07:00
|
|
|
(NS_STYLE_TABLE_EMPTY_CELLS_HIDE != emptyCellStyle)) {
|
|
|
|
|
|
|
|
|
|
|
|
bool isRoot = aBuilder->IsAtRootOfPseudoStackingContext();
|
|
|
|
if (!isRoot) {
|
|
|
|
nsDisplayTableItem* currentItem = aBuilder->GetCurrentTableItem();
|
|
|
|
if (currentItem) {
|
|
|
|
currentItem->UpdateForFrameBackground(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// display outset box-shadows if we need to.
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleBorder* borderStyle = StyleBorder();
|
2012-04-17 22:14:31 -07:00
|
|
|
bool hasBoxShadow = !!borderStyle->mBoxShadow;
|
2012-04-02 17:30:45 -07:00
|
|
|
if (hasBoxShadow) {
|
2013-02-14 03:08:08 -08:00
|
|
|
aLists.BorderBackground()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayBoxShadowOuter(aBuilder, this));
|
2012-04-02 17:30:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// display background if we need to.
|
|
|
|
if (aBuilder->IsForEventDelivery() ||
|
|
|
|
(((!tableFrame->IsBorderCollapse() || isRoot) &&
|
2013-02-16 13:51:02 -08:00
|
|
|
(!StyleBackground()->IsTransparent() || StyleDisplay()->mAppearance)))) {
|
2012-04-02 17:30:45 -07:00
|
|
|
// 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
|
|
|
|
nsDisplayTableItem* item =
|
|
|
|
new (aBuilder) nsDisplayTableCellBackground(aBuilder, this);
|
2013-02-14 03:08:08 -08:00
|
|
|
aLists.BorderBackground()->AppendNewToTop(item);
|
2012-04-02 17:30:45 -07:00
|
|
|
item->UpdateForFrameBackground(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// display inset box-shadows if we need to.
|
|
|
|
if (hasBoxShadow) {
|
2013-02-14 03:08:08 -08:00
|
|
|
aLists.BorderBackground()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayBoxShadowInner(aBuilder, this));
|
2012-04-02 17:30:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// display borders if we need to
|
2013-12-13 09:42:43 -08:00
|
|
|
ProcessBorders(tableFrame, aBuilder, aLists);
|
2012-04-02 17:30:45 -07:00
|
|
|
|
|
|
|
// and display the selection border if we need to
|
|
|
|
if (IsSelected()) {
|
2013-02-14 03:08:08 -08:00
|
|
|
aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
|
|
|
nsDisplayGeneric(aBuilder, this, ::PaintTableCellSelection,
|
|
|
|
"TableCellSelection",
|
|
|
|
nsDisplayItem::TYPE_TABLE_CELL_SELECTION));
|
2009-12-12 10:50:30 -08:00
|
|
|
}
|
2008-04-06 04:34:14 -07:00
|
|
|
}
|
2012-04-02 17:30:45 -07:00
|
|
|
|
|
|
|
// the 'empty-cells' property has no effect on 'outline'
|
2013-02-14 03:08:08 -08:00
|
|
|
DisplayOutline(aBuilder, aLists);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
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;
|
2012-07-30 07:20:58 -07:00
|
|
|
pushTableItem.Push(aBuilder, nullptr);
|
2009-12-12 10:50:25 -08:00
|
|
|
|
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).
|
2013-02-14 03:08:08 -08:00
|
|
|
BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-06-28 03:13:13 -07:00
|
|
|
nsIFrame::LogicalSides
|
2014-03-13 00:39:33 -07:00
|
|
|
nsTableCellFrame::GetLogicalSkipSides(const nsHTMLReflowState* aReflowState) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-05-05 10:55:54 -07:00
|
|
|
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
|
|
|
|
NS_STYLE_BOX_DECORATION_BREAK_CLONE)) {
|
2014-06-28 03:13:13 -07:00
|
|
|
return LogicalSides();
|
2014-05-05 10:55:54 -07:00
|
|
|
}
|
|
|
|
|
2014-06-28 03:13:13 -07:00
|
|
|
LogicalSides skip;
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != GetPrevInFlow()) {
|
2014-06-28 03:13:14 -07:00
|
|
|
skip |= eLogicalSideBitsBStart;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != GetNextInFlow()) {
|
2014-06-28 03:13:14 -07:00
|
|
|
skip |= eLogicalSideBitsBEnd;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
2010-10-06 21:25:46 -07:00
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsTableCellFrame::GetBorderOverflow()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-10-06 21:25:46 -07:00
|
|
|
return nsMargin(0, 0, 0, 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Align the cell's child frame within the cell
|
|
|
|
|
|
|
|
void nsTableCellFrame::VerticallyAlignChild(nscoord aMaxAscent)
|
|
|
|
{
|
|
|
|
/* It's the 'border-collapse' on the table that matters */
|
|
|
|
nsMargin borderPadding = GetUsedBorderAndPadding();
|
|
|
|
|
|
|
|
nscoord topInset = borderPadding.top;
|
|
|
|
nscoord bottomInset = borderPadding.bottom;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t 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
|
2013-01-15 04:22:03 -08:00
|
|
|
kidYTop = std::max(0, kidYTop);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-28 22:48:45 -07:00
|
|
|
if (kidYTop != kidRect.y) {
|
|
|
|
// Invalidate at the old position first
|
|
|
|
firstKid->InvalidateFrameSubtree();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
firstKid->SetPosition(nsPoint(kidRect.x, kidYTop));
|
2014-07-24 01:30:07 -07:00
|
|
|
WritingMode wm = GetWritingMode();
|
|
|
|
nsHTMLReflowMetrics desiredSize(wm);
|
|
|
|
desiredSize.SetSize(wm, GetLogicalSize(wm));
|
2010-10-06 21:25:46 -07:00
|
|
|
|
|
|
|
nsRect overflow(nsPoint(0,0), GetSize());
|
|
|
|
overflow.Inflate(GetBorderOverflow());
|
|
|
|
desiredSize.mOverflowAreas.SetAllTo(overflow);
|
|
|
|
ConsiderChildOverflow(desiredSize.mOverflowAreas, firstKid);
|
2007-03-22 10:30:00 -07:00
|
|
|
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);
|
2012-08-28 22:48:45 -07:00
|
|
|
|
|
|
|
// Invalidate new overflow rect
|
|
|
|
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(),
|
2010-10-06 21:25:46 -07:00
|
|
|
desiredSize.VisualOverflow(), 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:03:49 -07:00
|
|
|
bool
|
|
|
|
nsTableCellFrame::UpdateOverflow()
|
|
|
|
{
|
|
|
|
nsRect bounds(nsPoint(0,0), GetSize());
|
|
|
|
bounds.Inflate(GetBorderOverflow());
|
|
|
|
nsOverflowAreas overflowAreas(bounds, bounds);
|
|
|
|
|
|
|
|
nsLayoutUtils::UnionChildOverflow(this, overflowAreas);
|
|
|
|
|
|
|
|
return FinishAndStoreOverflow(overflowAreas, GetSize());
|
|
|
|
}
|
|
|
|
|
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'.
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t
|
2010-08-31 09:05:12 -07:00
|
|
|
nsTableCellFrame::GetVerticalAlign() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleCoord& verticalAlign = StyleTextReset()->mVerticalAlign;
|
2010-08-31 09:05:12 -07:00
|
|
|
if (verticalAlign.GetUnit() == eStyleUnit_Enumerated) {
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t value = verticalAlign.GetIntValue();
|
2010-08-31 09:05:12 -07:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
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)
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2008-09-13 07:38:29 -07:00
|
|
|
if (tableFrame->IsBorderCollapse())
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2011-08-24 13:54:30 -07:00
|
|
|
nsIFrame* innerFrame = kidFrame->GetFirstPrincipalChild();
|
2008-09-13 07:38:29 -07:00
|
|
|
while(innerFrame) {
|
|
|
|
nsIAtom* frameType = innerFrame->GetType();
|
|
|
|
if (nsGkAtoms::textFrame == frameType) {
|
|
|
|
nsTextFrame* textFrame = static_cast<nsTextFrame*>(innerFrame);
|
|
|
|
if (textFrame->HasNoncollapsedCharacters())
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2008-09-13 07:38:29 -07:00
|
|
|
}
|
|
|
|
else if (nsGkAtoms::placeholderFrame != frameType) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2008-09-13 07:38:29 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsIFrame *floatFrame = nsLayoutUtils::GetFloatFromPlaceholder(innerFrame);
|
|
|
|
if (floatFrame)
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2008-09-13 07:38:29 -07:00
|
|
|
}
|
|
|
|
innerFrame = innerFrame->GetNextSibling();
|
2010-04-27 09:15:01 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2008-09-13 07:38:29 -07:00
|
|
|
}
|
|
|
|
|
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;
|
2014-06-17 05:19:38 -07:00
|
|
|
if (nsLayoutUtils::GetFirstLineBaseline(GetWritingMode(), inner, &result))
|
2007-03-22 10:30:00 -07:00
|
|
|
return result + borderPadding;
|
|
|
|
return inner->GetContentRect().YMost() - inner->GetPosition().y +
|
|
|
|
borderPadding;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t nsTableCellFrame::GetRowSpan()
|
2010-04-27 09:15:01 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rowSpan=1;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent);
|
|
|
|
|
|
|
|
// Don't look at the content's rowspan if we're a pseudo cell
|
2013-02-15 21:38:33 -08:00
|
|
|
if (hc && !StyleContext()->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;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t nsTableCellFrame::GetColSpan()
|
2010-04-27 09:15:01 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t colSpan=1;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent);
|
|
|
|
|
|
|
|
// Don't look at the content's colspan if we're a pseudo cell
|
2013-02-15 21:38:33 -08:00
|
|
|
if (hc && !StyleContext()->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
|
2014-07-24 10:03:25 -07:00
|
|
|
nsTableCellFrame::GetMinISize(nsRenderingContext *aRenderingContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
|
|
|
|
|
|
|
nsIFrame *inner = mFrames.FirstChild();
|
|
|
|
result = nsLayoutUtils::IntrinsicForContainer(aRenderingContext, inner,
|
2014-07-24 10:03:26 -07:00
|
|
|
nsLayoutUtils::MIN_ISIZE);
|
2007-03-22 10:30:00 -07:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2014-07-24 10:03:25 -07:00
|
|
|
nsTableCellFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
|
|
|
|
nsIFrame *inner = mFrames.FirstChild();
|
|
|
|
result = nsLayoutUtils::IntrinsicForContainer(aRenderingContext, inner,
|
2014-07-24 10:03:26 -07:00
|
|
|
nsLayoutUtils::PREF_ISIZE);
|
2007-03-22 10:30:00 -07:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-07-24 10:03:26 -07:00
|
|
|
/* virtual */ nsIFrame::IntrinsicISizeOffsetData
|
|
|
|
nsTableCellFrame::IntrinsicISizeOffsets(nsRenderingContext* aRenderingContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-07-24 10:03:26 -07:00
|
|
|
IntrinsicISizeOffsetData result =
|
|
|
|
nsContainerFrame::IntrinsicISizeOffsets(aRenderingContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2014-07-24 01:30:07 -07:00
|
|
|
WritingMode wm = aMet.GetWritingMode();
|
|
|
|
if ((aMet.ISize(wm) < 0) || (aMet.ISize(wm) > PROBABLY_TOO_LARGE)) {
|
|
|
|
printf("WARNING: cell content %p has large inline size %d \n",
|
|
|
|
static_cast<void*>(aChild), int32_t(aMet.ISize(wm)));
|
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)
|
|
|
|
{
|
2013-09-25 04:42:35 -07:00
|
|
|
const nsTableCellFrame* firstCellInFlow =
|
|
|
|
static_cast<nsTableCellFrame*>(aCellFrame.FirstInFlow());
|
|
|
|
nsTableFrame* firstTableInFlow =
|
|
|
|
static_cast<nsTableFrame*>(aTableFrame.FirstInFlow());
|
|
|
|
nsTableRowFrame* row =
|
|
|
|
static_cast<nsTableRowFrame*>(firstCellInFlow->GetParent());
|
|
|
|
nsTableRowGroupFrame* firstRGInFlow =
|
|
|
|
static_cast<nsTableRowGroupFrame*>(row->GetParent());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rowIndex;
|
2007-03-22 10:30:00 -07:00
|
|
|
firstCellInFlow->GetRowIndex(rowIndex);
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rowSpan = aTableFrame.GetEffectiveRowSpan(*firstCellInFlow);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-06-18 03:47:00 -07:00
|
|
|
nscoord computedHeight = firstTableInFlow->GetCellSpacingY(rowIndex,
|
|
|
|
rowIndex + rowSpan - 1);
|
|
|
|
computedHeight -= aVerticalBorderPadding;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rowX;
|
2007-03-22 10:30:00 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-05-12 17:47:52 -07:00
|
|
|
void
|
|
|
|
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) {
|
2013-09-25 04:42:34 -07:00
|
|
|
FirstInFlow()->AddStateBits(NS_TABLE_CELL_HAD_SPECIAL_REFLOW);
|
2007-06-18 16:19:39 -07:00
|
|
|
}
|
|
|
|
|
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;
|
2013-12-27 09:59:21 -08:00
|
|
|
nsSize availSize(aReflowState.AvailableWidth(), aReflowState.AvailableHeight());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-12-27 09:59:21 -08:00
|
|
|
nsMargin borderPadding = aReflowState.ComputedPhysicalPadding();
|
2007-03-22 10:30:00 -07:00
|
|
|
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;
|
|
|
|
|
2014-07-24 01:30:07 -07:00
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
|
|
|
nsHTMLReflowMetrics kidSize(wm, aDesiredSize.mFlags);
|
|
|
|
kidSize.ClearSize();
|
2013-12-27 09:59:21 -08:00
|
|
|
SetPriorAvailWidth(aReflowState.AvailableWidth());
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
|
|
|
NS_ASSERTION(firstKid, "Frame construction error, a table cell always has an inner cell frame");
|
2012-01-16 15:38:10 -08:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
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 {
|
2011-10-17 07:59:28 -07:00
|
|
|
SetHasPctOverHeight(false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, firstKid,
|
2014-07-24 01:28:46 -07:00
|
|
|
LogicalSize(firstKid->GetWritingMode(),
|
|
|
|
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
|
2011-10-17 07:59:28 -07:00
|
|
|
kidReflowState.mFlags.mSpecialHeightReflow = false;
|
2010-04-27 09:15:01 -07:00
|
|
|
|
2007-06-18 16:19:39 -07:00
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow ||
|
2013-09-25 04:42:34 -07:00
|
|
|
(FirstInFlow()->GetStateBits() & NS_TABLE_CELL_HAD_SPECIAL_REFLOW)) {
|
2007-06-18 16:19:39 -07:00
|
|
|
// 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.
|
2011-10-17 07:59:28 -07:00
|
|
|
kidReflowState.mFlags.mVResize = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsPoint kidOrigin(leftInset, topInset);
|
2012-08-28 22:48:45 -07:00
|
|
|
nsRect origRect = firstKid->GetRect();
|
|
|
|
nsRect origVisualOverflow = firstKid->GetVisualOverflowRect();
|
|
|
|
bool firstReflow = (firstKid->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
ReflowChild(firstKid, aPresContext, kidSize, kidReflowState,
|
2013-03-15 15:32:35 -07:00
|
|
|
kidOrigin.x, kidOrigin.y, 0, 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
|
|
|
|
2012-08-28 22:48:45 -07:00
|
|
|
// XXXbz is this invalidate actually needed, really?
|
|
|
|
if (GetStateBits() & NS_FRAME_IS_DIRTY) {
|
|
|
|
InvalidateFrameSubtree();
|
|
|
|
}
|
|
|
|
|
2012-06-25 12:59:42 -07:00
|
|
|
#ifdef DEBUG
|
2007-03-22 10:30:00 -07:00
|
|
|
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();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isEmpty;
|
2008-04-08 05:28:34 -07:00
|
|
|
if (prevInFlow) {
|
|
|
|
isEmpty = static_cast<nsTableCellFrame*>(prevInFlow)->GetContentEmpty();
|
|
|
|
} else {
|
2013-12-27 09:59:52 -08: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
|
2014-01-16 17:34:44 -08:00
|
|
|
FinishReflowChild(firstKid, aPresContext, kidSize, &kidReflowState,
|
2007-03-22 10:30:00 -07:00
|
|
|
kidOrigin.x, kidOrigin.y, 0);
|
2008-02-08 01:36:32 -08:00
|
|
|
|
2012-08-28 22:48:45 -07:00
|
|
|
nsTableFrame::InvalidateTableFrame(firstKid, origRect, origVisualOverflow,
|
|
|
|
firstReflow);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// first, compute the height which can be set w/o being restricted by aMaxSize.height
|
2014-07-24 01:30:07 -07:00
|
|
|
LogicalSize cellSize(wm);
|
|
|
|
LogicalMargin logicalInsets(wm, nsMargin(topInset, rightInset,
|
|
|
|
bottomInset, leftInset));
|
|
|
|
cellSize.BSize(wm) = kidSize.BSize(wm);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-07-24 01:30:07 -07:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != cellSize.BSize(wm)) {
|
|
|
|
cellSize.BSize(wm) += logicalInsets.BStartEnd(wm);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// next determine the cell's width
|
2014-07-24 01:30:07 -07:00
|
|
|
cellSize.ISize(wm) = kidSize.ISize(wm); // at this point, we've factored in the cell's style attributes
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// factor in border and padding
|
2014-07-24 01:30:07 -07:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != cellSize.ISize(wm)) {
|
|
|
|
cellSize.ISize(wm) += logicalInsets.IStartEnd(wm);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// set the cell's desired size and max element size
|
2014-07-24 01:30:07 -07:00
|
|
|
aDesiredSize.SetSize(wm, cellSize);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// the overflow area will be computed when the child will be vertically aligned
|
|
|
|
|
|
|
|
if (aReflowState.mFlags.mSpecialHeightReflow) {
|
2013-12-27 09:59:52 -08:00
|
|
|
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
|
2011-10-17 07:59:28 -07:00
|
|
|
SetHasPctOverHeight(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2013-12-27 09:59:21 -08:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.AvailableHeight()) {
|
2013-12-27 09:59:52 -08:00
|
|
|
aDesiredSize.Height() = mRect.height;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-28 22:48:45 -07:00
|
|
|
// If our parent is in initial reflow, it'll handle invalidating our
|
|
|
|
// entire overflow rect.
|
|
|
|
if (!(GetParent()->GetStateBits() & NS_FRAME_FIRST_REFLOW) &&
|
2013-12-27 09:59:52 -08:00
|
|
|
nsSize(aDesiredSize.Width(), aDesiredSize.Height()) != mRect.Size()) {
|
2012-08-28 22:48:45 -07:00
|
|
|
InvalidateFrame();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// remember the desired size for this reflow
|
|
|
|
SetDesiredSize(aDesiredSize);
|
|
|
|
|
2014-08-20 17:48:56 -07:00
|
|
|
// Any absolutely-positioned children will get reflowed in
|
|
|
|
// nsFrame::FixupPositionedTableParts in another pass, so propagate our
|
|
|
|
// dirtiness to them before our parent clears our dirty bits.
|
|
|
|
PushDirtyBitToAbsoluteFrames();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----- 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)
|
2011-12-27 12:18:48 -08:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 14:53:44 -07:00
|
|
|
a11y::AccType
|
|
|
|
nsTableCellFrame::AccessibleType()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-12-17 17:25:52 -08:00
|
|
|
return a11y::eHTMLTableCellType;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* This is primarily for editor access via nsITableLayout */
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsTableCellFrame::GetCellIndexes(int32_t &aRowIndex, int32_t &aColIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult res = GetRowIndex(aRowIndex);
|
|
|
|
if (NS_FAILED(res))
|
|
|
|
{
|
|
|
|
aColIndex = 0;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
aColIndex = mColIndex;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-05-24 15:20:40 -07:00
|
|
|
nsTableCellFrame*
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_NewTableCellFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aIsBorderCollapse)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
2013-02-16 13:51:02 -08:00
|
|
|
aBorder = StyleBorder()->GetComputedBorder();
|
2007-03-22 10:30:00 -07:00
|
|
|
return &aBorder;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsTableCellFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::tableCellFrame;
|
|
|
|
}
|
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2007-03-22 10:30:00 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
/* virtual */ bool
|
2014-05-05 10:55:54 -07:00
|
|
|
nsBCTableCellFrame::GetBorderRadii(const nsSize& aFrameSize,
|
|
|
|
const nsSize& aBorderArea,
|
2014-06-28 03:13:13 -07:00
|
|
|
Sides aSkipSides,
|
2014-05-05 10:55:54 -07:00
|
|
|
nscoord aRadii[8]) const
|
2010-09-07 15:20:35 -07:00
|
|
|
{
|
|
|
|
NS_FOR_CSS_HALF_CORNERS(corner) {
|
|
|
|
aRadii[corner] = 0;
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-09-07 15:20:35 -07:00
|
|
|
}
|
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2007-03-22 10:30:00 -07:00
|
|
|
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
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
|
2007-03-22 10:30:00 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-06 21:25:46 -07:00
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsBCTableCellFrame::GetBorderOverflow()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsMargin halfBorder;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t p2t = nsPresContext::AppUnitsPerCSSPixel();
|
2007-03-22 10:30:00 -07:00
|
|
|
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);
|
2010-10-06 21:25:46 -07:00
|
|
|
return halfBorder;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2011-04-07 18:04:40 -07:00
|
|
|
nsBCTableCellFrame::PaintBackground(nsRenderingContext& aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRect& aDirtyRect,
|
2009-09-12 15:44:18 -07:00
|
|
|
nsPoint aPt,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t 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);
|
|
|
|
|
2013-02-16 13:51:02 -08:00
|
|
|
nsStyleBorder myBorder(*StyleBorder());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_FOR_CSS_SIDES(side) {
|
2011-04-18 20:07:22 -07:00
|
|
|
myBorder.SetBorderWidth(side, borderWidth.Side(side));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2013-02-15 21:38:33 -08:00
|
|
|
StyleContext(), myBorder,
|
2012-07-30 07:20:58 -07:00
|
|
|
aFlags, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|