Determine the frame's height based on min/max height

@return float|int|mixed|string
960637
protected function _calculate_height()
    {
        $style = $this->_frame->get_style();
        $height = $style->height;

        $cellmap = $this->_frame->get_cellmap();
        $cellmap->assign_frame_heights();
        $rows = $cellmap->get_rows();

        // Determine our content height
        $content_height = 0;
        foreach ($rows as $r) {
            $content_height += $r["height"];
        }

        $cb = $this->_frame->get_containing_block();

        if (!($style->overflow === "visible" ||
            ($style->overflow === "hidden" && $height === "auto"))
        ) {
            // Only handle min/max height if the height is independent of the frame's content

            $min_height = $style->min_height;
            $max_height = $style->max_height;

            if (isset($cb["h"])) {
                $min_height = $style->length_in_pt($min_height, $cb["h"]);
                $max_height = $style->length_in_pt($max_height, $cb["h"]);

            } else if (isset($cb["w"])) {
                if (mb_strpos($min_height, "%") !== false) {
                    $min_height = 0;
                } else {
                    $min_height = $style->length_in_pt($min_height, $cb["w"]);
                }
                if (mb_strpos($max_height, "%") !== false) {
                    $max_height = "none";
                } else {
                    $max_height = $style->length_in_pt($max_height, $cb["w"]);
                }
            }

            if ($max_height !== "none" && $min_height > $max_height) {
                // Swap 'em
                list($max_height, $min_height) = array($min_height, $max_height);
            }

            if ($max_height !== "none" && $height > $max_height) {
                $height = $max_height;
            }

            if ($height < $min_height) {
                $height = $min_height;
            }
        } else {
            // Use the content height or the height value, whichever is greater
            if ($height !== "auto") {
                $height = $style->length_in_pt($height, $cb["h"]);

                if ($height <= $content_height) {
                    $height = $content_height;
                } else {
                    $cellmap->set_frame_heights($height, $content_height);
                }
            } else {
                $height = $content_height;
            }
        }

        return $height;
    }
492888
public function getMetaImageResizeHeight($height = null)
    {
        if ($height) {
            return $height;
        }
        
        if ($height = $this->owner->ImageMetaResizeHeight) {
            return $height;
        }
        
        return $this->owner->getFieldFromParent('DefaultImageResizeHeight');
    }
682296
public function getSize()
    {
        if (!$this->isClosed()) {
            $stat = fstat($this->handle);
        }
        
        return isset($stat['size']) ? $stat['size'] : null;
    }
394365
private function getImageRtfWidth()
    {
        if ($this->_width > 0) {
            return PHPRtfLite_Unit::getUnitInTwips($this->_width);
        }

        $imageWidth = $this->_imageWidth ? $this->_imageWidth : 100;
        if ($this->_height > 0) {
            $imageHeight = $this->_imageHeight ? $this->_imageHeight : 100;
            $width = ($imageWidth / $imageHeight) * $this->_height;
            return PHPRtfLite_Unit::getUnitInTwips($width);
        }

        return PHPRtfLite_Unit::getPointsInTwips($imageWidth);
    }
987542
public function getIsChromeFrame()
    {
        if (!isset($this->name)) {
            BrowserDetector::detect($this, $this->getUserAgent());
        }

        return $this->isChromeFrame;
    }
122382
public function getWidth()
    {
        if (null === $this->width && !$this->initialised) {
            $this->refreshDimensions();
        }

        if (null === $this->width) {
            $width = getenv('COLUMNS');
            if (false !== $width) {
                $this->width = (int) trim($width);
            }
        }

        return $this->width ?: static::DEFAULT_WIDTH;
    }
831616
public function getCurrentStyleHeight(): float
    {
        if (empty($this->currentStyle)) {
            return $this->default_font_size;
        }
        $style = $this->getStyle($this->currentStyle);

        return $style['size'];
    }
876289
public function getFootnotesHeight(): float
    {
        $h = 0;
        foreach ($this->printedfootnotes as $element) {
            $h += $element->getHeight($this);
        }

        return $h;
    }
660833
public function parse()
    {
        if ($this->buffer === '') {
            return false;
        }
        $this->frame = null;
        $this->offset = 0;
        $this->bufferSize = strlen($this->buffer);
        while ($this->offset < $this->bufferSize) {
            if ($this->mode === self::MODE_HEADER) {
                $this->skipEmptyLines();
                if ($this->detectFrameHead()) {
                    $this->mode = self::MODE_BODY;
                } else {
                    break;
                }
            }
            if ($this->detectFrameEnd()) {
                $this->mode = self::MODE_HEADER;
            }
            break;
        }

        if ($this->offset > 0) {
            // remove parsed buffer
            $this->buffer = substr($this->buffer, $this->offset);
        }
        return $this->frame !== null;
    }
990916
function calcAvailableHeight() {
        var availableHt = $windowContent.height();

        $editorHolder.siblings().each(function (i, elem) {
            var $elem = $(elem);
            if ($elem.css("display") !== "none" && $elem.css("position") !== "absolute") {
                availableHt -= $elem.outerHeight();
            }
        });

        // Clip value to 0 (it could be negative if a panel wants more space than we have)
        return Math.max(availableHt, 0);
    }
773004
function get_min_max_width()
    {
        /*if ( !is_null($this->_min_max_cache)  )
          return $this->_min_max_cache;*/
        $frame = $this->_frame;
        $style = $frame->get_style();
        $this->_block_parent = $frame->find_block_parent();
        $line_width = $frame->get_containing_block("w");

        $str = $text = $frame->get_text();
        $size = $style->font_size;
        $font = $style->font_family;

        $word_spacing = (float)$style->length_in_pt($style->word_spacing);
        $char_spacing = (float)$style->length_in_pt($style->letter_spacing);

        switch ($style->white_space) {
            default:
            case "normal":
                $str = preg_replace(self::$_whitespace_pattern, " ", $str);
            case "pre-wrap":
            case "pre-line":

                // Find the longest word (i.e. minimum length)

                // This technique (using arrays & an anonymous function) is actually
                // faster than doing a single-pass character by character scan.  Heh,
                // yes I took the time to bench it ;)
                $words = array_flip(preg_split("/[\s-]+/u", $str, -1, PREG_SPLIT_DELIM_CAPTURE));
                $root = $this;
                array_walk($words, function(&$val, $str) use ($font, $size, $word_spacing, $char_spacing, $root) {
                    $val = $root->getFontMetrics()->getTextWidth($str, $font, $size, $word_spacing, $char_spacing);
                });

                arsort($words);
                $min = reset($words);
                break;

            case "pre":
                $lines = array_flip(preg_split("/\n/u", $str));
                $root = $this;
                array_walk($lines, function(&$val, $str) use ($font, $size, $word_spacing, $char_spacing, $root) {
                    $val = $root->getFontMetrics()->getTextWidth($str, $font, $size, $word_spacing, $char_spacing);
                });

                arsort($lines);
                $min = reset($lines);
                break;

            case "nowrap":
                $min = $this->getFontMetrics()->getTextWidth($this->_collapse_white_space($str), $font, $size, $word_spacing, $char_spacing);
                break;
        }

        switch ($style->white_space) {
            default:
            case "normal":
            case "nowrap":
                $str = preg_replace(self::$_whitespace_pattern, " ", $text);
                break;

            case "pre-line":
                //XXX: Is this correct?
                $str = preg_replace("/[ \t]+/u", " ", $text);

            case "pre-wrap":
                // Find the longest word (i.e. minimum length)
                $lines = array_flip(preg_split("/\n/", $text));
                $root = $this;
                array_walk($lines, function(&$val, $str) use ($font, $size, $word_spacing, $char_spacing, $root) {
                    $val = $root->getFontMetrics()->getTextWidth($str, $font, $size, $word_spacing, $char_spacing);
                });
                arsort($lines);
                reset($lines);
                $str = key($lines);
                break;
        }

        $max = $this->getFontMetrics()->getTextWidth($str, $font, $size, $word_spacing, $char_spacing);

        $delta = (float)$style->length_in_pt(array($style->margin_left,
            $style->border_left_width,
            $style->padding_left,
            $style->padding_right,
            $style->border_right_width,
            $style->margin_right), $line_width);
        $min += $delta;
        $max += $delta;

        return $this->_min_max_cache = array($min, $max, "min" => $min, "max" => $max);
    }
285857
public function getHeight() {
        $height = getenv('LINES');
        if (false !== $height) {
            return (int)trim($height);
        }

        $dimensions = $this->dimensions;

        return $dimensions[1] ?: 50;
    }
225429
public function getHeight()
    {
        if ($this->height === null) {
            $this->height = intval($this->systemCall('tput lines'));
        }

        return $this->height;
    }
260336
function get_margin_height() {
    $style = $this->_frame->get_style();
    
    if ( $style->list_style_type === "none" ) {
      return 0;
    }
    
    return $style->get_font_size() * self::BULLET_SIZE + 2 * self::BULLET_PADDING;
  }
315055
public function getFullWidth() : int {
        $first = $this->getFullStart();
        $last = $this->getEndPosition();

        return $last - $first;
    }
1229198
function getSize()
    {
        $size = $this->_t__wrap_stream->getSize();
        if ($size !== null) {
            $segmentSize = $size - $this->getSegmentOffset();
            $size = ($this->getSegmentLimit() == -1)
                ? $segmentSize
                : min($segmentSize - $this->getSegmentLimit(), $this->getSegmentLimit());
        }

        return $size;
    }
872166
public function getStyle()
    {
        $style = '';

        // Always add fixed height as a fallback if autosetting or JS fails.
        $height = $this->FixedHeight;
        if (!$height) {
            $height = 800;
        }
        $style .= "height: {$height}px; ";

        if ($this->AutoWidth) {
            $style .= "width: 100%; ";
        } elseif ($this->FixedWidth) {
            $style .= "width: {$this->FixedWidth}px; ";
        }

        return $style;
    }