Enum layout_2020::geom::Size
source · pub(crate) enum Size<T> {
Initial,
MinContent,
MaxContent,
FitContent,
Stretch,
Numeric(T),
}
Expand description
The possible values accepted by the sizing properties. https://drafts.csswg.org/css-sizing/#sizing-properties
Variants§
Initial
Represents an auto
value for the preferred and minimum size properties,
or none
for the maximum size properties.
https://drafts.csswg.org/css-sizing/#valdef-width-auto
https://drafts.csswg.org/css-sizing/#valdef-max-width-none
MinContent
MaxContent
FitContent
Stretch
Numeric(T)
Represents a numeric <length-percentage>
, but resolved as a T
.
https://drafts.csswg.org/css-sizing/#valdef-width-length-percentage-0
Implementations§
source§impl<T> Size<T>
impl<T> Size<T>
pub(crate) fn is_numeric(&self) -> bool
pub(crate) fn is_initial(&self) -> bool
source§impl Size<Au>
impl Size<Au>
sourcepub(crate) fn resolve<F: FnOnce() -> ContentSizes>(
&self,
initial_behavior: Self,
stretch_size: Au,
content_size: &LazyCell<ContentSizes, F>,
) -> Au
pub(crate) fn resolve<F: FnOnce() -> ContentSizes>( &self, initial_behavior: Self, stretch_size: Au, content_size: &LazyCell<ContentSizes, F>, ) -> Au
Resolves any size into a numerical value.
sourcepub(crate) fn resolve_non_initial<F: FnOnce() -> ContentSizes>(
&self,
stretch_size: Au,
content_size: &LazyCell<ContentSizes, F>,
) -> Option<Au>
pub(crate) fn resolve_non_initial<F: FnOnce() -> ContentSizes>( &self, stretch_size: Au, content_size: &LazyCell<ContentSizes, F>, ) -> Option<Au>
Resolves a non-initial size into a numerical value.
Returns None
if the size is the initial one.
sourcepub(crate) fn maybe_resolve_extrinsic(
&self,
stretch_size: Option<Au>,
) -> Option<Au>
pub(crate) fn maybe_resolve_extrinsic( &self, stretch_size: Option<Au>, ) -> Option<Au>
Tries to resolve an extrinsic size into a numerical value. Extrinsic sizes are those based on the context of an element, without regard for its contents. https://drafts.csswg.org/css-sizing-3/#extrinsic
Returns None
if either:
- The size is intrinsic.
- The size is the initial one.
TODO: should we allow it to behave as
stretch
instead of assuming it’s intrinsic? - The provided
stretch_size
isNone
but we need its value.
Trait Implementations§
source§impl From<GenericMaxSize<NonNegative<LengthPercentage>>> for Size<LengthPercentage>
impl From<GenericMaxSize<NonNegative<LengthPercentage>>> for Size<LengthPercentage>
source§fn from(max_size: StyleMaxSize) -> Self
fn from(max_size: StyleMaxSize) -> Self
source§impl From<GenericSize<NonNegative<LengthPercentage>>> for Size<LengthPercentage>
impl From<GenericSize<NonNegative<LengthPercentage>>> for Size<LengthPercentage>
impl<T: Copy> Copy for Size<T>
impl<T> StructuralPartialEq for Size<T>
Auto Trait Implementations§
impl<T> Freeze for Size<T>where
T: Freeze,
impl<T> RefUnwindSafe for Size<T>where
T: RefUnwindSafe,
impl<T> Send for Size<T>where
T: Send,
impl<T> Sync for Size<T>where
T: Sync,
impl<T> Unpin for Size<T>where
T: Unpin,
impl<T> UnwindSafe for Size<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moresource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.