Skip to content

Commit

Permalink
Merge pull request #691 from vivliostyle/fix/issue690
Browse files Browse the repository at this point in the history
fix: top margin at forced break was ignored when target-counter is used
  • Loading branch information
MurakamiShinyu authored Jan 24, 2021
2 parents ec1f1a4 + c8485ad commit 24c6347
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion packages/core/src/vivliostyle/vgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/
import * as Asserts from "./asserts";
import * as Base from "./base";
import * as Break from "./break";
import * as Css from "./css";
import * as CssCascade from "./css-cascade";
import * as CssProp from "./css-prop";
Expand Down Expand Up @@ -1265,7 +1266,7 @@ export class ViewFactory
? frontEdgeUnforcedBreakBlackListVert
: frontEdgeUnforcedBreakBlackListHor;
}
} else if (atUnforcedBreak) {
} else if (atUnforcedBreak && !this.isAtForcedBreak()) {
blackList = this.nodeContext.vertical
? frontEdgeUnforcedBreakBlackListVert
: frontEdgeUnforcedBreakBlackListHor;
Expand Down Expand Up @@ -1305,6 +1306,30 @@ export class ViewFactory
return frame.result();
}

/**
* Check if the current position is at a forced break
* (Fix for Issue #690)
*/
private isAtForcedBreak(): boolean {
for (
let nodeContext = this.nodeContext;
nodeContext && !nodeContext.after;
nodeContext = nodeContext.parent
) {
if (Break.isForcedBreakValue(nodeContext.breakBefore)) {
return true;
}
if (
nodeContext.parent &&
(nodeContext.parent.sourceNode as Element).firstElementChild !==
nodeContext.sourceNode
) {
break;
}
}
return false;
}

private processAfterIfcontinues(
element: Element,
cascStyle: CssCascade.ElementStyle,
Expand Down

1 comment on commit 24c6347

@vercel
Copy link

@vercel vercel bot commented on 24c6347 Jan 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.