diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2015-08-31 18:56:52 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2015-09-01 12:18:19 -0700 |
commit | 676f7014e8ccaa28ea0abd8cb6193622c7c472ef (patch) | |
tree | 6fe79dac0b06138e9582fb86c4289f68b8b9d877 /components/layout/inline.rs | |
parent | 9f85370885c84ebb58cd7f4a72a6e78948f468dc (diff) | |
download | servo-676f7014e8ccaa28ea0abd8cb6193622c7c472ef.tar.gz servo-676f7014e8ccaa28ea0abd8cb6193622c7c472ef.zip |
layout: Implement partial support for inline absolute containing blocks.
Improves the position of the down arrows on google.com SERPs.
Diffstat (limited to 'components/layout/inline.rs')
-rw-r--r-- | components/layout/inline.rs | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 4202b6b9d16..8893a6efb76 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -1277,7 +1277,7 @@ impl InlineFlow { } fn containing_block_range_for_flow(&self, opaque_flow: OpaqueFlow) -> Range<FragmentIndex> { - let index = FragmentIndex(self.fragments.fragments.iter().position(|fragment| { + match self.fragments.fragments.iter().position(|fragment| { match fragment.specific { SpecificFragmentInfo::InlineAbsolute(ref inline_absolute) => { OpaqueFlow::from_flow(&*inline_absolute.flow_ref) == opaque_flow @@ -1288,9 +1288,19 @@ impl InlineFlow { } _ => false, } - }).expect("containing_block_range_for_flow(): couldn't find inline absolute fragment!") - as isize); - self.containing_block_range_for_flow_surrounding_fragment_at_index(index) + }) { + Some(index) => { + let index = FragmentIndex(index as isize); + self.containing_block_range_for_flow_surrounding_fragment_at_index(index) + } + None => { + // FIXME(pcwalton): This is quite wrong. We should only return the range + // surrounding the inline fragments that constitute the containing block. But this + // suffices to get Google looking right. + Range::new(FragmentIndex(0), + FragmentIndex(self.fragments.fragments.len() as isize)) + } + } } } @@ -1762,9 +1772,7 @@ impl Flow for InlineFlow { } fn contains_positioned_fragments(&self) -> bool { - self.fragments.fragments.iter().any(|fragment| { - fragment.style.get_box().position != position::T::static_ - }) + self.fragments.fragments.iter().any(|fragment| fragment.is_positioned()) } fn contains_relatively_positioned_fragments(&self) -> bool { @@ -1777,10 +1785,13 @@ impl Flow for InlineFlow { let mut containing_block_size = LogicalSize::new(self.base.writing_mode, Au(0), Au(0)); for index in self.containing_block_range_for_flow(for_flow).each_index() { let fragment = &self.fragments.fragments[index.get() as usize]; + if fragment.is_absolutely_positioned() { + continue + } containing_block_size.inline = containing_block_size.inline + fragment.border_box.size.inline; containing_block_size.block = max(containing_block_size.block, - fragment.border_box.size.block) + fragment.border_box.size.block); } containing_block_size } |