Skip to content

Commit

Permalink
Fix orphans check
Browse files Browse the repository at this point in the history
This effectively forbids line breaks before the first line. Also, check
the orphans property on the block parent, as it only applies to block container
elements per spec.

Based on work in #1356
Fixes #1617

Co-authored-by: David Sickmiller <david@sickmiller.com>
  • Loading branch information
2 people authored and bsweeney committed Sep 18, 2021
1 parent 5a4e350 commit d1d7669
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/FrameDecorator/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,12 @@ protected function _page_break_allowed(Frame $frame)

// Rule C
$block_parent = $frame->find_block_parent();
if (count($block_parent->get_line_boxes()) < $frame->get_style()->orphans) {
$parent_style = $block_parent->get_style();
// The line number of the frame can be less than the current
// number of line boxes, in case we are backtracking. As long as
// we are not checking for widows yet, just checking against the
// number of line boxes is sufficient in most cases, though.
if (count($block_parent->get_line_boxes()) <= $parent_style->orphans) {
Helpers::dompdf_debug("page-break", "orphans");

return false;
Expand Down

0 comments on commit d1d7669

Please sign in to comment.