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 / Fixed.php

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

93 lines 3.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\FrameReflower\Block;
11
12 /**
13 * Positions fixely positioned frames
14 */
15 class Fixed extends Absolute
16 {
17
18 /**
19 * @param AbstractFrameDecorator $frame
20 */
21 function position(AbstractFrameDecorator $frame): void
22 {
23 if ($frame->get_reflower() instanceof Block) {
24 parent::position($frame);
25 } else {
26 // Legacy positioning logic for image and table frames
27 // TODO: Resolve dimensions, margins, and offsets similar to the
28 // block case in the reflowers and use the simplified logic above
29 $style = $frame->get_style();
30 $root = $frame->get_root();
31 $initialcb = $root->get_containing_block();
32 $initialcb_style = $root->get_style();
33
34 $p = $frame->find_block_parent();
35 if ($p) {
36 $p->add_line();
37 }
38 // Compute the margins of the @page style
39 $margin_top = (float)$initialcb_style->length_in_pt($initialcb_style->margin_top, $initialcb["h"]);
40 $margin_right = (float)$initialcb_style->length_in_pt($initialcb_style->margin_right, $initialcb["w"]);
41 $margin_bottom = (float)$initialcb_style->length_in_pt($initialcb_style->margin_bottom, $initialcb["h"]);
42 $margin_left = (float)$initialcb_style->length_in_pt($initialcb_style->margin_left, $initialcb["w"]);
43
44 // The needed computed style of the element
45 $height = (float)$style->length_in_pt($style->get_specified("height"), $initialcb["h"]);
46 $width = (float)$style->length_in_pt($style->get_specified("width"), $initialcb["w"]);
47
48 $top = $style->length_in_pt($style->get_specified("top"), $initialcb["h"]);
49 $right = $style->length_in_pt($style->get_specified("right"), $initialcb["w"]);
50 $bottom = $style->length_in_pt($style->get_specified("bottom"), $initialcb["h"]);
51 $left = $style->length_in_pt($style->get_specified("left"), $initialcb["w"]);
52
53 $y = $margin_top;
54 if (isset($top)) {
55 $y = (float)$top + $margin_top;
56 if ($top === "auto") {
57 $y = $margin_top;
58 if (isset($bottom) && $bottom !== "auto") {
59 $y = $initialcb["h"] - $bottom - $margin_bottom;
60 if ($frame->is_auto_height()) {
61 $y -= $height;
62 } else {
63 $y -= $frame->get_margin_height();
64 }
65 }
66 }
67 }
68
69 $x = $margin_left;
70 if (isset($left)) {
71 $x = (float)$left + $margin_left;
72 if ($left === "auto") {
73 $x = $margin_left;
74 if (isset($right) && $right !== "auto") {
75 $x = $initialcb["w"] - $right - $margin_right;
76 if ($frame->is_auto_width()) {
77 $x -= $width;
78 } else {
79 $x -= $frame->get_margin_width();
80 }
81 }
82 }
83 }
84
85 $frame->set_position($x, $y);
86
87 foreach ($frame->get_children() as $child) {
88 $child->set_position($x, $y);
89 }
90 }
91 }
92 }
93