diff --git a/components/layout/block.rs b/components/layout/block.rs index 39a0fe715f7..6396558aaeb 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -562,33 +562,20 @@ impl Encodable for BlockFlowFlags { } impl BlockFlow { - pub fn from_node_and_fragment(node: &ThreadSafeLayoutNode, fragment: Fragment) -> BlockFlow { + pub fn from_node_and_fragment(node: &ThreadSafeLayoutNode, + fragment: Fragment, + float_kind: Option) + -> BlockFlow { let writing_mode = node.style().writing_mode; BlockFlow { - base: BaseFlow::new(Some((*node).clone()), - writing_mode, - ForceNonfloatedFlag::ForceNonfloated), + base: BaseFlow::new(Some((*node).clone()), writing_mode, match float_kind { + Some(_) => ForceNonfloatedFlag::FloatIfNecessary, + None => ForceNonfloatedFlag::ForceNonfloated, + }), fragment: fragment, inline_size_of_preceding_left_floats: Au(0), inline_size_of_preceding_right_floats: Au(0), - float: None, - flags: BlockFlowFlags::empty(), - } - } - - pub fn float_from_node_and_fragment(node: &ThreadSafeLayoutNode, - fragment: Fragment, - float_kind: FloatKind) - -> BlockFlow { - let writing_mode = node.style().writing_mode; - BlockFlow { - base: BaseFlow::new(Some((*node).clone()), - writing_mode, - ForceNonfloatedFlag::FloatIfNecessary), - fragment: fragment, - inline_size_of_preceding_left_floats: Au(0), - inline_size_of_preceding_right_floats: Au(0), - float: Some(box FloatedBlockInfo::new(float_kind)), + float: float_kind.map(|kind| box FloatedBlockInfo::new(kind)), flags: BlockFlowFlags::empty(), } } diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 12f9900b088..6c4537e8b26 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -331,7 +331,7 @@ impl<'a> FlowConstructor<'a> { if child.is_table() { let fragment = Fragment::new(child_node, SpecificFragmentInfo::TableWrapper); let mut new_child = - FlowRef::new(box TableWrapperFlow::from_node_and_fragment(child_node, fragment)); + FlowRef::new(box TableWrapperFlow::from_node_and_fragment(child_node, fragment, None)); new_child.add_new_child(child.clone()); child.finish(); *child = new_child @@ -602,7 +602,7 @@ impl<'a> FlowConstructor<'a> { /// /// FIXME(pcwalton): It is not clear to me that there isn't a cleaner way to handle /// `