function _getPagesTraverse(&$box, $penalty) { if (!is_a($box, 'GenericContainerBox')) { return array(); } $locations = array(); for ($i = 0, $content_size = count($box->content); $i < $content_size; $i++) { $previous_child =& PageBreakLocator::_getPrevious($i, $box->content, $content_size); $next_child =& PageBreakLocator::_getNext($i, $box->content, $content_size); $child =& $box->content[$i]; /** * Note that page-break-xxx properties apply to block-level elements only */ if (is_a($child, 'BRBox')) { // Do nothing } elseif ($child->isBlockLevel()) { $locations = array_merge($locations, PageBreakLocator::_getPagesTraverseBlock($child, $next_child, $previous_child, $penalty)); } elseif (is_a($child, 'TableCellBox')) { $null = null; $child_locations = PageBreakLocator::_getPagesTraverseBlock($child, $null, $null, $penalty); $locations = array_merge($locations, $child_locations); } elseif (is_a($child, 'InlineBox')) { $more_before = 0; $more_after = 0; if (is_a($previous_child, 'BRBox')) { $more_before = PageBreakLocator::_getMoreBefore($i, $box->content, $content_size); } if (is_a($next_child, 'BRBox')) { $more_after = PageBreakLocator::_getMoreAfter($i, $box->content, $content_size); } $locations = array_merge($locations, PageBreakLocator::_getPagesTraverseInline($child, $penalty, $more_before, $more_after)); } elseif (is_a($child, 'TableRowBox')) { $locations = array_merge($locations, PageBreakLocator::_getPagesTraverseTableRow($child, $penalty)); } } return $locations; }