PluginProbe
MBE eShip / trunk
MBE eShip vtrunk
2.8.1 trunk 1.0.0 1.1.0 1.1.3 1.2.1 1.2.2 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.7.1 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.0 2.1.1 2.1.2 2.2.1 All 37 releases
mail-boxes-etc / lib / dompdf / src / Positioner / Inline.php

Inline.php in MBE eShip trunk, at lib/dompdf/src/Positioner/Inline.php

53 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package dompdf
4 * @link https://github.com/dompdf/dompdf
5 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
6 */
7 namespace Dompdf\Positioner;
8
9 use Dompdf\FrameDecorator\AbstractFrameDecorator;
10 use Dompdf\FrameDecorator\Inline as InlineFrameDecorator;
11 use Dompdf\Exception;
12 use Dompdf\Helpers;
13
14 /**
15 * Positions inline frames
16 *
17 * @package dompdf
18 */
19 class Inline extends AbstractPositioner
20 {
21
22 /**
23 * @param AbstractFrameDecorator $frame
24 * @throws Exception
25 */
26 function position(AbstractFrameDecorator $frame): void
27 {
28 // Find our nearest block level parent and access its lines property
29 $block = $frame->find_block_parent();
30
31 if (!$block) {
32 throw new Exception("No block-level parent found. Not good.");
33 }
34
35 $cb = $frame->get_containing_block();
36 $line = $block->get_current_line_box();
37
38 if (!$frame->is_text_node() && !($frame instanceof InlineFrameDecorator)) {
39 // Atomic inline boxes and replaced inline elements
40 // (inline-block, inline-table, img etc.)
41 $width = $frame->get_margin_width();
42 $available_width = $cb["w"] - $line->left - $line->w - $line->right;
43
44 if (Helpers::lengthGreater($width, $available_width)) {
45 $block->add_line();
46 $line = $block->get_current_line_box();
47 }
48 }
49
50 $frame->set_position($cb["x"] + $line->w, $line->y);
51 }
52 }
53