layout: Float table wrappers directly instead of generating a block

wrapper around them.

Fixes Wikipedia tables leaking out.

Along the way, I refactored tables' width calculation significantly.
This was necessary in order to properly handle floated tables, as some
of the logic had to be ported over from block flows.
This commit is contained in:
Patrick Walton 2014-09-19 22:46:41 -07:00
parent e9a7b44f68
commit 62bb9093d7
9 changed files with 270 additions and 217 deletions

View file

@ -735,7 +735,13 @@ impl<'a> FlowConstructor<'a> {
fn build_flow_for_table_wrapper(&mut self, node: &ThreadSafeLayoutNode,
float_value: float::T) -> ConstructionResult {
let fragment = Fragment::new_from_specific_info(node, TableWrapperFragment);
let wrapper_flow = box TableWrapperFlow::from_node_and_fragment(node, fragment);
let wrapper_flow = match float_value {
float::none => box TableWrapperFlow::from_node_and_fragment(node, fragment),
_ => {
let float_kind = FloatKind::from_property(float_value);
box TableWrapperFlow::float_from_node_and_fragment(node, fragment, float_kind)
}
};
let mut wrapper_flow = FlowRef::new(wrapper_flow as Box<Flow>);
let table_fragment = Fragment::new_from_specific_info(node, TableFragment);
@ -784,19 +790,7 @@ impl<'a> FlowConstructor<'a> {
}
}
match float_value {
float::none => {
FlowConstructionResult(wrapper_flow, abs_descendants)
}
_ => {
let float_kind = FloatKind::from_property(float_value);
let float_flow = box BlockFlow::float_from_node(self, node, float_kind) as Box<Flow>;
let mut float_flow = FlowRef::new(float_flow);
float_flow.add_new_child(wrapper_flow);
float_flow.finish(self.layout_context);
FlowConstructionResult(float_flow, abs_descendants)
}
}
FlowConstructionResult(wrapper_flow, abs_descendants)
}
/// Builds a flow for a node with `display: table-caption`. This yields a `TableCaptionFlow`