From efa1885e1b6f87622b6e86445af9044c080422f1 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 3 Dec 2019 11:33:44 +0100 Subject: [PATCH] Remove IndependentFormattingContext::layout Callers should handle replaced v.s. not separately --- components/layout_2020/formatting_contexts.rs | 18 ------------- components/layout_2020/positioned.rs | 25 +++++++++++++------ 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/components/layout_2020/formatting_contexts.rs b/components/layout_2020/formatting_contexts.rs index c6e4611db56..0527d8eda38 100644 --- a/components/layout_2020/formatting_contexts.rs +++ b/components/layout_2020/formatting_contexts.rs @@ -91,24 +91,6 @@ impl IndependentFormattingContext { Contents::Flow(f) => Err(NR(Kind::Flow(f))), } } - - pub fn layout<'a>( - &'a self, - layout_context: &LayoutContext, - containing_block: &ContainingBlock, - tree_rank: usize, - absolutely_positioned_fragments: &mut Vec>, - ) -> IndependentLayout { - match self.as_replaced() { - Ok(replaced) => replaced.layout(&self.style, containing_block), - Err(ifc) => ifc.layout( - layout_context, - containing_block, - tree_rank, - absolutely_positioned_fragments, - ), - } - } } impl<'a> NonReplacedIFC<'a> { diff --git a/components/layout_2020/positioned.rs b/components/layout_2020/positioned.rs index cd801e7e1c0..c7b27bb27fc 100644 --- a/components/layout_2020/positioned.rs +++ b/components/layout_2020/positioned.rs @@ -292,14 +292,23 @@ impl<'a> AbsolutelyPositionedFragment<'a> { containing_block.mode, containing_block_for_children.mode, "Mixed writing modes are not supported yet" ); - let dummy_tree_rank = 0; - let mut absolutely_positioned_fragments = vec![]; - let mut independent_layout = self.absolutely_positioned_box.contents.layout( - layout_context, - &containing_block_for_children, - dummy_tree_rank, - &mut absolutely_positioned_fragments, - ); + let mut absolutely_positioned_fragments = Vec::new(); + let mut independent_layout = match self.absolutely_positioned_box.contents.as_replaced() { + // FIXME: implement https://drafts.csswg.org/css2/visudet.html#abs-replaced-width + Ok(replaced) => replaced.layout( + &self.absolutely_positioned_box.contents.style, + &containing_block_for_children, + ), + Err(non_replaced) => { + let dummy_tree_rank = 0; + non_replaced.layout( + layout_context, + &containing_block_for_children, + dummy_tree_rank, + &mut absolutely_positioned_fragments, + ) + }, + }; let inline_start = match inline_anchor { Anchor::Start(start) => start + pb.inline_start + margin.inline_start,