Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Table cell with rowspan may disappear after page break #1441

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/core/src/vivliostyle/repetitive-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ export class RepetitiveElements
if (nodeContext && !this.affectTo(nodeContext)) {
return offset;
}
if (nodeContext && this.isAfterLastContent(nodeContext)) {
if (
!this.enableSkippingFooter &&
nodeContext &&
this.isAfterLastContent(nodeContext)
) {
offset += this.footerHeight;
}
if (!this.enableSkippingHeader) {
Expand Down
43 changes: 40 additions & 3 deletions packages/core/src/vivliostyle/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,48 @@ export class InsideTableRowBreakPosition extends BreakPosition.AbstractBreakPosi
const formattingContext = this.formattingContext;
const row = formattingContext.getRowByIndex(this.rowIndex);
let penalty = 0;
if (!formattingContext.isFreelyFragmentableRow(row)) {

const breakPositions = this.getAcceptableCellBreakPositions();
const cellFragments = this.getCellFragments();

// If there is a box break in a row-spanning cell, do not add penalty.
// This is to prevent the cell content from disappearing due to the situation
// that a box break occurs in a row-spanning cell but the row break fails.
// (Issue #1403)
const foundBoxBreakInRowSpanningCell = breakPositions.some(
(bp, i) =>
bp.breakPosition instanceof Layout.BoxBreakPosition &&
(cellFragments[i].cellNodeContext.sourceNode as HTMLTableCellElement)
.rowSpan > 1,
);
if (
!foundBoxBreakInRowSpanningCell &&
!formattingContext.isFreelyFragmentableRow(row)
) {
penalty += 10;
}
this.getAcceptableCellBreakPositions().forEach((bp) => {
penalty += bp.breakPosition.getMinBreakPenalty();

breakPositions.forEach((bp, i) => {
let penalty1 = bp.breakPosition.getMinBreakPenalty();
if (
foundBoxBreakInRowSpanningCell &&
bp.breakPosition instanceof BreakPosition.EdgeBreakPosition &&
bp.breakPosition.overflows &&
penalty1 >= 3
) {
// When a box break occurs in a row-spanning cell, the height of the row group decreases,
// and the overflows flag that was set before the box break may be no longer valid.
// So,check the overflow again, and if the cell does not overflow, reduce the penalty.
// (Issue #1403)
const overflows = cellFragments[i].column.checkOverflowAndSaveEdge(
bp.nodeContext,
null,
);
if (!overflows) {
penalty1 -= 3;
}
}
penalty += penalty1;
});
return penalty;
}
Expand Down
Loading