1<?php
2
3/**
4 * This is an internal HTML2PS filter; you never need to use it.
5 */
6
7class PreTreeFilterHeightConstraint extends PreTreeFilter {
8  function process(&$tree, $data, &$pipeline) {
9    if (!is_a($tree, 'GenericFormattedBox')) {
10      return;
11    };
12
13    /**
14     * In non-quirks mode, percentage height should be ignored for children of boxes having
15     * non-constrained height
16     */
17    global $g_config;
18    if ($g_config['mode'] != 'quirks') {
19      if (!is_null($tree->parent)) {
20        $parent_hc = $tree->parent->get_height_constraint();
21        $hc        = $tree->get_height_constraint();
22
23        if (is_null($parent_hc->constant) &&
24            $hc->constant[1]) {
25          $hc->constant = null;
26          $tree->put_height_constraint($hc);
27        };
28      };
29    };
30
31    /**
32     * Set box height to constrained value
33     */
34    $hc     = $tree->get_height_constraint();
35    $height = $tree->get_height();
36
37    $tree->height = $hc->apply($height, $tree);
38
39    /**
40     * Proceed to this box children
41     */
42    if (is_a($tree, 'GenericContainerBox')) {
43      for ($i=0, $size = count($tree->content); $i<$size; $i++) {
44        $this->process($tree->content[$i], $data, $pipeline);
45      };
46    };
47  }
48}
49?>