mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Add support for tables that are floated.
This commit is contained in:
parent
b64f27b2b6
commit
6a9001b4fd
4 changed files with 76 additions and 4 deletions
|
@ -684,7 +684,8 @@ impl<'a, 'b> FlowConstructor<'a, 'b> {
|
||||||
|
|
||||||
/// Builds a flow for a node with `display: table`. This yields a `TableWrapperFlow` with possibly
|
/// Builds a flow for a node with `display: table`. This yields a `TableWrapperFlow` with possibly
|
||||||
/// other `TableCaptionFlow`s or `TableFlow`s underneath it.
|
/// other `TableCaptionFlow`s or `TableFlow`s underneath it.
|
||||||
fn build_flow_for_table_wrapper(&mut self, node: &ThreadSafeLayoutNode) -> ConstructionResult {
|
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 fragment = Fragment::new_from_specific_info(node, TableWrapperFragment);
|
||||||
let wrapper_flow = box TableWrapperFlow::from_node_and_fragment(node, fragment);
|
let wrapper_flow = box TableWrapperFlow::from_node_and_fragment(node, fragment);
|
||||||
let mut wrapper_flow = FlowRef::new(wrapper_flow as Box<Flow>);
|
let mut wrapper_flow = FlowRef::new(wrapper_flow as Box<Flow>);
|
||||||
|
@ -734,8 +735,21 @@ impl<'a, 'b> FlowConstructor<'a, 'b> {
|
||||||
abs_descendants.push(wrapper_flow.clone());
|
abs_descendants.push(wrapper_flow.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match float_value {
|
||||||
|
float::none => {
|
||||||
FlowConstructionResult(wrapper_flow, abs_descendants)
|
FlowConstructionResult(wrapper_flow, abs_descendants)
|
||||||
}
|
}
|
||||||
|
float_kind => {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Builds a flow for a node with `display: table-caption`. This yields a `TableCaptionFlow`
|
/// Builds a flow for a node with `display: table-caption`. This yields a `TableCaptionFlow`
|
||||||
/// with possibly other `BlockFlow`s or `InlineFlow`s underneath it.
|
/// with possibly other `BlockFlow`s or `InlineFlow`s underneath it.
|
||||||
|
@ -858,8 +872,8 @@ impl<'a, 'b> PostorderNodeMutTraversal for FlowConstructor<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Table items contribute table flow construction results.
|
// Table items contribute table flow construction results.
|
||||||
(display::table, _, _) => {
|
(display::table, float_value, _) => {
|
||||||
let construction_result = self.build_flow_for_table_wrapper(node);
|
let construction_result = self.build_flow_for_table_wrapper(node, float_value);
|
||||||
node.set_flow_construction_result(construction_result)
|
node.set_flow_construction_result(construction_result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,3 +122,4 @@ flaky_gpu,flaky_linux == acid2_noscroll.html acid2_ref_broken.html
|
||||||
== inline_block_margin_a.html inline_block_margin_ref.html
|
== inline_block_margin_a.html inline_block_margin_ref.html
|
||||||
== inline_block_img_a.html inline_block_img_ref.html
|
== inline_block_img_a.html inline_block_img_ref.html
|
||||||
== inline_block_baseline_a.html inline_block_baseline_ref.html
|
== inline_block_baseline_a.html inline_block_baseline_ref.html
|
||||||
|
== float_table_a.html float_table_ref.html
|
||||||
|
|
35
tests/ref/float_table_a.html
Normal file
35
tests/ref/float_table_a.html
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<style type="text/css">
|
||||||
|
@font-face {
|
||||||
|
font-family: 'ahem';
|
||||||
|
src: url(fonts/ahem/ahem.ttf);
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
font-family: 'ahem';
|
||||||
|
font-size: 100px;
|
||||||
|
color: red;
|
||||||
|
float: right;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>X</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
22
tests/ref/float_table_ref.html
Normal file
22
tests/ref/float_table_ref.html
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
background-color: red;
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue