From dba3e41a63506842e84e43451d6f41156c672321 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 3 Sep 2015 11:41:24 -0700 Subject: layout: Lay absolutely-positioned blocks with inline containing blocks out of flow. Removes the long space before the site-specific drop-down in the Google SERPs. --- components/layout/fragment.rs | 7 +++++++ components/layout/inline.rs | 25 ++++++++++++++++--------- 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'components/layout') diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index c11d9170679..7895acee9a8 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -2378,6 +2378,13 @@ impl Fragment { self.style.get_box().position == position::T::absolute } + pub fn is_inline_absolute(&self) -> bool { + match self.specific { + SpecificFragmentInfo::InlineAbsolute(..) => true, + _ => false, + } + } + pub fn meld_with_next_inline_fragment(&mut self, next_fragment: &Fragment) { if let Some(ref mut inline_context_of_this_fragment) = self.inline_context { if let Some(ref inline_context_of_next_fragment) = next_fragment.inline_context { diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 6066b4a8473..ac2d4755d13 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -738,13 +738,17 @@ impl LineBreaker { layout_context: &LayoutContext) { let indentation = self.indentation_for_pending_fragment(); self.pending_line.range.extend_by(FragmentIndex(1)); - self.pending_line.bounds.size.inline = self.pending_line.bounds.size.inline + - fragment.margin_box_inline_size() + - indentation; - self.pending_line.inline_metrics = - self.new_inline_metrics_for_line(&fragment, layout_context); - self.pending_line.bounds.size.block = - self.new_block_size_for_line(&fragment, layout_context); + + if !fragment.is_inline_absolute() { + self.pending_line.bounds.size.inline = self.pending_line.bounds.size.inline + + fragment.margin_box_inline_size() + + indentation; + self.pending_line.inline_metrics = + self.new_inline_metrics_for_line(&fragment, layout_context); + self.pending_line.bounds.size.block = + self.new_block_size_for_line(&fragment, layout_context); + } + self.new_fragments.push(fragment); } @@ -1079,8 +1083,11 @@ impl InlineFlow { fragment.border_box.size.inline, fragment.border_box.size.block); fragment.update_late_computed_inline_position_if_necessary(); - inline_start_position_for_fragment = inline_start_position_for_fragment + - fragment.border_box.size.inline + fragment.margin.inline_end; + + if !fragment.is_inline_absolute() { + inline_start_position_for_fragment = inline_start_position_for_fragment + + fragment.border_box.size.inline + fragment.margin.inline_end; + } } } } -- cgit v1.2.3