LibWeb: Raise the baseline of text with veritcal-align: super

This raises the baseline of the given text by one third of the parent's
font size.
This commit is contained in:
Tim Ledbetter 2025-03-23 01:34:58 +00:00 committed by Jelle Raaijmakers
parent fc45121b70
commit 6fbbbc9b81
Notes: github-actions[bot] 2025-03-27 23:48:00 +00:00

View file

@ -327,9 +327,14 @@ void LineBuilder::update_last_line()
auto const x_height = CSSPixels::nearest_value_for(m_context.containing_block().first_available_font().pixel_metrics().x_height);
return m_current_block_offset + line_box_baseline + ((effective_box_top_offset - effective_box_bottom_offset - x_height - fragment.height()) / 2);
}
case CSS::VerticalAlign::Super:
// https://drafts.csswg.org/css-inline/#valdef-baseline-shift-super
// Raise by the offset appropriate for superscripts of the parents box.
// The UA may use the parents font metrics to find this offset; otherwise it defaults to raising by one third of the parents used font-size.
// FIXME: Use font metrics to find a more appropriate offset, if possible
return alphabetic_baseline - m_context.containing_block().computed_values().font_size() / 3;
case CSS::VerticalAlign::Bottom:
case CSS::VerticalAlign::Sub:
case CSS::VerticalAlign::Super:
case CSS::VerticalAlign::TextBottom:
case CSS::VerticalAlign::TextTop:
// FIXME: These are all 'baseline'