Пример #1
0
 function get_float_offsets()
 {
     $enable_css_float = $this->_block_frame->get_dompdf()->get_option("enable_css_float");
     if (!$enable_css_float) {
         return;
     }
     static $anti_infinite_loop = 500;
     // FIXME smelly hack
     $reflower = $this->_block_frame->get_reflower();
     if (!$reflower) {
         return;
     }
     $cb_w = null;
     $block = $this->_block_frame;
     $root = $block->get_root();
     if (!$root) {
         return;
     }
     $floating_frames = $this->get_floats_inside($root);
     foreach ($floating_frames as $child_key => $floating_frame) {
         $id = $floating_frame->get_id();
         if (isset($this->floating_blocks[$id])) {
             continue;
         }
         $floating_style = $floating_frame->get_style();
         $float = $floating_style->float;
         $floating_width = $floating_frame->get_margin_width();
         if (!$cb_w) {
             $cb_w = $floating_frame->get_containing_block("w");
         }
         $line_w = $this->get_width();
         if (!$floating_frame->_float_next_line && $cb_w <= $line_w + $floating_width && $cb_w > $line_w) {
             $floating_frame->_float_next_line = true;
             continue;
         }
         // If the child is still shifted by the floating element
         if ($anti_infinite_loop-- > 0 && $floating_frame->get_position("y") + $floating_frame->get_margin_height() > $this->y && $block->get_position("x") + $block->get_margin_width() > $floating_frame->get_position("x")) {
             if ($float === "left") {
                 $this->left += $floating_width;
             } else {
                 $this->right += $floating_width;
             }
             $this->floating_blocks[$id] = true;
         } else {
             $root->remove_floating_frame($child_key);
         }
     }
 }