Block.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\Positioner;
  9. use Dompdf\FrameDecorator\AbstractFrameDecorator;
  10. /**
  11. * Positions block frames
  12. *
  13. * @access private
  14. * @package dompdf
  15. */
  16. class Block extends AbstractPositioner {
  17. function position(AbstractFrameDecorator $frame)
  18. {
  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. if (!$float || $float === "none") {
  25. $p->add_line(true);
  26. }
  27. $y = $p->get_current_line_box()->y;
  28. } else {
  29. $y = $cb["y"];
  30. }
  31. $x = $cb["x"];
  32. // Relative positionning
  33. if ($style->position === "relative") {
  34. $top = (float)$style->length_in_pt($style->top, $cb["h"]);
  35. //$right = (float)$style->length_in_pt($style->right, $cb["w"]);
  36. //$bottom = (float)$style->length_in_pt($style->bottom, $cb["h"]);
  37. $left = (float)$style->length_in_pt($style->left, $cb["w"]);
  38. $x += $left;
  39. $y += $top;
  40. }
  41. $frame->set_position($x, $y);
  42. }
  43. }