composer package updates
[openemr.git] / vendor / dompdf / dompdf / src / Positioner / ListBullet.php
blob29da406e5350cee66d1e5106460ebb3a7f27bf8c
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 */
10 namespace Dompdf\Positioner;
12 use Dompdf\FrameDecorator\AbstractFrameDecorator;
14 /**
15 * Positions list bullets
17 * @package dompdf
19 class ListBullet extends AbstractPositioner
22 /**
23 * @param AbstractFrameDecorator $frame
25 function position(AbstractFrameDecorator $frame)
28 // Bullets & friends are positioned an absolute distance to the left of
29 // the content edge of their parent element
30 $cb = $frame->get_containing_block();
32 // Note: this differs from most frames in that we must position
33 // ourselves after determining our width
34 $x = $cb["x"] - $frame->get_width();
36 $p = $frame->find_block_parent();
38 $y = $p->get_current_line_box()->y;
40 // This is a bit of a hack...
41 $n = $frame->get_next_sibling();
42 if ($n) {
43 $style = $n->get_style();
44 $line_height = $style->length_in_pt($style->line_height, $style->get_font_size());
45 $offset = (float)$style->length_in_pt($line_height, $n->get_containing_block("h")) - $frame->get_height();
46 $y += $offset / 2;
49 // Now the position is the left top of the block which should be marked with the bullet.
50 // We tried to find out the y of the start of the first text character within the block.
51 // But the top margin/padding does not fit, neither from this nor from the next sibling
52 // The "bit of a hack" above does not work also.
54 // Instead let's position the bullet vertically centered to the block which should be marked.
55 // But for get_next_sibling() the get_containing_block is all zero, and for find_block_parent()
56 // the get_containing_block is paper width and the entire list as height.
58 // if ($p) {
59 // //$cb = $n->get_containing_block();
60 // $cb = $p->get_containing_block();
61 // $y += $cb["h"]/2;
62 // print 'cb:'.$cb["x"].':'.$cb["y"].':'.$cb["w"].':'.$cb["h"].':';
63 // }
65 // Todo:
66 // For now give up on the above. Use Guesswork with font y-pos in the middle of the line spacing
68 /*$style = $p->get_style();
69 $font_size = $style->get_font_size();
70 $line_height = (float)$style->length_in_pt($style->line_height, $font_size);
71 $y += ($line_height - $font_size) / 2; */
73 //Position is x-end y-top of character position of the bullet.
74 $frame->set_position($x, $y);