mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
layout: Generate anonymous table objects as necessary per CSS 2.1 §
17.2.1. Improves Facebook Timeline.
This commit is contained in:
parent
b0a7d1bf86
commit
f0954f8799
4 changed files with 101 additions and 3 deletions
|
@ -302,6 +302,41 @@ impl<'a> FlowConstructor<'a> {
|
|||
Fragment::new(node, specific_fragment_info)
|
||||
}
|
||||
|
||||
/// Generates anonymous table objects per CSS 2.1 § 17.2.1.
|
||||
fn generate_anonymous_table_flows_if_necessary(&mut self,
|
||||
flow: &mut FlowRef,
|
||||
child: &mut FlowRef,
|
||||
child_node: &ThreadSafeLayoutNode) {
|
||||
if !flow.is_block_flow() {
|
||||
return
|
||||
}
|
||||
|
||||
if child.is_table_cell() {
|
||||
let fragment = Fragment::new(child_node, SpecificFragmentInfo::TableRow);
|
||||
let mut new_child = FlowRef::new(box TableRowFlow::from_node_and_fragment(child_node,
|
||||
fragment));
|
||||
new_child.add_new_child(child.clone());
|
||||
child.finish();
|
||||
*child = new_child
|
||||
}
|
||||
if child.is_table_row() || child.is_table_rowgroup() {
|
||||
let fragment = Fragment::new(child_node, SpecificFragmentInfo::Table);
|
||||
let mut new_child = FlowRef::new(box TableFlow::from_node_and_fragment(child_node,
|
||||
fragment));
|
||||
new_child.add_new_child(child.clone());
|
||||
child.finish();
|
||||
*child = new_child
|
||||
}
|
||||
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));
|
||||
new_child.add_new_child(child.clone());
|
||||
child.finish();
|
||||
*child = new_child
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates an inline flow from a set of inline fragments, then adds it as a child of the given
|
||||
/// flow or pushes it onto the given flow list.
|
||||
///
|
||||
|
@ -393,11 +428,12 @@ impl<'a> FlowConstructor<'a> {
|
|||
first_fragment: &mut bool) {
|
||||
match kid.swap_out_construction_result() {
|
||||
ConstructionResult::None => {}
|
||||
ConstructionResult::Flow(kid_flow, kid_abs_descendants) => {
|
||||
ConstructionResult::Flow(mut kid_flow, kid_abs_descendants) => {
|
||||
// If kid_flow is TableCaptionFlow, kid_flow should be added under
|
||||
// TableWrapperFlow.
|
||||
if flow.is_table() && kid_flow.is_table_caption() {
|
||||
self.set_flow_construction_result(&kid, ConstructionResult::Flow(kid_flow,
|
||||
self.set_flow_construction_result(&kid,
|
||||
ConstructionResult::Flow(kid_flow,
|
||||
Descendants::new()))
|
||||
} else if flow.need_anonymous_flow(&*kid_flow) {
|
||||
consecutive_siblings.push(kid_flow)
|
||||
|
@ -417,6 +453,7 @@ impl<'a> FlowConstructor<'a> {
|
|||
let consecutive_siblings = mem::replace(consecutive_siblings, vec!());
|
||||
self.generate_anonymous_missing_child(consecutive_siblings, flow, node);
|
||||
}
|
||||
self.generate_anonymous_table_flows_if_necessary(flow, &mut kid_flow, &kid);
|
||||
flow.add_new_child(kid_flow);
|
||||
}
|
||||
abs_descendants.push_descendants(kid_abs_descendants);
|
||||
|
|
|
@ -289,6 +289,7 @@ experimental == rtl_simple.html rtl_simple_ref.html
|
|||
== table_auto_width.html table_auto_width_ref.html
|
||||
== table_caption_bottom_a.html table_caption_bottom_ref.html
|
||||
== table_caption_top_a.html table_caption_top_ref.html
|
||||
== table_cell_float_a.html table_cell_float_ref.html
|
||||
== table_colspan_fixed_a.html table_colspan_fixed_ref.html
|
||||
== table_colspan_simple_a.html table_colspan_simple_ref.html
|
||||
== table_containing_block_a.html table_containing_block_ref.html
|
||||
|
|
29
tests/ref/table_cell_float_a.html
Normal file
29
tests/ref/table_cell_float_a.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<!-- Tests that an element with `display: table-cell` is correctly positioned next to a float. -->
|
||||
<style>
|
||||
body, html {
|
||||
margin: 0;
|
||||
}
|
||||
section {
|
||||
float: left;
|
||||
display: block;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: firebrick;
|
||||
}
|
||||
.a {
|
||||
display: table-cell;
|
||||
width: 128px;
|
||||
height: 64px;
|
||||
background: green;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<section></section>
|
||||
<div class=a></div>
|
||||
</body>
|
||||
</html>
|
||||
|
31
tests/ref/table_cell_float_ref.html
Normal file
31
tests/ref/table_cell_float_ref.html
Normal file
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<!-- Tests that an element with `display: table-cell` is correctly positioned next to a float. -->
|
||||
<style>
|
||||
body, html {
|
||||
margin: 0;
|
||||
}
|
||||
section {
|
||||
float: left;
|
||||
display: block;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: firebrick;
|
||||
}
|
||||
.a {
|
||||
position: absolute;
|
||||
left: 32px;
|
||||
top: 0;
|
||||
width: 128px;
|
||||
height: 64px;
|
||||
background: green;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<section></section>
|
||||
<div class=a></div>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue