From 0803ef98e3f70a51f8a7b27c49adad60df4d9e8d Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 27 Sep 2016 18:26:40 -0700 Subject: [PATCH] layout: Don't count lines that consist solely of hypothetical boxes when determining the baseline offset of the last line. Improves Twitter by placing the favorite icon in the right place vertically. --- components/layout/inline.rs | 13 ++++++---- tests/wpt/mozilla/meta/MANIFEST.json | 24 +++++++++++++++++++ ...line_absolute_hypothetical_baseline_a.html | 10 ++++++++ ...ne_absolute_hypothetical_baseline_ref.html | 4 ++++ 4 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 tests/wpt/mozilla/tests/css/inline_absolute_hypothetical_baseline_a.html create mode 100644 tests/wpt/mozilla/tests/css/inline_absolute_hypothetical_baseline_ref.html diff --git a/components/layout/inline.rs b/components/layout/inline.rs index d1d50b22fe43..bae35f7cac5b 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 fc7ee02cb96e..208db196a245 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 000000000000..c54a2c369903 --- /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 000000000000..e5c686e02a57 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/inline_absolute_hypothetical_baseline_ref.html @@ -0,0 +1,4 @@ + + +
A C D
+
B