diff --git a/components/layout/inline.rs b/components/layout/inline.rs index d1d50b22fe4..bae35f7cac5 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -1262,13 +1262,16 @@ impl InlineFlow { } pub fn baseline_offset_of_last_line(&self) -> Option { - match self.lines.last() { - None => None, - Some(ref last_line) => { - Some(last_line.bounds.start.b + last_line.bounds.size.block - - last_line.inline_metrics.depth_below_baseline) + // Find the last line that doesn't consist entirely of hypothetical boxes. + for line in self.lines.iter().rev() { + if (line.range.begin().get()..line.range.end().get()).any(|index| { + !self.fragments.fragments[index as usize].is_hypothetical() + }) { + return Some(line.bounds.start.b + line.bounds.size.block - + line.inline_metrics.depth_below_baseline) } } + None } } diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index fc7ee02cb96..208db196a24 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -2372,6 +2372,18 @@ "url": "/_mozilla/css/incremental_visibility_a.html" } ], + "css/inline_absolute_hypothetical_baseline_a.html": [ + { + "path": "css/inline_absolute_hypothetical_baseline_a.html", + "references": [ + [ + "/_mozilla/css/inline_absolute_hypothetical_baseline_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/inline_absolute_hypothetical_baseline_a.html" + } + ], "css/inline_absolute_hypothetical_clip_a.html": [ { "path": "css/inline_absolute_hypothetical_clip_a.html", @@ -16010,6 +16022,18 @@ "url": "/_mozilla/css/incremental_visibility_a.html" } ], + "css/inline_absolute_hypothetical_baseline_a.html": [ + { + "path": "css/inline_absolute_hypothetical_baseline_a.html", + "references": [ + [ + "/_mozilla/css/inline_absolute_hypothetical_baseline_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/inline_absolute_hypothetical_baseline_a.html" + } + ], "css/inline_absolute_hypothetical_clip_a.html": [ { "path": "css/inline_absolute_hypothetical_clip_a.html", diff --git a/tests/wpt/mozilla/tests/css/inline_absolute_hypothetical_baseline_a.html b/tests/wpt/mozilla/tests/css/inline_absolute_hypothetical_baseline_a.html new file mode 100644 index 00000000000..c54a2c36990 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/inline_absolute_hypothetical_baseline_a.html @@ -0,0 +1,10 @@ + + + + +
+
A
+ B +
+C +D diff --git a/tests/wpt/mozilla/tests/css/inline_absolute_hypothetical_baseline_ref.html b/tests/wpt/mozilla/tests/css/inline_absolute_hypothetical_baseline_ref.html new file mode 100644 index 00000000000..e5c686e02a5 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/inline_absolute_hypothetical_baseline_ref.html @@ -0,0 +1,4 @@ + + +
A C D
+
B