servo: Merge #13470 - layout: Improve the interaction between baseline-offset-of-last-line-in-flow logic and inline absolute hypothetical boxes (from pcwalton:inline-absolute-hypothetical-baseline); r=notriddle

See commits for details. These changes place the heart icon on Twitter in the right place.

r? @notriddle

Source-Repo: https://github.com/servo/servo
Source-Revision: ccfc60161b8d92217b9f77040d6928d429bcbe9d
This commit is contained in:
Patrick Walton 2016-09-29 00:11:33 -05:00
Родитель 6a060bf7d3
Коммит 31b454a47b
2 изменённых файлов: 11 добавлений и 7 удалений

Просмотреть файл

@ -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 &&

Просмотреть файл

@ -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() {