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 27, 2024
1 parent c18f6d7 commit 21ac6f9
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 @@ -1307,8 +1307,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 @@ -1807,6 +1810,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 @@ -1841,6 +1845,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 @@ -1889,6 +1894,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 @@ -1906,11 +1913,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 @@ -1920,8 +1929,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 21ac6f9

Please sign in to comment.