diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-10-26 13:57:00 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-11-02 11:31:01 +0000 |
commit | 1943b3c2a1dcee36c233724fc4ee7613d71b9cf6 (patch) | |
tree | 8c1b5f12357025c197da5427ae02cfdc2f3570d6 /chromium/third_party/blink/renderer/core/layout/ng/table | |
parent | 21ba0c5d4bf8fba15dddd97cd693bad2358b77fd (diff) | |
download | qtwebengine-chromium-1943b3c2a1dcee36c233724fc4ee7613d71b9cf6.tar.gz |
BASELINE: Update Chromium to 94.0.4606.111
Change-Id: I924781584def20fc800bedf6ff41fdb96c438193
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/layout/ng/table')
16 files changed, 110 insertions, 148 deletions
diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table.cc b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table.cc index b86bbc8863d..91ec2886457 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table.cc +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table.cc @@ -12,7 +12,9 @@ #include "third_party/blink/renderer/core/layout/ng/ng_layout_result.h" #include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_caption.h" +#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_cell_interface.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_column.h" +#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row_interface.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_section.h" #include "third_party/blink/renderer/core/layout/ng/table/ng_table_borders.h" #include "third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_helpers.h" @@ -95,6 +97,8 @@ void LayoutNGTable::TableGridStructureChanged() { NOT_DESTROYED(); // Callers must ensure table layout gets invalidated. InvalidateCachedTableBorders(); + if (StyleRef().BorderCollapse() == EBorderCollapse::kCollapse) + SetShouldDoFullPaintInvalidation(PaintInvalidationReason::kStyle); } bool LayoutNGTable::HasBackgroundForPaint() const { @@ -263,13 +267,6 @@ void LayoutNGTable::AddVisualEffectOverflow() { } #endif -void LayoutNGTable::Paint(const PaintInfo& paint_info) const { - NOT_DESTROYED(); - DCHECK_EQ(PhysicalFragmentCount(), 1u); - NGBoxFragmentPainter(*LayoutNGMixin<LayoutBlock>::GetPhysicalFragment(0)) - .Paint(paint_info); -} - LayoutUnit LayoutNGTable::BorderLeft() const { NOT_DESTROYED(); // DCHECK(cached_table_borders_.get()) diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table.h b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table.h index a6a8767c0a8..1d441e51db4 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table.h +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table.h @@ -7,8 +7,7 @@ #include "base/dcheck_is_on.h" #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/core/layout/layout_block.h" -#include "third_party/blink/renderer/core/layout/ng/layout_ng_mixin.h" +#include "third_party/blink/renderer/core/layout/ng/layout_ng_block.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_interface.h" #include "third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_types.h" @@ -32,7 +31,7 @@ class NGTableBorders; // on LayoutObject. They are invalidated inside // LayoutObject::SetNeeds*Layout. -class CORE_EXPORT LayoutNGTable : public LayoutNGMixin<LayoutBlock>, +class CORE_EXPORT LayoutNGTable : public LayoutNGBlock, public LayoutNGTableInterface { public: explicit LayoutNGTable(Element*); @@ -91,8 +90,6 @@ class CORE_EXPORT LayoutNGTable : public LayoutNGMixin<LayoutBlock>, LayoutBox* CreateAnonymousBoxWithSameTypeAs( const LayoutObject* parent) const override; - void Paint(const PaintInfo&) const final; - LayoutUnit BorderTop() const override; LayoutUnit BorderBottom() const override; diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_caption.h b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_caption.h index 7d8a907e54d..f62eaa20b0f 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_caption.h +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_caption.h @@ -14,6 +14,11 @@ namespace blink { class LayoutNGTableInterface; class NGPhysicalFragment; +extern template class CORE_EXTERN_TEMPLATE_EXPORT + LayoutNGBlockFlowMixin<LayoutTableCaption>; +extern template class CORE_EXTERN_TEMPLATE_EXPORT + LayoutNGMixin<LayoutTableCaption>; + class CORE_EXPORT LayoutNGTableCaption final : public LayoutNGBlockFlowMixin<LayoutTableCaption> { public: diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_cell_legacy.h b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_cell_legacy.h index 71c8579f8d5..ccbb074a093 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_cell_legacy.h +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_cell_legacy.h @@ -11,6 +11,11 @@ namespace blink { +extern template class CORE_EXTERN_TEMPLATE_EXPORT + LayoutNGBlockFlowMixin<LayoutTableCell>; +extern template class CORE_EXTERN_TEMPLATE_EXPORT + LayoutNGMixin<LayoutTableCell>; + // This is a LayoutNG variant of LayoutTableCell. // There are 3 table cell classes in Chrome // LayoutNGTableCell - TablesNG cell, whole table is NG. diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.cc b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.cc index edd56cef89d..b28bbad2a6b 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.cc +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.cc @@ -4,6 +4,7 @@ #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.h" +#include "third_party/blink/renderer/core/editing/position_with_affinity.h" #include "third_party/blink/renderer/core/layout/layout_object_factory.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_cell.h" diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.h b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.h index 4f1f82d2ce7..96bb6968162 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.h +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.h @@ -7,8 +7,9 @@ #include "base/dcheck_is_on.h" #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/core/layout/layout_block.h" -#include "third_party/blink/renderer/core/layout/ng/layout_ng_mixin.h" +#include "third_party/blink/renderer/core/layout/ng/layout_ng_block.h" +#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row_interface.h" +#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_section_interface.h" namespace blink { @@ -18,7 +19,7 @@ class LayoutNGTable; // NOTE: // Legacy table row inherits from LayoutBox, not LayoutBlock. // Every child of LayoutNGTableRow must be LayoutNGTableCell. -class CORE_EXPORT LayoutNGTableRow : public LayoutNGMixin<LayoutBlock>, +class CORE_EXPORT LayoutNGTableRow : public LayoutNGBlock, public LayoutNGTableRowInterface { public: explicit LayoutNGTableRow(Element*); diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row_interface.h b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row_interface.h index 6e2580c57e5..014c7022040 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row_interface.h +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row_interface.h @@ -13,6 +13,7 @@ class LayoutObject; class LayoutNGTableInterface; class LayoutNGTableSectionInterface; class LayoutNGTableCellInterface; +class LayoutTableRow; // Abstract class defining table row methods. // Used for Legacy/NG interoperability. diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_section.h b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_section.h index a80d5599b7a..ed3a833e99f 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_section.h +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/layout_ng_table_section.h @@ -6,8 +6,7 @@ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_TABLE_LAYOUT_NG_TABLE_SECTION_H_ #include "third_party/blink/renderer/core/core_export.h" -#include "third_party/blink/renderer/core/layout/layout_block.h" -#include "third_party/blink/renderer/core/layout/ng/layout_ng_mixin.h" +#include "third_party/blink/renderer/core/layout/ng/layout_ng_block.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_section_interface.h" namespace blink { @@ -16,7 +15,7 @@ class LayoutNGTable; // NOTE: // Every child of LayoutNGTableSection must be LayoutNGTableRow. -class CORE_EXPORT LayoutNGTableSection : public LayoutNGMixin<LayoutBlock>, +class CORE_EXPORT LayoutNGTableSection : public LayoutNGBlock, public LayoutNGTableSectionInterface { public: explicit LayoutNGTableSection(Element*); diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_borders.cc b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_borders.cc index 30b2bce1965..da34d5e5b6b 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_borders.cc +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_borders.cc @@ -43,73 +43,6 @@ bool IsSourceMoreSpecificThanEdge(EBorderStyle source_style, return source_style > edge_border_style; } -// Side of the style the collapsed border belongs to. -enum class LogicalEdgeSide { kInlineStart, kInlineEnd, kBlockStart, kBlockEnd }; - -NGTableBorders::EdgeSide LogicalEdgeToPhysical( - LogicalEdgeSide logical_side, - WritingDirectionMode table_writing_direction) { - // https://www.w3.org/TR/css-writing-modes-4/#logical-to-physical - switch (logical_side) { - case LogicalEdgeSide::kInlineStart: - switch (table_writing_direction.GetWritingMode()) { - case WritingMode::kHorizontalTb: - return table_writing_direction.Direction() == TextDirection::kLtr - ? NGTableBorders::EdgeSide::kLeft - : NGTableBorders::EdgeSide::kRight; - case WritingMode::kVerticalLr: - case WritingMode::kVerticalRl: - case WritingMode::kSidewaysRl: - return table_writing_direction.Direction() == TextDirection::kLtr - ? NGTableBorders::EdgeSide::kTop - : NGTableBorders::EdgeSide::kBottom; - case WritingMode::kSidewaysLr: - return table_writing_direction.Direction() == TextDirection::kLtr - ? NGTableBorders::EdgeSide::kBottom - : NGTableBorders::EdgeSide::kTop; - } - case LogicalEdgeSide::kInlineEnd: - switch (table_writing_direction.GetWritingMode()) { - case WritingMode::kHorizontalTb: - return table_writing_direction.Direction() == TextDirection::kLtr - ? NGTableBorders::EdgeSide::kRight - : NGTableBorders::EdgeSide::kLeft; - case WritingMode::kVerticalLr: - case WritingMode::kVerticalRl: - case WritingMode::kSidewaysRl: - return table_writing_direction.Direction() == TextDirection::kLtr - ? NGTableBorders::EdgeSide::kBottom - : NGTableBorders::EdgeSide::kTop; - case WritingMode::kSidewaysLr: - return table_writing_direction.Direction() == TextDirection::kLtr - ? NGTableBorders::EdgeSide::kTop - : NGTableBorders::EdgeSide::kBottom; - } - case LogicalEdgeSide::kBlockStart: - switch (table_writing_direction.GetWritingMode()) { - case WritingMode::kHorizontalTb: - return NGTableBorders::EdgeSide::kTop; - case WritingMode::kVerticalLr: - case WritingMode::kSidewaysLr: - return NGTableBorders::EdgeSide::kLeft; - case WritingMode::kVerticalRl: - case WritingMode::kSidewaysRl: - return NGTableBorders::EdgeSide::kRight; - } - case LogicalEdgeSide::kBlockEnd: - switch (table_writing_direction.GetWritingMode()) { - case WritingMode::kHorizontalTb: - return NGTableBorders::EdgeSide::kBottom; - case WritingMode::kVerticalLr: - case WritingMode::kSidewaysLr: - return NGTableBorders::EdgeSide::kRight; - case WritingMode::kVerticalRl: - case WritingMode::kSidewaysRl: - return NGTableBorders::EdgeSide::kLeft; - } - } -} - class ColBordersMarker { STACK_ALLOCATED(); @@ -575,22 +508,20 @@ void NGTableBorders::MergeBorders(wtf_size_t cell_start_row, EnsureCellRowFits(cell_start_row + clamped_rowspan - 1); } } + + PhysicalToLogical<EdgeSide> edge_side(table_writing_direction, EdgeSide::kTop, + EdgeSide::kRight, EdgeSide::kBottom, + EdgeSide::kLeft); MergeRowAxisBorder(cell_start_row, cell_start_column, clamped_colspan, - source_style, box_order, - LogicalEdgeToPhysical(LogicalEdgeSide::kBlockStart, - table_writing_direction)); + source_style, box_order, edge_side.BlockStart()); MergeRowAxisBorder(cell_start_row + clamped_rowspan, cell_start_column, clamped_colspan, source_style, box_order, - LogicalEdgeToPhysical(LogicalEdgeSide::kBlockEnd, - table_writing_direction)); + edge_side.BlockEnd()); MergeColumnAxisBorder(cell_start_row, cell_start_column, clamped_rowspan, - source_style, box_order, - LogicalEdgeToPhysical(LogicalEdgeSide::kInlineStart, - table_writing_direction)); + source_style, box_order, edge_side.InlineStart()); MergeColumnAxisBorder(cell_start_row, cell_start_column + clamped_colspan, clamped_rowspan, source_style, box_order, - LogicalEdgeToPhysical(LogicalEdgeSide::kInlineEnd, - table_writing_direction)); + edge_side.InlineEnd()); if (mark_inner_borders) { MarkInnerBordersAsDoNotFill(cell_start_row, cell_start_column, clamped_rowspan, clamped_colspan); diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_borders.h b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_borders.h index eb511df8368..ed5589394b4 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_borders.h +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_borders.h @@ -7,6 +7,7 @@ #include "base/dcheck_is_on.h" #include "base/memory/scoped_refptr.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/core/style/computed_style_constants.h" #include "third_party/blink/renderer/platform/geometry/layout_unit.h" diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm.cc b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm.cc index a08545a90ad..1468774fe8c 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm.cc +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm.cc @@ -5,9 +5,11 @@ #include "third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm.h" #include "third_party/blink/renderer/core/layout/geometry/writing_mode_converter.h" +#include "third_party/blink/renderer/core/layout/ng/mathml/ng_math_layout_utils.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_break_token.h" #include "third_party/blink/renderer/core/layout/ng/ng_box_fragment.h" #include "third_party/blink/renderer/core/layout/ng/ng_constraint_space_builder.h" +#include "third_party/blink/renderer/core/layout/ng/ng_disable_side_effects_scope.h" #include "third_party/blink/renderer/core/layout/ng/ng_layout_result.h" #include "third_party/blink/renderer/core/layout/ng/ng_length_utils.h" #include "third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.h" @@ -26,6 +28,8 @@ #include "third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.h" #include "third_party/blink/renderer/core/layout/ng/table/ng_table_node.h" #include "third_party/blink/renderer/core/layout/text_autosizer.h" +#include "third_party/blink/renderer/core/mathml/mathml_element.h" +#include "third_party/blink/renderer/core/mathml_names.h" namespace blink { @@ -58,7 +62,7 @@ void ComputeCaptionFragments( const ComputedStyle& table_style, const NGTableGroupedChildren& grouped_children, const LayoutUnit table_inline_size, - Vector<NGTableLayoutAlgorithm::CaptionResult>& captions, + Vector<NGTableLayoutAlgorithm::CaptionResult>* captions, LayoutUnit& captions_block_size) { const LogicalSize available_size = {table_inline_size, kIndefiniteSize}; for (NGBlockNode caption : grouped_children.captions) { @@ -70,9 +74,15 @@ void ComputeCaptionFragments( SetOrthogonalFallbackInlineSizeIfNeeded(table_style, caption, &builder); builder.SetAvailableSize(available_size); builder.SetPercentageResolutionSize(available_size); - builder.SetStretchInlineSizeIfAuto(true); + builder.SetInlineAutoBehavior(NGAutoBehavior::kStretchImplicit); NGConstraintSpace caption_constraint_space = builder.ToConstraintSpace(); + // If we are discarding the results (compute-only) and we are after layout + // (|!NeedsLayout|,) make sure not to update the cached layout results. + absl::optional<NGDisableSideEffectsScope> disable_side_effects; + if (!captions && !caption.GetLayoutBox()->NeedsLayout()) + disable_side_effects.emplace(); + scoped_refptr<const NGLayoutResult> caption_result = caption.Layout(caption_constraint_space); NGFragment fragment(table_constraint_space.GetWritingDirection(), @@ -82,9 +92,11 @@ void ComputeCaptionFragments( ResolveInlineMargins(caption_style, table_style, table_inline_size, fragment.InlineSize(), &margins); - captions.push_back(NGTableLayoutAlgorithm::CaptionResult{ - caption, std::move(caption_result), margins}); captions_block_size += fragment.BlockSize() + margins.BlockSum(); + if (captions) { + captions->push_back(NGTableLayoutAlgorithm::CaptionResult{ + caption, std::move(caption_result), margins}); + } } } @@ -119,7 +131,7 @@ LayoutUnit ComputeEmptyTableInlineSize( const bool has_collapsed_borders) { // If table has a css inline size, use that. if (space.IsFixedInlineSize() || - (space.StretchInlineSizeIfAuto() && + (space.IsInlineAutoBehaviorStretch() && table_style.LogicalWidth().IsAuto()) || !table_style.LogicalWidth().IsAuto() || !table_style.LogicalMinWidth().IsAuto()) { @@ -437,12 +449,12 @@ LayoutUnit NGTableLayoutAlgorithm::ComputeCaptionBlockSize( const NGTableNode& node, const NGConstraintSpace& space, const LayoutUnit table_inline_size) { - Vector<NGTableLayoutAlgorithm::CaptionResult> captions; NGTableGroupedChildren grouped_children(node); LayoutUnit captions_block_size; ComputeCaptionFragments(space, node.Style(), grouped_children, - table_inline_size, captions, captions_block_size); + table_inline_size, /* captions */ nullptr, + captions_block_size); return captions_block_size; } @@ -510,7 +522,7 @@ scoped_refptr<const NGLayoutResult> NGTableLayoutAlgorithm::Layout() { Vector<CaptionResult> captions; LayoutUnit captions_block_size; ComputeCaptionFragments(ConstraintSpace(), Style(), grouped_children, - container_builder_.InlineSize(), captions, + container_builder_.InlineSize(), &captions, captions_block_size); NGTableTypes::Rows rows; @@ -632,7 +644,7 @@ void NGTableLayoutAlgorithm::ComputeRows( } LayoutUnit css_table_block_size; - if (ConstraintSpace().IsFixedBlockSizeIndefinite() && + if (ConstraintSpace().IsInitialBlockSizeIndefinite() && !ConstraintSpace().IsFixedBlockSize()) { // We get here when a flexbox wants to use the table's intrinsic height as // an input to the flex algorithm. @@ -801,10 +813,18 @@ scoped_refptr<const NGLayoutResult> NGTableLayoutAlgorithm::GenerateFragment( NGConstraintSpaceBuilder section_space_builder( table_writing_direction.GetWritingMode(), table_writing_direction, /* is_new_fc */ true); - section_space_builder.SetAvailableSize( - {section_available_inline_size, sections[section_index].block_size}); + + LogicalSize available_size = {section_available_inline_size, + kIndefiniteSize}; + + // Sections without rows can receive redistributed height from the table. + if (constraint_space_data->sections[section_index].rowspan == 0) { + section_space_builder.SetIsFixedBlockSize(true); + available_size.block_size = sections[section_index].block_size; + } + + section_space_builder.SetAvailableSize(available_size); section_space_builder.SetIsFixedInlineSize(true); - section_space_builder.SetIsFixedBlockSize(true); section_space_builder.SetPercentageResolutionSize( {section_available_inline_size, kIndefiniteSize}); section_space_builder.SetTableSectionData(constraint_space_data, @@ -878,6 +898,9 @@ scoped_refptr<const NGLayoutResult> NGTableLayoutAlgorithm::GenerateFragment( grid_converter.ToPhysical(table_grid_rect), border_spacing, column_block_size); + if (Node().GetDOMNode() && + Node().GetDOMNode()->HasTagName(mathml_names::kMtableTag)) + table_baseline = MathTableBaseline(Style(), block_offset); if (table_baseline) container_builder_.SetBaseline(*table_baseline); diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_helpers.cc b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_helpers.cc index 23e0a287cf3..499b76401d3 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_helpers.cc +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_helpers.cc @@ -13,11 +13,15 @@ namespace { // Implements spec distribution algorithm: // https://www.w3.org/TR/css-tables-3/#width-distribution-algorithm +// |treat_target_size_as_constrained| constrained target can grow fixed-width +// columns. unconstrained target cannot grow fixed-width columns beyond +// specified size. Vector<LayoutUnit> DistributeInlineSizeToComputedInlineSizeAuto( LayoutUnit target_inline_size, LayoutUnit inline_border_spacing, const NGTableTypes::Column* start_column, - const NGTableTypes::Column* end_column) { + const NGTableTypes::Column* end_column, + const bool treat_target_size_as_constrained) { unsigned all_columns_count = 0; unsigned percent_columns_count = 0; unsigned fixed_columns_count = 0; @@ -263,7 +267,7 @@ Vector<LayoutUnit> DistributeInlineSizeToComputedInlineSizeAuto( DCHECK(last_computed_size); *last_computed_size += rounding_error_inline_size; } - } else if (fixed_columns_count > 0) { + } else if (fixed_columns_count > 0 && treat_target_size_as_constrained) { // Grow fixed columns if available. LayoutUnit rounding_error_inline_size = distributable_inline_size; LayoutUnit* last_computed_size = nullptr; @@ -304,9 +308,8 @@ Vector<LayoutUnit> DistributeInlineSizeToComputedInlineSizeAuto( LayoutUnit* computed_size = computed_sizes.begin(); for (const NGTableTypes::Column* column = start_column; column != end_column; ++column, ++computed_size) { - if (column->is_mergeable) + if (column->is_mergeable || !column->percent) continue; - DCHECK(column->percent); last_computed_size = computed_size; LayoutUnit percent_inline_size = column->ResolvePercentInlineSize(target_inline_size); @@ -321,8 +324,7 @@ Vector<LayoutUnit> DistributeInlineSizeToComputedInlineSizeAuto( rounding_error_inline_size -= delta; *computed_size = percent_inline_size + delta; } - if (rounding_error_inline_size != LayoutUnit()) { - DCHECK(last_computed_size); + if (rounding_error_inline_size != LayoutUnit() && last_computed_size) { *last_computed_size += rounding_error_inline_size; } } @@ -351,7 +353,6 @@ Vector<LayoutUnit> SynchronizeAssignableTableInlineSizeAndColumnsFixed( return column.is_constrained && column.max_inline_size == LayoutUnit(); }; - float total_percent = 0.0f; LayoutUnit total_percent_inline_size; LayoutUnit total_auto_max_inline_size; LayoutUnit total_fixed_inline_size; @@ -362,7 +363,6 @@ Vector<LayoutUnit> SynchronizeAssignableTableInlineSizeAndColumnsFixed( all_columns_count++; if (column.percent) { percent_columns_count++; - total_percent += *column.percent; total_percent_inline_size += column.ResolvePercentInlineSize(target_inline_size); } else if (TreatAsFixed(column)) { @@ -661,9 +661,9 @@ void DistributeColspanCellToColumnsAuto( column->max_inline_size = LayoutUnit(); } Vector<LayoutUnit> computed_sizes = - DistributeInlineSizeToComputedInlineSizeAuto(colspan_cell_min_inline_size, - inline_border_spacing, - start_column, end_column); + DistributeInlineSizeToComputedInlineSizeAuto( + colspan_cell_min_inline_size, inline_border_spacing, start_column, + end_column, true); LayoutUnit* computed_size = computed_sizes.begin(); for (NGTableTypes::Column* column = start_column; column != end_column; ++column, ++computed_size) { @@ -672,12 +672,14 @@ void DistributeColspanCellToColumnsAuto( } computed_sizes = DistributeInlineSizeToComputedInlineSizeAuto( colspan_cell_max_inline_size, inline_border_spacing, start_column, - end_column); + end_column, /* treat_target_size_as_constrained */ + colspan_cell.cell_inline_constraint.is_constrained); computed_size = computed_sizes.begin(); for (NGTableTypes::Column* column = start_column; column != end_column; ++column, ++computed_size) { column->max_inline_size = - std::max(*column->max_inline_size, *computed_size); + std::max(std::max(*column->min_inline_size, *column->max_inline_size), + *computed_size); } } @@ -730,10 +732,12 @@ void DistributeExcessBlockSizeToRows( row->has_rowspan_start; }; - auto IsEmptyRow = [](const NGTableTypes::Row* row) { - return row->block_size == LayoutUnit() && - (!row->percent || *row->percent == 0); - }; + auto IsEmptyRow = + [&percentage_resolution_block_size](const NGTableTypes::Row* row) { + bool is_percent = percentage_resolution_block_size != kIndefiniteSize && + row->percent && *row->percent != 0; + return row->block_size == LayoutUnit() && !is_percent; + }; unsigned percent_rows_with_deficit_count = 0; unsigned rows_with_originating_rowspan = 0; @@ -1042,7 +1046,7 @@ NGTableAlgorithmHelpers::SynchronizeAssignableTableInlineSizeAndColumns( start_column + column_constraints.data.size(); return DistributeInlineSizeToComputedInlineSizeAuto( assignable_table_inline_size, inline_border_spacing, start_column, - end_column); + end_column, /* treat_target_size_as_constrained */ true); } } diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.cc b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.cc index 8551bd9371f..49b1ef31923 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.cc +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.cc @@ -197,7 +197,7 @@ NGTableTypes::Row ComputeMinimumRowBlockSize( table_writing_direction, cell, cell_borders, {cell_inline_size, kIndefiniteSize}, cell_percentage_inline_size, /* alignment_baseline */ absl::nullopt, start_column, - /* is_fixed_block_size_indefinite */ false, + /* is_initial_block_size_indefinite */ true, is_table_block_size_specified, /* is_hidden_for_paint */ false, has_collapsed_borders, NGCacheSlot::kMeasure); @@ -210,7 +210,6 @@ NGTableTypes::Row ComputeMinimumRowBlockSize( LayoutUnit max_cell_block_size; absl::optional<float> row_percent; bool is_constrained = false; - bool is_empty = true; bool has_rowspan_start = false; wtf_size_t start_cell_index = cell_block_constraints->size(); NGRowBaselineTabulator row_baseline_tabulator; @@ -218,7 +217,6 @@ NGTableTypes::Row ComputeMinimumRowBlockSize( // Gather block sizes of all cells. for (NGBlockNode cell = To<NGBlockNode>(row.FirstChild()); cell; cell = To<NGBlockNode>(cell.NextSibling())) { - is_empty = false; colspan_cell_tabulator->FindNextFreeColumn(); const ComputedStyle& cell_style = cell.Style(); const NGBoxStrut cell_borders = table_borders.CellBorder( @@ -461,7 +459,7 @@ NGConstraintSpace NGTableAlgorithmUtils::CreateTableCellConstraintSpace( LayoutUnit percentage_inline_size, absl::optional<LayoutUnit> alignment_baseline, wtf_size_t column_index, - bool is_fixed_block_size_indefinite, + bool is_initial_block_size_indefinite, bool is_table_block_size_specified, bool is_hidden_for_paint, bool has_collapsed_borders, @@ -482,10 +480,9 @@ NGConstraintSpace NGTableAlgorithmUtils::CreateTableCellConstraintSpace( builder.SetAvailableSize(cell_size); builder.SetIsFixedInlineSize(true); - if (cell_size.block_size != kIndefiniteSize) { + if (cell_size.block_size != kIndefiniteSize) builder.SetIsFixedBlockSize(true); - builder.SetIsFixedBlockSizeIndefinite(is_fixed_block_size_indefinite); - } + builder.SetIsInitialBlockSizeIndefinite(is_initial_block_size_indefinite); // Standard: // https://www.w3.org/TR/css-tables-3/#computing-the-table-height "the @@ -497,7 +494,7 @@ NGConstraintSpace NGTableAlgorithmUtils::CreateTableCellConstraintSpace( builder.SetTableCellAlignmentBaseline(alignment_baseline); builder.SetTableCellColumnIndex(column_index); builder.SetIsRestrictedBlockSizeTableCell( - is_table_block_size_specified || !cell_style.LogicalHeight().IsAuto()); + is_table_block_size_specified || cell_style.LogicalHeight().IsFixed()); builder.SetIsTableCellHiddenForPaint(is_hidden_for_paint); builder.SetIsTableCellWithCollapsedBorders(has_collapsed_borders); builder.SetHideTableCellIfEmpty( @@ -552,7 +549,7 @@ NGTableAlgorithmUtils::ComputeColumnConstraints( bool is_first_section = true; wtf_size_t row_index = 0; wtf_size_t section_index = 0; - for (const NGBlockNode& section : grouped_children) { + for (NGBlockNode section : grouped_children) { if (!section.IsEmptyTableSection()) { ComputeSectionInlineConstraints( section, is_fixed_layout, is_first_section, table_writing_mode, @@ -572,7 +569,7 @@ NGTableAlgorithmUtils::ComputeColumnConstraints( void NGTableAlgorithmUtils::ComputeSectionMinimumRowBlockSizes( const NGBlockNode& section, const LayoutUnit cell_percentage_inline_size, - const bool is_table_block_size_restricted, + const bool is_table_block_size_specified, const NGTableTypes::ColumnLocations& column_locations, const NGTableBorders& table_borders, const LayoutUnit block_border_spacing, @@ -594,7 +591,7 @@ void NGTableAlgorithmUtils::ComputeSectionMinimumRowBlockSizes( row = To<NGBlockNode>(row.NextSibling())) { colspan_cell_tabulator.StartRow(); NGTableTypes::Row row_constraint = ComputeMinimumRowBlockSize( - row, cell_percentage_inline_size, is_table_block_size_restricted, + row, cell_percentage_inline_size, is_table_block_size_specified, column_locations, table_borders, current_row++, section_index, /* is_section_collapsed */ section.Style().Visibility() == EVisibility::kCollapse, diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.h b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.h index 9b13752c46c..4b91e6178b4 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.h +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_utils.h @@ -5,6 +5,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_TABLE_NG_TABLE_LAYOUT_ALGORITHM_UTILS_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_TABLE_NG_TABLE_LAYOUT_ALGORITHM_UTILS_H_ +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/renderer/core/layout/ng/table/ng_table_layout_algorithm_types.h" #include "third_party/blink/renderer/core/style/computed_style_constants.h" @@ -41,7 +42,7 @@ class NGTableAlgorithmUtils { LayoutUnit percentage_inline_size, absl::optional<LayoutUnit> alignment_baseline, wtf_size_t column_index, - bool is_fixed_block_size_indefinite, + bool is_initial_block_size_indefinite, bool is_restricted_block_size_table, bool is_hidden_for_paint, bool has_collapsed_borders, @@ -60,7 +61,7 @@ class NGTableAlgorithmUtils { static void ComputeSectionMinimumRowBlockSizes( const NGBlockNode& section, const LayoutUnit cell_percentage_resolution_inline_size, - const bool is_restricted_block_size_table, + const bool is_table_block_size_specified, const NGTableTypes::ColumnLocations& column_locations, const NGTableBorders& table_borders, const LayoutUnit block_border_spacing, diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_row_layout_algorithm.cc b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_row_layout_algorithm.cc index 15825bdae0a..eb13896a4d0 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_row_layout_algorithm.cc +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_row_layout_algorithm.cc @@ -60,7 +60,7 @@ scoped_refptr<const NGLayoutResult> NGTableRowLayoutAlgorithm::Layout() { // Our initial block-size is definite if this cell has a fixed block-size, // or we have grown and the table has a specified block-size. - bool is_fixed_block_size_definite = + const bool is_initial_block_size_definite = cell_data.is_constrained || (cell_data.has_grown && table_data.is_table_block_size_specified); @@ -71,7 +71,7 @@ scoped_refptr<const NGLayoutResult> NGTableRowLayoutAlgorithm::Layout() { return NGTableAlgorithmUtils::CreateTableCellConstraintSpace( table_data.table_writing_direction, cell, cell_data.border_box_borders, {cell_inline_size, cell_block_size}, container_builder_.InlineSize(), - row_baseline, start_column, !is_fixed_block_size_definite, + row_baseline, start_column, !is_initial_block_size_definite, table_data.is_table_block_size_specified, is_hidden_for_paint, table_data.has_collapsed_borders, NGCacheSlot::kLayout); }; diff --git a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_section_layout_algorithm.cc b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_section_layout_algorithm.cc index 61d7a8fddc7..55dc9d646e3 100644 --- a/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_section_layout_algorithm.cc +++ b/chromium/third_party/blink/renderer/core/layout/ng/table/ng_table_section_layout_algorithm.cc @@ -33,6 +33,8 @@ scoped_refptr<const NGLayoutResult> NGTableSectionLayoutAlgorithm::Layout() { absl::optional<LayoutUnit> section_baseline; + const LogicalSize available_size = {container_builder_.InlineSize(), + kIndefiniteSize}; LogicalOffset offset; bool is_first_row = true; wtf_size_t row_index = table_data.sections[section_index].start_row_index; @@ -44,12 +46,9 @@ scoped_refptr<const NGLayoutResult> NGTableSectionLayoutAlgorithm::Layout() { table_data.table_writing_direction.GetWritingMode(), table_data.table_writing_direction, /* is_new_fc */ true); - row_space_builder.SetAvailableSize({container_builder_.InlineSize(), - table_data.rows[row_index].block_size}); + row_space_builder.SetAvailableSize(available_size); + row_space_builder.SetPercentageResolutionSize(available_size); row_space_builder.SetIsFixedInlineSize(true); - row_space_builder.SetIsFixedBlockSize(true); - row_space_builder.SetPercentageResolutionSize( - {container_builder_.InlineSize(), kIndefiniteSize}); row_space_builder.SetTableRowData(&table_data, row_index); NGConstraintSpace row_space = row_space_builder.ToConstraintSpace(); scoped_refptr<const NGLayoutResult> row_result = row.Layout(row_space); @@ -66,9 +65,9 @@ scoped_refptr<const NGLayoutResult> NGTableSectionLayoutAlgorithm::Layout() { is_first_row = false; row_index++; } - if (table_data.sections[section_index].rowspan == 0) { - // Sections without rows can get redistributed height from table. - DCHECK(ConstraintSpace().IsFixedBlockSize()); + if (ConstraintSpace().IsFixedBlockSize()) { + // A fixed block-size should only occur for a section without children. + DCHECK_EQ(table_data.sections[section_index].rowspan, 0u); container_builder_.SetFragmentBlockSize( ConstraintSpace().AvailableSize().block_size); } else { |