PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.25
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.25
1.10.25 1.10.24 1.10.23 1.10.22 1.10.21 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 All 169 releases
woocommerce-pos / vendor_prefixed / dompdf / dompdf / src / FrameReflower / Inline.php

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

165 lines 5.9 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\FrameReflower;
9
10 use WCPOS\Vendor\Dompdf\FrameDecorator\Block as BlockFrameDecorator;
11 use WCPOS\Vendor\Dompdf\FrameDecorator\Inline as InlineFrameDecorator;
12 use WCPOS\Vendor\Dompdf\FrameDecorator\Text as TextFrameDecorator;
13 /**
14 * Reflows inline frames
15 *
16 * @package dompdf
17 */
18 class Inline extends AbstractFrameReflower
19 {
20 /**
21 * Inline constructor.
22 * @param InlineFrameDecorator $frame
23 */
24 function __construct(InlineFrameDecorator $frame)
25 {
26 parent::__construct($frame);
27 }
28 /**
29 * Handle reflow of empty inline frames.
30 *
31 * Regular inline frames are positioned together with their text (or inline)
32 * children after child reflow. Empty inline frames have no children that
33 * could determine the positioning, so they need to be handled separately.
34 *
35 * @param BlockFrameDecorator $block
36 */
37 protected function reflow_empty(BlockFrameDecorator $block) : void
38 {
39 /** @var InlineFrameDecorator */
40 $frame = $this->_frame;
41 $style = $frame->get_style();
42 // Resolve width, so the margin width can be checked
43 $style->set_used("width", 0.0);
44 $cb = $frame->get_containing_block();
45 $line = $block->get_current_line_box();
46 $width = $frame->get_margin_width();
47 if ($width > $cb["w"] - $line->left - $line->w - $line->right) {
48 $block->add_line();
49 // Find the appropriate inline ancestor to split
50 $child = $frame;
51 $p = $child->get_parent();
52 while ($p instanceof InlineFrameDecorator && !$child->get_prev_sibling()) {
53 $child = $p;
54 $p = $p->get_parent();
55 }
56 if ($p instanceof InlineFrameDecorator) {
57 // Split parent and stop current reflow. Reflow continues
58 // via child-reflow loop of split parent
59 $p->split($child);
60 return;
61 }
62 }
63 $frame->position();
64 $block->add_frame_to_line($frame);
65 }
66 /**
67 * @param BlockFrameDecorator|null $block
68 */
69 function reflow(?BlockFrameDecorator $block = null)
70 {
71 /** @var InlineFrameDecorator */
72 $frame = $this->_frame;
73 // Check if a page break is forced
74 $page = $frame->get_root();
75 $page->check_forced_page_break($frame);
76 if ($page->is_full()) {
77 return;
78 }
79 // Counters and generated content
80 $this->_set_content();
81 $style = $frame->get_style();
82 // Resolve auto margins
83 // https://www.w3.org/TR/CSS21/visudet.html#inline-width
84 // https://www.w3.org/TR/CSS21/visudet.html#inline-non-replaced
85 if ($style->margin_left === "auto") {
86 $style->set_used("margin_left", 0.0);
87 }
88 if ($style->margin_right === "auto") {
89 $style->set_used("margin_right", 0.0);
90 }
91 if ($style->margin_top === "auto") {
92 $style->set_used("margin_top", 0.0);
93 }
94 if ($style->margin_bottom === "auto") {
95 $style->set_used("margin_bottom", 0.0);
96 }
97 // Handle line breaks
98 if ($frame->get_node()->nodeName === "br") {
99 if ($block) {
100 $line = $block->get_current_line_box();
101 $frame->set_containing_line($line);
102 $block->maximize_line_height($frame->get_margin_height(), $frame);
103 $block->add_line(\true);
104 $next = $frame->get_next_sibling();
105 $p = $frame->get_parent();
106 if ($next && $p instanceof InlineFrameDecorator) {
107 $p->split($next);
108 }
109 }
110 return;
111 }
112 // Handle empty inline frames
113 if (!$frame->get_first_child()) {
114 if ($block) {
115 $this->reflow_empty($block);
116 }
117 return;
118 }
119 // Add margin, padding & border width to the first and last children,
120 // so they are accounted for during text layout
121 if (($f = $frame->get_first_child()) && $f instanceof TextFrameDecorator) {
122 $f_style = $f->get_style();
123 $f_style->margin_left = $style->margin_left;
124 $f_style->padding_left = $style->padding_left;
125 $f_style->border_left_width = $style->border_left_width;
126 }
127 if (($l = $frame->get_last_child()) && $l instanceof TextFrameDecorator) {
128 $l_style = $l->get_style();
129 $l_style->margin_right = $style->margin_right;
130 $l_style->padding_right = $style->padding_right;
131 $l_style->border_right_width = $style->border_right_width;
132 }
133 $frame->position();
134 $cb = $frame->get_containing_block();
135 // Set the containing blocks and reflow each child. The containing
136 // block is not changed by line boxes.
137 foreach ($frame->get_children() as $child) {
138 $child->set_containing_block($cb);
139 $child->reflow($block);
140 // Stop reflow if the frame has been reset by a line or page break
141 // due to child reflow
142 if (!$frame->content_set) {
143 return;
144 }
145 }
146 // Assume the position of the first in-flow child, otherwise use the
147 // fallback position that was set before child reflow
148 $child = $frame->get_first_child();
149 while ($child && !$child->is_in_flow()) {
150 $child = $child->get_next_sibling();
151 }
152 if ($child) {
153 [$x, $y] = $child->get_position();
154 $frame->set_position($x, $y);
155 }
156 // Handle relative positioning
157 foreach ($frame->get_children() as $child) {
158 $this->position_relative($child);
159 }
160 if ($block) {
161 $block->add_frame_to_line($frame);
162 }
163 }
164 }
165