block_positioner.cls.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. * Positions block frames
  10. *
  11. * @access private
  12. * @package dompdf
  13. */
  14. class Block_Positioner extends Positioner {
  15. function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
  16. //........................................................................
  17. function position() {
  18. $frame = $this->_frame;
  19. $style = $frame->get_style();
  20. $cb = $frame->get_containing_block();
  21. $p = $frame->find_block_parent();
  22. if ( $p ) {
  23. $float = $style->float;
  24. $enable_css_float = $frame->get_dompdf()->get_option("enable_css_float");
  25. if ( !$enable_css_float || !$float || $float === "none" ) {
  26. $p->add_line(true);
  27. }
  28. $y = $p->get_current_line_box()->y;
  29. }
  30. else {
  31. $y = $cb["y"];
  32. }
  33. $x = $cb["x"];
  34. // Relative positionning
  35. if ( $style->position === "relative" ) {
  36. $top = $style->length_in_pt($style->top, $cb["h"]);
  37. //$right = $style->length_in_pt($style->right, $cb["w"]);
  38. //$bottom = $style->length_in_pt($style->bottom, $cb["h"]);
  39. $left = $style->length_in_pt($style->left, $cb["w"]);
  40. $x += $left;
  41. $y += $top;
  42. }
  43. $frame->set_position($x, $y);
  44. }
  45. }