Enable the code to support for 'vertical-align: baseline' in table-cells. bug 10207. a:waterson@mozilla.org. was r:karnaze@netscape.com.

This commit is contained in:
rbs%maths.uq.edu.au 2000-07-28 09:19:26 +00:00
Родитель af8754b765
Коммит fc667ea4ee
10 изменённых файлов: 26 добавлений и 298 удалений

Просмотреть файл

@ -518,14 +518,9 @@ void nsTableCellFrame::SetBorderEdge(PRUint8 aSide,
* Align the cell's child frame within the cell
*
*/
#ifndef MOZ_MATHML
void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState)
#else
void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nscoord aMaxAscent)
#endif
{
const nsStyleText* textStyle =
(const nsStyleText*)mStyleContext->GetStyleData(eStyleStruct_Text);
@ -539,12 +534,7 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContex
nscoord topInset = borderPadding.top;
nscoord bottomInset = borderPadding.bottom;
#ifndef MOZ_MATHML
PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue();
}
#else
// As per bug 10207, we map 'sub', 'super', 'text-top', 'text-bottom',
// length and percentage values to 'baseline'
// XXX It seems that we don't get to see length and percentage values here
@ -559,8 +549,7 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContex
{
verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_BASELINE;
}
}
#endif
}
nscoord height = mRect.height;
nsRect kidRect;
@ -576,10 +565,8 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContex
case NS_STYLE_VERTICAL_ALIGN_BASELINE:
// Align the baselines of the child frame with the baselines of
// other children in the same row which have 'vertical-align: baseline'
#ifdef MOZ_MATHML
kidYTop = topInset + aMaxAscent - GetDesiredAscent();
break;
#endif
case NS_STYLE_VERTICAL_ALIGN_TOP:
// Align the top of the child frame with the top of the content area,
@ -604,7 +591,6 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContex
}
}
#ifdef MOZ_MATHML
// As per bug 10207, we map 'sub', 'super', 'text-top', 'text-bottom',
// length and percentage values to 'baseline'
// XXX It seems that we don't get to see length and percentage values here
@ -626,7 +612,6 @@ nsTableCellFrame::HasVerticalAlignBaseline()
}
return PR_TRUE;
}
#endif
PRInt32 nsTableCellFrame::GetRowSpan()
{
@ -916,10 +901,10 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
aDesiredSize.height = cellHeight;
aDesiredSize.ascent = topInset;
aDesiredSize.descent = bottomInset;
#ifdef MOZ_MATHML
aDesiredSize.ascent += kidSize.ascent;
aDesiredSize.descent += kidSize.descent;
#endif
if (aDesiredSize.mFlags & NS_REFLOW_CALC_MAX_WIDTH) {
aDesiredSize.mMaximumWidth = kidSize.mMaximumWidth + leftInset + rightInset;
}
@ -934,11 +919,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
// remember my desired size for this reflow
SetDesiredSize(aDesiredSize);
#ifndef MOZ_MATHML
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
#endif
if (nsDebugTable::gRflCell) nsTableFrame::DebugReflow("TC::Rfl ex", this, nsnull, &aDesiredSize, aStatus);
return NS_OK;

Просмотреть файл

@ -142,16 +142,11 @@ public:
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
#endif
#ifndef MOZ_MATHML
virtual void VerticallyAlignChild(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState);
#else
virtual void VerticallyAlignChild(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nscoord aMaxAscent);
PRBool HasVerticalAlignBaseline();
#endif
/**
* return the cell's specified row span. this is what was specified in the
@ -207,9 +202,7 @@ public:
/** return the desired size returned by this frame during its last reflow */
virtual nsSize GetDesiredSize();
#ifdef MOZ_MATHML
virtual nscoord GetDesiredAscent();
#endif
/** set the desired size returned by this frame during its last reflow */
virtual void SetDesiredSize(const nsHTMLReflowMetrics & aDesiredSize);
@ -281,9 +274,7 @@ protected:
/** these are the last computed desired and max element sizes */
nsSize mDesiredSize;
#ifdef MOZ_MATHML
nscoord mDesiredAscent;
#endif
/** these are the Pass 1 maximum width and max element sizes */
nscoord mMaximumWidth;
@ -329,18 +320,14 @@ inline void nsTableCellFrame::SetPriorAvailWidth(nscoord aPriorAvailWidth)
inline nsSize nsTableCellFrame::GetDesiredSize()
{ return mDesiredSize; }
#ifdef MOZ_MATHML
inline nscoord nsTableCellFrame::GetDesiredAscent()
{ return mDesiredAscent; }
#endif
inline void nsTableCellFrame::SetDesiredSize(const nsHTMLReflowMetrics & aDesiredSize)
{
mDesiredSize.width = aDesiredSize.width;
mDesiredSize.height = aDesiredSize.height;
#ifdef MOZ_MATHML
mDesiredAscent = aDesiredSize.ascent;
#endif
}
inline nscoord nsTableCellFrame::GetMaximumWidth() const

Просмотреть файл

@ -97,7 +97,6 @@ void nsTableCellReflowState::FixUp(const nsSize& aAvailSpace)
}
}
#ifdef MOZ_MATHML
// 'old' is old cached cell's desired size
// 'raw' is new cell's size without including style constraints from CalculateCellActualSize()
// 'new' is new cell's size including style constraints
@ -116,7 +115,6 @@ TallestCellGotShorter(nscoord aOld,
}
return tallestCellGotShorter;
}
#endif
/* ----------- nsTableRowpFrame ---------- */
@ -367,11 +365,9 @@ nsTableRowFrame::DidResize(nsIPresContext* aPresContext,
// But some content crashes when this reflow is issued, to be investigated
//XXX nsReflowStatus status;
//ReflowChild(cellFrame, aPresContext, desiredSize, kidReflowState, status);
#ifndef MOZ_MATHML
((nsTableCellFrame *)cellFrame)->VerticallyAlignChild(aPresContext, aReflowState);
#else
((nsTableCellFrame *)cellFrame)->VerticallyAlignChild(aPresContext, aReflowState, mMaxCellAscent);
#endif
/* if we're collapsing borders, notify the cell that the border edge length has changed */
if (NS_STYLE_BORDER_COLLAPSE == tableFrame->GetBorderCollapseStyle()) {
((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_LEFT,
@ -390,9 +386,8 @@ nsTableRowFrame::DidResize(nsIPresContext* aPresContext,
// Let our base class do the usual work
}
#ifdef MOZ_MATHML
// returns max-ascent amongst all cells that have 'vertical-align: baseline'
// including cells with rowspans
// *including* cells with rowspans
nscoord nsTableRowFrame::GetMaxCellAscent() const
{
return mMaxCellAscent;
@ -406,7 +401,6 @@ nscoord nsTableRowFrame::GetMaxCellDescent() const
return mMaxCellDescent;
}
#endif
#endif
/** returns the height of the tallest child in this row (ignoring any cell with rowspans) */
nscoord nsTableRowFrame::GetTallestCell() const
@ -418,32 +412,17 @@ void
nsTableRowFrame::ResetTallestCell()
{
mTallestCell = 0;
#ifdef MOZ_MATHML
mMaxCellAscent = 0;
mMaxCellDescent = 0;
#endif
}
void
nsTableRowFrame::SetTallestCell(nscoord aHeight,
#ifdef MOZ_MATHML
nscoord aAscent,
nscoord aDescent,
#endif
nsTableFrame* aTableFrame,
nsTableCellFrame* aCellFrame)
{
#ifndef MOZ_MATHML
NS_ASSERTION((aTableFrame && aCellFrame) || (!aTableFrame && !aCellFrame), "invalid call");
if ((aHeight != NS_UNCONSTRAINEDSIZE) &&
(aHeight > mTallestCell)) {
PRInt32 rowSpan = (!aTableFrame) ? 1 : aTableFrame->GetEffectiveRowSpan(*aCellFrame);
if (rowSpan == 1) {
mTallestCell = aHeight;
}
}
#else
NS_ASSERTION((aTableFrame && aCellFrame) , "invalid call");
if (aHeight != NS_UNCONSTRAINEDSIZE) {
if (!(aCellFrame->HasVerticalAlignBaseline())) { // only the cell's height matters
@ -473,7 +452,6 @@ nsTableRowFrame::SetTallestCell(nscoord aHeight,
}
}
}
#endif
}
void
@ -484,25 +462,12 @@ nsTableRowFrame::CalcTallestCell()
if (NS_FAILED(rv)) return;
nscoord cellSpacingX = tableFrame->GetCellSpacingX();
#ifndef MOZ_MATHML
mTallestCell = 0;
#else
ResetTallestCell();
#endif
for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame; kidFrame->GetNextSibling(&kidFrame)) {
nsCOMPtr<nsIAtom> frameType;
kidFrame->GetFrameType(getter_AddRefs(frameType));
if (nsLayoutAtoms::tableCellFrame == frameType.get()) {
#ifndef MOZ_MATHML
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan((nsTableCellFrame &)*kidFrame);
if (rowSpan == 1) {
nscoord availWidth = ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth();
nsSize desSize = ((nsTableCellFrame *)kidFrame)->GetDesiredSize();
CalculateCellActualSize(kidFrame, desSize.width, desSize.height, availWidth);
SetTallestCell(desSize.height);
}
#else
nscoord availWidth = ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth();
nsSize desSize = ((nsTableCellFrame *)kidFrame)->GetDesiredSize();
CalculateCellActualSize(kidFrame, desSize.width, desSize.height, availWidth);
@ -510,7 +475,6 @@ nsTableRowFrame::CalcTallestCell()
nscoord ascent = ((nsTableCellFrame *)kidFrame)->GetDesiredAscent();
nscoord descent = desSize.height - ascent;
SetTallestCell(desSize.height, ascent, descent, tableFrame, (nsTableCellFrame*)kidFrame);
#endif
}
}
}
@ -1042,14 +1006,11 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
// logic needed for backwards compatibility
CalculateCellActualSize(kidFrame, desiredSize.width,
desiredSize.height, availWidth);
#ifndef MOZ_MATHML
SetTallestCell(desiredSize.height, aReflowState.tableFrame, (nsTableCellFrame*)kidFrame);
#else
// height may have changed, adjust descent to absorb any excess difference
nscoord ascent = ((nsTableCellFrame *)kidFrame)->GetDesiredAscent();
nscoord descent = desiredSize.height - ascent;
SetTallestCell(desiredSize.height, ascent, descent, aReflowState.tableFrame, (nsTableCellFrame*)kidFrame);
#endif
// Place the child
PlaceChild(aPresContext, aReflowState, kidFrame, desiredSize,
@ -1171,11 +1132,7 @@ nsTableRowFrame::InitialReflow(nsIPresContext* aPresContext,
// XXX do we need to call CalculateCellActualSize?
PlaceChild(aPresContext, aReflowState, kidFrame, kidSize, x, 0,
aDesiredSize.maxElementSize, &kidMaxElementSize);
#ifndef MOZ_MATHML
SetTallestCell(aDesiredSize.height, aReflowState.tableFrame, (nsTableCellFrame*)kidFrame);
#else
SetTallestCell(aDesiredSize.height, aDesiredSize.ascent, aDesiredSize.descent, aReflowState.tableFrame, (nsTableCellFrame*)kidFrame);
#endif
x += kidSize.width + cellSpacingX;
}
else
@ -1376,10 +1333,8 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
nsSize oldCellMinSize = ((nsTableCellFrame*)aNextFrame)->GetPass1MaxElementSize();
nscoord oldCellMaximumWidth = ((nsTableCellFrame*)aNextFrame)->GetMaximumWidth();
nsSize oldCellDesSize = ((nsTableCellFrame*)aNextFrame)->GetDesiredSize();
#ifdef MOZ_MATHML
nscoord oldCellDesAscent = ((nsTableCellFrame*)aNextFrame)->GetDesiredAscent();
nscoord oldCellDesDescent = oldCellDesSize.height - oldCellDesAscent;
#endif
// Reflow the cell passing it the incremental reflow command. We can't pass
// in a max width of NS_UNCONSTRAINEDSIZE, because the max width must match
@ -1387,10 +1342,8 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
rv = ReflowChild(aNextFrame, aPresContext, cellMet, kidRS,
aReflowState.x, 0, 0, aStatus);
nsSize initCellDesSize(cellMet.width, cellMet.height);
#ifdef MOZ_MATHML
nscoord initCellDesAscent = cellMet.ascent;
nscoord initCellDesDescent = cellMet.descent;
#endif
// Update the cell layout data.. If the cell's maximum width changed,
// then inform the table that its maximum width needs to be recomputed
@ -1428,35 +1381,12 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
// takes into account the specified height (in the style), and any special
// logic needed for backwards compatibility
CalculateCellActualSize(aNextFrame, cellMet.width, cellMet.height, cellAvailWidth);
#ifdef MOZ_MATHML
// height may have changed, adjust descent to absorb any excess difference
cellMet.descent = cellMet.height - cellMet.ascent;
#endif
// if the cell got shorter and it may have been the tallest, recalc the tallest cell
PRBool tallestCellGotShorter = PR_FALSE;
#ifndef MOZ_MATHML
if (initCellDesSize.height < oldCellDesSize.height) {
if (oldCellDesSize.height == GetTallestCell()) {
tallestCellGotShorter = PR_TRUE;
}
else {
nscoord width = initCellDesSize.width;
nscoord height = initCellDesSize.height;
CalculateCellActualSize(aNextFrame, width, height, cellAvailWidth); // considers style
nscoord tallest = GetTallestCell();
if ((height == tallest) && (cellMet.height < tallest)) {
tallestCellGotShorter = PR_TRUE;
}
}
}
if (tallestCellGotShorter) {
CalcTallestCell();
}
else {
SetTallestCell(cellMet.height, aReflowState.tableFrame, (nsTableCellFrame*)aNextFrame);
}
#else
PRBool hasVerticalAlignBaseline = ((nsTableCellFrame*)aNextFrame)->HasVerticalAlignBaseline();
if (!hasVerticalAlignBaseline) {
// only the height matters
@ -1485,22 +1415,9 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
else {
SetTallestCell(cellMet.height, cellMet.ascent, cellMet.descent, aReflowState.tableFrame, (nsTableCellFrame*)aNextFrame);
}
#endif
// if the cell's desired size didn't changed, our height is unchanged
aDesiredSize.mNothingChanged = PR_FALSE;
#ifndef MOZ_MATHML
if ((initCellDesSize.width == oldCellDesSize.width) &&
(initCellDesSize.height == oldCellDesSize.height)) {
aDesiredSize.height = mRect.height;
aDesiredSize.mNothingChanged = PR_TRUE;
}
else {
aDesiredSize.height = GetTallestCell();
}
PRInt32 rowSpan = aReflowState.tableFrame->GetEffectiveRowSpan((nsTableCellFrame&)*aNextFrame);
cellMet.height = (rowSpan == 1) ? aDesiredSize.height : PR_MAX(aDesiredSize.height, cellMet.height);
#else
PRInt32 rowSpan = aReflowState.tableFrame->GetEffectiveRowSpan((nsTableCellFrame&)*aNextFrame);
if (initCellDesSize.width == oldCellDesSize.width) {
if (!hasVerticalAlignBaseline) { // only the cell's height matters
@ -1518,7 +1435,7 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
}
aDesiredSize.height = (aDesiredSize.mNothingChanged) ? mRect.height : GetTallestCell();
cellMet.height = (rowSpan == 1) ? aDesiredSize.height : PR_MAX(aDesiredSize.height, cellMet.height);
#endif
// Now place the child
PlaceChild(aPresContext, aReflowState, aNextFrame, cellMet, aReflowState.x,
0, aDesiredSize.maxElementSize, &kidMaxElementSize);
@ -1529,11 +1446,7 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
aDesiredSize.width = aReflowState.availSize.width;
if (!aDesiredSize.mNothingChanged) {
if (aDesiredSize.height == mRect.height) { // our height didn't change
#ifndef MOZ_MATHML
((nsTableCellFrame *)aNextFrame)->VerticallyAlignChild(aPresContext, aReflowState.reflowState);
#else
((nsTableCellFrame *)aNextFrame)->VerticallyAlignChild(aPresContext, aReflowState.reflowState, mMaxCellAscent);
#endif
nsRect dirtyRect;
aNextFrame->GetRect(dirtyRect);
dirtyRect.height = mRect.height;
@ -1692,13 +1605,9 @@ void nsTableRowFrame::ReflowCellFrame(nsIPresContext* aPresContext,
ReflowChild(aCellFrame, aPresContext, desiredSize, cellReflowState,
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
aCellFrame->SizeTo(aPresContext, cellSize.width, aAvailableHeight);
#ifndef MOZ_MATHML
aCellFrame->VerticallyAlignChild(aPresContext, aReflowState);
#else
// XXX What happens if this cell has 'vertical-align: baseline' ?
// XXX Why is it assumed that the cell's ascent hasn't changed ?
aCellFrame->VerticallyAlignChild(aPresContext, aReflowState, mMaxCellAscent);
#endif
aCellFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
}

Просмотреть файл

@ -155,10 +155,8 @@ public:
#endif
void SetTallestCell(nscoord aHeight,
#ifdef MOZ_MATHML
nscoord aAscent,
nscoord aDescent,
#endif
nsTableFrame* aTableFrame = nsnull,
nsTableCellFrame* aCellFrame = nsnull);
@ -170,12 +168,11 @@ public:
/** returns the tallest child in this row (ignoring any cell with rowspans) */
nscoord GetTallestCell() const;
#ifdef MOZ_MATHML
// Support for cells with 'vertical-align: baseline'.
/**
* returns the max-ascent amongst all the cells that have
* 'vertical-align: baseline', including cells with rowspans.
* 'vertical-align: baseline', *including* cells with rowspans.
* returns 0 if we don't have any cell with 'vertical-align: baseline'
*/
nscoord GetMaxCellAscent() const;
@ -183,11 +180,10 @@ public:
#if 0 // nobody uses this
/**
* returns the max-descent amongst all the cells that have
* 'vertical-align: baseline', ignoring any cell with rowspans.
* 'vertical-align: baseline', *ignoring* any cell with rowspans.
* returns 0 if we don't have any cell with 'vertical-align: baseline'
*/
nscoord GetMaxCellDescent() const;
#endif
#endif
/** returns the ordinal position of this row in its table */
@ -322,11 +318,9 @@ private:
nscoord mTallestCell; // not my height, but the height of my tallest child
nsSize mMaxElementSize; // cached max element size
#ifdef MOZ_MATHML
// max-ascent and max-descent amongst all cells that have 'vertical-align: baseline'
nscoord mMaxCellAscent; // does include cells with rowspan > 1
nscoord mMaxCellDescent; // does *not* include cells with rowspan > 1
#endif
};
inline PRInt32 nsTableRowFrame::GetRowIndex() const

Просмотреть файл

@ -678,7 +678,6 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext* aPresCon
((nsTableRowFrame*)rowFrame)->CalculateCellActualSize(cellFrame, cellDesSize.width,
cellDesSize.height, cellDesSize.width);
cellFrameSize.height = cellDesSize.height;
#ifdef MOZ_MATHML
// see if the cell has 'vertical-align: baseline'
if (((nsTableCellFrame*)cellFrame)->HasVerticalAlignBaseline()) {
// to ensure that a spanning cell with a long descender doesn't
@ -686,8 +685,7 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext* aPresCon
// that will be done to align the cell on the baseline of the row.
cellFrameSize.height += ((nsTableRowFrame*)rowFrame)->GetMaxCellAscent()
- ((nsTableCellFrame*)cellFrame)->GetDesiredAscent();
}
#endif
}
}
if (availHeightOfRowsSpanned >= cellFrameSize.height) {
@ -695,11 +693,7 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext* aPresCon
// spans. Set the cell frame's height
cellFrame->SizeTo(aPresContext, cellFrameSize.width, availHeightOfRowsSpanned);
// Realign cell content based on new height
#ifndef MOZ_MATHML
((nsTableCellFrame*)cellFrame)->VerticallyAlignChild(aPresContext, aReflowState);
#else
((nsTableCellFrame*)cellFrame)->VerticallyAlignChild(aPresContext, aReflowState, ((nsTableRowFrame*)rowFrame)->GetMaxCellAscent());
#endif
}
else {
// the cell's height is larger than the available space of the rows it

Просмотреть файл

@ -518,14 +518,9 @@ void nsTableCellFrame::SetBorderEdge(PRUint8 aSide,
* Align the cell's child frame within the cell
*
*/
#ifndef MOZ_MATHML
void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState)
#else
void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nscoord aMaxAscent)
#endif
{
const nsStyleText* textStyle =
(const nsStyleText*)mStyleContext->GetStyleData(eStyleStruct_Text);
@ -539,12 +534,7 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContex
nscoord topInset = borderPadding.top;
nscoord bottomInset = borderPadding.bottom;
#ifndef MOZ_MATHML
PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_MIDDLE;
if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) {
verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue();
}
#else
// As per bug 10207, we map 'sub', 'super', 'text-top', 'text-bottom',
// length and percentage values to 'baseline'
// XXX It seems that we don't get to see length and percentage values here
@ -559,8 +549,7 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContex
{
verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_BASELINE;
}
}
#endif
}
nscoord height = mRect.height;
nsRect kidRect;
@ -576,10 +565,8 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContex
case NS_STYLE_VERTICAL_ALIGN_BASELINE:
// Align the baselines of the child frame with the baselines of
// other children in the same row which have 'vertical-align: baseline'
#ifdef MOZ_MATHML
kidYTop = topInset + aMaxAscent - GetDesiredAscent();
break;
#endif
case NS_STYLE_VERTICAL_ALIGN_TOP:
// Align the top of the child frame with the top of the content area,
@ -604,7 +591,6 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContex
}
}
#ifdef MOZ_MATHML
// As per bug 10207, we map 'sub', 'super', 'text-top', 'text-bottom',
// length and percentage values to 'baseline'
// XXX It seems that we don't get to see length and percentage values here
@ -626,7 +612,6 @@ nsTableCellFrame::HasVerticalAlignBaseline()
}
return PR_TRUE;
}
#endif
PRInt32 nsTableCellFrame::GetRowSpan()
{
@ -916,10 +901,10 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
aDesiredSize.height = cellHeight;
aDesiredSize.ascent = topInset;
aDesiredSize.descent = bottomInset;
#ifdef MOZ_MATHML
aDesiredSize.ascent += kidSize.ascent;
aDesiredSize.descent += kidSize.descent;
#endif
if (aDesiredSize.mFlags & NS_REFLOW_CALC_MAX_WIDTH) {
aDesiredSize.mMaximumWidth = kidSize.mMaximumWidth + leftInset + rightInset;
}
@ -934,11 +919,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
// remember my desired size for this reflow
SetDesiredSize(aDesiredSize);
#ifndef MOZ_MATHML
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
#endif
if (nsDebugTable::gRflCell) nsTableFrame::DebugReflow("TC::Rfl ex", this, nsnull, &aDesiredSize, aStatus);
return NS_OK;

Просмотреть файл

@ -142,16 +142,11 @@ public:
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
#endif
#ifndef MOZ_MATHML
virtual void VerticallyAlignChild(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState);
#else
virtual void VerticallyAlignChild(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nscoord aMaxAscent);
PRBool HasVerticalAlignBaseline();
#endif
/**
* return the cell's specified row span. this is what was specified in the
@ -207,9 +202,7 @@ public:
/** return the desired size returned by this frame during its last reflow */
virtual nsSize GetDesiredSize();
#ifdef MOZ_MATHML
virtual nscoord GetDesiredAscent();
#endif
/** set the desired size returned by this frame during its last reflow */
virtual void SetDesiredSize(const nsHTMLReflowMetrics & aDesiredSize);
@ -281,9 +274,7 @@ protected:
/** these are the last computed desired and max element sizes */
nsSize mDesiredSize;
#ifdef MOZ_MATHML
nscoord mDesiredAscent;
#endif
/** these are the Pass 1 maximum width and max element sizes */
nscoord mMaximumWidth;
@ -329,18 +320,14 @@ inline void nsTableCellFrame::SetPriorAvailWidth(nscoord aPriorAvailWidth)
inline nsSize nsTableCellFrame::GetDesiredSize()
{ return mDesiredSize; }
#ifdef MOZ_MATHML
inline nscoord nsTableCellFrame::GetDesiredAscent()
{ return mDesiredAscent; }
#endif
inline void nsTableCellFrame::SetDesiredSize(const nsHTMLReflowMetrics & aDesiredSize)
{
mDesiredSize.width = aDesiredSize.width;
mDesiredSize.height = aDesiredSize.height;
#ifdef MOZ_MATHML
mDesiredAscent = aDesiredSize.ascent;
#endif
}
inline nscoord nsTableCellFrame::GetMaximumWidth() const

Просмотреть файл

@ -97,7 +97,6 @@ void nsTableCellReflowState::FixUp(const nsSize& aAvailSpace)
}
}
#ifdef MOZ_MATHML
// 'old' is old cached cell's desired size
// 'raw' is new cell's size without including style constraints from CalculateCellActualSize()
// 'new' is new cell's size including style constraints
@ -116,7 +115,6 @@ TallestCellGotShorter(nscoord aOld,
}
return tallestCellGotShorter;
}
#endif
/* ----------- nsTableRowpFrame ---------- */
@ -367,11 +365,9 @@ nsTableRowFrame::DidResize(nsIPresContext* aPresContext,
// But some content crashes when this reflow is issued, to be investigated
//XXX nsReflowStatus status;
//ReflowChild(cellFrame, aPresContext, desiredSize, kidReflowState, status);
#ifndef MOZ_MATHML
((nsTableCellFrame *)cellFrame)->VerticallyAlignChild(aPresContext, aReflowState);
#else
((nsTableCellFrame *)cellFrame)->VerticallyAlignChild(aPresContext, aReflowState, mMaxCellAscent);
#endif
/* if we're collapsing borders, notify the cell that the border edge length has changed */
if (NS_STYLE_BORDER_COLLAPSE == tableFrame->GetBorderCollapseStyle()) {
((nsTableCellFrame *)(cellFrame))->SetBorderEdgeLength(NS_SIDE_LEFT,
@ -390,9 +386,8 @@ nsTableRowFrame::DidResize(nsIPresContext* aPresContext,
// Let our base class do the usual work
}
#ifdef MOZ_MATHML
// returns max-ascent amongst all cells that have 'vertical-align: baseline'
// including cells with rowspans
// *including* cells with rowspans
nscoord nsTableRowFrame::GetMaxCellAscent() const
{
return mMaxCellAscent;
@ -406,7 +401,6 @@ nscoord nsTableRowFrame::GetMaxCellDescent() const
return mMaxCellDescent;
}
#endif
#endif
/** returns the height of the tallest child in this row (ignoring any cell with rowspans) */
nscoord nsTableRowFrame::GetTallestCell() const
@ -418,32 +412,17 @@ void
nsTableRowFrame::ResetTallestCell()
{
mTallestCell = 0;
#ifdef MOZ_MATHML
mMaxCellAscent = 0;
mMaxCellDescent = 0;
#endif
}
void
nsTableRowFrame::SetTallestCell(nscoord aHeight,
#ifdef MOZ_MATHML
nscoord aAscent,
nscoord aDescent,
#endif
nsTableFrame* aTableFrame,
nsTableCellFrame* aCellFrame)
{
#ifndef MOZ_MATHML
NS_ASSERTION((aTableFrame && aCellFrame) || (!aTableFrame && !aCellFrame), "invalid call");
if ((aHeight != NS_UNCONSTRAINEDSIZE) &&
(aHeight > mTallestCell)) {
PRInt32 rowSpan = (!aTableFrame) ? 1 : aTableFrame->GetEffectiveRowSpan(*aCellFrame);
if (rowSpan == 1) {
mTallestCell = aHeight;
}
}
#else
NS_ASSERTION((aTableFrame && aCellFrame) , "invalid call");
if (aHeight != NS_UNCONSTRAINEDSIZE) {
if (!(aCellFrame->HasVerticalAlignBaseline())) { // only the cell's height matters
@ -473,7 +452,6 @@ nsTableRowFrame::SetTallestCell(nscoord aHeight,
}
}
}
#endif
}
void
@ -484,25 +462,12 @@ nsTableRowFrame::CalcTallestCell()
if (NS_FAILED(rv)) return;
nscoord cellSpacingX = tableFrame->GetCellSpacingX();
#ifndef MOZ_MATHML
mTallestCell = 0;
#else
ResetTallestCell();
#endif
for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame; kidFrame->GetNextSibling(&kidFrame)) {
nsCOMPtr<nsIAtom> frameType;
kidFrame->GetFrameType(getter_AddRefs(frameType));
if (nsLayoutAtoms::tableCellFrame == frameType.get()) {
#ifndef MOZ_MATHML
PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan((nsTableCellFrame &)*kidFrame);
if (rowSpan == 1) {
nscoord availWidth = ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth();
nsSize desSize = ((nsTableCellFrame *)kidFrame)->GetDesiredSize();
CalculateCellActualSize(kidFrame, desSize.width, desSize.height, availWidth);
SetTallestCell(desSize.height);
}
#else
nscoord availWidth = ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth();
nsSize desSize = ((nsTableCellFrame *)kidFrame)->GetDesiredSize();
CalculateCellActualSize(kidFrame, desSize.width, desSize.height, availWidth);
@ -510,7 +475,6 @@ nsTableRowFrame::CalcTallestCell()
nscoord ascent = ((nsTableCellFrame *)kidFrame)->GetDesiredAscent();
nscoord descent = desSize.height - ascent;
SetTallestCell(desSize.height, ascent, descent, tableFrame, (nsTableCellFrame*)kidFrame);
#endif
}
}
}
@ -1042,14 +1006,11 @@ NS_METHOD nsTableRowFrame::ResizeReflow(nsIPresContext* aPresContext,
// logic needed for backwards compatibility
CalculateCellActualSize(kidFrame, desiredSize.width,
desiredSize.height, availWidth);
#ifndef MOZ_MATHML
SetTallestCell(desiredSize.height, aReflowState.tableFrame, (nsTableCellFrame*)kidFrame);
#else
// height may have changed, adjust descent to absorb any excess difference
nscoord ascent = ((nsTableCellFrame *)kidFrame)->GetDesiredAscent();
nscoord descent = desiredSize.height - ascent;
SetTallestCell(desiredSize.height, ascent, descent, aReflowState.tableFrame, (nsTableCellFrame*)kidFrame);
#endif
// Place the child
PlaceChild(aPresContext, aReflowState, kidFrame, desiredSize,
@ -1171,11 +1132,7 @@ nsTableRowFrame::InitialReflow(nsIPresContext* aPresContext,
// XXX do we need to call CalculateCellActualSize?
PlaceChild(aPresContext, aReflowState, kidFrame, kidSize, x, 0,
aDesiredSize.maxElementSize, &kidMaxElementSize);
#ifndef MOZ_MATHML
SetTallestCell(aDesiredSize.height, aReflowState.tableFrame, (nsTableCellFrame*)kidFrame);
#else
SetTallestCell(aDesiredSize.height, aDesiredSize.ascent, aDesiredSize.descent, aReflowState.tableFrame, (nsTableCellFrame*)kidFrame);
#endif
x += kidSize.width + cellSpacingX;
}
else
@ -1376,10 +1333,8 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
nsSize oldCellMinSize = ((nsTableCellFrame*)aNextFrame)->GetPass1MaxElementSize();
nscoord oldCellMaximumWidth = ((nsTableCellFrame*)aNextFrame)->GetMaximumWidth();
nsSize oldCellDesSize = ((nsTableCellFrame*)aNextFrame)->GetDesiredSize();
#ifdef MOZ_MATHML
nscoord oldCellDesAscent = ((nsTableCellFrame*)aNextFrame)->GetDesiredAscent();
nscoord oldCellDesDescent = oldCellDesSize.height - oldCellDesAscent;
#endif
// Reflow the cell passing it the incremental reflow command. We can't pass
// in a max width of NS_UNCONSTRAINEDSIZE, because the max width must match
@ -1387,10 +1342,8 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
rv = ReflowChild(aNextFrame, aPresContext, cellMet, kidRS,
aReflowState.x, 0, 0, aStatus);
nsSize initCellDesSize(cellMet.width, cellMet.height);
#ifdef MOZ_MATHML
nscoord initCellDesAscent = cellMet.ascent;
nscoord initCellDesDescent = cellMet.descent;
#endif
// Update the cell layout data.. If the cell's maximum width changed,
// then inform the table that its maximum width needs to be recomputed
@ -1428,35 +1381,12 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
// takes into account the specified height (in the style), and any special
// logic needed for backwards compatibility
CalculateCellActualSize(aNextFrame, cellMet.width, cellMet.height, cellAvailWidth);
#ifdef MOZ_MATHML
// height may have changed, adjust descent to absorb any excess difference
cellMet.descent = cellMet.height - cellMet.ascent;
#endif
// if the cell got shorter and it may have been the tallest, recalc the tallest cell
PRBool tallestCellGotShorter = PR_FALSE;
#ifndef MOZ_MATHML
if (initCellDesSize.height < oldCellDesSize.height) {
if (oldCellDesSize.height == GetTallestCell()) {
tallestCellGotShorter = PR_TRUE;
}
else {
nscoord width = initCellDesSize.width;
nscoord height = initCellDesSize.height;
CalculateCellActualSize(aNextFrame, width, height, cellAvailWidth); // considers style
nscoord tallest = GetTallestCell();
if ((height == tallest) && (cellMet.height < tallest)) {
tallestCellGotShorter = PR_TRUE;
}
}
}
if (tallestCellGotShorter) {
CalcTallestCell();
}
else {
SetTallestCell(cellMet.height, aReflowState.tableFrame, (nsTableCellFrame*)aNextFrame);
}
#else
PRBool hasVerticalAlignBaseline = ((nsTableCellFrame*)aNextFrame)->HasVerticalAlignBaseline();
if (!hasVerticalAlignBaseline) {
// only the height matters
@ -1485,22 +1415,9 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
else {
SetTallestCell(cellMet.height, cellMet.ascent, cellMet.descent, aReflowState.tableFrame, (nsTableCellFrame*)aNextFrame);
}
#endif
// if the cell's desired size didn't changed, our height is unchanged
aDesiredSize.mNothingChanged = PR_FALSE;
#ifndef MOZ_MATHML
if ((initCellDesSize.width == oldCellDesSize.width) &&
(initCellDesSize.height == oldCellDesSize.height)) {
aDesiredSize.height = mRect.height;
aDesiredSize.mNothingChanged = PR_TRUE;
}
else {
aDesiredSize.height = GetTallestCell();
}
PRInt32 rowSpan = aReflowState.tableFrame->GetEffectiveRowSpan((nsTableCellFrame&)*aNextFrame);
cellMet.height = (rowSpan == 1) ? aDesiredSize.height : PR_MAX(aDesiredSize.height, cellMet.height);
#else
PRInt32 rowSpan = aReflowState.tableFrame->GetEffectiveRowSpan((nsTableCellFrame&)*aNextFrame);
if (initCellDesSize.width == oldCellDesSize.width) {
if (!hasVerticalAlignBaseline) { // only the cell's height matters
@ -1518,7 +1435,7 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
}
aDesiredSize.height = (aDesiredSize.mNothingChanged) ? mRect.height : GetTallestCell();
cellMet.height = (rowSpan == 1) ? aDesiredSize.height : PR_MAX(aDesiredSize.height, cellMet.height);
#endif
// Now place the child
PlaceChild(aPresContext, aReflowState, aNextFrame, cellMet, aReflowState.x,
0, aDesiredSize.maxElementSize, &kidMaxElementSize);
@ -1529,11 +1446,7 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
aDesiredSize.width = aReflowState.availSize.width;
if (!aDesiredSize.mNothingChanged) {
if (aDesiredSize.height == mRect.height) { // our height didn't change
#ifndef MOZ_MATHML
((nsTableCellFrame *)aNextFrame)->VerticallyAlignChild(aPresContext, aReflowState.reflowState);
#else
((nsTableCellFrame *)aNextFrame)->VerticallyAlignChild(aPresContext, aReflowState.reflowState, mMaxCellAscent);
#endif
nsRect dirtyRect;
aNextFrame->GetRect(dirtyRect);
dirtyRect.height = mRect.height;
@ -1692,13 +1605,9 @@ void nsTableRowFrame::ReflowCellFrame(nsIPresContext* aPresContext,
ReflowChild(aCellFrame, aPresContext, desiredSize, cellReflowState,
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
aCellFrame->SizeTo(aPresContext, cellSize.width, aAvailableHeight);
#ifndef MOZ_MATHML
aCellFrame->VerticallyAlignChild(aPresContext, aReflowState);
#else
// XXX What happens if this cell has 'vertical-align: baseline' ?
// XXX Why is it assumed that the cell's ascent hasn't changed ?
aCellFrame->VerticallyAlignChild(aPresContext, aReflowState, mMaxCellAscent);
#endif
aCellFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
}

Просмотреть файл

@ -155,10 +155,8 @@ public:
#endif
void SetTallestCell(nscoord aHeight,
#ifdef MOZ_MATHML
nscoord aAscent,
nscoord aDescent,
#endif
nsTableFrame* aTableFrame = nsnull,
nsTableCellFrame* aCellFrame = nsnull);
@ -170,12 +168,11 @@ public:
/** returns the tallest child in this row (ignoring any cell with rowspans) */
nscoord GetTallestCell() const;
#ifdef MOZ_MATHML
// Support for cells with 'vertical-align: baseline'.
/**
* returns the max-ascent amongst all the cells that have
* 'vertical-align: baseline', including cells with rowspans.
* 'vertical-align: baseline', *including* cells with rowspans.
* returns 0 if we don't have any cell with 'vertical-align: baseline'
*/
nscoord GetMaxCellAscent() const;
@ -183,11 +180,10 @@ public:
#if 0 // nobody uses this
/**
* returns the max-descent amongst all the cells that have
* 'vertical-align: baseline', ignoring any cell with rowspans.
* 'vertical-align: baseline', *ignoring* any cell with rowspans.
* returns 0 if we don't have any cell with 'vertical-align: baseline'
*/
nscoord GetMaxCellDescent() const;
#endif
#endif
/** returns the ordinal position of this row in its table */
@ -322,11 +318,9 @@ private:
nscoord mTallestCell; // not my height, but the height of my tallest child
nsSize mMaxElementSize; // cached max element size
#ifdef MOZ_MATHML
// max-ascent and max-descent amongst all cells that have 'vertical-align: baseline'
nscoord mMaxCellAscent; // does include cells with rowspan > 1
nscoord mMaxCellDescent; // does *not* include cells with rowspan > 1
#endif
};
inline PRInt32 nsTableRowFrame::GetRowIndex() const

Просмотреть файл

@ -678,7 +678,6 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext* aPresCon
((nsTableRowFrame*)rowFrame)->CalculateCellActualSize(cellFrame, cellDesSize.width,
cellDesSize.height, cellDesSize.width);
cellFrameSize.height = cellDesSize.height;
#ifdef MOZ_MATHML
// see if the cell has 'vertical-align: baseline'
if (((nsTableCellFrame*)cellFrame)->HasVerticalAlignBaseline()) {
// to ensure that a spanning cell with a long descender doesn't
@ -686,8 +685,7 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext* aPresCon
// that will be done to align the cell on the baseline of the row.
cellFrameSize.height += ((nsTableRowFrame*)rowFrame)->GetMaxCellAscent()
- ((nsTableCellFrame*)cellFrame)->GetDesiredAscent();
}
#endif
}
}
if (availHeightOfRowsSpanned >= cellFrameSize.height) {
@ -695,11 +693,7 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext* aPresCon
// spans. Set the cell frame's height
cellFrame->SizeTo(aPresContext, cellFrameSize.width, availHeightOfRowsSpanned);
// Realign cell content based on new height
#ifndef MOZ_MATHML
((nsTableCellFrame*)cellFrame)->VerticallyAlignChild(aPresContext, aReflowState);
#else
((nsTableCellFrame*)cellFrame)->VerticallyAlignChild(aPresContext, aReflowState, ((nsTableRowFrame*)rowFrame)->GetMaxCellAscent());
#endif
}
else {
// the cell's height is larger than the available space of the rows it