mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #6947 - pcwalton:table-center, r=glennw
layout: Don't use the block container inline size as the initial computed table inline size. Makes google.com fully centered. r? @glennw cc @SimonSapin <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6947) <!-- Reviewable:end -->
This commit is contained in:
commit
2205570083
33 changed files with 118 additions and 80 deletions
|
@ -216,6 +216,12 @@ impl TableWrapperFlow {
|
|||
|accumulator, intermediate_column_inline_sizes| {
|
||||
accumulator + intermediate_column_inline_sizes.size
|
||||
});
|
||||
let preferred_width_of_all_columns =
|
||||
self.column_intrinsic_inline_sizes.iter()
|
||||
.fold(border_padding + spacing,
|
||||
|accumulator, column_intrinsic_inline_sizes| {
|
||||
accumulator + column_intrinsic_inline_sizes.preferred
|
||||
});
|
||||
|
||||
// Delegate to the appropriate inline size computer to find the constraint inputs and write
|
||||
// the constraint solutions in.
|
||||
|
@ -223,6 +229,7 @@ impl TableWrapperFlow {
|
|||
if self.block_flow.base.flags.is_float() {
|
||||
let inline_size_computer = FloatedTable {
|
||||
minimum_width_of_all_columns: minimum_width_of_all_columns,
|
||||
preferred_width_of_all_columns: preferred_width_of_all_columns,
|
||||
border_collapse: border_collapse,
|
||||
};
|
||||
let input =
|
||||
|
@ -241,6 +248,7 @@ impl TableWrapperFlow {
|
|||
|
||||
let inline_size_computer = Table {
|
||||
minimum_width_of_all_columns: minimum_width_of_all_columns,
|
||||
preferred_width_of_all_columns: preferred_width_of_all_columns,
|
||||
border_collapse: border_collapse,
|
||||
};
|
||||
let input =
|
||||
|
@ -703,13 +711,14 @@ struct IntermediateColumnInlineSize {
|
|||
|
||||
fn initial_computed_inline_size(block: &mut BlockFlow,
|
||||
containing_block_inline_size: Au,
|
||||
minimum_width_of_all_columns: Au)
|
||||
minimum_width_of_all_columns: Au,
|
||||
preferred_width_of_all_columns: Au)
|
||||
-> MaybeAuto {
|
||||
let inline_size_from_style = MaybeAuto::from_style(block.fragment.style.content_inline_size(),
|
||||
containing_block_inline_size);
|
||||
match inline_size_from_style {
|
||||
MaybeAuto::Auto => {
|
||||
MaybeAuto::Specified(max(containing_block_inline_size, minimum_width_of_all_columns))
|
||||
MaybeAuto::Specified(min(containing_block_inline_size, preferred_width_of_all_columns))
|
||||
}
|
||||
MaybeAuto::Specified(inline_size_from_style) => {
|
||||
MaybeAuto::Specified(max(inline_size_from_style, minimum_width_of_all_columns))
|
||||
|
@ -719,6 +728,7 @@ fn initial_computed_inline_size(block: &mut BlockFlow,
|
|||
|
||||
struct Table {
|
||||
minimum_width_of_all_columns: Au,
|
||||
preferred_width_of_all_columns: Au,
|
||||
border_collapse: border_collapse::T,
|
||||
}
|
||||
|
||||
|
@ -739,7 +749,8 @@ impl ISizeAndMarginsComputer for Table {
|
|||
layout_context);
|
||||
initial_computed_inline_size(block,
|
||||
containing_block_inline_size,
|
||||
self.minimum_width_of_all_columns)
|
||||
self.minimum_width_of_all_columns,
|
||||
self.preferred_width_of_all_columns)
|
||||
}
|
||||
|
||||
fn solve_inline_size_constraints(&self,
|
||||
|
@ -752,6 +763,7 @@ impl ISizeAndMarginsComputer for Table {
|
|||
|
||||
struct FloatedTable {
|
||||
minimum_width_of_all_columns: Au,
|
||||
preferred_width_of_all_columns: Au,
|
||||
border_collapse: border_collapse::T,
|
||||
}
|
||||
|
||||
|
@ -772,7 +784,8 @@ impl ISizeAndMarginsComputer for FloatedTable {
|
|||
layout_context);
|
||||
initial_computed_inline_size(block,
|
||||
containing_block_inline_size,
|
||||
self.minimum_width_of_all_columns)
|
||||
self.minimum_width_of_all_columns,
|
||||
self.preferred_width_of_all_columns)
|
||||
}
|
||||
|
||||
fn solve_inline_size_constraints(&self,
|
||||
|
|
|
@ -284,6 +284,7 @@ flaky_cpu == linebreak_simple_a.html linebreak_simple_b.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_center_a.html table_center_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
|
||||
|
@ -294,6 +295,7 @@ flaky_cpu == linebreak_simple_a.html linebreak_simple_b.html
|
|||
== table_padding_a.html table_padding_ref.html
|
||||
== table_percentage_capping_a.html table_percentage_capping_ref.html
|
||||
== table_percentage_width_a.html table_percentage_width_ref.html
|
||||
== table_preferred_width_a.html table_preferred_width_ref.html
|
||||
== table_row_direction_a.html table_row_direction_ref.html
|
||||
== table_width_attribute_a.html table_width_attribute_ref.html
|
||||
== text_align_complex_a.html text_align_complex_ref.html
|
||||
|
|
12
tests/ref/table_center_a.html
Normal file
12
tests/ref/table_center_a.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<style>
|
||||
body, html {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<center><table border=0 cellspacing=0><tr><td style="border: none; padding: 0; height: 100px; width: 100px; background: green"></td></tr></table></center>
|
||||
</body>
|
||||
</html>
|
||||
|
13
tests/ref/table_center_ref.html
Normal file
13
tests/ref/table_center_ref.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<style>
|
||||
body, html {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<center><div style="height: 100px; width: 100px; background: green"></div></center>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
35
tests/ref/table_preferred_width_a.html
Normal file
35
tests/ref/table_preferred_width_a.html
Normal file
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
#a {
|
||||
width: 500px;
|
||||
}
|
||||
table, table * {
|
||||
border: none;
|
||||
border-spacing: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
<div id=a><table><td>
|
||||
Hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
</td></table></div>
|
||||
|
35
tests/ref/table_preferred_width_ref.html
Normal file
35
tests/ref/table_preferred_width_ref.html
Normal file
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
#a {
|
||||
width: 500px;
|
||||
}
|
||||
table, table * {
|
||||
border: none;
|
||||
border-spacing: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
<div id=a>
|
||||
Hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
hello hello hello hello
|
||||
</div>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
[background-attachment-applies-to-001.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[background-attachment-applies-to-002.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[background-attachment-applies-to-003.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[background-attachment-applies-to-004.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[background-attachment-applies-to-007.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[background-attachment-applies-to-013.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[background-repeat-applies-to-007.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[c5525-fltmult-000.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[line-height-applies-to-001.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[line-height-applies-to-002.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[line-height-applies-to-003.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[line-height-applies-to-004.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[line-height-applies-to-006.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[line-height-applies-to-007.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[line-height-applies-to-013.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[margin-bottom-applies-to-001.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[margin-bottom-applies-to-002.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[margin-bottom-applies-to-003.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[margin-bottom-applies-to-004.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[margin-bottom-applies-to-006.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[margin-bottom-applies-to-007.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +1,3 @@
|
|||
[run-in-basic-017.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
||||
expected: FAIL
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[table-visual-layout-026a.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[table-visual-layout-026b.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[table-visual-layout-026c.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -1,3 +0,0 @@
|
|||
[table-visual-layout-026d.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
|
@ -0,0 +1,3 @@
|
|||
[vertical-align-baseline-009.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
Loading…
Add table
Add a link
Reference in a new issue