List_Bullet_Positioner

Positions list bullets.

Defined (1)

The class is defined in the following location(s).

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