function apply(&$box, &$context)
 {
     $this->_maxw = 0;
     // We need to add text indent to the width
     $ti = $box->getCSSProperty(CSS_TEXT_INDENT);
     $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);
     return max($this->_maxw, $wc->apply($this->_maxw, $box->parent->get_width())) + $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);
     # 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 reflow_whitespace(&$linebox_started, &$previous_whitespace)
 {
     $previous_whitespace = false;
     $linebox_started = false;
     $size = count($this->content);
     for ($i = 0; $i < $size; $i++) {
         $child =& $this->content[$i];
         $child->reflow_whitespace($linebox_started, $previous_whitespace);
     }
     // remove the last whitespace in block box
     $this->remove_last_whitespace();
     // Non-inline box have terminated; we may be sure that line box will be closed
     // at this moment and new line box after this will be generated
     if (!is_inline($this)) {
         $linebox_started = false;
     }
     return;
 }