Skip to content

Commit

Permalink
layout: When line-height is not Normal use metrics of first font no…
Browse files Browse the repository at this point in the history
…t fallback

This fixes an issue revealed by more consistent font fallback.
  • Loading branch information
mrobinson committed Apr 30, 2024
1 parent 4715f64 commit cb5d2e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
20 changes: 16 additions & 4 deletions components/layout_2020/flow/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,8 +1317,11 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
&container_state.style,
self.inline_box_state_stack.last().map(|c| &c.base),
);
let mut block_size =
container_state.get_block_size_contribution(vertical_align, &font_metrics);
let mut block_size = container_state.get_block_size_contribution(
vertical_align,
&font_metrics,
&container_state.font_metrics,
);
block_size.adjust_for_baseline_offset(container_state.baseline_offset);
block_size
} else if quirks_mode && !flags.is_collapsible_whitespace() {
Expand Down Expand Up @@ -1819,6 +1822,7 @@ impl InlineContainerState {
effective_vertical_align(&style, parent_container),
&style,
&font_metrics,
&font_metrics,
line_height,
);
if let Some(parent_container) = parent_container {
Expand Down Expand Up @@ -1853,6 +1857,7 @@ impl InlineContainerState {
vertical_align: VerticalAlign,
style: &ComputedValues,
font_metrics: &FontMetrics,
font_metrics_of_first_font: &FontMetrics,
line_height: Length,
) -> LineBlockSizes {
if !is_baseline_relative(vertical_align) {
Expand Down Expand Up @@ -1901,6 +1906,8 @@ impl InlineContainerState {
// considering with other zero line height boxes that converge on other block axis
// locations when using the above formula.
if style.get_font().line_height != LineHeight::Normal {
ascent = font_metrics_of_first_font.ascent;
descent = font_metrics_of_first_font.descent;
let half_leading =
(Au::from_f32_px(line_height.px()) - (ascent + descent)).scale_by(0.5);
ascent += half_leading;
Expand All @@ -1918,11 +1925,13 @@ impl InlineContainerState {
&self,
vertical_align: VerticalAlign,
font_metrics: &FontMetrics,
font_metrics_of_first_font: &FontMetrics,
) -> LineBlockSizes {
Self::get_block_sizes_with_style(
vertical_align,
&self.style,
font_metrics,
font_metrics_of_first_font,
line_height(&self.style, font_metrics),
)
}
Expand All @@ -1932,8 +1941,11 @@ impl InlineContainerState {
child_vertical_align: VerticalAlign,
child_block_size: &LineBlockSizes,
) -> Au {
let block_size =
self.get_block_size_contribution(child_vertical_align.clone(), &self.font_metrics);
let block_size = self.get_block_size_contribution(
child_vertical_align.clone(),
&self.font_metrics,
&self.font_metrics,
);
self.baseline_offset +
match child_vertical_align {
// `top` and `bottom are not actually relative to the baseline, but this value is unused
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions tests/wpt/meta/css/CSS2/visudet/line-height-201.html.ini

This file was deleted.

0 comments on commit cb5d2e1

Please sign in to comment.