tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5544Rust 88Markdown 11TOML 91926 Sutichaykuna

Units trait WIP

Signed-off-by: Nico Burns <nico@nicoburns.com>

7c123d3d5dffec52b7d432cbfdfd2b1ba6354040 · ruwaq Nico Burns · (1 wata ñawpaq) · tayta 647d235a5 · kay commitpi sach'ata qhaway

Semántico sayk'uy · 58

src/compute/grid/placement.rs

src/style/block.rs

src/style/flex.rs

src/style/grid.rs

src/style/mod.rs

5 qillqakuna · +100 −74

diff --git a/src/compute/grid/placement.rs b/src/compute/grid/placement.rs
index f7f43b3d3..761077518 100644
--- a/src/compute/grid/placement.rs
+++ b/src/compute/grid/placement.rs
@@ -4,7 +4,7 @@ use super::types::{CellOccupancyMatrix, CellOccupancyState, GridItem};
 use super::{NamedLineResolver, OriginZeroLine};
 use crate::geometry::Line;
 use crate::geometry::{AbsoluteAxis, InBothAbsAxis};
-use crate::style::{AlignItems, GridAutoFlow, OriginZeroGridPlacement};
+use crate::style::{AlignItems, GridAutoFlow, OriginZeroGridPlacement, Units};
 use crate::tree::NodeId;
 use crate::util::sys::Vec;
 use crate::{CoreStyle, Direction, GridItemStyle};
@@ -87,7 +87,7 @@ pub(super) fn place_grid_items<'a, S, ChildIter>(
     grid_auto_flow: GridAutoFlow,
     align_items: AlignItems,
     justify_items: AlignItems,
-    named_line_resolver: &NamedLineResolver<<S as CoreStyle>::CustomIdent>,
+    named_line_resolver: &NamedLineResolver<<S::Units as Units>::Str>,
 ) where
     S: GridItemStyle + 'a,
     ChildIter: Iterator<Item = (usize, NodeId, S)>,
diff --git a/src/style/block.rs b/src/style/block.rs
index 467c2f761..23b9c8dce 100644
--- a/src/style/block.rs
+++ b/src/style/block.rs
@@ -6,7 +6,7 @@ pub trait BlockContainerStyle: CoreStyle {
     /// Defines which row in the grid the item should start and end at
     #[inline(always)]
     fn text_align(&self) -> TextAlign {
-        Style::<Self::CustomIdent>::DEFAULT.text_align
+        Style::<Self::Units>::DEFAULT.text_align
     }
 }
 
diff --git a/src/style/flex.rs b/src/style/flex.rs
index e4c7654ad..a8f05ebd4 100644
--- a/src/style/flex.rs
+++ b/src/style/flex.rs
@@ -1,5 +1,7 @@
 //! Style types for Flexbox layout
-use super::{AlignContent, AlignItems, AlignSelf, CoreStyle, Dimension, JustifyContent, LengthPercentage, Style};
+use super::{
+    AlignContent, AlignItems, AlignSelf, CoreStyle, Dimension, JustifyContent, LengthPercentage, Style, Units,
+};
 use crate::geometry::Size;
 
 /// The set of styles required for a Flexbox container
@@ -7,18 +9,18 @@ pub trait FlexboxContainerStyle: CoreStyle {
     /// Which direction does the main axis flow in?
     #[inline(always)]
     fn flex_direction(&self) -> FlexDirection {
-        Style::<Self::CustomIdent>::DEFAULT.flex_direction
+        Style::<Self::Units>::DEFAULT.flex_direction
     }
     /// Should elements wrap, or stay in a single line?
     #[inline(always)]
     fn flex_wrap(&self) -> FlexWrap {
-        Style::<Self::CustomIdent>::DEFAULT.flex_wrap
+        Style::<Self::Units>::DEFAULT.flex_wrap
     }
 
     /// How large should the gaps between items in a grid or flex container be?
     #[inline(always)]
     fn gap(&self) -> Size<LengthPercentage> {
-        Style::<Self::CustomIdent>::DEFAULT.gap
+        Style::<Self::Units>::DEFAULT.gap
     }
 
     // Alignment properties
@@ -26,17 +28,17 @@ pub trait FlexboxContainerStyle: CoreStyle {
     /// How should content contained within this item be aligned in the cross/block axis
     #[inline(always)]
     fn align_content(&self) -> Option<AlignContent> {
-        Style::<Self::CustomIdent>::DEFAULT.align_content
+        Style::<Self::Units>::DEFAULT.align_content
     }
     /// How this node's children aligned in the cross/block axis?
     #[inline(always)]
     fn align_items(&self) -> Option<AlignItems> {
-        Style::<Self::CustomIdent>::DEFAULT.align_items
+        Style::<Self::Units>::DEFAULT.align_items
     }
     /// How this node's children should be aligned in the inline axis
     #[inline(always)]
     fn justify_content(&self) -> Option<JustifyContent> {
-        Style::<Self::CustomIdent>::DEFAULT.justify_content
+        Style::<Self::Units>::DEFAULT.justify_content
     }
 }
 
@@ -45,24 +47,24 @@ pub trait FlexboxItemStyle: CoreStyle {
     /// Sets the initial main axis size of the item
     #[inline(always)]
     fn flex_basis(&self) -> Dimension {
-        Style::<Self::CustomIdent>::DEFAULT.flex_basis
+        Style::<Self::Units>::DEFAULT.flex_basis
     }
     /// The relative rate at which this item grows when it is expanding to fill space
     #[inline(always)]
     fn flex_grow(&self) -> f32 {
-        Style::<Self::CustomIdent>::DEFAULT.flex_grow
+        Style::<Self::Units>::DEFAULT.flex_grow
     }
     /// The relative rate at which this item shrinks when it is contracting to fit into space
     #[inline(always)]
     fn flex_shrink(&self) -> f32 {
-        Style::<Self::CustomIdent>::DEFAULT.flex_shrink
+        Style::<Self::Units>::DEFAULT.flex_shrink
     }
 
     /// How this node should be aligned in the cross/block axis
     /// Falls back to the parents [`AlignItems`] if not set
     #[inline(always)]
     fn align_self(&self) -> Option<AlignSelf> {
-        Style::<Self::CustomIdent>::DEFAULT.align_self
+        Style::<Self::Units>::DEFAULT.align_self
     }
 }
 
diff --git a/src/style/grid.rs b/src/style/grid.rs
index 3ade9ab9b..caa858ef2 100644
--- a/src/style/grid.rs
+++ b/src/style/grid.rs
@@ -1,7 +1,7 @@
 //! Style types for CSS Grid layout
 use super::{
     AlignContent, AlignItems, AlignSelf, CheapCloneStr, CompactLength, CoreStyle, Dimension, JustifyContent,
-    LengthPercentage, LengthPercentageAuto, Style,
+    LengthPercentage, LengthPercentageAuto, Style, Units,
 };
 use crate::compute::grid::{GridCoordinate, GridLine, OriginZeroLine};
 use crate::geometry::{AbsoluteAxis, AbstractAxis, Line, MinMax, Size};
@@ -135,12 +135,12 @@ where
 /// The set of styles required for a CSS Grid container
 pub trait GridContainerStyle: CoreStyle {
     /// The type for a `repeat()` within a grid_template_rows or grid_template_columns
-    type Repetition<'a>: GenericRepetition<CustomIdent = Self::CustomIdent>
+    type Repetition<'a>: GenericRepetition<CustomIdent = <Self::Units as Units>::Str>
     where
         Self: 'a;
 
     /// The type returned by grid_template_rows and grid_template_columns
-    type TemplateTrackList<'a>: Iterator<Item = GenericGridTemplateComponent<Self::CustomIdent, Self::Repetition<'a>>>
+    type TemplateTrackList<'a>: Iterator<Item = GenericGridTemplateComponent<<Self::Units as Units>::Str, Self::Repetition<'a>>>
         + ExactSizeIterator
         + Clone
     where
@@ -153,12 +153,12 @@ pub trait GridContainerStyle: CoreStyle {
 
     /// The type returned by grid_template_row_names and grid_template_column_names
     //IntoIterator<Item = &'a Self::LineNameSet<'a>>
-    type TemplateLineNames<'a>: TemplateLineNames<'a, Self::CustomIdent>
+    type TemplateLineNames<'a>: TemplateLineNames<'a, <Self::Units as Units>::Str>
     where
         Self: 'a;
 
     /// The type of custom identifiers used to identify named grid lines and areas
-    type GridTemplateAreas<'a>: IntoIterator<Item = GridTemplateArea<Self::CustomIdent>>
+    type GridTemplateAreas<'a>: IntoIterator<Item = GridTemplateArea<<Self::Units as Units>::Str>>
     where
         Self: 'a;
 
@@ -184,13 +184,13 @@ pub trait GridContainerStyle: CoreStyle {
     /// Controls how items get placed into the grid for auto-placed items
     #[inline(always)]
     fn grid_auto_flow(&self) -> GridAutoFlow {
-        Style::<Self::CustomIdent>::DEFAULT.grid_auto_flow
+        Style::<Self::Units>::DEFAULT.grid_auto_flow
     }
 
     /// How large should the gaps between items in a grid or flex container be?
     #[inline(always)]
     fn gap(&self) -> Size<LengthPercentage> {
-        Style::<Self::CustomIdent>::DEFAULT.gap
+        Style::<Self::Units>::DEFAULT.gap
     }
 
     // Alignment properties
@@ -198,22 +198,22 @@ pub trait GridContainerStyle: CoreStyle {
     /// How should content contained within this item be aligned in the cross/block axis
     #[inline(always)]
     fn align_content(&self) -> Option<AlignContent> {
-        Style::<Self::CustomIdent>::DEFAULT.align_content
+        Style::<Self::Units>::DEFAULT.align_content
     }
     /// How should contained within this item be aligned in the main/inline axis
     #[inline(always)]
     fn justify_content(&self) -> Option<JustifyContent> {
-        Style::<Self::CustomIdent>::DEFAULT.justify_content
+        Style::<Self::Units>::DEFAULT.justify_content
     }
     /// How this node's children aligned in the cross/block axis?
     #[inline(always)]
     fn align_items(&self) -> Option<AlignItems> {
-        Style::<Self::CustomIdent>::DEFAULT.align_items
+        Style::<Self::Units>::DEFAULT.align_items
     }
     /// How this node's children should be aligned in the inline axis
     #[inline(always)]
     fn justify_items(&self) -> Option<AlignItems> {
-        Style::<Self::CustomIdent>::DEFAULT.justify_items
+        Style::<Self::Units>::DEFAULT.justify_items
     }
 
     /// Get a grid item's row or column placement depending on the axis passed
@@ -239,12 +239,12 @@ pub trait GridContainerStyle: CoreStyle {
 pub trait GridItemStyle: CoreStyle {
     /// Defines which row in the grid the item should start and end at
     #[inline(always)]
-    fn grid_row(&self) -> Line<GridPlacement<Self::CustomIdent>> {
+    fn grid_row(&self) -> Line<GridPlacement<<Self::Units as Units>::Str>> {
         Default::default()
     }
     /// Defines which column in the grid the item should start and end at
     #[inline(always)]
-    fn grid_column(&self) -> Line<GridPlacement<Self::CustomIdent>> {
+    fn grid_column(&self) -> Line<GridPlacement<<Self::Units as Units>::Str>> {
         Default::default()
     }
 
@@ -252,18 +252,18 @@ pub trait GridItemStyle: CoreStyle {
     /// Falls back to the parents [`AlignItems`] if not set
     #[inline(always)]
     fn align_self(&self) -> Option<AlignSelf> {
-        Style::<Self::CustomIdent>::DEFAULT.align_self
+        Style::<Self::Units>::DEFAULT.align_self
     }
     /// How this node should be aligned in the inline axis
     /// Falls back to the parents [`super::JustifyItems`] if not set
     #[inline(always)]
     fn justify_self(&self) -> Option<AlignSelf> {
-        Style::<Self::CustomIdent>::DEFAULT.justify_self
+        Style::<Self::Units>::DEFAULT.justify_self
     }
 
     /// Get a grid item's row or column placement depending on the axis passed
     #[inline(always)]
-    fn grid_placement(&self, axis: AbsoluteAxis) -> Line<GridPlacement<Self::CustomIdent>> {
+    fn grid_placement(&self, axis: AbsoluteAxis) -> Line<GridPlacement<<Self::Units as Units>::Str>> {
         match axis {
             AbsoluteAxis::Horizontal => self.grid_column(),
             AbsoluteAxis::Vertical => self.grid_row(),
diff --git a/src/style/mod.rs b/src/style/mod.rs
index e32018624..840a6123b 100644
--- a/src/style/mod.rs
+++ b/src/style/mod.rs
@@ -64,6 +64,25 @@ impl<T> CheapCloneStr for T where
 {
 }
 
+/// Allows Taffy to abstract of the types it uses to represent strings and calc expressions.
+/// In future it may be extended to abstract the scalar number type (currently f32)
+pub trait Units {
+    /// Trait that represents a cheaply clonable string. If you're unsure what to use here
+    /// consider `Arc<str>` or `string_cache::Atom`.
+    type Str: CheapCloneStr;
+
+    /// Type representing a calc expression.
+    /// If you're not using Calc then you can just use `()`
+    type Calc: 'static;
+}
+
+pub struct DefaultUnits;
+
+impl Units for DefaultUnits {
+    type Str = String;
+    type Calc = ();
+}
+
 /// Trait that represents a cheaply clonable string. If you're unsure what to use here
 /// consider `Arc<str>` or `string_cache::Atom`.
 #[cfg(not(any(feature = "alloc", feature = "std")))]
@@ -78,7 +97,7 @@ impl<T> CheapCloneStr for T {}
 /// to override the default implementation for each style property that your style type actually supports.
 pub trait CoreStyle {
     /// The type of custom identifiers used to identify named grid lines and areas
-    type CustomIdent: CheapCloneStr;
+    type Units: Units;
 
     /// Which box generation mode should be used
     #[inline(always)]
@@ -112,7 +131,7 @@ pub trait CoreStyle {
     /// How children overflowing their container should affect layout
     #[inline(always)]
     fn overflow(&self) -> Point<Overflow> {
-        Style::<Self::CustomIdent>::DEFAULT.overflow
+        Style::<Self::Units>::DEFAULT.overflow
     }
     /// How much space (in points) should be reserved for the scrollbars of `Overflow::Scroll` and `Overflow::Auto` nodes.
     #[inline(always)]
@@ -124,52 +143,52 @@ pub trait CoreStyle {
     /// What should the `position` value of this struct use as a base offset?
     #[inline(always)]
     fn position(&self) -> Position {
-        Style::<Self::CustomIdent>::DEFAULT.position
+        Style::<Self::Units>::DEFAULT.position
     }
     /// How should the position of this element be tweaked relative to the layout defined?
     #[inline(always)]
     fn inset(&self) -> Rect<LengthPercentageAuto> {
-        Style::<Self::CustomIdent>::DEFAULT.inset
+        Style::<Self::Units>::DEFAULT.inset
     }
 
     // Size properies
     /// Sets the initial size of the item
     #[inline(always)]
     fn size(&self) -> Size<Dimension> {
-        Style::<Self::CustomIdent>::DEFAULT.size
+        Style::<Self::Units>::DEFAULT.size
     }
     /// Controls the minimum size of the item
     #[inline(always)]
     fn min_size(&self) -> Size<Dimension> {
-        Style::<Self::CustomIdent>::DEFAULT.min_size
+        Style::<Self::Units>::DEFAULT.min_size
     }
     /// Controls the maximum size of the item
     #[inline(always)]
     fn max_size(&self) -> Size<Dimension> {
-        Style::<Self::CustomIdent>::DEFAULT.max_size
+        Style::<Self::Units>::DEFAULT.max_size
     }
     /// Sets the preferred aspect ratio for the item
     /// The ratio is calculated as width divided by height.
     #[inline(always)]
     fn aspect_ratio(&self) -> Option<f32> {
-        Style::<Self::CustomIdent>::DEFAULT.aspect_ratio
+        Style::<Self::Units>::DEFAULT.aspect_ratio
     }
 
     // Spacing Properties
     /// How large should the margin be on each side?
     #[inline(always)]
     fn margin(&self) -> Rect<LengthPercentageAuto> {
-        Style::<Self::CustomIdent>::DEFAULT.margin
+        Style::<Self::Units>::DEFAULT.margin
     }
     /// How large should the padding be on each side?
     #[inline(always)]
     fn padding(&self) -> Rect<LengthPercentage> {
-        Style::<Self::CustomIdent>::DEFAULT.padding
+        Style::<Self::Units>::DEFAULT.padding
     }
     /// How large should the border be on each side?
     #[inline(always)]
     fn border(&self) -> Rect<LengthPercentage> {
-        Style::<Self::CustomIdent>::DEFAULT.border
+        Style::<Self::Units>::DEFAULT.border
     }
 }
 
@@ -427,10 +446,10 @@ crate::util::parse::impl_parse_for_keyword_enum!(Direction,
 #[derive(Clone, PartialEq, Debug)]
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[cfg_attr(feature = "serde", serde(default))]
-pub struct Style<S: CheapCloneStr = DefaultCheapStr> {
+pub struct Style<U: Units = DefaultCheapStr> {
     /// This is a dummy field which is necessary to make Taffy compile with the `grid` feature disabled
     /// It should always be set to `core::marker::PhantomData`.
-    pub dummy: core::marker::PhantomData<S>,
+    pub dummy: core::marker::PhantomData<U>,
     /// What layout strategy should be used?
     pub display: Display,
     /// Whether a child is display:table or not. This affects children of block layouts.
@@ -547,10 +566,10 @@ pub struct Style<S: CheapCloneStr = DefaultCheapStr> {
     // Grid container properies
     /// Defines the track sizing functions (heights) of the grid rows
     #[cfg(feature = "grid")]
-    pub grid_template_rows: GridTrackVec<GridTemplateComponent<S>>,
+    pub grid_template_rows: GridTrackVec<GridTemplateComponent<U::Str>>,
     /// Defines the track sizing functions (widths) of the grid columns
     #[cfg(feature = "grid")]
-    pub grid_template_columns: GridTrackVec<GridTemplateComponent<S>>,
+    pub grid_template_columns: GridTrackVec<GridTemplateComponent<U::Str>>,
     /// Defines the size of implicitly created rows
     #[cfg(feature = "grid")]
     pub grid_auto_rows: GridTrackVec<TrackSizingFunction>,
@@ -564,26 +583,26 @@ pub struct Style<S: CheapCloneStr = DefaultCheapStr> {
     // Grid container named properties
     /// Defines the rectangular grid areas
     #[cfg(feature = "grid")]
-    pub grid_template_areas: GridTrackVec<GridTemplateArea<S>>,
+    pub grid_template_areas: GridTrackVec<GridTemplateArea<U::Str>>,
     /// The named lines between the columns
     #[cfg(feature = "grid")]
-    pub grid_template_column_names: GridTrackVec<GridTrackVec<S>>,
+    pub grid_template_column_names: GridTrackVec<GridTrackVec<U>>,
     /// The named lines between the rows
     #[cfg(feature = "grid")]
-    pub grid_template_row_names: GridTrackVec<GridTrackVec<S>>,
+    pub grid_template_row_names: GridTrackVec<GridTrackVec<U>>,
 
     // Grid child properties
     /// Defines which row in the grid the item should start and end at
     #[cfg(feature = "grid")]
-    pub grid_row: Line<GridPlacement<S>>,
+    pub grid_row: Line<GridPlacement<U::Str>>,
     /// Defines which column in the grid the item should start and end at
     #[cfg(feature = "grid")]
-    pub grid_column: Line<GridPlacement<S>>,
+    pub grid_column: Line<GridPlacement<U::Str>>,
 }
 
-impl<S: CheapCloneStr> Style<S> {
+impl<U: Units> Style<U> {
     /// The [`Default`] layout, in a form that can be used in const functions
-    pub const DEFAULT: Style<S> = Style {
+    pub const DEFAULT: Style<U> = Style {
         dummy: core::marker::PhantomData,
         display: Display::DEFAULT,
         item_is_table: false,
@@ -652,20 +671,20 @@ impl<S: CheapCloneStr> Style<S> {
         #[cfg(feature = "grid")]
         grid_auto_flow: GridAutoFlow::Row,
         #[cfg(feature = "grid")]
-        grid_row: Line { start: GridPlacement::<S>::Auto, end: GridPlacement::<S>::Auto },
+        grid_row: Line { start: GridPlacement::<U>::Auto, end: GridPlacement::<U>::Auto },
         #[cfg(feature = "grid")]
-        grid_column: Line { start: GridPlacement::<S>::Auto, end: GridPlacement::<S>::Auto },
+        grid_column: Line { start: GridPlacement::<U>::Auto, end: GridPlacement::<U>::Auto },
     };
 }
 
-impl<S: CheapCloneStr> Default for Style<S> {
+impl<U: Units> Default for Style<U> {
     fn default() -> Self {
         Style::DEFAULT
     }
 }
 
-impl<S: CheapCloneStr> CoreStyle for Style<S> {
-    type CustomIdent = S;
+impl<U: Units> CoreStyle for Style<U> {
+    type Units = U;
 
     #[inline(always)]
     fn box_generation_mode(&self) -> BoxGenerationMode {
@@ -738,7 +757,7 @@ impl<S: CheapCloneStr> CoreStyle for Style<S> {
 }
 
 impl<T: CoreStyle> CoreStyle for &'_ T {
-    type CustomIdent = T::CustomIdent;
+    type Units = T::Units;
 
     #[inline(always)]
     fn box_generation_mode(&self) -> BoxGenerationMode {
@@ -807,7 +826,7 @@ impl<T: CoreStyle> CoreStyle for &'_ T {
 }
 
 #[cfg(feature = "block_layout")]
-impl<S: CheapCloneStr> BlockContainerStyle for Style<S> {
+impl<U: Units> BlockContainerStyle for Style<U> {
     #[inline(always)]
     fn text_align(&self) -> TextAlign {
         self.text_align
@@ -823,7 +842,7 @@ impl<T: BlockContainerStyle> BlockContainerStyle for &'_ T {
 }
 
 #[cfg(feature = "block_layout")]
-impl<S: CheapCloneStr> BlockItemStyle for Style<S> {
+impl<U: Units> BlockItemStyle for Style<U> {
     #[inline(always)]
     fn is_table(&self) -> bool {
         self.item_is_table
@@ -863,7 +882,7 @@ impl<T: BlockItemStyle> BlockItemStyle for &'_ T {
 }
 
 #[cfg(feature = "flexbox")]
-impl<S: CheapCloneStr> FlexboxContainerStyle for Style<S> {
+impl<U: Units> FlexboxContainerStyle for Style<U> {
     #[inline(always)]
     fn flex_direction(&self) -> FlexDirection {
         self.flex_direction
@@ -919,7 +938,7 @@ impl<T: FlexboxContainerStyle> FlexboxContainerStyle for &'_ T {
 }
 
 #[cfg(feature = "flexbox")]
-impl<S: CheapCloneStr> FlexboxItemStyle for Style<S> {
+impl<U: Units> FlexboxItemStyle for Style<U> {
     #[inline(always)]
     fn flex_basis(&self) -> Dimension {
         self.flex_basis
@@ -959,16 +978,18 @@ impl<T: FlexboxItemStyle> FlexboxItemStyle for &'_ T {
 }
 
 #[cfg(feature = "grid")]
-impl<S: CheapCloneStr> GridContainerStyle for Style<S> {
+impl<U: Units> GridContainerStyle for Style<U> {
     type Repetition<'a>
-        = &'a GridTemplateRepetition<S>
+        = &'a GridTemplateRepetition<U::Str>
     where
         Self: 'a;
 
     type TemplateTrackList<'a>
         = core::iter::Map<
-        core::slice::Iter<'a, GridTemplateComponent<S>>,
-        fn(&'a GridTemplateComponent<S>) -> GenericGridTemplateComponent<S, &'a GridTemplateRepetition<S>>,
+        core::slice::Iter<'a, GridTemplateComponent<U::Str>>,
+        fn(
+            &'a GridTemplateComponent<U::Str>,
+        ) -> GenericGridTemplateComponent<U::Str, &'a GridTemplateRepetition<U::Str>>,
     >
     where
         Self: 'a;
@@ -980,12 +1001,15 @@ impl<S: CheapCloneStr> GridContainerStyle for Style<S> {
 
     #[cfg(feature = "grid")]
     type TemplateLineNames<'a>
-        = core::iter::Map<core::slice::Iter<'a, GridTrackVec<S>>, fn(&GridTrackVec<S>) -> core::slice::Iter<'_, S>>
+        = core::iter::Map<
+        core::slice::Iter<'a, GridTrackVec<U::Str>>,
+        fn(&GridTrackVec<U::Str>) -> core::slice::Iter<'_, U::Str>,
+    >
     where
         Self: 'a;
     #[cfg(feature = "grid")]
     type GridTemplateAreas<'a>
-        = core::iter::Cloned<core::slice::Iter<'a, GridTemplateArea<S>>>
+        = core::iter::Cloned<core::slice::Iter<'a, GridTemplateArea<U::Str>>>
     where
         Self: 'a;
 
@@ -1136,14 +1160,14 @@ impl<T: GridContainerStyle> GridContainerStyle for &'_ T {
 }
 
 #[cfg(feature = "grid")]
-impl<S: CheapCloneStr> GridItemStyle for Style<S> {
+impl<U: Units> GridItemStyle for Style<U> {
     #[inline(always)]
-    fn grid_row(&self) -> Line<GridPlacement<S>> {
+    fn grid_row(&self) -> Line<GridPlacement<U::Str>> {
         // TODO: Investigate eliminating clone
         self.grid_row.clone()
     }
     #[inline(always)]
-    fn grid_column(&self) -> Line<GridPlacement<S>> {
+    fn grid_column(&self) -> Line<GridPlacement<U::Str>> {
         // TODO: Investigate eliminating clone
         self.grid_column.clone()
     }
@@ -1160,11 +1184,11 @@ impl<S: CheapCloneStr> GridItemStyle for Style<S> {
 #[cfg(feature = "grid")]
 impl<T: GridItemStyle> GridItemStyle for &'_ T {
     #[inline(always)]
-    fn grid_row(&self) -> Line<GridPlacement<Self::CustomIdent>> {
+    fn grid_row(&self) -> Line<GridPlacement<<T::Units as Units>::Str>> {
         (*self).grid_row()
     }
     #[inline(always)]
-    fn grid_column(&self) -> Line<GridPlacement<Self::CustomIdent>> {
+    fn grid_column(&self) -> Line<GridPlacement<<T::Units as Units>::Str>> {
         (*self).grid_column()
     }
     #[inline(always)]
@@ -1321,7 +1345,7 @@ mod tests {
         assert_type_size::<MaxTrackSizingFunction>(8);
         assert_type_size::<TrackSizingFunction>(16);
         assert_type_size::<Vec<TrackSizingFunction>>(24);
-        assert_type_size::<Vec<GridTemplateComponent<S>>>(24);
+        assert_type_size::<Vec<GridTemplateComponent<U>>>(24);
 
         // String-type dependent (String)
         assert_type_size::<GridTemplateComponent<String>>(56);