<commit_before><?php
/**
 * @package dompdf
 * @link    http://dompdf.github.com/
 * @author  <NAME> <<EMAIL>>
 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 */
namespace Dompdf\FrameDecorator;

use Dompdf\Dompdf;
use Dompdf\Frame;
use Dompdf\FrameDecorator\Block as BlockFrameDecorator;

/**
 * Decorates table cells for layout
 *
 * @package dompdf
 */
class TableCell extends BlockFrameDecorator
{

    protected $_resolved_borders;
    protected $_content_height;

    //........................................................................

    /**
     * TableCell constructor.
     * @param Frame $frame
     * @param Dompdf $dompdf
     */
    function __construct(Frame $frame, Dompdf $dompdf)
    {
        parent::__construct($frame, $dompdf);
        $this->_resolved_borders = array();
        $this->_content_height = 0;
    }

    //........................................................................

    function reset()
    {
        parent::reset();
        $this->_resolved_borders = array();
        $this->_content_height = 0;
        $this->_frame->reset();
    }

    /**
     * @return int
     */
    function get_content_height()
    {
        return $this->_content_height;
    }

    /**
     * @param $height
     */
    function set_content_height($height)
    {
        $this->_content_height = $height;
    }

    /**
     * @param $height
     */
    function set_cell_height($height)
    {
        $style = $this->get_style();
        $v_space = (float)$style->length_in_pt(
            array(
                $style->margin_top,
                $style->padding_top,
                $style->border_top_width,
                $style->border_bottom_width,
                $style->padding_bottom,
                $style->margin_bottom
            ),
            (float)$style->length_in_pt($style->width)
        );

        $new_height = $height - $v_space;
        $style->height = $new_height;

        if ($new_height > $this->_content_height) {
            $y_offset = 0;

            // Adjust our vertical alignment
            switch ($style->vertical_align) {
                default:
                case "baseline":
                    // FIXME: this isn't right

                case "top":<commit_msg>Calculate table cell vertical space using height<commit_after><?php
/**
 * @package dompdf
 * @link    http://dompdf.github.com/
 * @author  <NAME> <<EMAIL>>
 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
 */
namespace Dompdf\FrameDecorator;

use Dompdf\Dompdf;
use Dompdf\Frame;
use Dompdf\FrameDecorator\Block as BlockFrameDecorator;

/**
 * Decorates table cells for layout
 *
 * @package dompdf
 */
class TableCell extends BlockFrameDecorator
{

    protected $_resolved_borders;
    protected $_content_height;

    //........................................................................

    /**
     * TableCell constructor.
     * @param Frame $frame
     * @param Dompdf $dompdf
     */
    function __construct(Frame $frame, Dompdf $dompdf)
    {
        parent::__construct($frame, $dompdf);
        $this->_resolved_borders = array();
        $this->_content_height = 0;
    }

    //........................................................................

    function reset()
    {
        parent::reset();
        $this->_resolved_borders = array();
        $this->_content_height = 0;
        $this->_frame->reset();
    }

    /**
     * @return int
     */
    function get_content_height()
    {
        return $this->_content_height;
    }

    /**
     * @param $height
     */
    function set_content_height($height)
    {
        $this->_content_height = $height;
    }

    /**
     * @param $height
     */
    function set_cell_height($height)
    {
        $style = $this->get_style();
        $v_space = (float)$style->length_in_pt(
            array(
                $style->margin_top,
                $style->padding_top,
                $style->border_top_width,
                $style->border_bottom_width,
                $style->padding_bottom,
                $style->margin_bottom
            ),
            (float)$style->length_in_pt($style->height)
        );

        $new_height = $height - $v_space;
        $style->height = $new_height;

        if ($new_height > $this->_content_height) {
            $y_offset = 0;

            // Adjust our vertical alignment
            switch ($style->vertical_align) {
                default:
                case "baseline":
                    // FIXME: this isn't right

                case "top":
{'fraction_non_alphanumeric': 0.18166089965397925, 'fraction_numerical': 0.0012975778546712802, 'mean_word_length': 1.5623268698060941, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7369523', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1260, 'n_words': 245}