mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
layout: When line-height is not Normal
use metrics of first font not fallback (#32165)
This fixes an issue revealed by more consistent font fallback.
This commit is contained in:
parent
8eeb888010
commit
77c50ad356
3 changed files with 16 additions and 8 deletions
|
@ -1317,8 +1317,11 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
|
||||||
&container_state.style,
|
&container_state.style,
|
||||||
self.inline_box_state_stack.last().map(|c| &c.base),
|
self.inline_box_state_stack.last().map(|c| &c.base),
|
||||||
);
|
);
|
||||||
let mut block_size =
|
let mut block_size = container_state.get_block_size_contribution(
|
||||||
container_state.get_block_size_contribution(vertical_align, &font_metrics);
|
vertical_align,
|
||||||
|
&font_metrics,
|
||||||
|
&container_state.font_metrics,
|
||||||
|
);
|
||||||
block_size.adjust_for_baseline_offset(container_state.baseline_offset);
|
block_size.adjust_for_baseline_offset(container_state.baseline_offset);
|
||||||
block_size
|
block_size
|
||||||
} else if quirks_mode && !flags.is_collapsible_whitespace() {
|
} else if quirks_mode && !flags.is_collapsible_whitespace() {
|
||||||
|
@ -1814,6 +1817,7 @@ impl InlineContainerState {
|
||||||
effective_vertical_align(&style, parent_container),
|
effective_vertical_align(&style, parent_container),
|
||||||
&style,
|
&style,
|
||||||
&font_metrics,
|
&font_metrics,
|
||||||
|
&font_metrics,
|
||||||
line_height,
|
line_height,
|
||||||
);
|
);
|
||||||
if let Some(parent_container) = parent_container {
|
if let Some(parent_container) = parent_container {
|
||||||
|
@ -1848,6 +1852,7 @@ impl InlineContainerState {
|
||||||
vertical_align: VerticalAlign,
|
vertical_align: VerticalAlign,
|
||||||
style: &ComputedValues,
|
style: &ComputedValues,
|
||||||
font_metrics: &FontMetrics,
|
font_metrics: &FontMetrics,
|
||||||
|
font_metrics_of_first_font: &FontMetrics,
|
||||||
line_height: Length,
|
line_height: Length,
|
||||||
) -> LineBlockSizes {
|
) -> LineBlockSizes {
|
||||||
if !is_baseline_relative(vertical_align) {
|
if !is_baseline_relative(vertical_align) {
|
||||||
|
@ -1896,6 +1901,8 @@ impl InlineContainerState {
|
||||||
// considering with other zero line height boxes that converge on other block axis
|
// considering with other zero line height boxes that converge on other block axis
|
||||||
// locations when using the above formula.
|
// locations when using the above formula.
|
||||||
if style.get_font().line_height != LineHeight::Normal {
|
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 =
|
let half_leading =
|
||||||
(Au::from_f32_px(line_height.px()) - (ascent + descent)).scale_by(0.5);
|
(Au::from_f32_px(line_height.px()) - (ascent + descent)).scale_by(0.5);
|
||||||
ascent += half_leading;
|
ascent += half_leading;
|
||||||
|
@ -1913,11 +1920,13 @@ impl InlineContainerState {
|
||||||
&self,
|
&self,
|
||||||
vertical_align: VerticalAlign,
|
vertical_align: VerticalAlign,
|
||||||
font_metrics: &FontMetrics,
|
font_metrics: &FontMetrics,
|
||||||
|
font_metrics_of_first_font: &FontMetrics,
|
||||||
) -> LineBlockSizes {
|
) -> LineBlockSizes {
|
||||||
Self::get_block_sizes_with_style(
|
Self::get_block_sizes_with_style(
|
||||||
vertical_align,
|
vertical_align,
|
||||||
&self.style,
|
&self.style,
|
||||||
font_metrics,
|
font_metrics,
|
||||||
|
font_metrics_of_first_font,
|
||||||
line_height(&self.style, font_metrics),
|
line_height(&self.style, font_metrics),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1927,8 +1936,11 @@ impl InlineContainerState {
|
||||||
child_vertical_align: VerticalAlign,
|
child_vertical_align: VerticalAlign,
|
||||||
child_block_size: &LineBlockSizes,
|
child_block_size: &LineBlockSizes,
|
||||||
) -> Au {
|
) -> Au {
|
||||||
let block_size =
|
let block_size = self.get_block_size_contribution(
|
||||||
self.get_block_size_contribution(child_vertical_align.clone(), &self.font_metrics);
|
child_vertical_align.clone(),
|
||||||
|
&self.font_metrics,
|
||||||
|
&self.font_metrics,
|
||||||
|
);
|
||||||
self.baseline_offset +
|
self.baseline_offset +
|
||||||
match child_vertical_align {
|
match child_vertical_align {
|
||||||
// `top` and `bottom are not actually relative to the baseline, but this value is unused
|
// `top` and `bottom are not actually relative to the baseline, but this value is unused
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[line-height-201.html]
|
|
||||||
expected: FAIL
|
|
|
@ -1,2 +0,0 @@
|
||||||
[first-available-font-006.html]
|
|
||||||
expected: FAIL
|
|
Loading…
Add table
Add a link
Reference in a new issue