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: Float box may appear twice at page break (Regression in v2.30.5) #1423

Merged
merged 1 commit into from
Nov 21, 2024
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
5 changes: 3 additions & 2 deletions packages/core/src/vivliostyle/layout-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ export function removeFollowingSiblings(
prevSibling = lastChild.previousSibling;
if (
lastChild.nodeType === 1 &&
(lastChild as Element).hasAttribute("data-vivliostyle-float-box")
(lastChild as Element).hasAttribute("data-vivliostyle-float-box-moved") &&
(viewNode as HTMLElement).style?.display === "inline"
) {
// Do not remove float box (Issue #1383)
// Do not remove float box moved after parent inline (Issue #1383, #1422)
continue;
}
parentNode.removeChild(lastChild);
Expand Down
10 changes: 7 additions & 3 deletions packages/core/src/vivliostyle/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,6 @@ export class Column extends VtreeImpl.Container implements Layout.Column {
nodeContext.vertical,
nodeContext.direction,
);
element.setAttribute("data-vivliostyle-float-box", "true");
Base.setCSSProperty(element, "float", "none");
Base.setCSSProperty(element, "display", "inline-block");
Base.setCSSProperty(element, "vertical-align", "top");
Expand Down Expand Up @@ -1119,9 +1118,14 @@ export class Column extends VtreeImpl.Container implements Layout.Column {
// relative', the absolute positioning of the float gets broken, since
// the inline parent can be pushed horizontally by exclusion floats
// after the layout of the float is done.
if (!nodeContext.firstPseudo) {
if (parent !== nodeContext.parent && !nodeContext.firstPseudo) {
// Unless float is specified on ::first-letter (Fix for issue #923)
parent.viewNode.appendChild(nodeContext.viewNode);
parent.viewNode.appendChild(element);

// Mark the moved float box so that it is not removed wrongly
// when page breaking occurs inside the inline parent.
// (Issue #1383, #1422)
element.setAttribute("data-vivliostyle-float-box-moved", "true");
}
}

Expand Down