pub enum LengthPercentage {
Length(NoCalcLength),
Percentage(Percentage),
Calc(Box<CalcLengthPercentage>),
}
Expand description
A <length-percentage>
value. This can be either a <length>
, a
<percentage>
, or a combination of both via calc()
.
https://drafts.csswg.org/css-values-4/#typedef-length-percentage
Variants§
Implementations§
source§impl LengthPercentage
impl LengthPercentage
sourcepub fn zero_percent() -> LengthPercentage
pub fn zero_percent() -> LengthPercentage
Returns a 0%
value.
sourcepub fn hundred_percent() -> LengthPercentage
pub fn hundred_percent() -> LengthPercentage
Returns a 100%
value.
fn parse_internal<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, num_context: AllowedNumericType, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>>
sourcepub fn parse_quirky<'i, 't>(
context: &ParserContext<'_>,
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>>
pub fn parse_quirky<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>>
Parses allowing the unitless length quirk. https://quirks.spec.whatwg.org/#the-unitless-length-quirk
sourcepub fn parse_non_negative<'i, 't>(
context: &ParserContext<'_>,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>>
pub fn parse_non_negative<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>>
Parse a non-negative length.
FIXME(emilio): This should be not public and we should use NonNegativeLengthPercentage instead.
sourcepub fn parse_non_negative_quirky<'i, 't>(
context: &ParserContext<'_>,
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>>
pub fn parse_non_negative_quirky<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>>
Parse a non-negative length, with quirks.
sourcefn to_calc_node(self) -> CalcNode
fn to_calc_node(self) -> CalcNode
Returns self as specified::calc::CalcNode. Note that this expect the clamping_mode is AllowedNumericType::All for Calc. The caller should take care about it when using this function.
sourcepub fn hundred_percent_minus(self, clamping_mode: AllowedNumericType) -> Self
pub fn hundred_percent_minus(self, clamping_mode: AllowedNumericType) -> Self
Construct the value representing calc(100% - self)
.
Trait Implementations§
source§impl Clone for LengthPercentage
impl Clone for LengthPercentage
source§fn clone(&self) -> LengthPercentage
fn clone(&self) -> LengthPercentage
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for LengthPercentage
impl Debug for LengthPercentage
source§impl From<Length> for LengthPercentage
impl From<Length> for LengthPercentage
source§fn from(len: Length) -> LengthPercentage
fn from(len: Length) -> LengthPercentage
Converts to this type from the input type.
source§impl From<NoCalcLength> for LengthPercentage
impl From<NoCalcLength> for LengthPercentage
source§fn from(len: NoCalcLength) -> Self
fn from(len: NoCalcLength) -> Self
Converts to this type from the input type.
source§impl From<Percentage> for LengthPercentage
impl From<Percentage> for LengthPercentage
source§fn from(pc: Percentage) -> Self
fn from(pc: Percentage) -> Self
Converts to this type from the input type.
source§impl From<Percentage> for LengthPercentage
impl From<Percentage> for LengthPercentage
source§fn from(pc: Percentage) -> Self
fn from(pc: Percentage) -> Self
Converts to this type from the input type.
source§impl MallocSizeOf for LengthPercentage
impl MallocSizeOf for LengthPercentage
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
source§impl Parse for LengthPercentage
impl Parse for LengthPercentage
source§fn parse<'i, 't>(
context: &ParserContext<'_>,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>>
fn parse<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>>
Parse a value of this type. Read more
source§impl PartialEq for LengthPercentage
impl PartialEq for LengthPercentage
source§fn eq(&self, other: &LengthPercentage) -> bool
fn eq(&self, other: &LengthPercentage) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl SpecifiedValueInfo for LengthPercentage
impl SpecifiedValueInfo for LengthPercentage
source§const SUPPORTED_TYPES: u8 = 0u8
const SUPPORTED_TYPES: u8 = 0u8
Supported CssTypes by the given value type. Read more
source§impl ToAbsoluteLength for LengthPercentage
impl ToAbsoluteLength for LengthPercentage
source§fn to_pixel_length(
&self,
_containing_len: Option<ComputedLength>,
) -> Result<CSSFloat, ()>
fn to_pixel_length( &self, _containing_len: Option<ComputedLength>, ) -> Result<CSSFloat, ()>
Returns the absolute length as pixel value.
source§impl ToComputedValue for LengthPercentage
impl ToComputedValue for LengthPercentage
§type ComputedValue = LengthPercentage
type ComputedValue = LengthPercentage
The computed value type we’re going to be converted to.
source§fn to_computed_value(&self, context: &Context<'_>) -> LengthPercentage
fn to_computed_value(&self, context: &Context<'_>) -> LengthPercentage
Convert a specified value to a computed value, using itself and the data
inside the
Context
.source§fn from_computed_value(computed: &LengthPercentage) -> Self
fn from_computed_value(computed: &LengthPercentage) -> Self
Convert a computed value to specified value form. Read more
source§impl ToCss for LengthPercentage
impl ToCss for LengthPercentage
source§impl ToShmem for LengthPercentage
impl ToShmem for LengthPercentage
source§impl Zero for LengthPercentage
impl Zero for LengthPercentage
source§impl ZeroNoPercent for LengthPercentage
impl ZeroNoPercent for LengthPercentage
source§fn is_zero_no_percent(&self) -> bool
fn is_zero_no_percent(&self) -> bool
So,
0px
should return true
, but 0%
or 1px
should return false
impl StructuralPartialEq for LengthPercentage
Auto Trait Implementations§
impl Freeze for LengthPercentage
impl RefUnwindSafe for LengthPercentage
impl Send for LengthPercentage
impl Sync for LengthPercentage
impl Unpin for LengthPercentage
impl UnwindSafe for LengthPercentage
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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>
Convert
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert