/** * Decorate the root Frame * * @param $root Frame The frame to decorate * @param $dompdf DOMPDF The dompdf instance * @return Page_Frame_Decorator */ static function decorate_root(Frame $root, DOMPDF $dompdf) { $frame = new Page_Frame_Decorator($root, $dompdf); $frame->set_reflower(new Page_Frame_Reflower($frame)); $root->set_decorator($frame); return $frame; }
/** * Returns the floating elements inside the first floating parent * * @param Page_Frame_Decorator $root * * @return Frame[] */ function get_floats_inside(Page_Frame_Decorator $root) { $floating_frames = $root->get_floating_frames(); if (count($floating_frames) == 0) { return $floating_frames; } // Find nearest floating element $p = $this->_block_frame; while ($p->get_style()->float === "none") { $parent = $p->get_parent(); if (!$parent) { break; } $p = $parent; } if ($p == $root) { return $floating_frames; } $parent = $p; $childs = array(); foreach ($floating_frames as $_floating) { $p = $_floating->get_parent(); while (($p = $p->get_parent()) && $p !== $parent) { } if ($p) { $childs[] = $p; } } return $childs; }