function get_min_width(&$context)
 {
     if (isset($this->_cache[CACHE_MIN_WIDTH])) {
         return $this->_cache[CACHE_MIN_WIDTH];
     }
     $content_size = count($this->content);
     /**
      * If box does not have any context, its minimal width is determined by extra horizontal space:
      * padding, border width and margins
      */
     if ($content_size == 0) {
         $min_width = $this->_get_hor_extra();
         $this->_cache[CACHE_MIN_WIDTH] = $min_width;
         return $min_width;
     }
     /**
      * If we're in 'nowrap' mode, minimal and maximal width will be equal
      */
     $white_space = $this->getCSSProperty(CSS_WHITE_SPACE);
     $pseudo_nowrap = $this->getCSSProperty(CSS_HTML2PS_NOWRAP);
     if ($white_space == WHITESPACE_NOWRAP || $pseudo_nowrap == NOWRAP_NOWRAP) {
         $min_width = $this->get_min_nowrap_width($context);
         $this->_cache[CACHE_MIN_WIDTH] = $min_width;
         return $min_width;
     }
     /**
      * We need to add text indent size to the with of the first item
      */
     $start_index = 0;
     while ($start_index < $content_size && $this->content[$start_index]->out_of_flow()) {
         $start_index++;
     }
     if ($start_index < $content_size) {
         $ti = $this->getCSSProperty(CSS_TEXT_INDENT);
         if (!$ti) {
             $ti = CSSTextIndent::default_value();
         }
         $minw = $ti->calculate($this) + $this->content[$start_index]->get_min_width($context);
     } else {
         $minw = 0;
     }
     for ($i = $start_index; $i < $content_size; $i++) {
         $item =& $this->content[$i];
         if (!$item->out_of_flow()) {
             $minw = max($minw, $item->get_min_width_natural($context));
         }
     }
     /**
      * Apply width constraint to min width. Return maximal value
      */
     $wc = $this->getCSSProperty(CSS_WIDTH);
     $min_width = max($minw, $wc->apply($minw, $this->parent->get_width())) + $this->_get_hor_extra();
     $this->_cache[CACHE_MIN_WIDTH] = $min_width;
     return $min_width;
 }
 function apply(&$box, &$context)
 {
     $this->_maxw = 0;
     // We need to add text indent to the max width
     $text_indent = $box->getCSSProperty(CSS_TEXT_INDENT);
     # kornev
     if (!$text_indent) {
         $text_indent = CSSTextIndent::default_value();
     }
     $this->_cmaxw = $text_indent->calculate($box);
     for ($i = 0, $size = count($box->content); $i < $size; $i++) {
         $child =& $box->content[$i];
         if ($child->isLineBreak()) {
             $this->line_break();
         } elseif (!$child->out_of_flow()) {
             if (is_inline($child) || $child->getCSSProperty(CSS_FLOAT) !== FLOAT_NONE) {
                 $this->add_width($child->get_max_width($context, $this->_limit));
             } else {
                 $this->line_break();
                 $this->add_width($child->get_max_width($context, $this->_limit));
                 // Process special case with percentage constrained table
                 $item_wc = $child->getCSSProperty(CSS_WIDTH);
                 if (is_a($child, "TableBox") && is_a($item_wc, "WCFraction")) {
                     $this->_cmaxw = max($this->_cmaxw, $item_wc->apply($box->get_width(), $box->parent->get_expandable_width()));
                 }
                 $this->line_break();
             }
         }
     }
     // Check if last line have maximal width
     //
     $this->line_break();
     // Note that max width cannot differ from constrained width,
     // if any width constraints apply
     //
     $wc = $box->getCSSProperty(CSS_WIDTH);
     # kornev
     if (!$wc) {
         $wc = CSSCompositeWidth::default_value();
     }
     if ($wc->applicable($box)) {
         if ($box->parent) {
             $this->_maxw = $wc->apply($this->_maxw, $box->parent->get_width());
         } else {
             $this->_maxw = $wc->apply($this->_maxw, $this->_maxw);
         }
     }
     return $this->_maxw + $box->_get_hor_extra();
 }
 function apply(&$box, &$context)
 {
     $this->_maxw = 0;
     // We need to add text indent to the max width
     $text_indent = $box->getCSSProperty(CSS_TEXT_INDENT);
     if (!$text_indent) {
         $text_indent = CSSTextIndent::default_value();
     }
     $this->_cmaxw = $text_indent->calculate($box);
     for ($i = 0, $size = count($box->content); $i < $size; $i++) {
         $child =& $box->content[$i];
         // Note that while BR-generated box is out of flow,
         // it should break the current line
         if ($child->isLineBreak()) {
             $this->line_break();
         } elseif (!$child->out_of_flow()) {
             if (is_inline($child)) {
                 $this->add_width($child->get_max_width_natural($context, $this->_limit));
             } elseif ($child->getCSSProperty(CSS_FLOAT) !== FLOAT_NONE) {
                 $wc = $child->getCSSProperty(CSS_WIDTH);
                 if (!$wc->isFraction()) {
                     $delta = $child->get_max_width($context, $this->_limit);
                 } else {
                     $delta = $child->get_max_width_natural($context, $this->_limit);
                 }
                 $this->add_width($delta);
             } else {
                 $this->_maxw = max($this->_maxw, $this->_cmaxw);
                 $this->_cmaxw = $child->get_max_width_natural($context, $this->_limit);
                 // Process special case with percentage constrained table
                 $item = $child;
                 $item_wc = $item->getCSSProperty(CSS_WIDTH);
                 if (is_a($item, "TableBox") && $item_wc->isFraction()) {
                     if (isset($child->parent) && $child->parent) {
                         $this->_cmaxw = max($this->_cmaxw, $item_wc->apply($child->get_width(), $child->parent->get_expandable_width()));
                     } else {
                         $this->_cmaxw = max($this->_cmaxw, $item_wc->apply($child->get_width(), $child->get_width()));
                     }
                 }
                 $this->line_break();
             }
         }
     }
     // Check if last line have maximal width
     //
     $this->_maxw = max($this->_maxw, $this->_cmaxw);
     return $this->_maxw + $box->_get_hor_extra();
 }
 function apply(&$box, &$context)
 {
     $this->_maxw = 0;
     // We need to add text indent to the width
     $ti = $box->getCSSProperty(CSS_TEXT_INDENT);
     # kornev
     if (!$ti) {
         $ti = CSSTextIndent::default_value();
     }
     $this->add_width($ti->calculate($box));
     for ($i = 0, $size = count($box->content); $i < $size; $i++) {
         $child =& $box->content[$i];
         if ($child->isLineBreak()) {
             $this->line_break();
         } elseif (!$child->out_of_flow()) {
             if (is_inline($child)) {
                 // Inline boxes content will not be wrapped, so we may calculate its max width
                 $this->add_width($child->get_max_width($context));
             } else {
                 // Non-inline boxes cause line break
                 $this->line_break();
                 $this->add_width($child->get_min_width($context));
                 $this->line_break();
             }
         }
     }
     // Check if last line have maximal width
     $this->line_break();
     // Apply width constraint to min width. Return maximal value
     $wc = $box->getCSSProperty(CSS_WIDTH);
     # kornev
     if (!$wc) {
         $wc = CSSCompositeWidth::default_value();
     }
     return max($this->_maxw, $wc->apply($this->_maxw, $box->parent->get_width())) + $box->_get_hor_extra();
 }