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 dompdf#1356
Fixes dompdf#1617

Co-authored-by: David Sickmiller <david@sickmiller.com>
  • Loading branch information
Mellthas and davidsickmiller committed Sep 13, 2021
1 parent 7671de2 commit 41157d6
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, 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 41157d6

Please sign in to comment.