| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @package dompdf |
| 5 |
* @link https://github.com/dompdf/dompdf |
| 6 |
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License |
| 7 |
*/ |
| 8 |
namespace WCPOS\Vendor\Dompdf\Positioner; |
| 9 |
|
| 10 |
use WCPOS\Vendor\Dompdf\FrameDecorator\AbstractFrameDecorator; |
| 11 |
use WCPOS\Vendor\Dompdf\FrameDecorator\Inline as InlineFrameDecorator; |
| 12 |
use WCPOS\Vendor\Dompdf\Exception; |
| 13 |
use WCPOS\Vendor\Dompdf\Helpers; |
| 14 |
/** |
| 15 |
* Positions inline frames |
| 16 |
* |
| 17 |
* @package dompdf |
| 18 |
*/ |
| 19 |
class Inline extends AbstractPositioner |
| 20 |
{ |
| 21 |
/** |
| 22 |
* @param AbstractFrameDecorator $frame |
| 23 |
* @throws Exception |
| 24 |
*/ |
| 25 |
function position(AbstractFrameDecorator $frame) : void |
| 26 |
{ |
| 27 |
// Find our nearest block level parent and access its lines property |
| 28 |
$block = $frame->find_block_parent(); |
| 29 |
$cb = $frame->get_containing_block(); |
| 30 |
if (!$block) { |
| 31 |
// FIXME: An inline frame without block parent should not be |
| 32 |
// possible, but this can occur currently when the body is styled |
| 33 |
// with `display: inline !important;` or `display: inline-block !important;` |
| 34 |
$frame->set_position($cb["x"], $cb["y"]); |
| 35 |
return; |
| 36 |
} |
| 37 |
$line = $block->get_current_line_box(); |
| 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 |
if (Helpers::lengthGreater($width, $available_width)) { |
| 44 |
$block->add_line(); |
| 45 |
$line = $block->get_current_line_box(); |
| 46 |
} |
| 47 |
} |
| 48 |
$frame->set_position($cb["x"] + $line->w, $line->y); |
| 49 |
} |
| 50 |
} |
| 51 |
|