Skip to content

Commit

Permalink
layout: Don't count lines that consist solely of hypothetical boxes when
Browse files Browse the repository at this point in the history
determining the baseline offset of the last line.

Improves Twitter by placing the favorite icon in the right place
vertically.
  • Loading branch information
pcwalton committed Sep 28, 2016
1 parent 3a56cc7 commit 0803ef9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
13 changes: 8 additions & 5 deletions components/layout/inline.rs
Expand Up @@ -1262,13 +1262,16 @@ impl InlineFlow {
}

pub fn baseline_offset_of_last_line(&self) -> Option<Au> {
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
}
}

Expand Down
24 changes: 24 additions & 0 deletions tests/wpt/mozilla/meta/MANIFEST.json
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
@@ -0,0 +1,10 @@
<!doctype html>
<meta charset="utf-8">
<title></title>
<link rel="match" href="inline_absolute_hypothetical_baseline_ref.html">
<div style="display: inline-block">
<div>A</div>
<span style="position: absolute;">B</span>
</div>
C
D
@@ -0,0 +1,4 @@
<!DOCTYPE html>
<meta charset="utf-8">
<div>A C D</div>
<div>B</div>

0 comments on commit 0803ef9

Please sign in to comment.