diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-09-29 00:11:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-29 00:11:33 -0500 |
commit | ccfc60161b8d92217b9f77040d6928d429bcbe9d (patch) | |
tree | 7e458f204f5200913968ba38e477373f67cb1c90 | |
parent | 13c4393516df0d3415ed28d107f3744d56b59623 (diff) | |
parent | b021952be9c556cb55ade993d0781d8a3f9b46aa (diff) | |
download | servo-ccfc60161b8d92217b9f77040d6928d429bcbe9d.tar.gz servo-ccfc60161b8d92217b9f77040d6928d429bcbe9d.zip |
Auto merge of #13470 - pcwalton:inline-absolute-hypothetical-baseline, r=notriddle
layout: Improve the interaction between baseline-offset-of-last-line-in-flow logic and inline absolute hypothetical boxes.
See commits for details. These changes place the heart icon on Twitter in the right place.
r? @notriddle
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13470)
<!-- Reviewable:end -->
-rw-r--r-- | components/layout/flow.rs | 4 | ||||
-rw-r--r-- | components/layout/inline.rs | 14 | ||||
-rw-r--r-- | tests/wpt/mozilla/meta/MANIFEST.json | 24 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/css/inline_absolute_hypothetical_baseline_a.html | 10 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/css/inline_absolute_hypothetical_baseline_ref.html | 4 |
5 files changed, 49 insertions, 7 deletions
diff --git a/components/layout/flow.rs b/components/layout/flow.rs index c8703272fd6..6cdbdeffe30 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -1404,7 +1404,9 @@ impl<'a> ImmutableFlowUtils for &'a Flow { fn baseline_offset_of_last_line_box_in_flow(self) -> Option<Au> { for kid in base(self).children.iter().rev() { if kid.is_inline_flow() { - return kid.as_inline().baseline_offset_of_last_line() + if let Some(baseline_offset) = kid.as_inline().baseline_offset_of_last_line() { + return Some(baseline_offset) + } } if kid.is_block_like() && kid.as_block().formatting_context_type() == FormattingContextType::None && diff --git a/components/layout/inline.rs b/components/layout/inline.rs index ec1d223cd36..099d9af14d5 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<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 } } @@ -1451,7 +1454,6 @@ impl Flow for InlineFlow { self.minimum_depth_below_baseline); scanner.scan_for_lines(self, layout_context); - // Now, go through each line and lay out the fragments inside. let line_count = self.lines.len(); for (line_index, line) in self.lines.iter_mut().enumerate() { 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 @@ +<!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 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 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<div>A C D</div> +<div>B</div> |