Absolute_Positioner

Positions absolutely positioned frames.

Defined (1)

The class is defined in the following location(s).

/lib/dompdf/include/absolute_positioner.cls.php  
  1. class Absolute_Positioner extends Positioner { 
  2.  
  3. function __construct(Frame_Decorator $frame) { parent::__construct($frame); } 
  4.  
  5. function position() { 
  6.  
  7. $frame = $this->_frame; 
  8. $style = $frame->get_style(); 
  9.  
  10. $p = $frame->find_positionned_parent(); 
  11.  
  12. list($x, $y, $w, $h) = $frame->get_containing_block(); 
  13.  
  14. $top = $style->length_in_pt($style->top, $h); 
  15. $right = $style->length_in_pt($style->right, $w); 
  16. $bottom = $style->length_in_pt($style->bottom, $h); 
  17. $left = $style->length_in_pt($style->left, $w); 
  18.  
  19. if ( $p && !($left === "auto" && $right === "auto") ) { 
  20. // Get the parent's padding box (see http://www.w3.org/TR/CSS21/visuren.html#propdef-top) 
  21. list($x, $y, $w, $h) = $p->get_padding_box(); 
  22.  
  23. list($width, $height) = array($frame->get_margin_width(), $frame->get_margin_height()); 
  24.  
  25. $orig_style = $this->_frame->get_original_style(); 
  26. $orig_width = $orig_style->width; 
  27. $orig_height = $orig_style->height; 
  28.  
  29. /**************************** 
  30.  
  31. Width auto:  
  32. ____________| left=auto | left=fixed | 
  33. right=auto | A | B | 
  34. right=fixed | C | D | 
  35.  
  36. Width fixed:  
  37. ____________| left=auto | left=fixed | 
  38. right=auto | E | F | 
  39. right=fixed | G | H | 
  40.  
  41. *****************************/ 
  42.  
  43. if ( $left === "auto" ) { 
  44. if ( $right === "auto" ) { 
  45. // A or E - Keep the frame at the same position 
  46. $x = $x + $frame->find_block_parent()->get_current_line_box()->w; 
  47. else { 
  48. if ( $orig_width === "auto" ) { 
  49. // C 
  50. $x += $w - $width - $right; 
  51. else { 
  52. // G 
  53. $x += $w - $width - $right; 
  54. else { 
  55. if ( $right === "auto" ) { 
  56. // B or F 
  57. $x += $left; 
  58. else { 
  59. if ( $orig_width === "auto" ) { 
  60. // D - TODO change width 
  61. $x += $left; 
  62. else { 
  63. // H - Everything is fixed: left + width win 
  64. $x += $left; 
  65.  
  66. // The same vertically 
  67. if ( $top === "auto" ) { 
  68. if ( $bottom === "auto" ) { 
  69. // A or E - Keep the frame at the same position 
  70. $y = $frame->find_block_parent()->get_current_line_box()->y; 
  71. else { 
  72. if ( $orig_height === "auto" ) { 
  73. // C 
  74. $y += $h - $height - $bottom; 
  75. else { 
  76. // G 
  77. $y += $h - $height - $bottom; 
  78. else { 
  79. if ( $bottom === "auto" ) { 
  80. // B or F 
  81. $y += $top; 
  82. else { 
  83. if ( $orig_height === "auto" ) { 
  84. // D - TODO change height 
  85. $y += $top; 
  86. else { 
  87. // H - Everything is fixed: top + height win 
  88. $y += $top; 
  89.  
  90. $frame->set_position($x, $y); 
  91.