pub struct TableLayout { /* private fields */ }Expand description
Table layout engine
Implementations§
Source§impl TableLayout
impl TableLayout
Sourcepub fn resolve_border_conflict(
&self,
border1: CollapsedBorder,
border2: CollapsedBorder,
) -> CollapsedBorder
pub fn resolve_border_conflict( &self, border1: CollapsedBorder, border2: CollapsedBorder, ) -> CollapsedBorder
Resolve border conflicts for collapsed border model
According to CSS2.1 Section 17.6.2, when two borders collapse:
- Hidden takes precedence over all other styles
- None has the lowest precedence
- Wider borders take precedence over narrower ones
- If widths are equal, style precedence is: double > solid > dashed > dotted > ridge > outset > groove > inset
- If width and style are equal, the border from the cell wins over the one from the row, which wins over the table
Source§impl TableLayout
impl TableLayout
Sourcepub fn compute_fixed_widths(&self, columns: &[ColumnWidth]) -> Vec<Length>
pub fn compute_fixed_widths(&self, columns: &[ColumnWidth]) -> Vec<Length>
Compute column widths using fixed layout algorithm
Sourcepub fn compute_auto_widths(&self, column_info: &[ColumnInfo]) -> Vec<Length>
pub fn compute_auto_widths(&self, column_info: &[ColumnInfo]) -> Vec<Length>
Compute column widths using auto layout algorithm
This implements the CSS2.1 automatic table layout algorithm:
- Calculate minimum and maximum width for each column based on content
- Assign fixed widths first
- Distribute remaining width to auto columns based on their min/max widths
- Handle proportional widths
Algorithm details:
- Fixed columns: Use their specified width
- Proportional columns: Distribute remaining width by ratio
- Auto columns: Use content-based min/max widths
- If space >= total max: Use max widths (no line breaking)
- If min <= space < max: Interpolate between min and max
- If space < min: Scale down from min (may overflow)
This matches Apache FOP’s AutoLayoutAlgorithm.java behavior.
Sourcepub fn measure_column_widths(
&self,
grid: &[Vec<Option<GridCell>>],
col_idx: usize,
) -> (Length, Length)
pub fn measure_column_widths( &self, grid: &[Vec<Option<GridCell>>], col_idx: usize, ) -> (Length, Length)
Measure content widths for cells in a column Returns (min_width, max_width) for the column
Sourcepub fn update_column_info_from_grid(
&self,
column_info: &mut [ColumnInfo],
grid: &[Vec<Option<GridCell>>],
)
pub fn update_column_info_from_grid( &self, column_info: &mut [ColumnInfo], grid: &[Vec<Option<GridCell>>], )
Update column info with measured widths from grid
Sourcepub fn distribute_colspan_widths(
&self,
column_info: &mut [ColumnInfo],
grid: &[Vec<Option<GridCell>>],
)
pub fn distribute_colspan_widths( &self, column_info: &mut [ColumnInfo], grid: &[Vec<Option<GridCell>>], )
Handle cells with colspan in width calculation This distributes the cell’s required width across spanned columns
Source§impl TableLayout
impl TableLayout
Source§impl TableLayout
impl TableLayout
Sourcepub fn with_border_spacing(self, spacing: Length) -> Self
pub fn with_border_spacing(self, spacing: Length) -> Self
Set border spacing
Sourcepub fn with_layout_mode(self, mode: TableLayoutMode) -> Self
pub fn with_layout_mode(self, mode: TableLayoutMode) -> Self
Set table layout mode
Sourcepub fn with_border_collapse(self, collapse: BorderCollapse) -> Self
pub fn with_border_collapse(self, collapse: BorderCollapse) -> Self
Set border collapse model
Sourcepub fn layout_mode(&self) -> TableLayoutMode
pub fn layout_mode(&self) -> TableLayoutMode
Get the current table layout mode
Sourcepub fn border_collapse(&self) -> BorderCollapse
pub fn border_collapse(&self) -> BorderCollapse
Get the current border collapse model
Auto Trait Implementations§
impl Freeze for TableLayout
impl RefUnwindSafe for TableLayout
impl Send for TableLayout
impl Sync for TableLayout
impl Unpin for TableLayout
impl UnsafeUnpin for TableLayout
impl UnwindSafe for TableLayout
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> 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