Няма описание

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. * Positions list bullets
  11. *
  12. * @access private
  13. * @package dompdf
  14. */
  15. class List_Bullet_Positioner extends Positioner {
  16. function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
  17. //........................................................................
  18. function position() {
  19. // Bullets & friends are positioned an absolute distance to the left of
  20. // the content edge of their parent element
  21. $cb = $this->_frame->get_containing_block();
  22. // Note: this differs from most frames in that we must position
  23. // ourselves after determining our width
  24. $x = $cb["x"] - $this->_frame->get_width();
  25. $p = $this->_frame->find_block_parent();
  26. $y = $p->get_current_line_box()->y;
  27. // This is a bit of a hack...
  28. $n = $this->_frame->get_next_sibling();
  29. if ( $n ) {
  30. $style = $n->get_style();
  31. $line_height = $style->length_in_pt($style->line_height, $style->get_font_size());
  32. $offset = $style->length_in_pt($line_height, $n->get_containing_block("h")) - $this->_frame->get_height();
  33. $y += $offset / 2;
  34. }
  35. // Now the position is the left top of the block which should be marked with the bullet.
  36. // We tried to find out the y of the start of the first text character within the block.
  37. // But the top margin/padding does not fit, neither from this nor from the next sibling
  38. // The "bit of a hack" above does not work also.
  39. // Instead let's position the bullet vertically centered to the block which should be marked.
  40. // But for get_next_sibling() the get_containing_block is all zero, and for find_block_parent()
  41. // the get_containing_block is paper width and the entire list as height.
  42. // if ($p) {
  43. // //$cb = $n->get_containing_block();
  44. // $cb = $p->get_containing_block();
  45. // $y += $cb["h"]/2;
  46. // print 'cb:'.$cb["x"].':'.$cb["y"].':'.$cb["w"].':'.$cb["h"].':';
  47. // }
  48. // Todo:
  49. // For now give up on the above. Use Guesswork with font y-pos in the middle of the line spacing
  50. /*$style = $p->get_style();
  51. $font_size = $style->get_font_size();
  52. $line_height = $style->length_in_pt($style->line_height, $font_size);
  53. $y += ($line_height - $font_size) / 2; */
  54. //Position is x-end y-top of character position of the bullet.
  55. $this->_frame->set_position($x, $y);
  56. }
  57. }