pub(crate) struct NamedLineResolver<S: CheapCloneStr> {
row_lines: HashMap<StrHasher<S>, SmallVec<[u32; 4]>, RandomState>,
column_lines: HashMap<StrHasher<S>, SmallVec<[u32; 4]>, RandomState>,
areas: HashMap<StrHasher<S>, AreaLines, RandomState>,
area_column_count: u16,
area_row_count: u16,
explicit_column_count: u16,
explicit_row_count: u16,
column_line_name_pairs: Vec<(u32, S)>,
row_line_name_pairs: Vec<(u32, S)>,
}Expand description
Resolver that takes grid lines names and area names as input and can then be used to resolve line names of grid placement properties into line numbers.
Fields§
§row_lines: HashMap<StrHasher<S>, SmallVec<[u32; 4]>, RandomState>Map of row line names to line numbers. Each line name may correspond to multiple lines
so we store a SmallVec
column_lines: HashMap<StrHasher<S>, SmallVec<[u32; 4]>, RandomState>Map of column line names to line numbers. Each line name may correspond to multiple lines
so we store a SmallVec
areas: HashMap<StrHasher<S>, AreaLines, RandomState>Map of area names to the lines of the area’s edges
area_column_count: u16Number of columns implied by grid area definitions
area_row_count: u16Number of rows implied by grid area definitions
explicit_column_count: u16The number of explicit columns in the grid. This is an input to the NamedLineResolver and is
used when computing the fallback line when a non-existent named line is specified.
explicit_row_count: u16The number of explicit rows in the grid. This is an input to the NamedLineResolver and is
used when computing the fallback line when a non-existent named line is specified.
column_line_name_pairs: Vec<(u32, S)>The (1-indexed line number, name) pairs of every column line named in the track template,
in source order (excludes the implicit names generated by grid-template-areas)
row_line_name_pairs: Vec<(u32, S)>The (1-indexed line number, name) pairs of every row line named in the track template,
in source order (excludes the implicit names generated by grid-template-areas)
Implementations§
Source§impl<S: CheapCloneStr> NamedLineResolver<S>
impl<S: CheapCloneStr> NamedLineResolver<S>
Sourcepub(crate) fn new(
style: &impl GridContainerStyle<CustomIdent = S>,
column_auto_repetitions: u16,
row_auto_repetitions: u16,
) -> Self
pub(crate) fn new( style: &impl GridContainerStyle<CustomIdent = S>, column_auto_repetitions: u16, row_auto_repetitions: u16, ) -> Self
Create and initialise a new NamedLineResolver
Sourcepub(crate) fn detailed_line_names(&self, axis: AbsoluteAxis) -> GridLineNames<S>
pub(crate) fn detailed_line_names(&self, axis: AbsoluteAxis) -> GridLineNames<S>
Build the per-line name groups of the explicit grid in the passed axis as a
GridLineNames, with repeat()s expanded. Only names given explicitly in the track
template are included; the implicit <name>-start/<name>-end names generated by
grid-template-areas are omitted (matching the resolved value of
grid-template-rows/grid-template-columns in browsers) but remain resolvable for
placement via GridLineNames::resolve_line_names.
Line indices are relative to the explicit grid (line 0 = start of the first explicit track).
Sourcepub(crate) fn resolve_row_names(
&self,
line: &Line<GridPlacement<S>>,
) -> Line<GenericGridPlacement<GridLine>>
pub(crate) fn resolve_row_names( &self, line: &Line<GridPlacement<S>>, ) -> Line<GenericGridPlacement<GridLine>>
Resolve named lines for both the start and end of a row-axis grid placement
Sourcepub(crate) fn resolve_column_names(
&self,
line: &Line<GridPlacement<S>>,
) -> Line<GenericGridPlacement<GridLine>>
pub(crate) fn resolve_column_names( &self, line: &Line<GridPlacement<S>>, ) -> Line<GenericGridPlacement<GridLine>>
Resolve named lines for both the start and end of a column-axis grid placement
Sourcepub(crate) fn resolve_line_names(
&self,
line: &Line<GridPlacement<S>>,
axis: GridAreaAxis,
) -> Line<GenericGridPlacement<GridLine>>
pub(crate) fn resolve_line_names( &self, line: &Line<GridPlacement<S>>, axis: GridAreaAxis, ) -> Line<GenericGridPlacement<GridLine>>
Resolve named lines for both the start and end of a grid placement
Sourcepub(crate) fn populate_detailed_line_resolvers(
self,
rows: &mut GridLineNames<S>,
columns: &mut GridLineNames<S>,
) -> HashMap<StrHasher<S>, AreaLines, RandomState>
pub(crate) fn populate_detailed_line_resolvers( self, rows: &mut GridLineNames<S>, columns: &mut GridLineNames<S>, ) -> HashMap<StrHasher<S>, AreaLines, RandomState>
Move the row and column line-name maps into the detailed grid information, and return the grid area map for the same purpose
Sourcepub(crate) fn area_column_count(&self) -> u16
pub(crate) fn area_column_count(&self) -> u16
Get the number of columns defined by the grid areas
Sourcepub(crate) fn area_row_count(&self) -> u16
pub(crate) fn area_row_count(&self) -> u16
Get the number of rows defined by the grid areas
Sourcepub(crate) fn set_explicit_column_count(&mut self, count: u16)
pub(crate) fn set_explicit_column_count(&mut self, count: u16)
Set the number of columns in the explicit grid
Sourcepub(crate) fn set_explicit_row_count(&mut self, count: u16)
pub(crate) fn set_explicit_row_count(&mut self, count: u16)
Set the number of rows in the explicit grid