Bug 1866836 Part 2 - Pass border and padding down from nsTableFrame::Reflow(). r=layout-reviewers,emilio

In Bug 1863421, we'll apply ApplySkipSides() for `borderPadding`. This patch
ensures we use the correct skipped border and padding everywhere.

This patch doesn't change behavior.

Differential Revision: https://phabricator.services.mozilla.com/D194789
This commit is contained in:
Ting-Yu Lin
2023-11-27 23:10:40 +00:00
parent a9cee7aceb
commit 4efe14dae3
2 changed files with 31 additions and 33 deletions

View File

@@ -68,7 +68,8 @@ using mozilla::gfx::ToDeviceColor;
namespace mozilla {
struct TableReflowInput final {
TableReflowInput(const ReflowInput& aReflowInput, TableReflowMode aMode)
TableReflowInput(const ReflowInput& aReflowInput,
const LogicalMargin& aBorderPadding, TableReflowMode aMode)
: mReflowInput(aReflowInput),
mWM(aReflowInput.GetWritingMode()),
mAvailSize(mWM) {
@@ -76,22 +77,17 @@ struct TableReflowInput final {
"TableReflowInput should only be created for nsTableFrame");
auto* table = static_cast<nsTableFrame*>(mReflowInput.mFrame);
// Bug 1863421: We need to call ApplySkipSides() for borderPadding.
// Otherwise, mAvailSize will be wrong in a continuation.
LogicalMargin borderPadding =
mReflowInput.ComputedLogicalBorderPadding(mWM);
mICoord = borderPadding.IStart(mWM) + table->GetColSpacing(-1);
mICoord = aBorderPadding.IStart(mWM) + table->GetColSpacing(-1);
mAvailSize.ISize(mWM) =
std::max(0, mReflowInput.ComputedISize() - table->GetColSpacing(-1) -
table->GetColSpacing(table->GetColCount()));
// Bug 1863421 will fix border-spacing issue in the block-axis in printing.
AdvanceBCoord(borderPadding.BStart(mWM));
AdvanceBCoord(aBorderPadding.BStart(mWM));
mAvailSize.BSize(mWM) = aMode == TableReflowMode::Measuring
? NS_UNCONSTRAINEDSIZE
: mReflowInput.AvailableBSize();
ReduceAvailableBSizeBy(borderPadding.BEnd(mWM) + table->GetRowSpacing(-1) +
ReduceAvailableBSizeBy(aBorderPadding.BEnd(mWM) + table->GetRowSpacing(-1) +
table->GetRowSpacing(table->GetRowCount()));
}
@@ -1651,6 +1647,10 @@ void nsTableFrame::Reflow(nsPresContext* aPresContext,
bool haveDesiredBSize = false;
SetHaveReflowedColGroups(false);
// Bug 1863421: We need to call ApplySkipSides() for borderPadding so that it
// is correct in a table continuation.
LogicalMargin borderPadding = aReflowInput.ComputedLogicalBorderPadding(wm);
// The tentative width is the width we assumed for the table when the child
// frames were positioned (which only matters in vertical-rl mode, because
// they're positioned relative to the right-hand edge). Then, after reflowing
@@ -1691,11 +1691,10 @@ void nsTableFrame::Reflow(nsPresContext* aPresContext,
// when there is a specified table bsize
if (!GetPrevInFlow() &&
NS_UNCONSTRAINEDSIZE != aReflowInput.AvailableBSize()) {
LogicalMargin bp = aReflowInput.ComputedLogicalBorderPadding(wm);
nscoord tableSpecifiedBSize =
CalcBorderBoxBSize(aReflowInput, bp, NS_UNCONSTRAINEDSIZE);
if (tableSpecifiedBSize > 0 &&
tableSpecifiedBSize != NS_UNCONSTRAINEDSIZE) {
nscoord tableSpecifiedBSize = CalcBorderBoxBSize(
aReflowInput, borderPadding, NS_UNCONSTRAINEDSIZE);
if (tableSpecifiedBSize != NS_UNCONSTRAINEDSIZE &&
tableSpecifiedBSize > 0) {
needToInitiateSpecialReflow = true;
}
}
@@ -1711,8 +1710,8 @@ void nsTableFrame::Reflow(nsPresContext* aPresContext,
const TableReflowMode firstReflowMode = needToInitiateSpecialReflow
? TableReflowMode::Measuring
: TableReflowMode::Final;
ReflowTable(aDesiredSize, aReflowInput, firstReflowMode, lastChildReflowed,
aStatus);
ReflowTable(aDesiredSize, aReflowInput, borderPadding, firstReflowMode,
lastChildReflowed, aStatus);
// When in vertical-rl mode, there may be two kinds of scenarios in which
// the positioning of all the children need to be adjusted along the x-axis
@@ -1748,17 +1747,15 @@ void nsTableFrame::Reflow(nsPresContext* aPresContext,
ReflowInput& mutable_rs = const_cast<ReflowInput&>(aReflowInput);
// distribute extra block-direction space to rows
aDesiredSize.BSize(wm) = CalcDesiredBSize(aReflowInput);
aDesiredSize.BSize(wm) = CalcDesiredBSize(aReflowInput, borderPadding);
mutable_rs.mFlags.mSpecialBSizeReflow = true;
ReflowTable(aDesiredSize, aReflowInput, TableReflowMode::Final,
lastChildReflowed, aStatus);
ReflowTable(aDesiredSize, aReflowInput, borderPadding,
TableReflowMode::Final, lastChildReflowed, aStatus);
if (lastChildReflowed && aStatus.IsIncomplete()) {
// if there is an incomplete child, then set the desired bsize
// to include it but not the next one
LogicalMargin borderPadding =
aReflowInput.ComputedLogicalBorderPadding(wm);
aDesiredSize.BSize(wm) =
borderPadding.BEnd(wm) + GetRowSpacing(GetRowCount()) +
lastChildReflowed->GetLogicalNormalRect(wm, containerSize).BEnd(wm);
@@ -1770,10 +1767,9 @@ void nsTableFrame::Reflow(nsPresContext* aPresContext,
}
aDesiredSize.ISize(wm) =
aReflowInput.ComputedISize() +
aReflowInput.ComputedLogicalBorderPadding(wm).IStartEnd(wm);
aReflowInput.ComputedISize() + borderPadding.IStartEnd(wm);
if (!haveDesiredBSize) {
aDesiredSize.BSize(wm) = CalcDesiredBSize(aReflowInput);
aDesiredSize.BSize(wm) = CalcDesiredBSize(aReflowInput, borderPadding);
}
if (IsRowInserted()) {
ProcessRowInserted(aDesiredSize.BSize(wm));
@@ -1801,7 +1797,6 @@ void nsTableFrame::Reflow(nsPresContext* aPresContext,
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, kid);
}
LogicalMargin borderPadding = aReflowInput.ComputedLogicalBorderPadding(wm);
SetColumnDimensions(aDesiredSize.BSize(wm), wm, borderPadding,
aDesiredSize.PhysicalSize());
NS_WARNING_ASSERTION(NS_UNCONSTRAINEDSIZE != aReflowInput.AvailableISize(),
@@ -1908,6 +1903,7 @@ bool nsTableFrame::ComputeCustomOverflow(OverflowAreas& aOverflowAreas) {
void nsTableFrame::ReflowTable(ReflowOutput& aDesiredSize,
const ReflowInput& aReflowInput,
const LogicalMargin& aBorderPadding,
TableReflowMode aReflowMode,
nsIFrame*& aLastChildReflowed,
nsReflowStatus& aStatus) {
@@ -1917,7 +1913,7 @@ void nsTableFrame::ReflowTable(ReflowOutput& aDesiredSize,
mTableLayoutStrategy->ComputeColumnISizes(aReflowInput);
}
TableReflowInput reflowInput(aReflowInput, aReflowMode);
TableReflowInput reflowInput(aReflowInput, aBorderPadding, aReflowMode);
ReflowChildren(reflowInput, aStatus, aLastChildReflowed,
aDesiredSize.mOverflowAreas);
@@ -2995,9 +2991,9 @@ void nsTableFrame::ReflowColGroups(gfxContext* aRenderingContext) {
}
}
nscoord nsTableFrame::CalcDesiredBSize(const ReflowInput& aReflowInput) {
nscoord nsTableFrame::CalcDesiredBSize(const ReflowInput& aReflowInput,
const LogicalMargin& aBorderPadding) {
WritingMode wm = aReflowInput.GetWritingMode();
LogicalMargin borderPadding = aReflowInput.ComputedLogicalBorderPadding(wm);
// get the natural bsize based on the last child's (row group) rect
RowGroupArray rowGroups = OrderedRowGroups();
@@ -3006,15 +3002,15 @@ nscoord nsTableFrame::CalcDesiredBSize(const ReflowInput& aReflowInput) {
// empty tables should not have a size in quirks mode
return 0;
}
return CalcBorderBoxBSize(aReflowInput, borderPadding,
borderPadding.BStartEnd(wm));
return CalcBorderBoxBSize(aReflowInput, aBorderPadding,
aBorderPadding.BStartEnd(wm));
}
nsTableCellMap* cellMap = GetCellMap();
MOZ_ASSERT(cellMap);
int32_t rowCount = cellMap->GetRowCount();
int32_t colCount = cellMap->GetColCount();
nscoord desiredBSize = borderPadding.BStartEnd(wm);
nscoord desiredBSize = aBorderPadding.BStartEnd(wm);
if (rowCount > 0 && colCount > 0) {
desiredBSize += GetRowSpacing(-1);
for (uint32_t rgIdx = 0; rgIdx < rowGroups.Length(); rgIdx++) {
@@ -3027,7 +3023,7 @@ nscoord nsTableFrame::CalcDesiredBSize(const ReflowInput& aReflowInput) {
// see if a specified table bsize requires dividing additional space to rows
if (!GetPrevInFlow()) {
nscoord bSize =
CalcBorderBoxBSize(aReflowInput, borderPadding, desiredBSize);
CalcBorderBoxBSize(aReflowInput, aBorderPadding, desiredBSize);
if (bSize > desiredBSize) {
// proportionately distribute the excess bsize to unconstrained rows in
// each unconstrained row group.