"Fossies" - the Fresh Open Source Software Archive

Member "icingaweb2-2.9.2/library/vendor/dompdf/src/Positioner/Absolute.php" (28 Jul 2021, 3763 Bytes) of package /linux/www/icingaweb2-2.9.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 /**
    3  * @package dompdf
    4  * @link    http://dompdf.github.com/
    5  * @author  Benj Carson <benjcarson@digitaljunkies.ca>
    6  * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
    7  */
    8 
    9 namespace Dompdf\Positioner;
   10 
   11 use Dompdf\FrameDecorator\AbstractFrameDecorator;
   12 
   13 /**
   14  * Positions absolutely positioned frames
   15  */
   16 class Absolute extends AbstractPositioner
   17 {
   18 
   19     /**
   20      * @param AbstractFrameDecorator $frame
   21      */
   22     function position(AbstractFrameDecorator $frame)
   23     {
   24         $style = $frame->get_style();
   25 
   26         $p = $frame->find_positionned_parent();
   27 
   28         list($x, $y, $w, $h) = $frame->get_containing_block();
   29 
   30         $top = $style->length_in_pt($style->top, $h);
   31         $right = $style->length_in_pt($style->right, $w);
   32         $bottom = $style->length_in_pt($style->bottom, $h);
   33         $left = $style->length_in_pt($style->left, $w);
   34 
   35         if ($p && !($left === "auto" && $right === "auto")) {
   36             // Get the parent's padding box (see http://www.w3.org/TR/CSS21/visuren.html#propdef-top)
   37             list($x, $y, $w, $h) = $p->get_padding_box();
   38         }
   39 
   40         list($width, $height) = array($frame->get_margin_width(), $frame->get_margin_height());
   41 
   42         $orig_style = $frame->get_original_style();
   43         $orig_width = $orig_style->width;
   44         $orig_height = $orig_style->height;
   45 
   46         /****************************
   47          *
   48          * Width auto:
   49          * ____________| left=auto | left=fixed |
   50          * right=auto  |     A     |     B      |
   51          * right=fixed |     C     |     D      |
   52          *
   53          * Width fixed:
   54          * ____________| left=auto | left=fixed |
   55          * right=auto  |     E     |     F      |
   56          * right=fixed |     G     |     H      |
   57          *****************************/
   58 
   59         if ($left === "auto") {
   60             if ($right === "auto") {
   61                 // A or E - Keep the frame at the same position
   62                 $x = $x + $frame->find_block_parent()->get_current_line_box()->w;
   63             } else {
   64                 if ($orig_width === "auto") {
   65                     // C
   66                     $x += $w - $width - $right;
   67                 } else {
   68                     // G
   69                     $x += $w - $width - $right;
   70                 }
   71             }
   72         } else {
   73             if ($right === "auto") {
   74                 // B or F
   75                 $x += (float)$left;
   76             } else {
   77                 if ($orig_width === "auto") {
   78                     // D - TODO change width
   79                     $x += (float)$left;
   80                 } else {
   81                     // H - Everything is fixed: left + width win
   82                     $x += (float)$left;
   83                 }
   84             }
   85         }
   86 
   87         // The same vertically
   88         if ($top === "auto") {
   89             if ($bottom === "auto") {
   90                 // A or E - Keep the frame at the same position
   91                 $y = $frame->find_block_parent()->get_current_line_box()->y;
   92             } else {
   93                 if ($orig_height === "auto") {
   94                     // C
   95                     $y += (float)$h - $height - (float)$bottom;
   96                 } else {
   97                     // G
   98                     $y += (float)$h - $height - (float)$bottom;
   99                 }
  100             }
  101         } else {
  102             if ($bottom === "auto") {
  103                 // B or F
  104                 $y += (float)$top;
  105             } else {
  106                 if ($orig_height === "auto") {
  107                     // D - TODO change height
  108                     $y += (float)$top;
  109                 } else {
  110                     // H - Everything is fixed: top + height win
  111                     $y += (float)$top;
  112                 }
  113             }
  114         }
  115 
  116         $frame->set_position($x, $y);
  117     }
  118 }