composer package updates
[openemr.git] / vendor / dompdf / dompdf / src / FrameReflower / Inline.php
blob68662a5741a93d9334e23996661ed6d243efcfb6
1 <?php
2 /**
3 * @package dompdf
4 * @link http://dompdf.github.com/
5 * @author Benj Carson <benjcarson@digitaljunkies.ca>
6 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7 */
8 namespace Dompdf\FrameReflower;
10 use Dompdf\Frame;
11 use Dompdf\FrameDecorator\Block as BlockFrameDecorator;
12 use Dompdf\FrameDecorator\Text as TextFrameDecorator;
14 /**
15 * Reflows inline frames
17 * @package dompdf
19 class Inline extends AbstractFrameReflower
22 /**
23 * Inline constructor.
24 * @param Frame $frame
26 function __construct(Frame $frame)
28 parent::__construct($frame);
31 /**
32 * @param BlockFrameDecorator|null $block
34 function reflow(BlockFrameDecorator $block = null)
36 $frame = $this->_frame;
38 // Check if a page break is forced
39 $page = $frame->get_root();
40 $page->check_forced_page_break($frame);
42 if ($page->is_full()) {
43 return;
46 $style = $frame->get_style();
48 // Generated content
49 $this->_set_content();
51 $frame->position();
53 $cb = $frame->get_containing_block();
55 // Add our margin, padding & border to the first and last children
56 if (($f = $frame->get_first_child()) && $f instanceof TextFrameDecorator) {
57 $f_style = $f->get_style();
58 $f_style->margin_left = $style->margin_left;
59 $f_style->padding_left = $style->padding_left;
60 $f_style->border_left = $style->border_left;
63 if (($l = $frame->get_last_child()) && $l instanceof TextFrameDecorator) {
64 $l_style = $l->get_style();
65 $l_style->margin_right = $style->margin_right;
66 $l_style->padding_right = $style->padding_right;
67 $l_style->border_right = $style->border_right;
70 if ($block) {
71 $block->add_frame_to_line($this->_frame);
74 // Set the containing blocks and reflow each child. The containing
75 // block is not changed by line boxes.
76 foreach ($frame->get_children() as $child) {
77 $child->set_containing_block($cb);
78 $child->reflow($block);
82 /**
83 * Determine current frame width based on contents
85 * @return float
87 public function calculate_auto_width()
89 $width = 0;
91 foreach ($this->_frame->get_children() as $child) {
92 if ($child->get_original_style()->width == 'auto') {
93 $width += $child->calculate_auto_width();
94 } else {
95 $width += $child->get_margin_width();
99 $this->_frame->get_style()->width = $width;
101 return $this->_frame->get_margin_width();