chromium/third_party/blink/renderer/core/layout/table/table_layout_algorithm.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/core/layout/table/table_layout_algorithm.h"

#include "third_party/blink/renderer/core/layout/block_break_token.h"
#include "third_party/blink/renderer/core/layout/constraint_space_builder.h"
#include "third_party/blink/renderer/core/layout/disable_layout_side_effects_scope.h"
#include "third_party/blink/renderer/core/layout/fragmentation_utils.h"
#include "third_party/blink/renderer/core/layout/geometry/writing_mode_converter.h"
#include "third_party/blink/renderer/core/layout/layout_result.h"
#include "third_party/blink/renderer/core/layout/length_utils.h"
#include "third_party/blink/renderer/core/layout/logical_box_fragment.h"
#include "third_party/blink/renderer/core/layout/mathml/math_layout_utils.h"
#include "third_party/blink/renderer/core/layout/physical_box_fragment.h"
#include "third_party/blink/renderer/core/layout/space_utils.h"
#include "third_party/blink/renderer/core/layout/table/layout_table.h"
#include "third_party/blink/renderer/core/layout/table/layout_table_caption.h"
#include "third_party/blink/renderer/core/layout/table/layout_table_cell.h"
#include "third_party/blink/renderer/core/layout/table/layout_table_column.h"
#include "third_party/blink/renderer/core/layout/table/layout_table_column_visitor.h"
#include "third_party/blink/renderer/core/layout/table/layout_table_section.h"
#include "third_party/blink/renderer/core/layout/table/table_borders.h"
#include "third_party/blink/renderer/core/layout/table/table_break_token_data.h"
#include "third_party/blink/renderer/core/layout/table/table_child_iterator.h"
#include "third_party/blink/renderer/core/layout/table/table_constraint_space_data.h"
#include "third_party/blink/renderer/core/layout/table/table_fragment_data.h"
#include "third_party/blink/renderer/core/layout/table/table_layout_utils.h"
#include "third_party/blink/renderer/core/layout/table/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 {

namespace {

TableTypes::Caption ComputeCaptionConstraint(
    const ConstraintSpace& table_space,
    const ComputedStyle& table_style,
    const TableGroupedChildren& grouped_children) {}

ConstraintSpace CreateCaptionConstraintSpace(
    const ConstraintSpace& table_constraint_space,
    const ComputedStyle& table_style,
    const BlockNode& caption,
    LogicalSize available_size,
    std::optional<LayoutUnit> block_offset = std::nullopt) {}

TableLayoutAlgorithm::CaptionResult LayoutCaption(
    const ConstraintSpace& table_constraint_space,
    const ComputedStyle& table_style,
    LayoutUnit table_inline_size,
    const ConstraintSpace& caption_constraint_space,
    const BlockNode& caption,
    BoxStrut margins,
    const BlockBreakToken* break_token = nullptr,
    const EarlyBreak* early_break = nullptr) {}

// Compute the margins of a caption as best as we can before layout (we need to
// lay out before we can resolve auto inline-margins). Remember that captions
// aren't actually inside the table, so its the *border-box* size of the table
// that matters here (not the content-box) when it comes to resolving
// percentages.
BoxStrut ComputeCaptionMargins(
    const ConstraintSpace& table_constraint_space,
    const BlockNode& caption,
    LayoutUnit table_border_box_inline_size,
    const BlockBreakToken* caption_break_token = nullptr) {}

void ComputeCaptionFragments(
    const BoxFragmentBuilder& table_builder,
    const ComputedStyle& table_style,
    const TableGroupedChildren& grouped_children,
    HeapVector<TableLayoutAlgorithm::CaptionResult>* captions,
    LayoutUnit& captions_block_size) {}

LayoutUnit ComputeUndistributableTableSpace(
    const TableTypes::Columns& column_constraints,
    LayoutUnit inline_table_border_padding,
    LayoutUnit inline_border_spacing) {}

// Empty table sizes have been a source of many inconsistencies
// between browsers.
LayoutUnit ComputeEmptyTableInlineSize(
    const ConstraintSpace& space,
    const ComputedStyle& table_style,
    const LayoutUnit assignable_table_inline_size,
    const LayoutUnit undistributable_space,
    const TableTypes::Caption& caption_constraint,
    const BoxStrut& table_border_padding,
    const bool has_collapsed_borders) {}

// standard: https://www.w3.org/TR/css-tables-3/#computing-the-table-width
LayoutUnit ComputeAssignableTableInlineSize(
    const TableNode& table,
    const ConstraintSpace& space,
    const TableTypes::Columns& column_constraints,
    const TableTypes::Caption& caption_constraint,
    const LayoutUnit undistributable_space,
    const BoxStrut& table_border_padding,
    const bool is_fixed_layout) {}

// If |shrink_collapsed| is true, collapsed columns have zero width.
void ComputeLocationsFromColumns(const TableTypes::Columns& column_constraints,
                                 const Vector<LayoutUnit>& column_sizes,
                                 LayoutUnit inline_border_spacing,
                                 bool shrink_collapsed,
                                 Vector<TableColumnLocation>* column_locations,
                                 bool* has_collapsed_columns) {}

scoped_refptr<const TableConstraintSpaceData> CreateConstraintSpaceData(
    const ComputedStyle& style,
    const Vector<TableColumnLocation>& column_locations,
    const TableTypes::Sections& sections,
    const TableTypes::Rows& rows,
    const TableTypes::CellBlockConstraints& cell_block_constraints,
    const LogicalSize& border_spacing) {}

// Columns do not generate fragments.
// Column geometry is needed for painting, and is stored
// in TableFragmentData. Geometry data is also copied
// back to LayoutObject.
class ColumnGeometriesBuilder {};

LayoutUnit ComputeTableSizeFromColumns(
    const Vector<TableColumnLocation>& column_locations,
    const BoxStrut& table_border_padding,
    const LogicalSize& border_spacing) {}

// Border-box block extent of what CSS calls the "table box" [1]
// (i.e. everything except for captions).
//
// [1] https://www.w3.org/TR/CSS22/tables.html#model
struct TableBoxExtent {};

// Call when beginning layout of the table box (typically right before laying
// out the first section).
TableBoxExtent BeginTableBoxLayout(
    LayoutUnit block_start_border_edge,
    LayoutUnit table_border_padding_block_start) {}

// Call when done with layout of the table box (typically right after having
// laid out the last table section).
LayoutUnit EndTableBoxLayout(LayoutUnit table_border_padding_block_end,
                             LayoutUnit border_spacing_after_last_section,
                             LayoutUnit minimal_table_grid_block_size,
                             TableBoxExtent* extent,
                             LayoutUnit* grid_block_size_inflation) {}

}  // namespace

LayoutUnit TableLayoutAlgorithm::ComputeTableInlineSize(
    const TableNode& table,
    const ConstraintSpace& space,
    const BoxStrut& table_border_padding) {}

LayoutUnit TableLayoutAlgorithm::ComputeCaptionBlockSize() {}

const LayoutResult* TableLayoutAlgorithm::Layout() {}

MinMaxSizesResult TableLayoutAlgorithm::ComputeMinMaxSizes(
    const MinMaxSizesFloatInput&) {}

const LayoutResult* TableLayoutAlgorithm::RelayoutAsLastTableBox() {}

void TableLayoutAlgorithm::ComputeRows(
    const LayoutUnit table_grid_inline_size,
    const TableGroupedChildren& grouped_children,
    const Vector<TableColumnLocation>& column_locations,
    const TableBorders& table_borders,
    const LogicalSize& border_spacing,
    const BoxStrut& table_border_padding,
    const LayoutUnit captions_block_size,
    TableTypes::Rows* rows,
    TableTypes::CellBlockConstraints* cell_block_constraints,
    TableTypes::Sections* sections,
    LayoutUnit* minimal_table_grid_block_size) {}

// Method also sets LogicalWidth/Height on columns.
void TableLayoutAlgorithm::ComputeTableSpecificFragmentData(
    const TableGroupedChildren& grouped_children,
    const Vector<TableColumnLocation>& column_locations,
    const TableTypes::Rows& rows,
    const TableBorders& table_borders,
    const LogicalRect& table_grid_rect,
    const LayoutUnit table_grid_block_size) {}

// Generated fragment structure
// +---- table wrapper fragment ----+
// |     top caption fragments      |
// |     table border/padding       |
// |       block_spacing            |
// |         section                |
// |       block_spacing            |
// |         section                |
// |       block_spacing            |
// |     table border/padding       |
// |     bottom caption fragments   |
// +--------------------------------+
const LayoutResult* TableLayoutAlgorithm::GenerateFragment(
    const LayoutUnit table_inline_size,
    LayoutUnit minimal_table_grid_block_size,
    const TableGroupedChildren& grouped_children,
    const Vector<TableColumnLocation>& column_locations,
    const TableTypes::Rows& rows,
    const TableTypes::CellBlockConstraints& cell_block_constraints,
    const TableTypes::Sections& sections,
    const HeapVector<CaptionResult>& captions,
    const TableBorders& table_borders,
    const LogicalSize& border_spacing) {}

}  // namespace blink