Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| LineBox | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| totalWidth | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\HtmlToPdf\Layout; |
| 6 | |
| 7 | /** |
| 8 | * One laid-out line inside an inline formatting context. |
| 9 | * |
| 10 | * `y` is the line's top edge in the parent block's coordinate space; |
| 11 | * `height` is the line's allocated vertical space. `baseline` is the |
| 12 | * distance from the line's top edge down to the line's single shared |
| 13 | * baseline (CSS2 §10.8): every baseline-aligned fragment places its own |
| 14 | * baseline here, so mixed-size runs line up. `fragments` are placed |
| 15 | * left-to-right in logical order; bidi visual reorder happens before |
| 16 | * this stage. |
| 17 | */ |
| 18 | final class LineBox |
| 19 | { |
| 20 | /** @param list<InlineFragment> $fragments */ |
| 21 | public function __construct( |
| 22 | public float $y, |
| 23 | public float $height, |
| 24 | public array $fragments, |
| 25 | public float $baseline = 0.0, |
| 26 | /** |
| 27 | * The line's inline-end edge as the fitter saw it — the parent's |
| 28 | * content edge, pulled in by any float intruding at this line's |
| 29 | * height (CSS 2.1 §9.5). `text-align` measures its slack against |
| 30 | * THIS rather than the container's inline size, so a right-aligned |
| 31 | * line beside a float stops at the float instead of sliding under |
| 32 | * it. Null means "no float narrowed this line", and alignment falls |
| 33 | * back to the container extent. |
| 34 | */ |
| 35 | public ?float $availableRight = null, |
| 36 | ) {} |
| 37 | |
| 38 | public function totalWidth(): float |
| 39 | { |
| 40 | $right = 0.0; |
| 41 | foreach ($this->fragments as $f) { |
| 42 | $right = max($right, $f->x + $f->width); |
| 43 | } |
| 44 | return $right; |
| 45 | } |
| 46 | } |