inline_frame_reflower.cls.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /**
  9. * Reflows inline frames
  10. *
  11. * @access private
  12. * @package dompdf
  13. */
  14. class Inline_Frame_Reflower extends Frame_Reflower {
  15. function __construct(Frame $frame) { parent::__construct($frame); }
  16. //........................................................................
  17. function reflow(Block_Frame_Decorator $block = null) {
  18. $frame = $this->_frame;
  19. // Check if a page break is forced
  20. $page = $frame->get_root();
  21. $page->check_forced_page_break($frame);
  22. if ( $page->is_full() )
  23. return;
  24. $style = $frame->get_style();
  25. // Generated content
  26. $this->_set_content();
  27. $frame->position();
  28. $cb = $frame->get_containing_block();
  29. // Add our margin, padding & border to the first and last children
  30. if ( ($f = $frame->get_first_child()) && $f instanceof Text_Frame_Decorator ) {
  31. $f_style = $f->get_style();
  32. $f_style->margin_left = $style->margin_left;
  33. $f_style->padding_left = $style->padding_left;
  34. $f_style->border_left = $style->border_left;
  35. }
  36. if ( ($l = $frame->get_last_child()) && $l instanceof Text_Frame_Decorator ) {
  37. $l_style = $l->get_style();
  38. $l_style->margin_right = $style->margin_right;
  39. $l_style->padding_right = $style->padding_right;
  40. $l_style->border_right = $style->border_right;
  41. }
  42. if ( $block ) {
  43. $block->add_frame_to_line($this->_frame);
  44. }
  45. // Set the containing blocks and reflow each child. The containing
  46. // block is not changed by line boxes.
  47. foreach ( $frame->get_children() as $child ) {
  48. $child->set_containing_block($cb);
  49. $child->reflow($block);
  50. }
  51. }
  52. }