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.
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_quirky_with_anchor_functions<'i, 't>(
context: &ParserContext<'_>,
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>>
pub fn parse_quirky_with_anchor_functions<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>>
Parses allowing the unitless length quirk, as well as allowing
anchor-positioning related functions, anchor() and anchor-size().
Sourcepub fn parse_non_negative_with_anchor_size<'i, 't>(
context: &ParserContext<'_>,
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>>
pub fn parse_non_negative_with_anchor_size<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, allow_quirks: AllowQuirks, ) -> Result<Self, ParseError<'i>>
Parses non-negative length, allowing the unitless length quirk,
as well as allowing anchor-size().
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.
Trait Implementations§
Source§impl Clone for LengthPercentage
impl Clone for LengthPercentage
Source§fn clone(&self) -> LengthPercentage
fn clone(&self) -> LengthPercentage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 EqualsPercentage for LengthPercentage
impl EqualsPercentage for LengthPercentage
Source§fn equals_percentage(&self, v: CSSFloat) -> bool
fn equals_percentage(&self, v: CSSFloat) -> bool
Returns true if this is a specific percentage value. This should exclude calc() even if it
only contains percentage component.
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
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
const SUPPORTED_TYPES: u8
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
Source§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§fn to_css<W>(&self, dest: &mut CssWriter<'_, W>) -> Resultwhere
W: Write,
fn to_css<W>(&self, dest: &mut CssWriter<'_, W>) -> Resultwhere
W: Write,
Serialize
self in CSS syntax, writing to dest.Source§fn to_css_string(&self) -> String
fn to_css_string(&self) -> String
Serialize
self in CSS syntax and return a string. Read moreSource§fn to_css_cssstring(&self) -> String
fn to_css_cssstring(&self) -> String
Serialize
self in CSS syntax and return a CssString. Read moreSource§impl ToShmem for LengthPercentage
impl ToShmem for LengthPercentage
Source§impl ToTyped for LengthPercentage
impl ToTyped for LengthPercentage
Source§fn to_typed_value(&self) -> Option<TypedValue>
fn to_typed_value(&self) -> Option<TypedValue>
Source§fn to_typed_value_list(&self) -> Option<TypedValueList>
fn to_typed_value_list(&self) -> Option<TypedValueList>
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 falseimpl 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 UnsafeUnpin 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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