暂无描述

inline_frame_decorator.cls.php 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * @package dompdf
  4. * @link http://dompdf.github.com/
  5. * @author Benj Carson <benjcarson@digitaljunkies.ca>
  6. * @author Helmut Tischer <htischer@weihenstephan.org>
  7. * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  8. */
  9. /**
  10. * Decorates frames for inline layout
  11. *
  12. * @access private
  13. * @package dompdf
  14. */
  15. class Inline_Frame_Decorator extends Frame_Decorator {
  16. function __construct(Frame $frame, DOMPDF $dompdf) { parent::__construct($frame, $dompdf); }
  17. function split(Frame $frame = null, $force_pagebreak = false) {
  18. if ( is_null($frame) ) {
  19. $this->get_parent()->split($this, $force_pagebreak);
  20. return;
  21. }
  22. if ( $frame->get_parent() !== $this )
  23. throw new DOMPDF_Exception("Unable to split: frame is not a child of this one.");
  24. $split = $this->copy( $this->_frame->get_node()->cloneNode() );
  25. $this->get_parent()->insert_child_after($split, $this);
  26. // Unset the current node's right style properties
  27. $style = $this->_frame->get_style();
  28. $style->margin_right = 0;
  29. $style->padding_right = 0;
  30. $style->border_right_width = 0;
  31. // Unset the split node's left style properties since we don't want them
  32. // to propagate
  33. $style = $split->get_style();
  34. $style->margin_left = 0;
  35. $style->padding_left = 0;
  36. $style->border_left_width = 0;
  37. //On continuation of inline element on next line,
  38. //don't repeat non-vertically repeatble background images
  39. //See e.g. in testcase image_variants, long desriptions
  40. if ( ($url = $style->background_image) && $url !== "none"
  41. && ($repeat = $style->background_repeat) && $repeat !== "repeat" && $repeat !== "repeat-y"
  42. ) {
  43. $style->background_image = "none";
  44. }
  45. // Add $frame and all following siblings to the new split node
  46. $iter = $frame;
  47. while ($iter) {
  48. $frame = $iter;
  49. $iter = $iter->get_next_sibling();
  50. $frame->reset();
  51. $split->append_child($frame);
  52. }
  53. $page_breaks = array("always", "left", "right");
  54. $frame_style = $frame->get_style();
  55. if( $force_pagebreak ||
  56. in_array($frame_style->page_break_before, $page_breaks) ||
  57. in_array($frame_style->page_break_after, $page_breaks) ) {
  58. $this->get_parent()->split($split, true);
  59. }
  60. }
  61. }