Skip to main content

TableLayout

Struct TableLayout 

Source
pub struct TableLayout { /* private fields */ }
Expand description

Table layout engine

Implementations§

Source§

impl TableLayout

Source

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:

  1. Hidden takes precedence over all other styles
  2. None has the lowest precedence
  3. Wider borders take precedence over narrower ones
  4. If widths are equal, style precedence is: double > solid > dashed > dotted > ridge > outset > groove > inset
  5. 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

Source

pub fn compute_fixed_widths(&self, columns: &[ColumnWidth]) -> Vec<Length>

Compute column widths using fixed layout algorithm

Source

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:

  1. Calculate minimum and maximum width for each column based on content
  2. Assign fixed widths first
  3. Distribute remaining width to auto columns based on their min/max widths
  4. 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.

Source

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

Source

pub fn update_column_info_from_grid( &self, column_info: &mut [ColumnInfo], grid: &[Vec<Option<GridCell>>], )

Update column info with measured widths from grid

Source

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

Source

pub fn create_grid( &self, rows: usize, cols: usize, ) -> Vec<Vec<Option<GridCell>>>

Create table grid from rows and cells

Source

pub fn place_cell( &self, grid: &mut [Vec<Option<GridCell>>], cell: GridCell, ) -> Result<()>

Place a cell in the grid

Source

pub fn layout_table( &self, area_tree: &mut AreaTree, column_widths: &[Length], grid: &[Vec<Option<GridCell>>], y_offset: Length, ) -> Result<AreaId>

Layout table into area tree

Source§

impl TableLayout

Source

pub fn new(available_width: Length) -> Self

Create a new table layout engine

Source

pub fn with_border_spacing(self, spacing: Length) -> Self

Set border spacing

Source

pub fn with_layout_mode(self, mode: TableLayoutMode) -> Self

Set table layout mode

Source

pub fn with_border_collapse(self, collapse: BorderCollapse) -> Self

Set border collapse model

Source

pub fn layout_mode(&self) -> TableLayoutMode

Get the current table layout mode

Source

pub fn border_collapse(&self) -> BorderCollapse

Get the current border collapse model

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.