pub(crate) struct TableLayout<'a> {Show 15 fields
table: &'a Table,
pbm: PaddingBorderMargin,
rows: Vec<RowLayout>,
columns: Vec<ColumnLayout>,
cell_measures: Vec<Vec<LogicalVec2<CellOrTrackMeasure>>>,
table_width: Au,
assignable_width: Au,
final_table_height: Au,
distributed_column_widths: Vec<Au>,
row_sizes: Vec<Au>,
row_baselines: Vec<Au>,
cells_laid_out: Vec<Vec<Option<CellLayout>>>,
basis_for_cell_padding_percentage: Au,
collapsed_borders: Option<LogicalVec2<Vec<Vec<CollapsedBorder>>>>,
is_in_fixed_mode: bool,
}
Expand description
A helper struct that performs the layout of the box tree version of a table into the fragment tree version. This implements https://drafts.csswg.org/css-tables/#table-layout-algorithm
Fields§
§table: &'a Table
§pbm: PaddingBorderMargin
§rows: Vec<RowLayout>
§columns: Vec<ColumnLayout>
§cell_measures: Vec<Vec<LogicalVec2<CellOrTrackMeasure>>>
§table_width: Au
The calculated width of the table, including space for the grid and also for any captions.
assignable_width: Au
The table width minus the total horizontal border spacing (if any). This is the width that we will be able to allocate to the columns.
final_table_height: Au
§distributed_column_widths: Vec<Au>
§row_sizes: Vec<Au>
§row_baselines: Vec<Au>
The accumulated baseline of each row, relative to the top of the row.
cells_laid_out: Vec<Vec<Option<CellLayout>>>
§basis_for_cell_padding_percentage: Au
§collapsed_borders: Option<LogicalVec2<Vec<Vec<CollapsedBorder>>>>
Information about collapsed borders.
is_in_fixed_mode: bool
Implementations§
Source§impl<'a> TableLayout<'a>
impl<'a> TableLayout<'a>
fn new(table: &'a Table) -> TableLayout<'a>
Sourcepub(crate) fn compute_cell_measures(
&mut self,
layout_context: &LayoutContext<'_>,
writing_mode: WritingMode,
)
pub(crate) fn compute_cell_measures( &mut self, layout_context: &LayoutContext<'_>, writing_mode: WritingMode, )
This is an implementation of Computing Cell Measures from https://drafts.csswg.org/css-tables/#computing-cell-measures.
Sourcefn compute_track_constrainedness_and_has_originating_cells(
&mut self,
writing_mode: WritingMode,
)
fn compute_track_constrainedness_and_has_originating_cells( &mut self, writing_mode: WritingMode, )
Compute the constrainedness of every column in the table.
A column is constrained if its corresponding table-column-group (if any), its corresponding table-column (if any), or any of the cells spanning only that column has a computed width that is not “auto”, and is not a percentage.
Sourcefn compute_column_measures(&mut self, writing_mode: WritingMode)
fn compute_column_measures(&mut self, writing_mode: WritingMode)
This is an implementation of Computing Column Measures from https://drafts.csswg.org/css-tables/#computing-column-measures.
fn distribute_colspanned_cells_to_columns( &mut self, colspan_cell_constraints: Vec<ColspanToDistribute>, )
Sourcefn distribute_colspanned_cell_to_columns(
&mut self,
colspan_cell_constraints: ColspanToDistribute,
)
fn distribute_colspanned_cell_to_columns( &mut self, colspan_cell_constraints: ColspanToDistribute, )
Distribute the inline size from a cell with colspan != 1 to the columns that it spans.
This is heavily inspired by the approach that Chromium takes in redistributing colspan
cells’ inline size to columns (DistributeColspanCellToColumnsAuto
in
blink/renderer/core/layout/table/table_layout_utils.cc
).
fn compute_measures( &mut self, layout_context: &LayoutContext<'_>, writing_mode: WritingMode, )
Sourcefn compute_grid_min_max(&self) -> ContentSizes
fn compute_grid_min_max(&self) -> ContentSizes
Compute the GRIDMIN and GRIDMAX.
Sourcefn compute_caption_minimum_inline_size(
&self,
layout_context: &LayoutContext<'_>,
) -> Au
fn compute_caption_minimum_inline_size( &self, layout_context: &LayoutContext<'_>, ) -> Au
Compute CAPMIN: https://drafts.csswg.org/css-tables/#capmin
fn compute_table_width( &mut self, containing_block_for_children: &ContainingBlock<'_>, )
Sourcefn distribute_width_to_columns(
target_inline_size: Au,
columns: &[ColumnLayout],
) -> Vec<Au>
fn distribute_width_to_columns( target_inline_size: Au, columns: &[ColumnLayout], ) -> Vec<Au>
Distribute width to columns, performing step 2.4 of table layout from https://drafts.csswg.org/css-tables/#table-layout-algorithm.
Sourcefn distribute_extra_width_to_columns(
columns: &[ColumnLayout],
column_sizes: &mut [Au],
column_sizes_sum: Au,
assignable_width: Au,
)
fn distribute_extra_width_to_columns( columns: &[ColumnLayout], column_sizes: &mut [Au], column_sizes_sum: Au, assignable_width: Au, )
This is an implementation of Distributing excess width to columns from https://drafts.csswg.org/css-tables/#distributing-width-to-columns.
Sourcefn layout_cells_in_row(
&mut self,
layout_context: &LayoutContext<'_>,
containing_block_for_table: &ContainingBlock<'_>,
parent_positioning_context: &mut PositioningContext,
)
fn layout_cells_in_row( &mut self, layout_context: &LayoutContext<'_>, containing_block_for_table: &ContainingBlock<'_>, parent_positioning_context: &mut PositioningContext, )
This is an implementation of Row layout (first pass) from https://drafts.csswg.org/css-tables/#row-layout.
Sourcefn do_first_row_layout(&mut self, writing_mode: WritingMode) -> Vec<Au>
fn do_first_row_layout(&mut self, writing_mode: WritingMode) -> Vec<Au>
Do the first layout of a table row, after laying out the cells themselves. This is more or less and implementation of https://drafts.csswg.org/css-tables/#row-layout.
Sourcefn calculate_row_sizes_after_first_layout(
&mut self,
row_sizes: &mut Vec<Au>,
writing_mode: WritingMode,
)
fn calculate_row_sizes_after_first_layout( &mut self, row_sizes: &mut Vec<Au>, writing_mode: WritingMode, )
After doing layout of table rows, calculate final row size and distribute space across rowspanned cells. This follows the implementation of LayoutNG and the priority agorithm described at https://github.com/w3c/csswg-drafts/issues/4418.
Sourcefn distribute_extra_size_to_rows(
&self,
excess_size: Au,
track_range: Range<usize>,
track_sizes: &mut [Au],
percentage_resolution_size: Option<Au>,
rowspan_distribution: bool,
)
fn distribute_extra_size_to_rows( &self, excess_size: Au, track_range: Range<usize>, track_sizes: &mut [Au], percentage_resolution_size: Option<Au>, rowspan_distribution: bool, )
An implementation of the same extra block size distribution algorithm used in LayoutNG and described at https://github.com/w3c/csswg-drafts/issues/4418.
Sourcefn compute_table_height_and_final_row_heights(
&mut self,
row_sizes: Vec<Au>,
containing_block_for_children: &ContainingBlock<'_>,
)
fn compute_table_height_and_final_row_heights( &mut self, row_sizes: Vec<Au>, containing_block_for_children: &ContainingBlock<'_>, )
Given computed row sizes, compute the final block size of the table and distribute extra block size to table rows.
fn layout_caption( &self, caption: &TableCaption, layout_context: &LayoutContext<'_>, parent_positioning_context: &mut PositioningContext, ) -> BoxFragment
Sourcefn layout(
self,
layout_context: &LayoutContext<'_>,
positioning_context: &mut PositioningContext,
containing_block_for_children: &ContainingBlock<'_>,
containing_block_for_table: &ContainingBlock<'_>,
depends_on_block_constraints: bool,
) -> CacheableLayoutResult
fn layout( self, layout_context: &LayoutContext<'_>, positioning_context: &mut PositioningContext, containing_block_for_children: &ContainingBlock<'_>, containing_block_for_table: &ContainingBlock<'_>, depends_on_block_constraints: bool, ) -> CacheableLayoutResult
Lay out the table (grid and captions) of this TableLayout
into fragments. This should
only be be called after calling [TableLayout.compute_measures
].
Sourcefn layout_grid(
&mut self,
layout_context: &LayoutContext<'_>,
positioning_context: &mut PositioningContext,
containing_block_for_logical_conversion: &ContainingBlock<'_>,
containing_block_for_children: &ContainingBlock<'_>,
) -> BoxFragment
fn layout_grid( &mut self, layout_context: &LayoutContext<'_>, positioning_context: &mut PositioningContext, containing_block_for_logical_conversion: &ContainingBlock<'_>, containing_block_for_children: &ContainingBlock<'_>, ) -> BoxFragment
Lay out the grid portion of this TableLayout
into fragments. This should only be be
called after calling [TableLayout.compute_measures
].
fn specific_layout_info_for_grid(&mut self) -> Option<SpecificLayoutInfo>
fn is_row_collapsed(&self, row_index: usize) -> bool
fn is_column_collapsed(&self, column_index: usize) -> bool
fn do_final_cell_layout( &mut self, row_index: usize, column_index: usize, dimensions: &TableAndTrackDimensions, baselines: &mut Baselines, row_fragment_layout: &mut RowFragmentLayout<'_>, row_group_fragment_layout: Option<&mut RowGroupFragmentLayout>, positioning_context_for_table: &mut PositioningContext, )
fn make_fragments_for_columns_and_column_groups( &self, dimensions: &TableAndTrackDimensions, fragments: &mut Vec<Fragment>, )
fn compute_border_collapse(&mut self, writing_mode: WritingMode)
fn get_collapsed_border_widths_for_area( &self, area: LogicalSides<usize>, ) -> Option<LogicalSides<Au>>
Auto Trait Implementations§
impl<'a> Freeze for TableLayout<'a>
impl<'a> !RefUnwindSafe for TableLayout<'a>
impl<'a> Send for TableLayout<'a>
impl<'a> Sync for TableLayout<'a>
impl<'a> Unpin for TableLayout<'a>
impl<'a> !UnwindSafe for TableLayout<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more