| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class LayoutVertical {
|
|
|
4 |
// Calculate the vertical offset of current box due the 'clear' CSS property
|
|
|
5 |
//
|
|
|
6 |
// @param $y initial Y coordinate to begin offset from
|
|
|
7 |
// @param $context flow context containing the list of floats to interact with
|
|
|
8 |
// @return updated value of Y coordinate
|
|
|
9 |
//
|
|
|
10 |
function apply_clear($box, $y, &$context) {
|
|
|
11 |
$clear = $box->get_css_property(CSS_CLEAR);
|
|
|
12 |
|
|
|
13 |
// Check if we need to offset box vertically due the 'clear' property
|
|
|
14 |
if ($clear == CLEAR_BOTH || $clear == CLEAR_LEFT) {
|
|
|
15 |
$floats =& $context->current_floats();
|
|
|
16 |
for ($cf = 0; $cf < count($floats); $cf++) {
|
|
|
17 |
$current_float =& $floats[$cf];
|
|
|
18 |
if ($current_float->get_css_property(CSS_FLOAT) == FLOAT_LEFT) {
|
|
|
19 |
// Float vertical margins are never collapsed
|
|
|
20 |
//
|
|
|
21 |
$margin = $box->get_css_property(CSS_MARGIN);
|
|
|
22 |
$y = min($y, $current_float->get_bottom_margin() - $margin->top->value);
|
|
|
23 |
};
|
|
|
24 |
}
|
|
|
25 |
};
|
|
|
26 |
|
|
|
27 |
if ($clear == CLEAR_BOTH || $clear == CLEAR_RIGHT) {
|
|
|
28 |
$floats =& $context->current_floats();
|
|
|
29 |
for ($cf = 0; $cf < count($floats); $cf++) {
|
|
|
30 |
$current_float =& $floats[$cf];
|
|
|
31 |
if ($current_float->get_css_property(CSS_FLOAT) == FLOAT_RIGHT) {
|
|
|
32 |
// Float vertical margins are never collapsed
|
|
|
33 |
$margin = $box->get_css_property(CSS_MARGIN);
|
|
|
34 |
$y = min($y, $current_float->get_bottom_margin() - $margin->top->value);
|
|
|
35 |
};
|
|
|
36 |
}
|
|
|
37 |
};
|
|
|
38 |
|
|
|
39 |
return $y;
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
?>
|