Commit 5550998d authored by Aleks Totic's avatar Aleks Totic Committed by Chromium LUCI CQ

[TablesNG] Fix empty section border spacing

Borders spacing for empty border sections was not being
handled correctly. Failing tests included:

external/wpt/css/css-tables/bounding-box-computation-3.html
fast/table/anonymous-table-section-removed.html
fast/table/multiple-captions-display.xhtml

The correct behaviour is:
- empty sections do contribute to border spacing
- sections are empty if they have no children. This is non-intuitive:
abspos child, or an empty row still make section non-empty. This
matches empty criteria for table cell when computing baseline.

Bug: 958381
Change-Id: Ib960a54794897ef346bfc26821efe26fb33a853f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2578696
Commit-Queue: Aleks Totic <atotic@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834884}
parent 66ff7b8c
...@@ -68,10 +68,10 @@ class CORE_EXPORT NGBoxFragment final : public NGFragment { ...@@ -68,10 +68,10 @@ class CORE_EXPORT NGBoxFragment final : public NGFragment {
return physical_box_fragment.Padding().ConvertToLogical(writing_direction_); return physical_box_fragment.Padding().ConvertToLogical(writing_direction_);
} }
bool HasDescendantsForTableCell() const { bool HasDescendantsForTablePart() const {
const NGPhysicalBoxFragment& box_fragment = const NGPhysicalBoxFragment& box_fragment =
To<NGPhysicalBoxFragment>(physical_fragment_); To<NGPhysicalBoxFragment>(physical_fragment_);
DCHECK(box_fragment.IsTableNGCell()); DCHECK(physical_fragment_.IsTableNGPart() || box_fragment.IsTableNGCell());
return !box_fragment.Children().empty() || return !box_fragment.Children().empty() ||
box_fragment.HasOutOfFlowPositionedFragmentainerDescendants() || box_fragment.HasOutOfFlowPositionedFragmentainerDescendants() ||
box_fragment.HasOutOfFlowPositionedDescendants(); box_fragment.HasOutOfFlowPositionedDescendants();
......
...@@ -786,28 +786,29 @@ scoped_refptr<const NGLayoutResult> NGTableLayoutAlgorithm::GenerateFragment( ...@@ -786,28 +786,29 @@ scoped_refptr<const NGLayoutResult> NGTableLayoutAlgorithm::GenerateFragment(
base::Optional<LayoutUnit> table_baseline; base::Optional<LayoutUnit> table_baseline;
wtf_size_t section_index = 0; wtf_size_t section_index = 0;
bool has_section = false; bool needs_end_border_spacing = false;
for (NGBlockNode section : grouped_children) { for (NGBlockNode section : grouped_children) {
scoped_refptr<const NGLayoutResult> section_result = scoped_refptr<const NGLayoutResult> section_result =
section.Layout(CreateSectionConstraintSpace(section_index++)); section.Layout(CreateSectionConstraintSpace(section_index++));
const NGPhysicalBoxFragment& physical_fragment = const NGPhysicalBoxFragment& physical_fragment =
To<NGPhysicalBoxFragment>(section_result->PhysicalFragment()); To<NGPhysicalBoxFragment>(section_result->PhysicalFragment());
NGBoxFragment fragment(table_writing_direction, physical_fragment); NGBoxFragment fragment(table_writing_direction, physical_fragment);
if (fragment.BlockSize() != LayoutUnit() || !has_section) if (fragment.HasDescendantsForTablePart()) {
section_offset.block_offset += border_spacing.block_size; section_offset.block_offset += border_spacing.block_size;
needs_end_border_spacing = true;
}
container_builder_.AddResult(*section_result, section_offset); container_builder_.AddResult(*section_result, section_offset);
if (!table_baseline) { if (!table_baseline) {
if (const auto& section_baseline = fragment.Baseline()) if (const auto& section_baseline = fragment.Baseline())
table_baseline = *section_baseline + section_offset.block_offset; table_baseline = *section_baseline + section_offset.block_offset;
} }
section_offset.block_offset += fragment.BlockSize(); section_offset.block_offset += fragment.BlockSize();
has_section = true;
} }
if (has_section) if (needs_end_border_spacing)
section_offset.block_offset += border_spacing.block_size; section_offset.block_offset += border_spacing.block_size;
LayoutUnit column_block_size = LayoutUnit column_block_size =
section_offset.block_offset - border_padding.block_start; section_offset.block_offset - border_padding.block_start;
if (has_section) if (needs_end_border_spacing)
column_block_size -= border_spacing.block_size * 2; column_block_size -= border_spacing.block_size * 2;
const LayoutUnit grid_block_size = std::max( const LayoutUnit grid_block_size = std::max(
......
...@@ -571,7 +571,7 @@ void NGRowBaselineTabulator::ProcessCell( ...@@ -571,7 +571,7 @@ void NGRowBaselineTabulator::ProcessCell(
const bool is_parallel, const bool is_parallel,
const bool descendant_depends_on_percentage_block_size) { const bool descendant_depends_on_percentage_block_size) {
if (is_parallel && is_baseline_aligned && if (is_parallel && is_baseline_aligned &&
fragment.HasDescendantsForTableCell()) { fragment.HasDescendantsForTablePart()) {
max_cell_baseline_depends_on_percentage_block_descendant_ |= max_cell_baseline_depends_on_percentage_block_descendant_ |=
descendant_depends_on_percentage_block_size; descendant_depends_on_percentage_block_size;
const LayoutUnit cell_baseline = fragment.FirstBaselineOrSynthesize(); const LayoutUnit cell_baseline = fragment.FirstBaselineOrSynthesize();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment