Back out changesets ed293fc9596c and f18cb4c41578 (bug 1174700) for fatal assertions in all Windows debug reftest runs.

CLOSED TREE

Assertion failure: origKidNormalPosition.B(wm) == 0, at c:/builds/moz2_slave/m-in-w32-d-0000000000000000000/build/src/layout/tables/nsTableRowFrame.cpp:861
TEST-UNEXPECTED-FAIL | file:///C:/slave/test/build/tests/reftest/tests/layout/reftests/writing-mode/ua-style-sheet-size-1.html | application terminated with exit code 1
This commit is contained in:
L. David Baron 2015-06-20 22:41:07 -07:00
parent 03af0d59a2
commit 2c5c24868e
8 changed files with 795 additions and 865 deletions

View File

@ -848,7 +848,7 @@ CalcUnpaginatedBSize(nsPresContext* aPresContext,
break;
}
else if (rowX >= rowIndex) {
computedBSize += row->GetUnpaginatedBSize(aPresContext);
computedBSize += row->GetUnpaginatedHeight(aPresContext);
}
}
return computedBSize;

View File

@ -1420,63 +1420,49 @@ nsTableFrame::GetLogicalSkipSides(const nsHTMLReflowState* aReflowState) const
}
void
nsTableFrame::SetColumnDimensions(nscoord aBSize, WritingMode aWM,
const LogicalMargin& aBorderPadding,
nscoord aContainerWidth)
nsTableFrame::SetColumnDimensions(nscoord aHeight, WritingMode aWM,
const LogicalMargin& aBorderPadding)
{
const nscoord colBSize = aBSize - (aBorderPadding.BStartEnd(aWM) +
GetRowSpacing(-1) + GetRowSpacing(GetRowCount()));
nscoord colHeight = aHeight -= aBorderPadding.BStartEnd(aWM) +
GetRowSpacing(-1) +
GetRowSpacing(GetRowCount());
int32_t colIdx = 0;
LogicalPoint colGroupOrigin(aWM,
aBorderPadding.IStart(aWM) + GetColSpacing(-1),
aBorderPadding.BStart(aWM) + GetRowSpacing(-1));
nsTableIterator iter(mColGroups);
for (nsIFrame* colGroupFrame = iter.First(); colGroupFrame;
colGroupFrame = iter.Next()) {
nsIFrame* colGroupFrame = iter.First();
bool tableIsLTR = StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR;
int32_t colX =tableIsLTR ? 0 : std::max(0, GetColCount() - 1);
nscoord cellSpacingX = GetColSpacing(colX);
int32_t tableColIncr = tableIsLTR ? 1 : -1;
nsPoint colGroupOrigin(aBorderPadding.IStart(aWM) + GetColSpacing(-1),
aBorderPadding.BStart(aWM) + GetRowSpacing(-1));
while (colGroupFrame) {
MOZ_ASSERT(colGroupFrame->GetType() == nsGkAtoms::tableColGroupFrame);
// first we need to figure out the size of the colgroup
int32_t groupFirstCol = colIdx;
nscoord colGroupISize = 0;
nscoord cellSpacingI = 0;
nscoord colGroupWidth = 0;
nsTableIterator iterCol(*colGroupFrame);
for (nsIFrame* colFrame = iterCol.First(); colFrame;
colFrame = iterCol.Next()) {
nsIFrame* colFrame = iterCol.First();
nsPoint colOrigin(0,0);
while (colFrame) {
if (NS_STYLE_DISPLAY_TABLE_COLUMN ==
colFrame->StyleDisplay()->mDisplay) {
NS_ASSERTION(colIdx < GetColCount(), "invalid number of columns");
cellSpacingI = GetColSpacing(colIdx);
colGroupISize += GetColumnISize(colIdx) + cellSpacingI;
++colIdx;
NS_ASSERTION(colX < GetColCount(), "invalid number of columns");
nscoord colWidth = GetColumnISize(colX);
nsRect colRect(colOrigin.x, colOrigin.y, colWidth, colHeight);
colFrame->SetRect(colRect);
cellSpacingX = GetColSpacing(colX);
colOrigin.x += colWidth + cellSpacingX;
colGroupWidth += colWidth + cellSpacingX;
colX += tableColIncr;
}
colFrame = iterCol.Next();
}
if (colGroupISize) {
colGroupISize -= cellSpacingI;
if (colGroupWidth) {
colGroupWidth -= cellSpacingX;
}
LogicalRect colGroupRect(aWM, colGroupOrigin.I(aWM), colGroupOrigin.B(aWM),
colGroupISize, colBSize);
colGroupFrame->SetRect(aWM, colGroupRect, aContainerWidth);
nscoord colGroupWidth = colGroupFrame->GetSize().width;
// then we can place the columns correctly within the group
colIdx = groupFirstCol;
LogicalPoint colOrigin(aWM);
for (nsIFrame* colFrame = iterCol.First(); colFrame;
colFrame = iterCol.Next()) {
if (NS_STYLE_DISPLAY_TABLE_COLUMN ==
colFrame->StyleDisplay()->mDisplay) {
nscoord colISize = GetColumnISize(colIdx);
LogicalRect colRect(aWM, colOrigin.I(aWM), colOrigin.B(aWM),
colISize, colBSize);
colFrame->SetRect(aWM, colRect, colGroupWidth);
cellSpacingI = GetColSpacing(colIdx);
colOrigin.I(aWM) += colISize + cellSpacingI;
++colIdx;
}
}
colGroupOrigin.I(aWM) += colGroupISize + cellSpacingI;
nsRect colGroupRect(colGroupOrigin.x, colGroupOrigin.y, colGroupWidth, colHeight);
colGroupFrame->SetRect(colGroupRect);
colGroupFrame = iter.Next();
colGroupOrigin.x += colGroupWidth + cellSpacingX;
}
}
@ -1920,8 +1906,7 @@ nsTableFrame::Reflow(nsPresContext* aPresContext,
}
LogicalMargin borderPadding = GetChildAreaOffset(wm, &aReflowState);
SetColumnDimensions(aDesiredSize.Height(), wm, borderPadding,
aDesiredSize.Width());
SetColumnDimensions(aDesiredSize.Height(), wm, borderPadding);
if (NeedToCollapse() &&
(NS_UNCONSTRAINEDSIZE != aReflowState.AvailableWidth())) {
AdjustForCollapsingRowsCols(aDesiredSize, wm, borderPadding);
@ -3341,13 +3326,13 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
nscoord amountUsedByRG = 0;
nscoord yOriginRow = 0;
nsRect rgNormalRect = rgFrame->GetNormalRect();
if (!rgFrame->HasStyleBSize()) {
if (!rgFrame->HasStyleHeight()) {
nsTableRowFrame* rowFrame = rgFrame->GetFirstRow();
while (rowFrame) {
nsRect rowNormalRect = rowFrame->GetNormalRect();
nscoord cellSpacingY = GetRowSpacing(rowFrame->GetRowIndex());
if ((amountUsed < aAmount) && rowFrame->HasPctBSize()) {
nscoord pctHeight = rowFrame->GetBSize(pctBasis);
if ((amountUsed < aAmount) && rowFrame->HasPctHeight()) {
nscoord pctHeight = rowFrame->GetHeight(pctBasis);
nscoord amountForRow = std::min(aAmount - amountUsed,
pctHeight - rowNormalRect.height);
if (amountForRow > 0) {
@ -3416,10 +3401,10 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
nsTableRowFrame* firstUnStyledRow = nullptr;
for (rgX = 0; rgX < rowGroups.Length() && !firstUnStyledRG; rgX++) {
nsTableRowGroupFrame* rgFrame = rowGroups[rgX];
if (!rgFrame->HasStyleBSize()) {
if (!rgFrame->HasStyleHeight()) {
nsTableRowFrame* rowFrame = rgFrame->GetFirstRow();
while (rowFrame) {
if (!rowFrame->HasStyleBSize()) {
if (!rowFrame->HasStyleHeight()) {
firstUnStyledRG = rgFrame;
firstUnStyledRow = rowFrame;
break;
@ -3445,10 +3430,10 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
else {
for (rgX = 0; rgX < rowGroups.Length(); rgX++) {
nsTableRowGroupFrame* rgFrame = rowGroups[rgX];
if (!firstUnStyledRG || !rgFrame->HasStyleBSize()) {
if (!firstUnStyledRG || !rgFrame->HasStyleHeight()) {
nsTableRowFrame* rowFrame = rgFrame->GetFirstRow();
while (rowFrame) {
if (!firstUnStyledRG || !rowFrame->HasStyleBSize()) {
if (!firstUnStyledRG || !rowFrame->HasStyleHeight()) {
NS_ASSERTION(rowFrame->GetSize().height >= 0,
"negative row frame height");
divisor += rowFrame->GetSize().height;
@ -3480,14 +3465,14 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
nsRect rgNormalRect = rgFrame->GetNormalRect();
nsRect rgVisualOverflow = rgFrame->GetVisualOverflowRect();
// see if there is an eligible row group or we distribute to all rows
if (!firstUnStyledRG || !rgFrame->HasStyleBSize() || !eligibleRows) {
if (!firstUnStyledRG || !rgFrame->HasStyleHeight() || !eligibleRows) {
nsTableRowFrame* rowFrame = rgFrame->GetFirstRow();
while (rowFrame) {
nscoord cellSpacingY = GetRowSpacing(rowFrame->GetRowIndex());
nsRect rowNormalRect = rowFrame->GetNormalRect();
nsRect rowVisualOverflow = rowFrame->GetVisualOverflowRect();
// see if there is an eligible row or we distribute to all rows
if (!firstUnStyledRow || !rowFrame->HasStyleBSize() || !eligibleRows) {
if (!firstUnStyledRow || !rowFrame->HasStyleHeight() || !eligibleRows) {
float ratio;
if (eligibleRows) {
if (!expandEmptyRows) {
@ -3928,7 +3913,26 @@ nsTableIterator::Init(nsIFrame* aFirstChild)
mFirstListChild = aFirstChild;
mFirstChild = aFirstChild;
mCurrentChild = nullptr;
mLeftToRight = true;
mCount = -1;
if (!mFirstChild) {
return;
}
nsTableFrame* table = nsTableFrame::GetTableFrame(mFirstChild);
mLeftToRight = (NS_STYLE_DIRECTION_LTR ==
table->StyleVisibility()->mDirection);
if (!mLeftToRight) {
mCount = 0;
nsIFrame* nextChild = mFirstChild->GetNextSibling();
while (nullptr != nextChild) {
mCount++;
mFirstChild = nextChild;
nextChild = nextChild->GetNextSibling();
}
}
}
nsIFrame*
@ -3945,8 +3949,26 @@ nsTableIterator::Next()
return nullptr;
}
mCurrentChild = mCurrentChild->GetNextSibling();
return mCurrentChild;
if (mLeftToRight) {
mCurrentChild = mCurrentChild->GetNextSibling();
return mCurrentChild;
}
else {
nsIFrame* targetChild = mCurrentChild;
mCurrentChild = nullptr;
nsIFrame* child = mFirstListChild;
while (child && (child != targetChild)) {
mCurrentChild = child;
child = child->GetNextSibling();
}
return mCurrentChild;
}
}
bool
nsTableIterator::IsLeftToRight()
{
return mLeftToRight;
}
int32_t
@ -5388,7 +5410,7 @@ BCMapCellInfo::SetRowGroupBEndContBCBorder()
currentBorder = CompareBorders(mTableFrame, nullptr, nullptr, mRowGroup,
mEndRow, nullptr, mTableWM,
eLogicalSideBEnd, ADJACENT);
mRowGroup->SetContinuousBCBorderWidth(eLogicalSideBEnd, currentBorder.width);
mRowGroup->SetContinuousBCBorderWidth(NS_SIDE_BOTTOM, currentBorder.width);
}
}
@ -5412,7 +5434,7 @@ BCMapCellInfo::SetInnerRowGroupBEndContBCBorder(const nsIFrame* aNextRowGroup,
currentBorder.width);
}
if (mRgAtEnd && mRowGroup) {
mRowGroup->SetContinuousBCBorderWidth(eLogicalSideBEnd, currentBorder.width);
mRowGroup->SetContinuousBCBorderWidth(NS_SIDE_BOTTOM, currentBorder.width);
}
}

View File

@ -810,8 +810,7 @@ protected:
void ExpandBCDamageArea(mozilla::TableArea& aRect) const;
void SetColumnDimensions(nscoord aHeight, WritingMode aWM,
const LogicalMargin& aBorderPadding,
nscoord aContainerWidth);
const LogicalMargin& aBorderPadding);
int32_t CollectRows(nsIFrame* aFrame,
nsTArray<nsTableRowFrame*>& aCollection);
@ -1010,10 +1009,12 @@ public:
explicit nsTableIterator(nsFrameList& aSource);
nsIFrame* First();
nsIFrame* Next();
bool IsLeftToRight();
int32_t Count();
protected:
void Init(nsIFrame* aFirstChild);
bool mLeftToRight;
nsIFrame* mFirstListChild;
nsIFrame* mFirstChild;
nsIFrame* mCurrentChild;

View File

@ -208,7 +208,6 @@ TableBackgroundPainter::PaintTableFrame(nsTableFrame* aTableFrame,
TableBackgroundData tableData(aTableFrame);
tableData.mRect.MoveTo(0,0); //using table's coords
tableData.mRect.Deflate(aDeflate);
WritingMode wm = aTableFrame->GetWritingMode();
if (mIsBorderCollapse && tableData.ShouldSetBCBorder()) {
if (aFirstRowGroup && aLastRowGroup && mNumCols > 0) {
//only handle non-degenerate tables; we need a more robust BC model
@ -220,14 +219,13 @@ TableBackgroundPainter::PaintTableFrame(nsTableFrame* aTableFrame,
}
border.right = tempBorder.right;
LogicalMargin logBorder(wm);
aLastRowGroup->GetContinuousBCBorderWidth(wm, logBorder);
border.bottom = logBorder.Bottom(wm);
aLastRowGroup->GetContinuousBCBorderWidth(tempBorder);
border.bottom = tempBorder.bottom;
nsTableRowFrame* rowFrame = aFirstRowGroup->GetFirstRow();
if (rowFrame) {
rowFrame->GetContinuousBCBorderWidth(wm, logBorder);
border.top = logBorder.Top(wm);
rowFrame->GetContinuousBCBorderWidth(tempBorder);
border.top = tempBorder.top;
}
border.left = aTableFrame->GetContinuousLeftBCBorderWidth();
@ -389,22 +387,21 @@ TableBackgroundPainter::PaintRowGroup(nsTableRowGroupFrame* aFrame,
MOZ_ASSERT(aFrame, "null frame");
nsTableRowFrame* firstRow = aFrame->GetFirstRow();
WritingMode wm = aFrame->GetWritingMode();
/* Load row group data */
if (aPassThrough) {
aRowGroupBGData.MakeInvisible();
} else {
if (mIsBorderCollapse && aRowGroupBGData.ShouldSetBCBorder()) {
LogicalMargin border(wm);
nsMargin border;
if (firstRow) {
//pick up first row's bstart border (= rg bstart border)
firstRow->GetContinuousBCBorderWidth(wm, border);
/* (row group doesn't store its bstart border) */
//pick up first row's top border (= rg top border)
firstRow->GetContinuousBCBorderWidth(border);
/* (row group doesn't store its top border) */
}
//overwrite sides+bottom borders with rg's own
aFrame->GetContinuousBCBorderWidth(wm, border);
aRowGroupBGData.SetBCBorder(border.GetPhysicalMargin(wm));
aFrame->GetContinuousBCBorderWidth(border);
aRowGroupBGData.SetBCBorder(border);
}
aPassThrough = !aRowGroupBGData.IsVisible();
}
@ -487,24 +484,25 @@ TableBackgroundPainter::PaintRow(nsTableRowFrame* aFrame,
MOZ_ASSERT(aFrame, "null frame");
/* Load row data */
WritingMode wm = aFrame->GetWritingMode();
if (aPassThrough) {
aRowBGData.MakeInvisible();
} else {
if (mIsBorderCollapse && aRowBGData.ShouldSetBCBorder()) {
LogicalMargin border(wm);
nsMargin border;
nsTableRowFrame* nextRow = aFrame->GetNextRow();
if (nextRow) { //outer top below us is inner bottom for us
border.BEnd(wm) = nextRow->GetOuterBStartContBCBorderWidth();
WritingMode wm = nextRow->GetWritingMode();
border.Side(wm.PhysicalSide(eLogicalSideBEnd)) =
nextRow->GetOuterBStartContBCBorderWidth();
}
else { //acquire rg's bottom border
nsTableRowGroupFrame* rowGroup = static_cast<nsTableRowGroupFrame*>(aFrame->GetParent());
rowGroup->GetContinuousBCBorderWidth(wm, border);
rowGroup->GetContinuousBCBorderWidth(border);
}
//get the rest of the borders; will overwrite all but bottom
aFrame->GetContinuousBCBorderWidth(wm, border);
aFrame->GetContinuousBCBorderWidth(border);
aRowBGData.SetBCBorder(border.GetPhysicalMargin(wm));
aRowBGData.SetBCBorder(border);
}
aPassThrough = !aRowBGData.IsVisible();
}

File diff suppressed because it is too large Load Diff

View File

@ -115,21 +115,21 @@ public:
virtual mozilla::WritingMode GetWritingMode() const override
{ return GetTableFrame()->GetWritingMode(); }
void UpdateBSize(nscoord aBSize,
nscoord aAscent,
nscoord aDescent,
nsTableFrame* aTableFrame = nullptr,
nsTableCellFrame* aCellFrame = nullptr);
void UpdateHeight(nscoord aHeight,
nscoord aAscent,
nscoord aDescent,
nsTableFrame* aTableFrame = nullptr,
nsTableCellFrame* aCellFrame = nullptr);
void ResetBSize(nscoord aRowStyleBSize);
void ResetHeight(nscoord aRowStyleHeight);
// calculate the bsize, considering content bsize of the
// cells and the style bsize of the row and cells, excluding pct bsizes
nscoord CalcBSize(const nsHTMLReflowState& aReflowState);
// calculate the height, considering content height of the
// cells and the style height of the row and cells, excluding pct heights
nscoord CalcHeight(const nsHTMLReflowState& aReflowState);
// Support for cells with 'vertical-align: baseline'.
/**
/**
* returns the max-ascent amongst all the cells that have
* 'vertical-align: baseline', *including* cells with rowspans.
* returns 0 if we don't have any cell with 'vertical-align: baseline'
@ -147,26 +147,26 @@ public:
void SetRowIndex (int aRowIndex);
/** used by row group frame code */
nscoord ReflowCellFrame(nsPresContext* aPresContext,
nscoord ReflowCellFrame(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
bool aIsTopOfPage,
nsTableCellFrame* aCellFrame,
nscoord aAvailableBSize,
nscoord aAvailableHeight,
nsReflowStatus& aStatus);
/**
* Collapse the row if required, apply col and colgroup visibility: collapse
* info to the cells in the row.
* @return the amount to shift bstart-wards all following rows
* @param aRowOffset - shift the row bstart-wards by this amount
* @param aISize - new isize of the row
* @return he amount to shift up all following rows
* @param aRowOffset - shift the row up by this amount
* @param aWidth - new width of the row
* @param aCollapseGroup - parent rowgroup is collapsed so this row needs
* to be collapsed
* @param aDidCollapse - the row has been collapsed
*/
nscoord CollapseRowIfNecessary(nscoord aRowOffset,
nscoord aISize,
nscoord aWidth,
bool aCollapseGroup,
bool& aDidCollapse);
bool& aDidCollapse);
/**
* Insert a cell frame after the last cell frame that has a col index
@ -178,39 +178,38 @@ public:
void InsertCellFrame(nsTableCellFrame* aFrame,
int32_t aColIndex);
nsresult CalculateCellActualBSize(nsTableCellFrame* aCellFrame,
nscoord& aDesiredBSize,
mozilla::WritingMode aWM);
nsresult CalculateCellActualHeight(nsTableCellFrame* aCellFrame,
nscoord& aDesiredHeight);
bool IsFirstInserted() const;
void SetFirstInserted(bool aValue);
nscoord GetContentBSize() const;
void SetContentBSize(nscoord aTwipValue);
nscoord GetContentHeight() const;
void SetContentHeight(nscoord aTwipValue);
bool HasStyleBSize() const;
bool HasStyleHeight() const;
bool HasFixedBSize() const;
void SetHasFixedBSize(bool aValue);
bool HasFixedHeight() const;
void SetHasFixedHeight(bool aValue);
bool HasPctBSize() const;
void SetHasPctBSize(bool aValue);
bool HasPctHeight() const;
void SetHasPctHeight(bool aValue);
nscoord GetFixedBSize() const;
void SetFixedBSize(nscoord aValue);
nscoord GetFixedHeight() const;
void SetFixedHeight(nscoord aValue);
float GetPctBSize() const;
void SetPctBSize(float aPctValue,
float GetPctHeight() const;
void SetPctHeight(float aPctValue,
bool aForce = false);
nscoord GetBSize(nscoord aBasis = 0) const;
nscoord GetHeight(nscoord aBasis = 0) const;
nsTableRowFrame* GetNextRow() const;
bool HasUnpaginatedBSize();
void SetHasUnpaginatedBSize(bool aValue);
nscoord GetUnpaginatedBSize(nsPresContext* aPresContext);
void SetUnpaginatedBSize(nsPresContext* aPresContext, nscoord aValue);
bool HasUnpaginatedHeight();
void SetHasUnpaginatedHeight(bool aValue);
nscoord GetUnpaginatedHeight(nsPresContext* aPresContext);
void SetUnpaginatedHeight(nsPresContext* aPresContext, nscoord aValue);
nscoord GetBStartBCBorderWidth() const { return mBStartBorderWidth; }
nscoord GetBEndBCBorderWidth() const { return mBEndBorderWidth; }
@ -224,9 +223,7 @@ public:
* GetContinuousBCBorderWidth will not overwrite that border
* see nsTablePainter about continuous borders
*/
void GetContinuousBCBorderWidth(mozilla::WritingMode aWM,
mozilla::LogicalMargin& aBorder);
void GetContinuousBCBorderWidth(nsMargin& aBorder);
/**
* @returns outer block-start bc border == prev row's block-end inner
*/
@ -258,10 +255,10 @@ protected:
*/
explicit nsTableRowFrame(nsStyleContext *aContext);
void InitChildReflowState(nsPresContext& aPresContext,
const mozilla::LogicalSize& aAvailSize,
bool aBorderCollapse,
nsTableCellReflowState& aReflowState);
void InitChildReflowState(nsPresContext& aPresContext,
const nsSize& aAvailSize,
bool aBorderCollapse,
nsTableCellReflowState& aReflowState);
virtual LogicalSides GetLogicalSkipSides(const nsHTMLReflowState* aReflowState = nullptr) const override;
@ -283,19 +280,19 @@ protected:
private:
struct RowBits {
unsigned mRowIndex:29;
unsigned mHasFixedBSize:1; // set if the dominating style bsize on the row or any cell is pixel based
unsigned mHasPctBSize:1; // set if the dominating style bsize on the row or any cell is pct based
unsigned mFirstInserted:1; // if true, then it was the bstart-most newly inserted row
unsigned mHasFixedHeight:1; // set if the dominating style height on the row or any cell is pixel based
unsigned mHasPctHeight:1; // set if the dominating style height on the row or any cell is pct based
unsigned mFirstInserted:1; // if true, then it was the top most newly inserted row
} mBits;
// the desired bsize based on the content of the tallest cell in the row
nscoord mContentBSize;
// the bsize based on a style percentage bsize on either the row or any cell
// if mHasPctBSize is set
nscoord mStylePctBSize;
// the bsize based on a style pixel bsize on the row or any
// cell if mHasFixedBSize is set
nscoord mStyleFixedBSize;
// the desired height based on the content of the tallest cell in the row
nscoord mContentHeight;
// the height based on a style percentage height on either the row or any cell
// if mHasPctHeight is set
nscoord mStylePctHeight;
// the height based on a style pixel height on the row or any
// cell if mHasFixedHeight is set
nscoord mStyleFixedHeight;
// max-ascent and max-descent amongst all cells that have 'vertical-align: baseline'
nscoord mMaxCellAscent; // does include cells with rowspan > 1
@ -314,7 +311,7 @@ private:
* this row has any cells that have non-auto-height. (Row-spanning
* cells are ignored.)
*/
void InitHasCellWithStyleBSize(nsTableFrame* aTableFrame);
void InitHasCellWithStyleHeight(nsTableFrame* aTableFrame);
};
@ -338,64 +335,64 @@ inline void nsTableRowFrame::SetFirstInserted(bool aValue)
mBits.mFirstInserted = aValue;
}
inline bool nsTableRowFrame::HasStyleBSize() const
inline bool nsTableRowFrame::HasStyleHeight() const
{
return (bool)mBits.mHasFixedBSize || (bool)mBits.mHasPctBSize;
return (bool)mBits.mHasFixedHeight || (bool)mBits.mHasPctHeight;
}
inline bool nsTableRowFrame::HasFixedBSize() const
inline bool nsTableRowFrame::HasFixedHeight() const
{
return (bool)mBits.mHasFixedBSize;
return (bool)mBits.mHasFixedHeight;
}
inline void nsTableRowFrame::SetHasFixedBSize(bool aValue)
inline void nsTableRowFrame::SetHasFixedHeight(bool aValue)
{
mBits.mHasFixedBSize = aValue;
mBits.mHasFixedHeight = aValue;
}
inline bool nsTableRowFrame::HasPctBSize() const
inline bool nsTableRowFrame::HasPctHeight() const
{
return (bool)mBits.mHasPctBSize;
return (bool)mBits.mHasPctHeight;
}
inline void nsTableRowFrame::SetHasPctBSize(bool aValue)
inline void nsTableRowFrame::SetHasPctHeight(bool aValue)
{
mBits.mHasPctBSize = aValue;
mBits.mHasPctHeight = aValue;
}
inline nscoord nsTableRowFrame::GetContentBSize() const
inline nscoord nsTableRowFrame::GetContentHeight() const
{
return mContentBSize;
return mContentHeight;
}
inline void nsTableRowFrame::SetContentBSize(nscoord aValue)
inline void nsTableRowFrame::SetContentHeight(nscoord aValue)
{
mContentBSize = aValue;
mContentHeight = aValue;
}
inline nscoord nsTableRowFrame::GetFixedBSize() const
inline nscoord nsTableRowFrame::GetFixedHeight() const
{
if (mBits.mHasFixedBSize) {
return mStyleFixedBSize;
}
return 0;
if (mBits.mHasFixedHeight)
return mStyleFixedHeight;
else
return 0;
}
inline float nsTableRowFrame::GetPctBSize() const
inline float nsTableRowFrame::GetPctHeight() const
{
if (mBits.mHasPctBSize) {
return (float)mStylePctBSize / 100.0f;
}
return 0.0f;
if (mBits.mHasPctHeight)
return (float)mStylePctHeight / 100.0f;
else
return 0.0f;
}
inline bool nsTableRowFrame::HasUnpaginatedBSize()
inline bool nsTableRowFrame::HasUnpaginatedHeight()
{
return (mState & NS_TABLE_ROW_HAS_UNPAGINATED_HEIGHT) ==
NS_TABLE_ROW_HAS_UNPAGINATED_HEIGHT;
}
inline void nsTableRowFrame::SetHasUnpaginatedBSize(bool aValue)
inline void nsTableRowFrame::SetHasUnpaginatedHeight(bool aValue)
{
if (aValue) {
mState |= NS_TABLE_ROW_HAS_UNPAGINATED_HEIGHT;
@ -413,16 +410,18 @@ nsTableRowFrame::GetBCBorderWidth(mozilla::WritingMode aWM)
}
inline void
nsTableRowFrame::GetContinuousBCBorderWidth(mozilla::WritingMode aWM,
mozilla::LogicalMargin& aBorder)
nsTableRowFrame::GetContinuousBCBorderWidth(nsMargin& aBorder)
{
int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
aBorder.IEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
mIStartContBorderWidth);
aBorder.BStart(aWM) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
mBStartContBorderWidth);
aBorder.IStart(aWM) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
mIEndContBorderWidth);
mozilla::WritingMode wm = GetWritingMode();
mozilla::LogicalMargin border(wm, aBorder);
border.IEnd(wm) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
mIStartContBorderWidth);
border.BStart(wm) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
mBStartContBorderWidth);
border.IStart(wm) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
mIEndContBorderWidth);
aBorder = border.GetPhysicalMargin(wm);
}
inline nscoord nsTableRowFrame::GetOuterBStartContBCBorderWidth()

View File

@ -255,14 +255,13 @@ nsTableRowGroupFrame::GetLogicalSkipSides(const nsHTMLReflowState* aReflowState)
return skip;
}
// Position and size aKidFrame and update our reflow state.
// Position and size aKidFrame and update our reflow state. The origin of
// aKidRect is relative to the upper-left origin of our frame
void
nsTableRowGroupFrame::PlaceChild(nsPresContext* aPresContext,
nsRowGroupReflowState& aReflowState,
nsIFrame* aKidFrame,
WritingMode aWM,
const LogicalPoint& aKidPosition,
nscoord aContainerWidth,
nsPoint aKidPosition,
nsHTMLReflowMetrics& aDesiredSize,
const nsRect& aOriginalKidRect,
const nsRect& aOriginalKidVisualOverflow)
@ -272,17 +271,17 @@ nsTableRowGroupFrame::PlaceChild(nsPresContext* aPresContext,
// Place and size the child
FinishReflowChild(aKidFrame, aPresContext, aDesiredSize, nullptr,
aWM, aKidPosition, aContainerWidth, 0);
aKidPosition.x, aKidPosition.y, 0);
nsTableFrame::InvalidateTableFrame(aKidFrame, aOriginalKidRect,
aOriginalKidVisualOverflow, isFirstReflow);
// Adjust the running block-offset
aReflowState.bCoord += aDesiredSize.BSize(aWM);
// Adjust the running y-offset
aReflowState.y += aDesiredSize.Height();
// If our block-size is constrained then update the available bsize
if (NS_UNCONSTRAINEDSIZE != aReflowState.availSize.BSize(aWM)) {
aReflowState.availSize.BSize(aWM) -= aDesiredSize.BSize(aWM);
// If our height is constrained then update the available height
if (NS_UNCONSTRAINEDSIZE != aReflowState.availSize.height) {
aReflowState.availSize.height -= aDesiredSize.Height();
}
}
@ -307,14 +306,13 @@ nsTableRowGroupFrame::InitChildReflowState(nsPresContext& aPresContext,
}
static void
CacheRowBSizesForPrinting(nsPresContext* aPresContext,
nsTableRowFrame* aFirstRow,
WritingMode aWM)
CacheRowHeightsForPrinting(nsPresContext* aPresContext,
nsTableRowFrame* aFirstRow)
{
for (nsTableRowFrame* row = aFirstRow; row; row = row->GetNextRow()) {
if (!row->GetPrevInFlow()) {
row->SetHasUnpaginatedBSize(true);
row->SetUnpaginatedBSize(aPresContext, row->BSize(aWM));
row->SetHasUnpaginatedHeight(true);
row->SetUnpaginatedHeight(aPresContext, row->GetSize().height);
}
}
}
@ -326,33 +324,21 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
nsReflowStatus& aStatus,
bool* aPageBreakBeforeEnd)
{
if (aPageBreakBeforeEnd) {
if (aPageBreakBeforeEnd)
*aPageBreakBeforeEnd = false;
}
WritingMode wm = aReflowState.reflowState.GetWritingMode();
nsTableFrame* tableFrame = GetTableFrame();
const bool borderCollapse = tableFrame->IsBorderCollapse();
// XXXldb Should we really be checking IsPaginated(),
// or should we *only* check available block-size?
// XXXldb Should we really be checking this rather than available height?
// (Think about multi-column layout!)
bool isPaginated = aPresContext->IsPaginated() &&
NS_UNCONSTRAINEDSIZE != aReflowState.availSize.BSize(wm);
NS_UNCONSTRAINEDSIZE != aReflowState.availSize.height;
bool haveRow = false;
bool reflowAllKids = aReflowState.reflowState.ShouldReflowAllKids() ||
tableFrame->IsGeometryDirty();
bool needToCalcRowBSizes = reflowAllKids;
nscoord containerWidth = aReflowState.reflowState.ComputedWidth();
if (containerWidth == NS_UNCONSTRAINEDSIZE) {
containerWidth = 0; // we can't position frames correctly in RTL yet,
// so they will need to be adjusted later
} else {
containerWidth +=
aReflowState.reflowState.ComputedPhysicalBorderPadding().LeftRight();
}
bool needToCalcRowHeights = reflowAllKids;
nsIFrame *prevKidFrame = nullptr;
for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame;
@ -363,7 +349,7 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
NS_NOTREACHED("yikes, a non-row child");
continue;
}
nscoord cellSpacingB = tableFrame->GetRowSpacing(rowFrame->GetRowIndex());
nscoord cellSpacingY = tableFrame->GetRowSpacing(rowFrame->GetRowIndex());
haveRow = true;
// Reflow the row frame
@ -372,7 +358,7 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
(aReflowState.reflowState.mFlags.mSpecialHeightReflow &&
(isPaginated || (kidFrame->GetStateBits() &
NS_FRAME_CONTAINS_RELATIVE_BSIZE)))) {
LogicalRect oldKidRect = kidFrame->GetLogicalRect(wm, containerWidth);
nsRect oldKidRect = kidFrame->GetRect();
nsRect oldKidVisualOverflow = kidFrame->GetVisualOverflowRect();
// XXXldb We used to only pass aDesiredSize.mFlags through for the
@ -381,10 +367,11 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
aDesiredSize.mFlags);
desiredSize.ClearSize();
// Reflow the child into the available space, giving it as much bsize as
// Reflow the child into the available space, giving it as much height as
// it wants. We'll deal with splitting later after we've computed the row
// bsizes, taking into account cells with row spans...
LogicalSize kidAvailSize = aReflowState.availSize;
// heights, taking into account cells with row spans...
WritingMode wm = kidFrame->GetWritingMode();
LogicalSize kidAvailSize(wm, aReflowState.availSize);
kidAvailSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState kidReflowState(aPresContext, aReflowState.reflowState,
kidFrame, kidAvailSize,
@ -393,8 +380,8 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
InitChildReflowState(*aPresContext, borderCollapse, kidReflowState);
// This can indicate that columns were resized.
if (aReflowState.reflowState.IsIResize()) {
kidReflowState.SetIResize(true);
if (aReflowState.reflowState.IsHResize()) {
kidReflowState.SetHResize(true);
}
NS_ASSERTION(kidFrame == mFrames.FirstChild() || prevKidFrame,
@ -405,35 +392,33 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
kidReflowState.mFlags.mIsTopOfPage = false;
}
LogicalPoint kidPosition(wm, 0, aReflowState.bCoord);
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
wm, kidPosition, containerWidth, 0, aStatus);
kidReflowState.ApplyRelativePositioning(&kidPosition, containerWidth);
0, aReflowState.y, 0, aStatus);
nsPoint kidPosition(0, aReflowState.y);
kidReflowState.ApplyRelativePositioning(&kidPosition);
// Place the child
PlaceChild(aPresContext, aReflowState, kidFrame,
wm, kidPosition, containerWidth,
desiredSize, oldKidRect.GetPhysicalRect(wm, containerWidth),
oldKidVisualOverflow);
aReflowState.bCoord += cellSpacingB;
PlaceChild(aPresContext, aReflowState, kidFrame, kidPosition,
desiredSize, oldKidRect, oldKidVisualOverflow);
aReflowState.y += cellSpacingY;
if (!reflowAllKids) {
if (IsSimpleRowFrame(aReflowState.tableFrame, kidFrame)) {
// Inform the row of its new bsize.
// Inform the row of its new height.
rowFrame->DidResize();
// the overflow area may have changed inflate the overflow area
const nsStylePosition *stylePos = StylePosition();
nsStyleUnit unit = stylePos->BSize(wm).GetUnit();
nsStyleUnit unit = stylePos->mHeight.GetUnit();
if (aReflowState.tableFrame->IsAutoHeight() &&
unit != eStyleUnit_Coord) {
// Because other cells in the row may need to be aligned
// differently, repaint the entire row
InvalidateFrame();
} else if (oldKidRect.BSize(wm) != desiredSize.BSize(wm)) {
needToCalcRowBSizes = true;
}
else if (oldKidRect.height != desiredSize.Height())
needToCalcRowHeights = true;
} else {
needToCalcRowBSizes = true;
needToCalcRowHeights = true;
}
}
@ -446,34 +431,33 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
} else {
SlideChild(aReflowState, kidFrame);
// Adjust the running b-offset so we know where the next row should be placed
nscoord bSize = kidFrame->BSize(wm) + cellSpacingB;
aReflowState.bCoord += bSize;
// Adjust the running y-offset so we know where the next row should be placed
nscoord height = kidFrame->GetSize().height + cellSpacingY;
aReflowState.y += height;
if (NS_UNCONSTRAINEDSIZE != aReflowState.availSize.BSize(wm)) {
aReflowState.availSize.BSize(wm) -= bSize;
if (NS_UNCONSTRAINEDSIZE != aReflowState.availSize.height) {
aReflowState.availSize.height -= height;
}
}
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, kidFrame);
}
if (haveRow) {
aReflowState.bCoord -= tableFrame->GetRowSpacing(GetStartRowIndex() +
GetRowCount());
}
if (haveRow)
aReflowState.y -= tableFrame->GetRowSpacing(GetStartRowIndex() +
GetRowCount());
// Return our desired rect
aDesiredSize.ISize(wm) = aReflowState.reflowState.AvailableISize();
aDesiredSize.BSize(wm) = aReflowState.bCoord;
aDesiredSize.Width() = aReflowState.reflowState.AvailableWidth();
aDesiredSize.Height() = aReflowState.y;
if (aReflowState.reflowState.mFlags.mSpecialHeightReflow) {
DidResizeRows(aDesiredSize);
if (isPaginated) {
CacheRowBSizesForPrinting(aPresContext, GetFirstRow(), wm);
CacheRowHeightsForPrinting(aPresContext, GetFirstRow());
}
}
else if (needToCalcRowBSizes) {
CalculateRowBSizes(aPresContext, aDesiredSize, aReflowState.reflowState);
else if (needToCalcRowHeights) {
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState.reflowState);
if (!reflowAllKids) {
InvalidateFrame();
}
@ -495,35 +479,34 @@ nsTableRowGroupFrame::GetFirstRow()
struct RowInfo {
RowInfo() { bSize = pctBSize = hasStyleBSize = hasPctBSize = isSpecial = 0; }
unsigned bSize; // content bsize or fixed bsize, excluding pct bsize
unsigned pctBSize:29; // pct bsize
unsigned hasStyleBSize:1;
unsigned hasPctBSize:1;
RowInfo() { height = pctHeight = hasStyleHeight = hasPctHeight = isSpecial = 0; }
unsigned height; // content height or fixed height, excluding pct height
unsigned pctHeight:29; // pct height
unsigned hasStyleHeight:1;
unsigned hasPctHeight:1;
unsigned isSpecial:1; // there is no cell originating in the row with rowspan=1 and there are at
// least 2 cells spanning the row and there is no style bsize on the row
// least 2 cells spanning the row and there is no style height on the row
};
static void
UpdateBSizes(RowInfo& aRowInfo,
nscoord aAdditionalBSize,
nscoord& aTotal,
nscoord& aUnconstrainedTotal)
UpdateHeights(RowInfo& aRowInfo,
nscoord aAdditionalHeight,
nscoord& aTotal,
nscoord& aUnconstrainedTotal)
{
aRowInfo.bSize += aAdditionalBSize;
aTotal += aAdditionalBSize;
if (!aRowInfo.hasStyleBSize) {
aUnconstrainedTotal += aAdditionalBSize;
aRowInfo.height += aAdditionalHeight;
aTotal += aAdditionalHeight;
if (!aRowInfo.hasStyleHeight) {
aUnconstrainedTotal += aAdditionalHeight;
}
}
void
nsTableRowGroupFrame::DidResizeRows(nsHTMLReflowMetrics& aDesiredSize)
{
// Update the cells spanning rows with their new bsizes.
// This is the place where all of the cells in the row get set to the bsize
// of the row.
// Reset the overflow area.
// update the cells spanning rows with their new heights
// this is the place where all of the cells in the row get set to the height of the row
// Reset the overflow area
aDesiredSize.mOverflowAreas.Clear();
for (nsTableRowFrame* rowFrame = GetFirstRow();
rowFrame; rowFrame = rowFrame->GetNextRow()) {
@ -532,13 +515,13 @@ nsTableRowGroupFrame::DidResizeRows(nsHTMLReflowMetrics& aDesiredSize)
}
}
// This calculates the bsize of all the rows and takes into account
// style bsize on the row group, style bsizes on rows and cells, style bsizes on rowspans.
// Actual row bsizes will be adjusted later if the table has a style bsize.
// Even if rows don't change bsize, this method must be called to set the bsizes of each
// cell in the row to the bsize of its row.
// This calculates the height of all the rows and takes into account
// style height on the row group, style heights on rows and cells, style heights on rowspans.
// Actual row heights will be adjusted later if the table has a style height.
// Even if rows don't change height, this method must be called to set the heights of each
// cell in the row to the height of its row.
void
nsTableRowGroupFrame::CalculateRowBSizes(nsPresContext* aPresContext,
nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState)
{
@ -551,20 +534,13 @@ nsTableRowGroupFrame::CalculateRowBSizes(nsPresContext* aPresContext,
// find the row corresponding to the row index we just found
nsTableRowFrame* startRowFrame = GetFirstRow();
if (!startRowFrame) {
return;
}
if (!startRowFrame) return;
// The current row group block-size is the block-origin of the 1st row
// we are about to calculate a block-size for.
WritingMode wm = aReflowState.GetWritingMode();
nscoord containerWidth = 0; // actual value is unimportant as we're initially
// computing sizes, not physical positions
nscoord startRowGroupBSize =
startRowFrame->GetLogicalNormalPosition(wm, containerWidth).B(wm);
// the current row group height is the y origin of the 1st row we are about to calculated a height for
nscoord startRowGroupHeight = startRowFrame->GetNormalPosition().y;
int32_t numRows = GetRowCount() - (startRowFrame->GetRowIndex() - GetStartRowIndex());
// Collect the current bsize of each row.
// collect the current height of each row. nscoord* rowHeights = nullptr;
if (numRows <= 0)
return;
@ -574,30 +550,30 @@ nsTableRowGroupFrame::CalculateRowBSizes(nsPresContext* aPresContext,
}
bool hasRowSpanningCell = false;
nscoord bSizeOfRows = 0;
nscoord bSizeOfUnStyledRows = 0;
// Get the bsize of each row without considering rowspans. This will be the max of
// the largest desired bsize of each cell, the largest style bsize of each cell,
// the style bsize of the row.
nscoord pctBSizeBasis = GetBSizeBasis(aReflowState);
nscoord heightOfRows = 0;
nscoord heightOfUnStyledRows = 0;
// Get the height of each row without considering rowspans. This will be the max of
// the largest desired height of each cell, the largest style height of each cell,
// the style height of the row.
nscoord pctHeightBasis = GetHeightBasis(aReflowState);
int32_t rowIndex; // the index in rowInfo, not among the rows in the row group
nsTableRowFrame* rowFrame;
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
nscoord nonPctBSize = rowFrame->GetContentBSize();
nscoord nonPctHeight = rowFrame->GetContentHeight();
if (isPaginated) {
nonPctBSize = std::max(nonPctBSize, rowFrame->BSize(wm));
nonPctHeight = std::max(nonPctHeight, rowFrame->GetSize().height);
}
if (!rowFrame->GetPrevInFlow()) {
if (rowFrame->HasPctBSize()) {
rowInfo[rowIndex].hasPctBSize = true;
rowInfo[rowIndex].pctBSize = rowFrame->GetBSize(pctBSizeBasis);
if (rowFrame->HasPctHeight()) {
rowInfo[rowIndex].hasPctHeight = true;
rowInfo[rowIndex].pctHeight = rowFrame->GetHeight(pctHeightBasis);
}
rowInfo[rowIndex].hasStyleBSize = rowFrame->HasStyleBSize();
nonPctBSize = std::max(nonPctBSize, rowFrame->GetFixedBSize());
rowInfo[rowIndex].hasStyleHeight = rowFrame->HasStyleHeight();
nonPctHeight = std::max(nonPctHeight, rowFrame->GetFixedHeight());
}
UpdateBSizes(rowInfo[rowIndex], nonPctBSize, bSizeOfRows, bSizeOfUnStyledRows);
UpdateHeights(rowInfo[rowIndex], nonPctHeight, heightOfRows, heightOfUnStyledRows);
if (!rowInfo[rowIndex].hasStyleBSize) {
if (!rowInfo[rowIndex].hasStyleHeight) {
if (isPaginated || tableFrame->HasMoreThanOneCell(rowIndex + startRowIndex)) {
rowInfo[rowIndex].isSpecial = true;
// iteratate the row's cell frames to see if any do not have rowspan > 1
@ -621,7 +597,7 @@ nsTableRowGroupFrame::CalculateRowBSizes(nsPresContext* aPresContext,
}
if (hasRowSpanningCell) {
// Get the bsize of cells with rowspans and allocate any extra space to the rows they span
// Get the height of cells with rowspans and allocate any extra space to the rows they span
// iteratate the child frames and process the row frames among them
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
// See if the row has an originating cell with rowspan > 1. We cannot determine this for a row in a
@ -631,69 +607,70 @@ nsTableRowGroupFrame::CalculateRowBSizes(nsPresContext* aPresContext,
nsTableCellFrame* cellFrame = rowFrame->GetFirstCell();
// iteratate the row's cell frames
while (cellFrame) {
nscoord cellSpacingB = tableFrame->GetRowSpacing(startRowIndex + rowIndex);
nscoord cellSpacingY = tableFrame->GetRowSpacing(startRowIndex + rowIndex);
int32_t rowSpan = tableFrame->GetEffectiveRowSpan(rowIndex + startRowIndex, *cellFrame);
if ((rowIndex + rowSpan) > numRows) {
// there might be rows pushed already to the nextInFlow
rowSpan = numRows - rowIndex;
}
if (rowSpan > 1) { // a cell with rowspan > 1, determine the bsize of the rows it spans
nscoord bsizeOfRowsSpanned = 0;
nscoord bsizeOfUnStyledRowsSpanned = 0;
if (rowSpan > 1) { // a cell with rowspan > 1, determine the height of the rows it spans
nscoord heightOfRowsSpanned = 0;
nscoord heightOfUnStyledRowsSpanned = 0;
nscoord numSpecialRowsSpanned = 0;
nscoord cellSpacingTotal = 0;
int32_t spanX;
for (spanX = 0; spanX < rowSpan; spanX++) {
bsizeOfRowsSpanned += rowInfo[rowIndex + spanX].bSize;
if (!rowInfo[rowIndex + spanX].hasStyleBSize) {
bsizeOfUnStyledRowsSpanned += rowInfo[rowIndex + spanX].bSize;
heightOfRowsSpanned += rowInfo[rowIndex + spanX].height;
if (!rowInfo[rowIndex + spanX].hasStyleHeight) {
heightOfUnStyledRowsSpanned += rowInfo[rowIndex + spanX].height;
}
if (0 != spanX) {
cellSpacingTotal += cellSpacingB;
cellSpacingTotal += cellSpacingY;
}
if (rowInfo[rowIndex + spanX].isSpecial) {
numSpecialRowsSpanned++;
}
}
nscoord bsizeOfAreaSpanned = bsizeOfRowsSpanned + cellSpacingTotal;
// get the bsize of the cell
LogicalSize cellFrameSize = cellFrame->GetLogicalSize(wm);
LogicalSize cellDesSize = cellFrame->GetDesiredSize();
rowFrame->CalculateCellActualBSize(cellFrame, cellDesSize.BSize(wm), wm);
cellFrameSize.BSize(wm) = cellDesSize.BSize(wm);
nscoord heightOfAreaSpanned = heightOfRowsSpanned + cellSpacingTotal;
// get the height of the cell
nsSize cellFrameSize = cellFrame->GetSize();
nsSize cellDesSize =
cellFrame->GetDesiredSize().GetPhysicalSize(cellFrame->GetWritingMode());
rowFrame->CalculateCellActualHeight(cellFrame, cellDesSize.height);
cellFrameSize.height = cellDesSize.height;
if (cellFrame->HasVerticalAlignBaseline()) {
// to ensure that a spanning cell with a long descender doesn't
// collide with the next row, we need to take into account the shift
// that will be done to align the cell on the baseline of the row.
cellFrameSize.BSize(wm) += rowFrame->GetMaxCellAscent() -
cellFrame->GetCellBaseline();
cellFrameSize.height += rowFrame->GetMaxCellAscent() -
cellFrame->GetCellBaseline();
}
if (bsizeOfAreaSpanned < cellFrameSize.BSize(wm)) {
// the cell's bsize is larger than the available space of the rows it
// spans so distribute the excess bsize to the rows affected
nscoord extra = cellFrameSize.BSize(wm) - bsizeOfAreaSpanned;
if (heightOfAreaSpanned < cellFrameSize.height) {
// the cell's height is larger than the available space of the rows it
// spans so distribute the excess height to the rows affected
nscoord extra = cellFrameSize.height - heightOfAreaSpanned;
nscoord extraUsed = 0;
if (0 == numSpecialRowsSpanned) {
//NS_ASSERTION(bsizeOfRowsSpanned > 0, "invalid row span situation");
bool haveUnStyledRowsSpanned = (bsizeOfUnStyledRowsSpanned > 0);
//NS_ASSERTION(heightOfRowsSpanned > 0, "invalid row span situation");
bool haveUnStyledRowsSpanned = (heightOfUnStyledRowsSpanned > 0);
nscoord divisor = (haveUnStyledRowsSpanned)
? bsizeOfUnStyledRowsSpanned : bsizeOfRowsSpanned;
? heightOfUnStyledRowsSpanned : heightOfRowsSpanned;
if (divisor > 0) {
for (spanX = rowSpan - 1; spanX >= 0; spanX--) {
if (!haveUnStyledRowsSpanned || !rowInfo[rowIndex + spanX].hasStyleBSize) {
// The amount of additional space each row gets is proportional to its bsize
float percent = ((float)rowInfo[rowIndex + spanX].bSize) / ((float)divisor);
if (!haveUnStyledRowsSpanned || !rowInfo[rowIndex + spanX].hasStyleHeight) {
// The amount of additional space each row gets is proportional to its height
float percent = ((float)rowInfo[rowIndex + spanX].height) / ((float)divisor);
// give rows their percentage, except for the first row which gets the remainder
nscoord extraForRow = (0 == spanX) ? extra - extraUsed
: NSToCoordRound(((float)(extra)) * percent);
extraForRow = std::min(extraForRow, extra - extraUsed);
// update the row bsize
UpdateBSizes(rowInfo[rowIndex + spanX], extraForRow, bSizeOfRows, bSizeOfUnStyledRows);
// update the row height
UpdateHeights(rowInfo[rowIndex + spanX], extraForRow, heightOfRows, heightOfUnStyledRows);
extraUsed += extraForRow;
if (extraUsed >= extra) {
NS_ASSERTION((extraUsed == extra), "invalid row bsize calculation");
NS_ASSERTION((extraUsed == extra), "invalid row height calculation");
break;
}
}
@ -701,7 +678,7 @@ nsTableRowGroupFrame::CalculateRowBSizes(nsPresContext* aPresContext,
}
else {
// put everything in the last row
UpdateBSizes(rowInfo[rowIndex + rowSpan - 1], extra, bSizeOfRows, bSizeOfUnStyledRows);
UpdateHeights(rowInfo[rowIndex + rowSpan - 1], extra, heightOfRows, heightOfUnStyledRows);
}
}
else {
@ -717,11 +694,11 @@ nsTableRowGroupFrame::CalculateRowBSizes(nsPresContext* aPresContext,
? extra - extraUsed
: NSToCoordRound(((float)(extra)) * percent);
extraForRow = std::min(extraForRow, extra - extraUsed);
// update the row bsize
UpdateBSizes(rowInfo[rowIndex + spanX], extraForRow, bSizeOfRows, bSizeOfUnStyledRows);
// update the row height
UpdateHeights(rowInfo[rowIndex + spanX], extraForRow, heightOfRows, heightOfUnStyledRows);
extraUsed += extraForRow;
if (extraUsed >= extra) {
NS_ASSERTION((extraUsed == extra), "invalid row bsize calculation");
NS_ASSERTION((extraUsed == extra), "invalid row height calculation");
break;
}
}
@ -735,113 +712,99 @@ nsTableRowGroupFrame::CalculateRowBSizes(nsPresContext* aPresContext,
} // while (rowFrame)
}
// pct bsize rows have already got their content bsizes.
// Give them their pct bsizes up to pctBSizeBasis
nscoord extra = pctBSizeBasis - bSizeOfRows;
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame && (extra > 0);
rowFrame = rowFrame->GetNextRow(), rowIndex++) {
// pct height rows have already got their content heights. Give them their pct heights up to pctHeightBasis
nscoord extra = pctHeightBasis - heightOfRows;
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame && (extra > 0); rowFrame = rowFrame->GetNextRow(), rowIndex++) {
RowInfo& rInfo = rowInfo[rowIndex];
if (rInfo.hasPctBSize) {
nscoord rowExtra = (rInfo.pctBSize > rInfo.bSize)
? rInfo.pctBSize - rInfo.bSize: 0;
if (rInfo.hasPctHeight) {
nscoord rowExtra = (rInfo.pctHeight > rInfo.height)
? rInfo.pctHeight - rInfo.height: 0;
rowExtra = std::min(rowExtra, extra);
UpdateBSizes(rInfo, rowExtra, bSizeOfRows, bSizeOfUnStyledRows);
UpdateHeights(rInfo, rowExtra, heightOfRows, heightOfUnStyledRows);
extra -= rowExtra;
}
}
bool styleBSizeAllocation = false;
nscoord rowGroupBSize = startRowGroupBSize + bSizeOfRows +
bool styleHeightAllocation = false;
nscoord rowGroupHeight = startRowGroupHeight + heightOfRows +
tableFrame->GetRowSpacing(0, numRows-1);
// if we have a style bsize, allocate the extra bsize to unconstrained rows
if ((aReflowState.ComputedBSize() > rowGroupBSize) &&
(NS_UNCONSTRAINEDSIZE != aReflowState.ComputedBSize())) {
nscoord extraComputedBSize = aReflowState.ComputedBSize() - rowGroupBSize;
// if we have a style height, allocate the extra height to unconstrained rows
if ((aReflowState.ComputedHeight() > rowGroupHeight) &&
(NS_UNCONSTRAINEDSIZE != aReflowState.ComputedHeight())) {
nscoord extraComputedHeight = aReflowState.ComputedHeight() - rowGroupHeight;
nscoord extraUsed = 0;
bool haveUnStyledRows = (bSizeOfUnStyledRows > 0);
bool haveUnStyledRows = (heightOfUnStyledRows > 0);
nscoord divisor = (haveUnStyledRows)
? bSizeOfUnStyledRows : bSizeOfRows;
? heightOfUnStyledRows : heightOfRows;
if (divisor > 0) {
styleBSizeAllocation = true;
styleHeightAllocation = true;
for (rowIndex = 0; rowIndex < numRows; rowIndex++) {
if (!haveUnStyledRows || !rowInfo[rowIndex].hasStyleBSize) {
if (!haveUnStyledRows || !rowInfo[rowIndex].hasStyleHeight) {
// The amount of additional space each row gets is based on the
// percentage of space it occupies
float percent = ((float)rowInfo[rowIndex].bSize) / ((float)divisor);
float percent = ((float)rowInfo[rowIndex].height) / ((float)divisor);
// give rows their percentage, except for the last row which gets the remainder
nscoord extraForRow = (numRows - 1 == rowIndex)
? extraComputedBSize - extraUsed
: NSToCoordRound(((float)extraComputedBSize) * percent);
extraForRow = std::min(extraForRow, extraComputedBSize - extraUsed);
// update the row bsize
UpdateBSizes(rowInfo[rowIndex], extraForRow, bSizeOfRows, bSizeOfUnStyledRows);
? extraComputedHeight - extraUsed
: NSToCoordRound(((float)extraComputedHeight) * percent);
extraForRow = std::min(extraForRow, extraComputedHeight - extraUsed);
// update the row height
UpdateHeights(rowInfo[rowIndex], extraForRow, heightOfRows, heightOfUnStyledRows);
extraUsed += extraForRow;
if (extraUsed >= extraComputedBSize) {
NS_ASSERTION((extraUsed == extraComputedBSize), "invalid row bsize calculation");
if (extraUsed >= extraComputedHeight) {
NS_ASSERTION((extraUsed == extraComputedHeight), "invalid row height calculation");
break;
}
}
}
}
rowGroupBSize = aReflowState.ComputedBSize();
rowGroupHeight = aReflowState.ComputedHeight();
}
if (wm.IsVertical()) {
// we need the correct containerWidth below for block positioning in
// vertical-rl writing mode
containerWidth = rowGroupBSize;
}
nscoord bOrigin = startRowGroupBSize;
// update the rows with their (potentially) new bsizes
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame;
rowFrame = rowFrame->GetNextRow(), rowIndex++) {
nscoord yOrigin = startRowGroupHeight;
// update the rows with their (potentially) new heights
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
nsRect rowBounds = rowFrame->GetRect();
LogicalSize rowBoundsSize(wm, rowBounds.Size());
nsRect rowVisualOverflow = rowFrame->GetVisualOverflowRect();
nscoord deltaB =
bOrigin - rowFrame->GetLogicalNormalPosition(wm, containerWidth).B(wm);
nscoord deltaY = yOrigin - rowFrame->GetNormalPosition().y;
nscoord rowBSize = (rowInfo[rowIndex].bSize > 0) ? rowInfo[rowIndex].bSize : 0;
nscoord rowHeight = (rowInfo[rowIndex].height > 0) ? rowInfo[rowIndex].height : 0;
if (deltaB != 0 || (rowBSize != rowBoundsSize.BSize(wm))) {
if (deltaY != 0 || (rowHeight != rowBounds.height)) {
// Resize/move the row to its final size and position
if (deltaB != 0) {
if (deltaY != 0) {
rowFrame->InvalidateFrameSubtree();
}
rowFrame->MovePositionBy(wm, LogicalPoint(wm, 0, deltaB));
rowFrame->SetSize(LogicalSize(wm, rowBoundsSize.ISize(wm), rowBSize));
rowFrame->MovePositionBy(nsPoint(0, deltaY));
rowFrame->SetSize(nsSize(rowBounds.width, rowHeight));
nsTableFrame::InvalidateTableFrame(rowFrame, rowBounds, rowVisualOverflow,
false);
if (deltaB != 0) {
if (deltaY != 0) {
nsTableFrame::RePositionViews(rowFrame);
// XXXbz we don't need to update our overflow area?
}
}
bOrigin += rowBSize + tableFrame->GetRowSpacing(startRowIndex + rowIndex);
yOrigin += rowHeight + tableFrame->GetRowSpacing(startRowIndex + rowIndex);
}
if (isPaginated && styleBSizeAllocation) {
// since the row group has a style bsize, cache the row bsizes,
// so next in flows can honor them
CacheRowBSizesForPrinting(aPresContext, GetFirstRow(), wm);
if (isPaginated && styleHeightAllocation) {
// since the row group has a style height, cache the row heights, so next in flows can honor them
CacheRowHeightsForPrinting(aPresContext, GetFirstRow());
}
DidResizeRows(aDesiredSize);
aDesiredSize.BSize(wm) = rowGroupBSize; // Adjust our desired size
aDesiredSize.Height() = rowGroupHeight; // Adjust our desired size
}
nscoord
nsTableRowGroupFrame::CollapseRowGroupIfNecessary(nscoord aBTotalOffset,
nscoord aISize)
nsTableRowGroupFrame::CollapseRowGroupIfNecessary(nscoord aYTotalOffset,
nscoord aWidth)
{
WritingMode wm = GetWritingMode(); // XXX pass from caller
nsTableFrame* tableFrame = GetTableFrame();
nscoord containerWidth = tableFrame->GetRect().width;
const nsStyleVisibility* groupVis = StyleVisibility();
bool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
if (collapseGroup) {
@ -850,44 +813,43 @@ nsTableRowGroupFrame::CollapseRowGroupIfNecessary(nscoord aBTotalOffset,
nsOverflowAreas overflow;
nsTableRowFrame* rowFrame = GetFirstRow();
nsTableRowFrame* rowFrame= GetFirstRow();
bool didCollapse = false;
nscoord bGroupOffset = 0;
nscoord yGroupOffset = 0;
while (rowFrame) {
bGroupOffset += rowFrame->CollapseRowIfNecessary(bGroupOffset,
aISize, collapseGroup,
yGroupOffset += rowFrame->CollapseRowIfNecessary(yGroupOffset,
aWidth, collapseGroup,
didCollapse);
ConsiderChildOverflow(overflow, rowFrame);
rowFrame = rowFrame->GetNextRow();
}
LogicalRect groupRect = GetLogicalRect(wm, containerWidth);
nsRect oldGroupRect = GetRect();
nsRect groupRect = GetRect();
nsRect oldGroupRect = groupRect;
nsRect oldGroupVisualOverflow = GetVisualOverflowRect();
groupRect.BSize(wm) -= bGroupOffset;
groupRect.height -= yGroupOffset;
if (didCollapse) {
// add back the cellspacing between rowgroups
groupRect.BSize(wm) += tableFrame->GetRowSpacing(GetStartRowIndex() +
GetRowCount());
groupRect.height += tableFrame->GetRowSpacing(GetStartRowIndex() +
GetRowCount());
}
groupRect.BStart(wm) -= aBTotalOffset;
groupRect.ISize(wm) = aISize;
groupRect.y -= aYTotalOffset;
groupRect.width = aWidth;
if (aBTotalOffset != 0) {
if (aYTotalOffset != 0) {
InvalidateFrameSubtree();
}
SetRect(wm, groupRect, containerWidth);
overflow.UnionAllWith(nsRect(0, 0, groupRect.Width(wm),
groupRect.Height(wm)));
FinishAndStoreOverflow(overflow, groupRect.Size(wm).GetPhysicalSize(wm));
SetRect(groupRect);
overflow.UnionAllWith(nsRect(0, 0, groupRect.width, groupRect.height));
FinishAndStoreOverflow(overflow, groupRect.Size());
nsTableFrame::RePositionViews(this);
nsTableFrame::InvalidateTableFrame(this, oldGroupRect, oldGroupVisualOverflow,
false);
return bGroupOffset;
return yGroupOffset;
}
// Move a child that was skipped during a reflow.
@ -896,14 +858,13 @@ nsTableRowGroupFrame::SlideChild(nsRowGroupReflowState& aReflowState,
nsIFrame* aKidFrame)
{
// Move the frame if we need to
WritingMode wm = aReflowState.reflowState.GetWritingMode();
LogicalPoint oldPosition = aKidFrame->GetLogicalNormalPosition(wm, 0);
LogicalPoint newPosition = oldPosition;
newPosition.B(wm) = aReflowState.bCoord;
if (oldPosition.B(wm) != newPosition.B(wm)) {
nsPoint oldPosition = aKidFrame->GetNormalPosition();
nsPoint newPosition = oldPosition;
newPosition.y = aReflowState.y;
if (oldPosition.y != newPosition.y) {
aKidFrame->InvalidateFrameSubtree();
aReflowState.reflowState.ApplyRelativePositioning(&newPosition, 0);
aKidFrame->SetPosition(wm, newPosition, 0);
aReflowState.reflowState.ApplyRelativePositioning(&newPosition);
aKidFrame->SetPosition(newPosition);
nsTableFrame::RePositionViews(aKidFrame);
aKidFrame->InvalidateFrameSubtree();
}
@ -939,14 +900,14 @@ nsTableRowGroupFrame::SplitSpanningCells(nsPresContext& aPresContext,
nsTableRowFrame& aFirstRow,
nsTableRowFrame& aLastRow,
bool aFirstRowIsTopOfPage,
nscoord aSpanningRowBEnd,
nscoord aSpanningRowBottom,
nsTableRowFrame*& aContRow,
nsTableRowFrame*& aFirstTruncatedRow,
nscoord& aDesiredBSize)
nscoord& aDesiredHeight)
{
NS_ASSERTION(aSpanningRowBEnd >= 0, "Can't split negative bsizes");
NS_ASSERTION(aSpanningRowBottom >= 0, "Can't split negative heights");
aFirstTruncatedRow = nullptr;
aDesiredBSize = 0;
aDesiredHeight = 0;
const bool borderCollapse = aTable.IsBorderCollapse();
int32_t lastRowIndex = aLastRow.GetRowIndex();
@ -961,14 +922,14 @@ nsTableRowGroupFrame::SplitSpanningCells(nsPresContext& aPresContext,
for (nsTableCellFrame* cell = row->GetFirstCell(); cell; cell = cell->GetNextCell()) {
int32_t rowSpan = aTable.GetEffectiveRowSpan(rowIndex, *cell);
// Only reflow rowspan > 1 cells which span aLastRow. Those which don't span aLastRow
// were reflowed correctly during the unconstrained bsize reflow.
// were reflowed correctly during the unconstrained height reflow.
if ((rowSpan > 1) && (rowIndex + rowSpan > lastRowIndex)) {
haveRowSpan = true;
nsReflowStatus status;
// Ask the row to reflow the cell to the bsize of all the rows it spans up through aLastRow
// cellAvailBSize is the space between the row group start and the end of the page
nscoord cellAvailBSize = aSpanningRowBEnd - rowPos.y;
NS_ASSERTION(cellAvailBSize >= 0, "No space for cell?");
// Ask the row to reflow the cell to the height of all the rows it spans up through aLastRow
// aAvailHeight is the space between the row group start and the end of the page
nscoord cellAvailHeight = aSpanningRowBottom - rowPos.y;
NS_ASSERTION(cellAvailHeight >= 0, "No space for cell?");
bool isTopOfPage = (row == &aFirstRow) && aFirstRowIsTopOfPage;
nsRect rowRect = row->GetNormalRect();
@ -976,7 +937,7 @@ nsTableRowGroupFrame::SplitSpanningCells(nsPresContext& aPresContext,
std::max(aReflowState.AvailableHeight() - rowRect.y,
0));
// don't let the available height exceed what
// CalculateRowBSizes set for it
// CalculateRowHeights set for it
rowAvailSize.height = std::min(rowAvailSize.height, rowRect.height);
nsHTMLReflowState rowReflowState(&aPresContext, aReflowState, row,
LogicalSize(row->GetWritingMode(),
@ -986,12 +947,12 @@ nsTableRowGroupFrame::SplitSpanningCells(nsPresContext& aPresContext,
InitChildReflowState(aPresContext, borderCollapse, rowReflowState);
rowReflowState.mFlags.mIsTopOfPage = isTopOfPage; // set top of page
nscoord cellBSize = row->ReflowCellFrame(&aPresContext, rowReflowState,
nscoord cellHeight = row->ReflowCellFrame(&aPresContext, rowReflowState,
isTopOfPage, cell,
cellAvailBSize, status);
aDesiredBSize = std::max(aDesiredBSize, rowPos.y + cellBSize);
cellAvailHeight, status);
aDesiredHeight = std::max(aDesiredHeight, rowPos.y + cellHeight);
if (NS_FRAME_IS_COMPLETE(status)) {
if (cellBSize > cellAvailBSize) {
if (cellHeight > cellAvailHeight) {
aFirstTruncatedRow = row;
if ((row != &aFirstRow) || !aFirstRowIsTopOfPage) {
// return now, since we will be getting another reflow after either (1) row is
@ -1021,7 +982,7 @@ nsTableRowGroupFrame::SplitSpanningCells(nsPresContext& aPresContext,
}
}
if (!haveRowSpan) {
aDesiredBSize = aLastRow.GetNormalRect().YMost();
aDesiredHeight = aLastRow.GetNormalRect().YMost();
}
}
@ -1101,7 +1062,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
// in the available space
for (nsTableRowFrame* rowFrame = firstRowThisPage; rowFrame; rowFrame = rowFrame->GetNextRow()) {
bool rowIsOnPage = true;
nscoord cellSpacingB = aTableFrame->GetRowSpacing(rowFrame->GetRowIndex());
nscoord cellSpacingY = aTableFrame->GetRowSpacing(rowFrame->GetRowIndex());
nsRect rowRect = rowFrame->GetNormalRect();
// See if the row fits on this page
if (rowRect.YMost() > availHeight) {
@ -1157,7 +1118,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
if (contRow) {
aDesiredSize.Height() += rowMetrics.Height();
if (prevRowFrame)
aDesiredSize.Height() += cellSpacingB;
aDesiredSize.Height() += cellSpacingY;
}
else return NS_ERROR_NULL_POINTER;
}
@ -1184,7 +1145,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
}
aDesiredSize.Height() += rowMetrics.Height();
if (prevRowFrame)
aDesiredSize.Height() += cellSpacingB;
aDesiredSize.Height() += cellSpacingY;
NS_WARNING("data loss - complete row needed more height than available, on top of page");
}
else {
@ -1223,10 +1184,10 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
// reflow the cells with rowspan >1 that occur on the page
nsTableRowFrame* firstTruncatedRow;
nscoord bMost;
nscoord yMost;
SplitSpanningCells(*aPresContext, aReflowState, *aTableFrame, *firstRowThisPage,
*lastRowThisPage, aReflowState.mFlags.mIsTopOfPage, spanningRowBottom, contRow,
firstTruncatedRow, bMost);
firstTruncatedRow, yMost);
if (firstTruncatedRow) {
// A rowspan >1 cell did not fit (and could not split) in the space we gave it
if (firstTruncatedRow == firstRowThisPage) {
@ -1280,7 +1241,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
} // if (firstTruncatedRow == firstRowThisPage)
} // if (firstTruncatedRow)
else {
aDesiredSize.Height() = std::max(aDesiredSize.Height(), bMost);
aDesiredSize.Height() = std::max(aDesiredSize.Height(), yMost);
if (contRow) {
aStatus = NS_FRAME_NOT_COMPLETE;
}
@ -1372,13 +1333,11 @@ nsTableRowGroupFrame::Reflow(nsPresContext* aPresContext,
NS_FRAME_SET_INCOMPLETE(aStatus);
}
SetHasStyleBSize((NS_UNCONSTRAINEDSIZE != aReflowState.ComputedBSize()) &&
(aReflowState.ComputedBSize() > 0));
SetHasStyleHeight((NS_UNCONSTRAINEDSIZE != aReflowState.ComputedHeight()) &&
(aReflowState.ComputedHeight() > 0));
// Just set our isize to what was available.
// The table will calculate the isize and not use our value.
WritingMode wm = aReflowState.GetWritingMode();
aDesiredSize.ISize(wm) = aReflowState.AvailableISize();
// just set our width to what was available. The table will calculate the width and not use our value.
aDesiredSize.Width() = aReflowState.AvailableWidth();
aDesiredSize.UnionOverflowAreasWithDesiredBounds();
@ -1554,16 +1513,16 @@ nsTableRowGroupFrame::GetUsedPadding() const
}
nscoord
nsTableRowGroupFrame::GetBSizeBasis(const nsHTMLReflowState& aReflowState)
nsTableRowGroupFrame::GetHeightBasis(const nsHTMLReflowState& aReflowState)
{
nscoord result = 0;
nsTableFrame* tableFrame = GetTableFrame();
int32_t startRowIndex = GetStartRowIndex();
if ((aReflowState.ComputedBSize() > 0) && (aReflowState.ComputedBSize() < NS_UNCONSTRAINEDSIZE)) {
if ((aReflowState.ComputedHeight() > 0) && (aReflowState.ComputedHeight() < NS_UNCONSTRAINEDSIZE)) {
nscoord cellSpacing = tableFrame->GetRowSpacing(startRowIndex,
std::max(startRowIndex,
startRowIndex + GetRowCount() - 1));
result = aReflowState.ComputedBSize() - cellSpacing;
result = aReflowState.ComputedHeight() - cellSpacing;
}
else {
const nsHTMLReflowState* parentRS = aReflowState.parentReflowState;
@ -1571,9 +1530,9 @@ nsTableRowGroupFrame::GetBSizeBasis(const nsHTMLReflowState& aReflowState)
parentRS = parentRS->parentReflowState;
}
if (parentRS && (tableFrame == parentRS->frame) &&
(parentRS->ComputedBSize() > 0) && (parentRS->ComputedBSize() < NS_UNCONSTRAINEDSIZE)) {
(parentRS->ComputedHeight() > 0) && (parentRS->ComputedHeight() < NS_UNCONSTRAINEDSIZE)) {
nscoord cellSpacing = tableFrame->GetRowSpacing(-1, tableFrame->GetRowCount());
result = parentRS->ComputedBSize() - cellSpacing;
result = parentRS->ComputedHeight() - cellSpacing;
}
}
@ -1665,21 +1624,21 @@ nsTableRowGroupFrame::GetBCBorderWidth(WritingMode aWM)
return border;
}
void nsTableRowGroupFrame::SetContinuousBCBorderWidth(LogicalSide aForSide,
void nsTableRowGroupFrame::SetContinuousBCBorderWidth(uint8_t aForSide,
BCPixelSize aPixelValue)
{
switch (aForSide) {
case eLogicalSideIEnd:
mIEndContBorderWidth = aPixelValue;
case NS_SIDE_RIGHT:
mRightContBorderWidth = aPixelValue;
return;
case eLogicalSideBEnd:
mBEndContBorderWidth = aPixelValue;
case NS_SIDE_BOTTOM:
mBottomContBorderWidth = aPixelValue;
return;
case eLogicalSideIStart:
mIStartContBorderWidth = aPixelValue;
case NS_SIDE_LEFT:
mLeftContBorderWidth = aPixelValue;
return;
default:
NS_ERROR("invalid LogicalSide argument");
NS_ERROR("invalid NS_SIDE argument");
}
}

View File

@ -23,20 +23,18 @@ struct nsRowGroupReflowState {
nsTableFrame* tableFrame;
// The available size (computed from the parent)
mozilla::LogicalSize availSize;
nsSize availSize;
// Running block-offset
nscoord bCoord;
// Running y-offset
nscoord y;
nsRowGroupReflowState(const nsHTMLReflowState& aReflowState,
nsTableFrame* aTableFrame)
: reflowState(aReflowState)
, tableFrame(aTableFrame)
, availSize(aReflowState.GetWritingMode(),
aReflowState.AvailableISize(),
aReflowState.AvailableBSize())
, bCoord(0)
:reflowState(aReflowState), tableFrame(aTableFrame)
{
availSize.width = reflowState.AvailableWidth();
availSize.height = reflowState.AvailableHeight();
y = 0;
}
~nsRowGroupReflowState() {}
@ -100,11 +98,11 @@ public:
const nsDisplayListSet& aLists) override;
/** calls Reflow for all of its child rows.
* Rows are all set to the same isize and stacked in the block direction.
* Rows are all set to the same width and stacked vertically.
* <P> rows are not split unless absolutely necessary.
*
* @param aDesiredSize isize set to isize of rows, bsize set to
* sum of bsize of rows that fit in AvailableBSize.
* @param aDesiredSize width set to width of rows, height set to
* sum of height of rows that fit in aMaxSize.height.
*
* @see nsIFrame::Reflow
*/
@ -160,38 +158,36 @@ public:
/**
* Get the total bsize of all the row rects
* Get the total height of all the row rects
*/
nscoord GetBSizeBasis(const nsHTMLReflowState& aReflowState);
nscoord GetHeightBasis(const nsHTMLReflowState& aReflowState);
mozilla::LogicalMargin GetBCBorderWidth(mozilla::WritingMode aWM);
/**
* Gets inner border widths before collapsing with cell borders
* Caller must get bstart border from previous row group or from table
* GetContinuousBCBorderWidth will not overwrite aBorder.BStart()
* Caller must get top border from previous row group or from table
* GetContinuousBCBorderWidth will not overwrite aBorder.top
* see nsTablePainter about continuous borders
*/
void GetContinuousBCBorderWidth(mozilla::WritingMode aWM,
mozilla::LogicalMargin& aBorder);
void GetContinuousBCBorderWidth(nsMargin& aBorder);
/**
* Sets full border widths before collapsing with cell borders
* @param aForSide - side to set; only IEnd, IStart, BEnd are valid
* @param aForSide - side to set; only right, left, and bottom valid
*/
void SetContinuousBCBorderWidth(mozilla::LogicalSide aForSide,
void SetContinuousBCBorderWidth(uint8_t aForSide,
BCPixelSize aPixelValue);
/**
* Adjust to the effect of visibibility:collapse on the row group and
* its children
* @return additional shift bstart-wards that should be applied
* to subsequent rowgroups due to rows and this
* rowgroup being collapsed
* @param aBTotalOffset the total amount that the rowgroup is shifted
* @param aISize new isize of the rowgroup
* @return additional shift upward that should be applied to
* subsequent rowgroups due to rows and this rowgroup
* being collapsed
* @param aYTotalOffset the total amount that the rowgroup is shifted up
* @param aWidth new width of the rowgroup
*/
nscoord CollapseRowGroupIfNecessary(nscoord aBTotalOffset,
nscoord aISize);
nscoord CollapseRowGroupIfNecessary(nscoord aYTotalOffset,
nscoord aWidth);
// nsILineIterator methods
public:
@ -351,16 +347,14 @@ protected:
void PlaceChild(nsPresContext* aPresContext,
nsRowGroupReflowState& aReflowState,
nsIFrame* aKidFrame,
mozilla::WritingMode aWM,
const mozilla::LogicalPoint& aKidPosition,
nscoord aContainerWidth,
nsPoint aKidPosition,
nsHTMLReflowMetrics& aDesiredSize,
const nsRect& aOriginalKidRect,
const nsRect& aOriginalKidVisualOverflow);
void CalculateRowBSizes(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState);
void CalculateRowHeights(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState);
void DidResizeRows(nsHTMLReflowMetrics& aDesiredSize);
@ -411,15 +405,15 @@ protected:
private:
// border widths in pixels in the collapsing border model
BCPixelSize mIEndContBorderWidth;
BCPixelSize mBEndContBorderWidth;
BCPixelSize mIStartContBorderWidth;
BCPixelSize mRightContBorderWidth;
BCPixelSize mBottomContBorderWidth;
BCPixelSize mLeftContBorderWidth;
public:
bool IsRepeatable() const;
void SetRepeatable(bool aRepeatable);
bool HasStyleBSize() const;
void SetHasStyleBSize(bool aValue);
void SetRepeatable(bool aRepeatable);
bool HasStyleHeight() const;
void SetHasStyleHeight(bool aValue);
bool HasInternalBreakBefore() const;
bool HasInternalBreakAfter() const;
};
@ -439,12 +433,12 @@ inline void nsTableRowGroupFrame::SetRepeatable(bool aRepeatable)
}
}
inline bool nsTableRowGroupFrame::HasStyleBSize() const
inline bool nsTableRowGroupFrame::HasStyleHeight() const
{
return (mState & NS_ROWGROUP_HAS_STYLE_HEIGHT) == NS_ROWGROUP_HAS_STYLE_HEIGHT;
}
inline void nsTableRowGroupFrame::SetHasStyleBSize(bool aValue)
inline void nsTableRowGroupFrame::SetHasStyleHeight(bool aValue)
{
if (aValue) {
mState |= NS_ROWGROUP_HAS_STYLE_HEIGHT;
@ -454,15 +448,15 @@ inline void nsTableRowGroupFrame::SetHasStyleBSize(bool aValue)
}
inline void
nsTableRowGroupFrame::GetContinuousBCBorderWidth(mozilla::WritingMode aWM,
mozilla::LogicalMargin& aBorder)
nsTableRowGroupFrame::GetContinuousBCBorderWidth(nsMargin& aBorder)
{
int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
aBorder.IEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
mIEndContBorderWidth);
aBorder.BEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
mBEndContBorderWidth);
aBorder.IStart(aWM) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
mIStartContBorderWidth);
aBorder.right = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
mRightContBorderWidth);
aBorder.bottom = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
mBottomContBorderWidth);
aBorder.left = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
mLeftContBorderWidth);
return;
}
#endif