mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
parent
5b46a59194
commit
a3af2303d6
17 changed files with 147 additions and 58 deletions
|
@ -311,11 +311,12 @@ impl Flow for TableFlow {
|
||||||
&mut self.collapsed_block_direction_border_widths_for_table);
|
&mut self.collapsed_block_direction_border_widths_for_table);
|
||||||
previous_collapsed_block_end_borders =
|
previous_collapsed_block_end_borders =
|
||||||
PreviousBlockCollapsedBorders::FromPreviousRow(
|
PreviousBlockCollapsedBorders::FromPreviousRow(
|
||||||
row.final_collapsed_borders.block_end.clone())
|
row.final_collapsed_borders.block_end.clone());
|
||||||
}
|
}
|
||||||
first_row = false
|
first_row = false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
computation.surrounding_size = computation.surrounding_size +
|
computation.surrounding_size = computation.surrounding_size +
|
||||||
self.total_horizontal_spacing();
|
self.total_horizontal_spacing();
|
||||||
|
@ -425,7 +426,7 @@ impl Flow for TableFlow {
|
||||||
collapsed_inline_direction_border_widths_for_table,
|
collapsed_inline_direction_border_widths_for_table,
|
||||||
&mut collapsed_block_direction_border_widths_for_table);
|
&mut collapsed_block_direction_border_widths_for_table);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assign_block_size<'a>(&mut self, _: &'a LayoutContext<'a>) {
|
fn assign_block_size<'a>(&mut self, _: &'a LayoutContext<'a>) {
|
||||||
|
@ -589,7 +590,7 @@ impl ColumnIntrinsicInlineSize {
|
||||||
///
|
///
|
||||||
/// TODO(pcwalton): There will probably be some `border-collapse`-related info in here too
|
/// TODO(pcwalton): There will probably be some `border-collapse`-related info in here too
|
||||||
/// eventually.
|
/// eventually.
|
||||||
#[derive(RustcEncodable, Clone, Copy)]
|
#[derive(RustcEncodable, Clone, Copy, Debug)]
|
||||||
pub struct ColumnComputedInlineSize {
|
pub struct ColumnComputedInlineSize {
|
||||||
/// The computed size of this inline column.
|
/// The computed size of this inline column.
|
||||||
pub size: Au,
|
pub size: Au,
|
||||||
|
@ -629,27 +630,21 @@ fn perform_border_collapse_for_row(child_table_row: &mut TableRowFlow,
|
||||||
next_block_borders: NextBlockCollapsedBorders,
|
next_block_borders: NextBlockCollapsedBorders,
|
||||||
inline_spacing: &mut Vec<Au>,
|
inline_spacing: &mut Vec<Au>,
|
||||||
block_spacing: &mut Vec<Au>) {
|
block_spacing: &mut Vec<Au>) {
|
||||||
|
let number_of_borders_inline_direction = child_table_row.preliminary_collapsed_borders.inline.len();
|
||||||
// Compute interior inline borders.
|
// Compute interior inline borders.
|
||||||
for (i, this_inline_border) in child_table_row.preliminary_collapsed_borders
|
for (i, this_inline_border) in child_table_row.preliminary_collapsed_borders
|
||||||
.inline
|
.inline
|
||||||
.iter()
|
.iter_mut()
|
||||||
.enumerate() {
|
.enumerate() {
|
||||||
child_table_row.final_collapsed_borders.inline.push_or_set(i, *this_inline_border);
|
child_table_row.final_collapsed_borders.inline.push_or_set(i, *this_inline_border);
|
||||||
|
if i == 0 {
|
||||||
|
child_table_row.final_collapsed_borders.inline[i].combine(&table_inline_borders.start);
|
||||||
|
} else if i + 1 == number_of_borders_inline_direction {
|
||||||
|
child_table_row.final_collapsed_borders.inline[i].combine(&table_inline_borders.end);
|
||||||
|
}
|
||||||
|
|
||||||
let inline_spacing = inline_spacing.get_mut_or_push(i, Au(0));
|
let inline_spacing = inline_spacing.get_mut_or_push(i, Au(0));
|
||||||
*inline_spacing = cmp::max(*inline_spacing, this_inline_border.width)
|
*inline_spacing = cmp::max(*inline_spacing, child_table_row.final_collapsed_borders.inline[i].width)
|
||||||
}
|
|
||||||
|
|
||||||
// Collapse edge interior borders with the table.
|
|
||||||
if let Some(ref mut first_inline_borders) = child_table_row.final_collapsed_borders
|
|
||||||
.inline
|
|
||||||
.get_mut(0) {
|
|
||||||
first_inline_borders.combine(&table_inline_borders.start)
|
|
||||||
}
|
|
||||||
if let Some(ref mut last_inline_borders) = child_table_row.final_collapsed_borders
|
|
||||||
.inline
|
|
||||||
.last_mut() {
|
|
||||||
last_inline_borders.combine(&table_inline_borders.end)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute block-start borders.
|
// Compute block-start borders.
|
||||||
|
@ -777,6 +772,7 @@ impl TableLikeFlow for BlockFlow {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inline collapsed borders for the table itself.
|
/// Inline collapsed borders for the table itself.
|
||||||
|
#[derive(Debug)]
|
||||||
struct TableInlineCollapsedBorders {
|
struct TableInlineCollapsedBorders {
|
||||||
/// The table border at the start of the inline direction.
|
/// The table border at the start of the inline direction.
|
||||||
start: CollapsedBorder,
|
start: CollapsedBorder,
|
||||||
|
|
|
@ -245,10 +245,13 @@ impl Flow for TableRowFlow {
|
||||||
.style()
|
.style()
|
||||||
.get_inheritedtable()
|
.get_inheritedtable()
|
||||||
.border_collapse == border_collapse::T::collapse;
|
.border_collapse == border_collapse::T::collapse;
|
||||||
// FIXME(pcwalton): Shouldn't use `CollapsedBorder::new()` here.
|
let row_style = &*self.block_flow.fragment.style;
|
||||||
self.preliminary_collapsed_borders.reset(CollapsedBorder::new());
|
self.preliminary_collapsed_borders.reset(
|
||||||
|
CollapsedBorder::inline_start(&row_style,
|
||||||
|
CollapsedBorderProvenance::FromTableRow));
|
||||||
|
|
||||||
{
|
{
|
||||||
|
let children_count = self.block_flow.base.children.len();
|
||||||
let mut iterator = self.block_flow.base.child_iter_mut().enumerate().peekable();
|
let mut iterator = self.block_flow.base.child_iter_mut().enumerate().peekable();
|
||||||
while let Some((i, kid)) = iterator.next() {
|
while let Some((i, kid)) = iterator.next() {
|
||||||
assert!(kid.is_table_cell());
|
assert!(kid.is_table_cell());
|
||||||
|
@ -268,6 +271,8 @@ impl Flow for TableRowFlow {
|
||||||
// Perform border collapse if necessary.
|
// Perform border collapse if necessary.
|
||||||
if collapsing_borders {
|
if collapsing_borders {
|
||||||
perform_inline_direction_border_collapse_for_row(
|
perform_inline_direction_border_collapse_for_row(
|
||||||
|
row_style,
|
||||||
|
children_count,
|
||||||
i,
|
i,
|
||||||
child_table_cell,
|
child_table_cell,
|
||||||
&mut iterator,
|
&mut iterator,
|
||||||
|
@ -829,10 +834,20 @@ pub struct BorderCollapseInfoForChildTableCell<'a> {
|
||||||
/// table row. This is done eagerly here so that at least the inline inside border collapse
|
/// table row. This is done eagerly here so that at least the inline inside border collapse
|
||||||
/// computations can be parallelized across all the rows of the table.
|
/// computations can be parallelized across all the rows of the table.
|
||||||
fn perform_inline_direction_border_collapse_for_row(
|
fn perform_inline_direction_border_collapse_for_row(
|
||||||
|
row_style: &ServoComputedValues,
|
||||||
|
children_count: usize,
|
||||||
child_index: usize,
|
child_index: usize,
|
||||||
child_table_cell: &mut TableCellFlow,
|
child_table_cell: &mut TableCellFlow,
|
||||||
iterator: &mut Peekable<Enumerate<MutFlowListIterator>>,
|
iterator: &mut Peekable<Enumerate<MutFlowListIterator>>,
|
||||||
preliminary_collapsed_borders: &mut CollapsedBordersForRow) {
|
preliminary_collapsed_borders: &mut CollapsedBordersForRow) {
|
||||||
|
// In the first cell, combine its border with the one coming from the row.
|
||||||
|
if child_index == 0 {
|
||||||
|
let first_inline_border = &mut preliminary_collapsed_borders.inline[0];
|
||||||
|
first_inline_border.combine(
|
||||||
|
&CollapsedBorder::inline_start(&*child_table_cell.block_flow.fragment.style,
|
||||||
|
CollapsedBorderProvenance::FromPreviousTableCell));
|
||||||
|
}
|
||||||
|
|
||||||
let inline_collapsed_border = preliminary_collapsed_borders.inline.push_or_set(
|
let inline_collapsed_border = preliminary_collapsed_borders.inline.push_or_set(
|
||||||
child_index + 1,
|
child_index + 1,
|
||||||
CollapsedBorder::inline_end(&*child_table_cell.block_flow.fragment.style,
|
CollapsedBorder::inline_end(&*child_table_cell.block_flow.fragment.style,
|
||||||
|
@ -845,12 +860,25 @@ fn perform_inline_direction_border_collapse_for_row(
|
||||||
CollapsedBorderProvenance::FromNextTableCell))
|
CollapsedBorderProvenance::FromNextTableCell))
|
||||||
};
|
};
|
||||||
|
|
||||||
let block_start_border =
|
// In the last cell, also take into account the border that may
|
||||||
|
// come from the row.
|
||||||
|
if child_index + 1 == children_count {
|
||||||
|
inline_collapsed_border.combine(
|
||||||
|
&CollapsedBorder::inline_end(&row_style,
|
||||||
|
CollapsedBorderProvenance::FromTableRow));
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut block_start_border =
|
||||||
CollapsedBorder::block_start(&*child_table_cell.block_flow.fragment.style,
|
CollapsedBorder::block_start(&*child_table_cell.block_flow.fragment.style,
|
||||||
CollapsedBorderProvenance::FromNextTableCell);
|
CollapsedBorderProvenance::FromNextTableCell);
|
||||||
|
block_start_border.combine(
|
||||||
|
&CollapsedBorder::block_start(row_style, CollapsedBorderProvenance::FromTableRow));
|
||||||
preliminary_collapsed_borders.block_start.push_or_set(child_index, block_start_border);
|
preliminary_collapsed_borders.block_start.push_or_set(child_index, block_start_border);
|
||||||
let block_end_border =
|
let mut block_end_border =
|
||||||
CollapsedBorder::block_end(&*child_table_cell.block_flow.fragment.style,
|
CollapsedBorder::block_end(&*child_table_cell.block_flow.fragment.style,
|
||||||
CollapsedBorderProvenance::FromPreviousTableCell);
|
CollapsedBorderProvenance::FromPreviousTableCell);
|
||||||
|
block_end_border.combine(
|
||||||
|
&CollapsedBorder::block_end(row_style, CollapsedBorderProvenance::FromTableRow));
|
||||||
|
|
||||||
preliminary_collapsed_borders.block_end.push_or_set(child_index, block_end_border);
|
preliminary_collapsed_borders.block_end.push_or_set(child_index, block_end_border);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[border-bottom-applies-to-004.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[border-bottom-color-applies-to-004.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[border-bottom-width-applies-to-004.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[border-conflict-style-101.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[border-left-applies-to-004.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[border-left-color-applies-to-004.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[border-left-width-applies-to-004.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[border-right-applies-to-004.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[border-right-color-applies-to-004.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[border-right-width-applies-to-004.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[vertical-align-121.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -792,6 +792,18 @@
|
||||||
"url": "/_mozilla/css/border_collapse_missing_cell_a.html"
|
"url": "/_mozilla/css/border_collapse_missing_cell_a.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"css/border_collapse_row_a.html": [
|
||||||
|
{
|
||||||
|
"path": "css/border_collapse_row_a.html",
|
||||||
|
"references": [
|
||||||
|
[
|
||||||
|
"/_mozilla/css/border_collapse_row_ref.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"url": "/_mozilla/css/border_collapse_row_a.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"css/border_collapse_rowgroup_a.html": [
|
"css/border_collapse_rowgroup_a.html": [
|
||||||
{
|
{
|
||||||
"path": "css/border_collapse_rowgroup_a.html",
|
"path": "css/border_collapse_rowgroup_a.html",
|
||||||
|
@ -10102,6 +10114,18 @@
|
||||||
"url": "/_mozilla/css/border_collapse_missing_cell_a.html"
|
"url": "/_mozilla/css/border_collapse_missing_cell_a.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"css/border_collapse_row_a.html": [
|
||||||
|
{
|
||||||
|
"path": "css/border_collapse_row_a.html",
|
||||||
|
"references": [
|
||||||
|
[
|
||||||
|
"/_mozilla/css/border_collapse_row_ref.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"url": "/_mozilla/css/border_collapse_row_a.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"css/border_collapse_rowgroup_a.html": [
|
"css/border_collapse_rowgroup_a.html": [
|
||||||
{
|
{
|
||||||
"path": "css/border_collapse_rowgroup_a.html",
|
"path": "css/border_collapse_rowgroup_a.html",
|
||||||
|
|
31
tests/wpt/mozilla/tests/css/border_collapse_row_a.html
Normal file
31
tests/wpt/mozilla/tests/css/border_collapse_row_a.html
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>row border collapse test</title>
|
||||||
|
<link rel="match" href="border_collapse_row_ref.html">
|
||||||
|
<style>
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
width: 64px;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
.tr_with_border {
|
||||||
|
border-top: 2px solid black;
|
||||||
|
border-right: 2px solid black;
|
||||||
|
border-bottom: 2px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<tr><td></td><td></td></tr>
|
||||||
|
<tr class="tr_with_border"><td></td><td></td></tr>
|
||||||
|
<tr class="tr_with_border"><td></td><td></td></tr>
|
||||||
|
<tr class="tr_with_border"><td></td><td></td></tr>
|
||||||
|
<tr class="tr_with_border"><td></td><td></td></tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
34
tests/wpt/mozilla/tests/css/border_collapse_row_ref.html
Normal file
34
tests/wpt/mozilla/tests/css/border_collapse_row_ref.html
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>row border collapse test - reference</title>
|
||||||
|
<style>
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
width: 64px;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
.td_left {
|
||||||
|
border-top: 2px solid black;
|
||||||
|
border-bottom: 2px solid black;
|
||||||
|
}
|
||||||
|
.td_right {
|
||||||
|
border-top: 2px solid black;
|
||||||
|
border-right: 2px solid black;
|
||||||
|
border-bottom: 2px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<tr><td></td><td></td></tr>
|
||||||
|
<tr><td class="td_left"></td><td class="td_right"</td></tr>
|
||||||
|
<tr><td class="td_left"></td><td class="td_right"</td></tr>
|
||||||
|
<tr><td class="td_left"></td><td class="td_right"</td></tr>
|
||||||
|
<tr><td class="td_left"></td><td class="td_right"</td></tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -8,6 +8,9 @@
|
||||||
FIXME(pcwalton): This is currently offset by -2px in block and inline directions because we
|
FIXME(pcwalton): This is currently offset by -2px in block and inline directions because we
|
||||||
don't correctly handle collapsed borders when calculating `table_border_padding` in
|
don't correctly handle collapsed borders when calculating `table_border_padding` in
|
||||||
`table_wrapper.rs`.
|
`table_wrapper.rs`.
|
||||||
|
|
||||||
|
FIXME(gpoesia): This test does not behave exactly like Gecko yet, because cell5's
|
||||||
|
height is currently 2px smaller in Servo.
|
||||||
-->
|
-->
|
||||||
<link rel=match href=border_collapse_simple_ref.html>
|
<link rel=match href=border_collapse_simple_ref.html>
|
||||||
<style>
|
<style>
|
||||||
|
@ -19,7 +22,7 @@ html {
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
/* See `FIXME` above. */
|
/* See `FIXME` above. */
|
||||||
padding: 2px;
|
padding-top: 2px;
|
||||||
}
|
}
|
||||||
table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
@ -28,14 +31,20 @@ table {
|
||||||
td {
|
td {
|
||||||
border: 2px solid black;
|
border: 2px solid black;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
width: 32px;
|
width: 30px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
}
|
}
|
||||||
td.cell5 {
|
td.cell5 {
|
||||||
border: 30px solid black;
|
border: 30px solid black;
|
||||||
|
width: 32px;
|
||||||
}
|
}
|
||||||
td.cell6 {
|
td.cell6 {
|
||||||
border: 4px solid black;
|
border: 4px solid black;
|
||||||
|
width: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#row1 td {
|
||||||
|
height: 32px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue