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
8 namespace Dompdf\FrameReflower
;
11 use Dompdf\FrameDecorator\Block
as BlockFrameDecorator
;
12 use Dompdf\FrameDecorator\Text
as TextFrameDecorator
;
15 * Reflows inline frames
19 class Inline
extends AbstractFrameReflower
26 function __construct(Frame
$frame)
28 parent
::__construct($frame);
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()) {
46 $style = $frame->get_style();
49 $this->_set_content();
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
;
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);
83 * Determine current frame width based on contents
87 public function calculate_auto_width()
91 foreach ($this->_frame
->get_children() as $child) {
92 if ($child->get_original_style()->width
== 'auto') {
93 $width +
= $child->calculate_auto_width();
95 $width +
= $child->get_margin_width();
99 $this->_frame
->get_style()->width
= $width;
101 return $this->_frame
->get_margin_width();