PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.20
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.20
1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 All 164 releases
woocommerce-pos / vendor_prefixed / dompdf / dompdf / src / Renderer / Inline.php

Inline.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.20, at vendor_prefixed/dompdf/dompdf/src/Renderer/Inline.php

96 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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\Renderer;
9
10 use WCPOS\Vendor\Dompdf\Frame;
11 /**
12 * Renders inline frames
13 *
14 * @package dompdf
15 */
16 class Inline extends AbstractRenderer
17 {
18 function render(Frame $frame)
19 {
20 // Get the first in-flow child
21 $child = $frame->get_first_child();
22 while ($child && !$child->is_in_flow()) {
23 $child = $child->get_next_sibling();
24 }
25 if (!$child) {
26 return;
27 // No children, no service
28 }
29 $style = $frame->get_style();
30 $node = $frame->get_node();
31 $this->_set_opacity($frame->get_opacity($style->opacity));
32 // Draw background & border behind each child. To do this, we need to
33 // to figure out just how much space each child takes. Retrieve the
34 // position of the first child again, to account for text and vertical
35 // alignment
36 [$x, $y] = $child->get_position();
37 [$w, $h] = $this->get_child_size($frame);
38 [, , $cbw] = $frame->get_containing_block();
39 $margin_left = $style->length_in_pt($style->margin_left, $cbw);
40 $pt = $style->length_in_pt($style->padding_top, $cbw);
41 $pb = $style->length_in_pt($style->padding_bottom, $cbw);
42 // Make sure that border and background start inside the left margin
43 // Extend the drawn box by border and padding in vertical direction, as
44 // these do not affect layout
45 // FIXME: Using a small vertical offset of a fraction of the height here
46 // to work around the vertical position being slightly off in general
47 $x += $margin_left;
48 $y -= $style->border_top_width + $pt - $h * 0.1;
49 $h += $style->border_top_width + $pt + $style->border_bottom_width + $pb;
50 $border_box = [$x, $y, $w, $h];
51 $this->_render_background($frame, $border_box);
52 $this->_render_border($frame, $border_box);
53 $this->_render_outline($frame, $border_box);
54 $this->addNamedDest($node);
55 $this->addHyperlink($node, $border_box);
56 $options = $this->_dompdf->getOptions();
57 if ($options->getDebugLayout() && $options->getDebugLayoutInline()) {
58 $this->debugLayout($border_box, "blue");
59 if ($options->getDebugLayoutPaddingBox()) {
60 $padding_box = [$x + $style->border_left_width, $y + $style->border_top_width, $w - $style->border_left_width - $style->border_right_width, $h - $style->border_top_width - $style->border_bottom_width];
61 $this->debugLayout($padding_box, "blue", [0.5, 0.5]);
62 }
63 }
64 }
65 protected function get_child_size(Frame $frame) : array
66 {
67 $w = 0.0;
68 $h = 0.0;
69 foreach ($frame->get_children() as $child) {
70 if (!$child->is_in_flow()) {
71 continue;
72 }
73 // Exclude trailing white space
74 if ($child->get_node()->nodeValue === " " && $child->get_prev_sibling() && !$child->get_next_sibling()) {
75 break;
76 }
77 $style = $child->get_style();
78 $auto_width = $style->width === "auto";
79 $auto_height = $style->height === "auto";
80 [, , $child_w, $child_h] = $child->get_border_box();
81 if ($auto_width || $auto_height) {
82 [$child_w2, $child_h2] = $this->get_child_size($child);
83 if ($auto_width) {
84 $child_w = $child_w2;
85 }
86 if ($auto_height) {
87 $child_h = $child_h2;
88 }
89 }
90 $w += $child_w;
91 $h = \max($h, $child_h);
92 }
93 return [$w, $h];
94 }
95 }
96