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, allow_anchor: AllowAnchorPositioningFunctions, ) -> 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_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.
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
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
source§impl From<NoCalcLength> for LengthPercentage
impl From<NoCalcLength> for LengthPercentage
source§fn from(len: NoCalcLength) -> Self
fn from(len: NoCalcLength) -> Self
source§impl From<Percentage> for LengthPercentage
impl From<Percentage> for LengthPercentage
source§fn from(pc: Percentage) -> Self
fn from(pc: Percentage) -> Self
source§impl From<Percentage> for LengthPercentage
impl From<Percentage> for LengthPercentage
source§fn from(pc: Percentage) -> Self
fn from(pc: Percentage) -> Self
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
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>>
source§impl PartialEq for LengthPercentage
impl PartialEq for LengthPercentage
source§impl SpecifiedValueInfo for LengthPercentage
impl SpecifiedValueInfo for LengthPercentage
source§const SUPPORTED_TYPES: u8 = 0u8
const SUPPORTED_TYPES: u8 = 0u8
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, ()>
source§impl ToComputedValue for LengthPercentage
impl ToComputedValue for LengthPercentage
source§type ComputedValue = LengthPercentage
type ComputedValue = LengthPercentage
source§fn to_computed_value(&self, context: &Context<'_>) -> LengthPercentage
fn to_computed_value(&self, context: &Context<'_>) -> LengthPercentage
Context
.source§fn from_computed_value(computed: &LengthPercentage) -> Self
fn from_computed_value(computed: &LengthPercentage) -> Self
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
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
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> 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 more