mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
LibWeb: Consider strut while calculating baseline for a line
Strut should be taken in account while computing baseline of a line. Otherwise it results in wrong alignment in boxes that has inline elements without any text. This also fixes red box in Acid 2.
This commit is contained in:
parent
d37d6b3479
commit
f0ab127a41
1 changed files with 11 additions and 1 deletions
|
@ -174,8 +174,18 @@ void LineBuilder::update_last_line()
|
|||
break;
|
||||
}
|
||||
|
||||
auto strut_baseline = [&] {
|
||||
auto& font = m_context.containing_block().font();
|
||||
auto const line_height = m_context.containing_block().line_height();
|
||||
auto const font_metrics = font.pixel_metrics();
|
||||
auto const typographic_height = font_metrics.ascent + font_metrics.descent;
|
||||
auto const leading = line_height - typographic_height;
|
||||
auto const half_leading = leading / 2;
|
||||
return font_metrics.ascent + half_leading;
|
||||
}();
|
||||
|
||||
auto line_box_baseline = [&] {
|
||||
float line_box_baseline = 0;
|
||||
float line_box_baseline = strut_baseline;
|
||||
for (auto& fragment : line_box.fragments()) {
|
||||
auto const& font = fragment.layout_node().font();
|
||||
auto const line_height = fragment.layout_node().line_height();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue