Skip to content

Commit

Permalink
Use margin height instead of border height in vertical alignment
Browse files Browse the repository at this point in the history
As the margin height is what affects the line-box height. Prevents
inline-block frames being pushed out of their line box due to large
margins.

Partially addresses #1946
  • Loading branch information
Mellthas committed Dec 1, 2021
1 parent 481cd62 commit 9f5690f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/FrameReflower/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ function vertical_align()
if (count($frames) === 1) {
continue;
}
$frameBox = $frame->get_border_box();
$imageHeightDiff = $height * 0.8 - $frameBox["h"];
$marginHeight = $frame->get_margin_height();
$imageHeightDiff = $height * 0.8 - $marginHeight;

$align = $frame->get_style()->vertical_align;
if (in_array($align, Style::$vertical_align_keywords, true)) {
Expand Down Expand Up @@ -623,7 +623,7 @@ function vertical_align()
break;
}
} else {
$y_offset = $baseline - (float)$style->length_in_pt($align, $style->font_size) - $frameBox["h"];
$y_offset = $baseline - (float)$style->length_in_pt($align, $style->font_size) - $marginHeight;
}
} else {
$parent = $frame->get_parent();
Expand Down

0 comments on commit 9f5690f

Please sign in to comment.