pub(in compute::grid) struct GridItem {Show 29 fields
pub node: NodeId,
pub source_order: u16,
pub row: Line<OriginZeroLine>,
pub column: Line<OriginZeroLine>,
pub overflow: Point<Overflow>,
pub box_sizing: BoxSizing,
pub size: Size<Dimension>,
pub min_size: Size<Dimension>,
pub max_size: Size<Dimension>,
pub aspect_ratio: Option<f32>,
pub padding: Rect<LengthPercentage>,
pub border: Rect<LengthPercentage>,
pub margin: Rect<LengthPercentageAuto>,
pub align_self: AlignSelf,
pub justify_self: AlignSelf,
pub baseline: Option<f32>,
pub baseline_shim: f32,
pub row_indexes: Line<u16>,
pub column_indexes: Line<u16>,
pub crosses_flexible_row: bool,
pub crosses_flexible_column: bool,
pub crosses_intrinsic_row: bool,
pub crosses_intrinsic_column: bool,
pub available_space_cache: Option<Size<Option<f32>>>,
pub min_content_contribution_cache: Size<Option<f32>>,
pub minimum_contribution_cache: Size<Option<f32>>,
pub max_content_contribution_cache: Size<Option<f32>>,
pub y_position: f32,
pub height: f32,
}
Expand description
Represents a single grid item
Fields§
§node: NodeId
The id of the node that this item represents
source_order: u16
The order of the item in the children array
We sort the list of grid items during track sizing. This field allows us to sort back the original order for final positioning
row: Line<OriginZeroLine>
The item’s definite row-start and row-end, as resolved by the placement algorithm (in origin-zero coordinates)
column: Line<OriginZeroLine>
The items definite column-start and column-end, as resolved by the placement algorithm (in origin-zero coordinates)
overflow: Point<Overflow>
The item’s overflow style
box_sizing: BoxSizing
The item’s box_sizing style
size: Size<Dimension>
The item’s size style
min_size: Size<Dimension>
The item’s min_size style
max_size: Size<Dimension>
The item’s max_size style
aspect_ratio: Option<f32>
The item’s aspect_ratio style
padding: Rect<LengthPercentage>
The item’s padding style
border: Rect<LengthPercentage>
The item’s border style
margin: Rect<LengthPercentageAuto>
The item’s margin style
align_self: AlignSelf
The item’s align_self property, or the parent’s align_items property is not set
justify_self: AlignSelf
The item’s justify_self property, or the parent’s justify_items property is not set
baseline: Option<f32>
The items first baseline (horizontal)
baseline_shim: f32
Shim for baseline alignment that acts like an extra top margin TODO: Support last baseline and vertical text baselines
row_indexes: Line<u16>
The item’s definite row-start and row-end (same as row
field, except in a different coordinate system)
(as indexes into the Vec
column_indexes: Line<u16>
The items definite column-start and column-end (same as column
field, except in a different coordinate system)
(as indexes into the Vec
crosses_flexible_row: bool
Whether the item crosses a flexible row
crosses_flexible_column: bool
Whether the item crosses a flexible column
crosses_intrinsic_row: bool
Whether the item crosses a intrinsic row
crosses_intrinsic_column: bool
Whether the item crosses a intrinsic column
available_space_cache: Option<Size<Option<f32>>>
Cache for the known_dimensions input to intrinsic sizing computation
min_content_contribution_cache: Size<Option<f32>>
Cache for the min-content size
minimum_contribution_cache: Size<Option<f32>>
Cache for the minimum contribution
max_content_contribution_cache: Size<Option<f32>>
Cache for the max-content size
y_position: f32
Final y position. Used to compute baseline alignment for the container.
height: f32
Final height. Used to compute baseline alignment for the container.
Implementations§
source§impl GridItem
impl GridItem
sourcepub fn new_with_placement_style_and_order<S: GridItemStyle>(
node: NodeId,
col_span: Line<OriginZeroLine>,
row_span: Line<OriginZeroLine>,
style: S,
parent_align_items: AlignItems,
parent_justify_items: AlignItems,
source_order: u16,
) -> Self
pub fn new_with_placement_style_and_order<S: GridItemStyle>( node: NodeId, col_span: Line<OriginZeroLine>, row_span: Line<OriginZeroLine>, style: S, parent_align_items: AlignItems, parent_justify_items: AlignItems, source_order: u16, ) -> Self
Create a new item given a concrete placement in both axes
sourcepub fn placement(&self, axis: AbstractAxis) -> Line<OriginZeroLine>
pub fn placement(&self, axis: AbstractAxis) -> Line<OriginZeroLine>
This item’s placement in the specified axis in OriginZero coordinates
sourcepub fn placement_indexes(&self, axis: AbstractAxis) -> Line<u16>
pub fn placement_indexes(&self, axis: AbstractAxis) -> Line<u16>
This item’s placement in the specified axis as GridTrackVec indices
sourcepub fn track_range_excluding_lines(&self, axis: AbstractAxis) -> Range<usize>
pub fn track_range_excluding_lines(&self, axis: AbstractAxis) -> Range<usize>
Returns a range which can be used as an index into the GridTrackVec in the specified axis which will produce a sub-slice of covering all the tracks and lines that this item spans excluding the lines that bound it.
sourcepub fn span(&self, axis: AbstractAxis) -> u16
pub fn span(&self, axis: AbstractAxis) -> u16
Returns the number of tracks that this item spans in the specified axis
sourcepub fn crosses_flexible_track(&self, axis: AbstractAxis) -> bool
pub fn crosses_flexible_track(&self, axis: AbstractAxis) -> bool
Returns the pre-computed value indicating whether the grid item crosses a flexible track in the specified axis
sourcepub fn crosses_intrinsic_track(&self, axis: AbstractAxis) -> bool
pub fn crosses_intrinsic_track(&self, axis: AbstractAxis) -> bool
Returns the pre-computed value indicating whether the grid item crosses an intrinsic track in the specified axis
sourcepub fn spanned_track_limit(
&mut self,
axis: AbstractAxis,
axis_tracks: &[GridTrack],
axis_parent_size: Option<f32>,
) -> Option<f32>
pub fn spanned_track_limit( &mut self, axis: AbstractAxis, axis_tracks: &[GridTrack], axis_parent_size: Option<f32>, ) -> Option<f32>
For an item spanning multiple tracks, the upper limit used to calculate its limited min-/max-content contribution is the sum of the fixed max track sizing functions of any tracks it spans, and is applied if it only spans such tracks.
sourcepub fn spanned_fixed_track_limit(
&mut self,
axis: AbstractAxis,
axis_tracks: &[GridTrack],
axis_parent_size: Option<f32>,
) -> Option<f32>
pub fn spanned_fixed_track_limit( &mut self, axis: AbstractAxis, axis_tracks: &[GridTrack], axis_parent_size: Option<f32>, ) -> Option<f32>
Similar to the spanned_track_limit, but excludes FitContent arguments from the limit. Used to clamp the automatic minimum contributions of an item
sourcefn known_dimensions(
&self,
inner_node_size: Size<Option<f32>>,
grid_area_size: Size<Option<f32>>,
) -> Size<Option<f32>>
fn known_dimensions( &self, inner_node_size: Size<Option<f32>>, grid_area_size: Size<Option<f32>>, ) -> Size<Option<f32>>
Compute the known_dimensions to be passed to the child sizing functions The key thing that is being done here is applying stretch alignment, which is necessary to allow percentage sizes further down the tree to resolve properly in some cases
sourcepub fn available_space(
&self,
axis: AbstractAxis,
other_axis_tracks: &[GridTrack],
other_axis_available_space: Option<f32>,
get_track_size_estimate: impl Fn(&GridTrack, Option<f32>) -> Option<f32>,
) -> Size<Option<f32>>
pub fn available_space( &self, axis: AbstractAxis, other_axis_tracks: &[GridTrack], other_axis_available_space: Option<f32>, get_track_size_estimate: impl Fn(&GridTrack, Option<f32>) -> Option<f32>, ) -> Size<Option<f32>>
Compute the available_space to be passed to the child sizing functions These are estimates based on either the max track sizing function or the provisional base size in the opposite axis to the one currently being sized. https://www.w3.org/TR/css-grid-1/#algo-overview
sourcepub fn available_space_cached(
&mut self,
axis: AbstractAxis,
other_axis_tracks: &[GridTrack],
other_axis_available_space: Option<f32>,
get_track_size_estimate: impl Fn(&GridTrack, Option<f32>) -> Option<f32>,
) -> Size<Option<f32>>
pub fn available_space_cached( &mut self, axis: AbstractAxis, other_axis_tracks: &[GridTrack], other_axis_available_space: Option<f32>, get_track_size_estimate: impl Fn(&GridTrack, Option<f32>) -> Option<f32>, ) -> Size<Option<f32>>
Retrieve the available_space from the cache or compute them using the passed parameters
sourcepub fn margins_axis_sums_with_baseline_shims(
&self,
inner_node_width: Option<f32>,
) -> Size<f32>
pub fn margins_axis_sums_with_baseline_shims( &self, inner_node_width: Option<f32>, ) -> Size<f32>
Compute the item’s resolved margins for size contributions. Horizontal percentage margins always resolve to zero if the container size is indefinite as otherwise this would introduce a cyclic dependency.
sourcepub fn min_content_contribution(
&self,
axis: AbstractAxis,
tree: &mut impl LayoutPartialTree,
available_space: Size<Option<f32>>,
inner_node_size: Size<Option<f32>>,
) -> f32
pub fn min_content_contribution( &self, axis: AbstractAxis, tree: &mut impl LayoutPartialTree, available_space: Size<Option<f32>>, inner_node_size: Size<Option<f32>>, ) -> f32
Compute the item’s min content contribution from the provided parameters
sourcepub fn min_content_contribution_cached(
&mut self,
axis: AbstractAxis,
tree: &mut impl LayoutPartialTree,
available_space: Size<Option<f32>>,
inner_node_size: Size<Option<f32>>,
) -> f32
pub fn min_content_contribution_cached( &mut self, axis: AbstractAxis, tree: &mut impl LayoutPartialTree, available_space: Size<Option<f32>>, inner_node_size: Size<Option<f32>>, ) -> f32
Retrieve the item’s min content contribution from the cache or compute it using the provided parameters
sourcepub fn max_content_contribution(
&self,
axis: AbstractAxis,
tree: &mut impl LayoutPartialTree,
available_space: Size<Option<f32>>,
inner_node_size: Size<Option<f32>>,
) -> f32
pub fn max_content_contribution( &self, axis: AbstractAxis, tree: &mut impl LayoutPartialTree, available_space: Size<Option<f32>>, inner_node_size: Size<Option<f32>>, ) -> f32
Compute the item’s max content contribution from the provided parameters
sourcepub fn max_content_contribution_cached(
&mut self,
axis: AbstractAxis,
tree: &mut impl LayoutPartialTree,
available_space: Size<Option<f32>>,
inner_node_size: Size<Option<f32>>,
) -> f32
pub fn max_content_contribution_cached( &mut self, axis: AbstractAxis, tree: &mut impl LayoutPartialTree, available_space: Size<Option<f32>>, inner_node_size: Size<Option<f32>>, ) -> f32
Retrieve the item’s max content contribution from the cache or compute it using the provided parameters
sourcepub fn minimum_contribution(
&mut self,
tree: &mut impl LayoutPartialTree,
axis: AbstractAxis,
axis_tracks: &[GridTrack],
known_dimensions: Size<Option<f32>>,
inner_node_size: Size<Option<f32>>,
) -> f32
pub fn minimum_contribution( &mut self, tree: &mut impl LayoutPartialTree, axis: AbstractAxis, axis_tracks: &[GridTrack], known_dimensions: Size<Option<f32>>, inner_node_size: Size<Option<f32>>, ) -> f32
The minimum contribution of an item is the smallest outer size it can have. Specifically:
- If the item’s computed preferred size behaves as auto or depends on the size of its containing block in the relevant axis: Its minimum contribution is the outer size that would result from assuming the item’s used minimum size as its preferred size;
- Else the item’s minimum contribution is its min-content contribution.
Because the minimum contribution often depends on the size of the item’s content, it is considered a type of intrinsic size contribution. See: https://www.w3.org/TR/css-grid-1/#min-size-auto
sourcepub fn minimum_contribution_cached(
&mut self,
tree: &mut impl LayoutPartialTree,
axis: AbstractAxis,
axis_tracks: &[GridTrack],
known_dimensions: Size<Option<f32>>,
inner_node_size: Size<Option<f32>>,
) -> f32
pub fn minimum_contribution_cached( &mut self, tree: &mut impl LayoutPartialTree, axis: AbstractAxis, axis_tracks: &[GridTrack], known_dimensions: Size<Option<f32>>, inner_node_size: Size<Option<f32>>, ) -> f32
Retrieve the item’s minimum contribution from the cache or compute it using the provided parameters