#[repr(transparent)]pub struct CompactLength(CompactLengthInner);
Expand description
A representation of a length as a compact 64-bit tagged pointer
Tuple Fields§
§0: CompactLengthInner
Implementations§
Source§impl CompactLength
impl CompactLength
Sourcepub const LENGTH_TAG: usize = 1usize
pub const LENGTH_TAG: usize = 1usize
The tag indicating a length value
Sourcepub const PERCENT_TAG: usize = 2usize
pub const PERCENT_TAG: usize = 2usize
The tag indicating a percentage value
Sourcepub const MIN_CONTENT_TAG: usize = 7usize
pub const MIN_CONTENT_TAG: usize = 7usize
The tag indicating a min-content value
Sourcepub const MAX_CONTENT_TAG: usize = 15usize
pub const MAX_CONTENT_TAG: usize = 15usize
The tag indicating a max-content value
Sourcepub const FIT_CONTENT_PX_TAG: usize = 23usize
pub const FIT_CONTENT_PX_TAG: usize = 23usize
The tag indicating a fit-content value with px limit
Sourcepub const FIT_CONTENT_PERCENT_TAG: usize = 31usize
pub const FIT_CONTENT_PERCENT_TAG: usize = 31usize
The tag indicating a fit-content value with percent limit
Source§impl CompactLength
impl CompactLength
Sourcepub const fn length(val: f32) -> Self
pub const fn length(val: f32) -> Self
An absolute length in some abstract units. Users of Taffy may define what they correspond to in their application (pixels, logical pixels, mm, etc) as they see fit.
Sourcepub const fn percent(val: f32) -> Self
pub const fn percent(val: f32) -> Self
A percentage length relative to the size of the containing block.
NOTE: percentages are represented as a f32 value in the range [0.0, 1.0] NOT the range [0.0, 100.0]
Sourcepub fn calc(ptr: *const ()) -> Self
pub fn calc(ptr: *const ()) -> Self
A calc()
value. The value passed here is treated as an opaque handle to
the actual calc representation and may be a pointer, index, etc.
The low 3 bits are used as a tag value and will be returned as 0.
Sourcepub const fn auto() -> Self
pub const fn auto() -> Self
The dimension should be automatically computed according to algorithm-specific rules regarding the default size of boxes.
Sourcepub const fn fr(val: f32) -> Self
pub const fn fr(val: f32) -> Self
The dimension as a fraction of the total available grid space (fr
units in CSS)
Specified value is the numerator of the fraction. Denominator is the sum of all fraction specified in that grid dimension
Spec: https://www.w3.org/TR/css3-grid-layout/#fr-unit
Sourcepub const fn min_content() -> Self
pub const fn min_content() -> Self
The size should be the “min-content” size. This is the smallest size that can fit the item’s contents with ALL soft line-wrapping opportunities taken
Sourcepub const fn max_content() -> Self
pub const fn max_content() -> Self
The size should be the “max-content” size. This is the smallest size that can fit the item’s contents with NO soft line-wrapping opportunities taken
Sourcepub const fn fit_content_px(limit: f32) -> Self
pub const fn fit_content_px(limit: f32) -> Self
The size should be computed according to the “fit content” formula:
max(min_content, min(max_content, limit))
where:
min_content
is the min-content sizemax_content
is the max-content sizelimit
is a LENGTH value passed to this function
The effect of this is that the item takes the size of limit
clamped
by the min-content and max-content sizes.
Sourcepub const fn fit_content_percent(limit: f32) -> Self
pub const fn fit_content_percent(limit: f32) -> Self
The size should be computed according to the “fit content” formula:
max(min_content, min(max_content, limit))
where:
min_content
is the min-content sizemax_content
is the max-content sizelimit
is a PERCENTAGE value passed to this function
The effect of this is that the item takes the size of limit
clamped
by the min-content and max-content sizes.
Sourcepub fn value(self) -> f32
pub fn value(self) -> f32
Get the numeric value associated with the CompactLength
(e.g. the pixel value for a LENGTH variant)
Sourcepub fn calc_value(self) -> *const ()
pub fn calc_value(self) -> *const ()
Get the calc pointer of the CompactLength
Sourcepub fn is_length_or_percentage(self) -> bool
pub fn is_length_or_percentage(self) -> bool
Returns true if the value is a length or percentage value
Sourcepub fn is_min_content(self) -> bool
pub fn is_min_content(self) -> bool
Returns true if the value is min-content
Sourcepub fn is_max_content(self) -> bool
pub fn is_max_content(self) -> bool
Returns true if the value is max-content
Sourcepub fn is_fit_content(self) -> bool
pub fn is_fit_content(self) -> bool
Returns true if the value is a fit-content(…) value
Sourcepub fn is_max_or_fit_content(self) -> bool
pub fn is_max_or_fit_content(self) -> bool
Returns true if the value is max-content or a fit-content(…) value
Sourcepub fn is_max_content_alike(&self) -> bool
pub fn is_max_content_alike(&self) -> bool
Returns true if the max track sizing function is MaxContent
, FitContent
or Auto
else false.
“In all cases, treat auto and fit-content() as max-content, except where specified otherwise for fit-content().”
See: https://www.w3.org/TR/css-grid-1/#algo-terms
Sourcepub fn is_min_or_max_content(&self) -> bool
pub fn is_min_or_max_content(&self) -> bool
Returns true if the min track sizing function is MinContent
or MaxContent
, else false.
Sourcepub fn is_intrinsic(self) -> bool
pub fn is_intrinsic(self) -> bool
Returns true if the value is auto, min-content, max-content, or fit-content(…)
Sourcepub fn uses_percentage(self) -> bool
pub fn uses_percentage(self) -> bool
Whether the track sizing functions depends on the size of the parent node
Trait Implementations§
Source§impl Clone for CompactLength
impl Clone for CompactLength
Source§fn clone(&self) -> CompactLength
fn clone(&self) -> CompactLength
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more