Struct layout_2020::table::layout::TableLayout
source · 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,
column_measures: Vec<CellOrTrackMeasure>,
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<CollapsedBorders>,
}
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
§column_measures: Vec<CellOrTrackMeasure>
§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<CollapsedBorders>
Information about collapsed borders.
Implementations§
source§impl<'a> TableLayout<'a>
impl<'a> TableLayout<'a>
fn new(table: &'a Table) -> TableLayout<'_>
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 compute_content_sizes_for_columns_with_span_up_to_n( &self, n: usize, old_column_measures: &[CellOrTrackMeasure], ) -> (usize, Vec<CellOrTrackMeasure>)
sourcefn compute_grid_min_max(
&mut self,
layout_context: &LayoutContext<'_>,
writing_mode: WritingMode,
) -> ContentSizes
fn compute_grid_min_max( &mut self, layout_context: &LayoutContext<'_>, writing_mode: WritingMode, ) -> ContentSizes
Compute the GRIDMIN and GRIDMAX.
Compute CAPMIN: https://drafts.csswg.org/css-tables/#capmin
fn compute_table_width( &mut self, containing_block_for_children: &ContainingBlock<'_>, containing_block_for_table: &ContainingBlock<'_>, grid_min_max: ContentSizes, caption_minimum_inline_size: Au, )
sourcefn distribute_width_to_columns(&self) -> Vec<Au>
fn distribute_width_to_columns(&self) -> 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(
&self,
column_sizes: &mut [Au],
column_sizes_sum: Au,
)
fn distribute_extra_width_to_columns( &self, column_sizes: &mut [Au], column_sizes_sum: 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<'_>,
containing_block_for_table: &ContainingBlock<'_>,
)
fn compute_table_height_and_final_row_heights( &mut self, row_sizes: Vec<Au>, containing_block_for_children: &ContainingBlock<'_>, containing_block_for_table: &ContainingBlock<'_>, )
Given computed row sizes, compute the final block size of the table and distribute extra block size to table rows.
sourcefn layout(
self,
layout_context: &LayoutContext<'_>,
positioning_context: &mut PositioningContext,
containing_block_for_children: &ContainingBlock<'_>,
containing_block_for_table: &ContainingBlock<'_>,
) -> IndependentLayout
fn layout( self, layout_context: &LayoutContext<'_>, positioning_context: &mut PositioningContext, containing_block_for_children: &ContainingBlock<'_>, containing_block_for_table: &ContainingBlock<'_>, ) -> IndependentLayout
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<'_>,
table_pbm: &PaddingBorderMargin,
positioning_context: &mut PositioningContext,
containing_block_for_logical_conversion: &ContainingBlock<'_>,
containing_block_for_children: &ContainingBlock<'_>,
containing_block_for_table: &ContainingBlock<'_>,
) -> BoxFragment
fn layout_grid( &mut self, layout_context: &LayoutContext<'_>, table_pbm: &PaddingBorderMargin, positioning_context: &mut PositioningContext, containing_block_for_logical_conversion: &ContainingBlock<'_>, containing_block_for_children: &ContainingBlock<'_>, containing_block_for_table: &ContainingBlock<'_>, ) -> BoxFragment
Lay out the grid portion of this TableLayout
into fragments. This should only be be
called after calling [TableLayout.compute_measures
].
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_borders_for_cell( &self, cell: &TableSlotCell, coordinates: Point2D<usize, UnknownUnit>, ) -> 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