Skip to content

Commit

Permalink
fix: Float box may appear twice at page break (Regression in v2.30.5)
Browse files Browse the repository at this point in the history
- fix #1422
  • Loading branch information
MurakamiShinyu committed Nov 21, 2024
1 parent 8a2db8e commit 4d7caa5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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

0 comments on commit 4d7caa5

Please sign in to comment.