#[repr(C)]pub struct NoCalcLength {
unit: LengthUnit,
value: CSSFloat,
}Expand description
A <length> without taking calc expressions into account
Fields§
§unit: LengthUnit§value: CSSFloatImplementations§
Source§impl NoCalcLength
impl NoCalcLength
Sourcepub fn new(unit: LengthUnit, value: CSSFloat) -> Self
pub fn new(unit: LengthUnit, value: CSSFloat) -> Self
Creates a length with the given unit and value.
Sourcepub fn length_unit(&self) -> LengthUnit
pub fn length_unit(&self) -> LengthUnit
Returns the unit of this length.
Sourcepub fn unitless_value(&self) -> CSSFloat
pub fn unitless_value(&self) -> CSSFloat
Return the unitless, raw value.
Sourcepub fn canonical_unit(&self) -> Option<&'static str>
pub fn canonical_unit(&self) -> Option<&'static str>
Return the canonical unit for this value, if one exists.
Sourcepub fn to(&self, unit: &str) -> Result<Self, ()>
pub fn to(&self, unit: &str) -> Result<Self, ()>
Convert this value to the specified unit, if possible.
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns whether the value of this length without unit is less than zero.
Sourcepub fn is_zero(&self) -> bool
pub fn is_zero(&self) -> bool
Returns whether the value of this length without unit is equal to zero.
Sourcepub fn is_infinite(&self) -> bool
pub fn is_infinite(&self) -> bool
Returns whether the value of this length without unit is infinite.
Sourcepub fn should_zoom_text(&self) -> bool
pub fn should_zoom_text(&self) -> bool
Whether text-only zoom should be applied to this length.
Generally, font-dependent/relative units don’t get text-only-zoomed, because the font they’re relative to should be zoomed already.
Sourcepub(crate) fn sort_key(&self) -> SortKey
pub(crate) fn sort_key(&self) -> SortKey
Returns the SortKey for this length. Must not be called on the internal
ServoCharacterWidth unit.
Sourcepub fn parse_dimension_with_flags(
parsing_mode: ParsingMode,
in_page_rule: bool,
value: CSSFloat,
unit: &str,
) -> Result<Self, ()>
pub fn parse_dimension_with_flags( parsing_mode: ParsingMode, in_page_rule: bool, value: CSSFloat, unit: &str, ) -> Result<Self, ()>
Parse a given absolute or relative dimension.
Sourcepub fn parse_dimension_with_context(
context: &ParserContext<'_>,
value: CSSFloat,
unit: &str,
) -> Result<Self, ()>
pub fn parse_dimension_with_context( context: &ParserContext<'_>, value: CSSFloat, unit: &str, ) -> Result<Self, ()>
Parse a given absolute or relative dimension.
pub(crate) fn try_op<O>(&self, other: &Self, op: O) -> Result<Self, ()>
pub(crate) fn map(&self, op: impl FnMut(f32) -> f32) -> Self
Sourcepub fn to_computed_pixel_length_without_context(&self) -> Result<CSSFloat, ()>
pub fn to_computed_pixel_length_without_context(&self) -> Result<CSSFloat, ()>
Get a px value without context (so only absolute units can be handled).
Sourcepub fn from_px(px_value: CSSFloat) -> NoCalcLength
pub fn from_px(px_value: CSSFloat) -> NoCalcLength
Get an absolute length from a px value.
Sourcepub fn to_px_if_absolute(&self) -> Option<CSSFloat>
pub fn to_px_if_absolute(&self) -> Option<CSSFloat>
Returns the value as a px-canonical length (absolute lengths only).
Sourcepub fn from_servo_character_width(value: i32) -> Self
pub fn from_servo_character_width(value: i32) -> Self
Construct an internal ServoCharacterWidth length from an i32 column count.
Sourcefn font_relative_to_computed_value(
&self,
context: &Context<'_>,
base_size: FontBaseSize,
line_height_base: LineHeightBase,
) -> Length
fn font_relative_to_computed_value( &self, context: &Context<'_>, base_size: FontBaseSize, line_height_base: LineHeightBase, ) -> Length
Compute a font-relative length against the given base sizes. Must only be called on a font-relative unit.
fn reference_font_size_and_length( &self, context: &Context<'_>, base_size: FontBaseSize, line_height_base: LineHeightBase, ) -> (Length, CSSFloat)
Sourcefn viewport_percentage_to_computed_value(
&self,
context: &Context<'_>,
) -> CSSPixelLength
fn viewport_percentage_to_computed_value( &self, context: &Context<'_>, ) -> CSSPixelLength
Compute the viewport-percentage length. Must only be called on a viewport-relative unit.
Sourcefn container_relative_to_computed_value(
&self,
context: &Context<'_>,
) -> CSSPixelLength
fn container_relative_to_computed_value( &self, context: &Context<'_>, ) -> CSSPixelLength
Compute the container-relative length. Must only be called on a container-relative unit.
Sourcefn servo_character_width_to_computed_value(
&self,
reference_font_size: Length,
) -> Length
fn servo_character_width_to_computed_value( &self, reference_font_size: Length, ) -> Length
Computes a ServoCharacterWidth length against a reference font size.
Sourcepub fn to_computed_value_with_base_size(
&self,
context: &Context<'_>,
base_size: FontBaseSize,
line_height_base: LineHeightBase,
) -> CSSPixelLength
pub fn to_computed_value_with_base_size( &self, context: &Context<'_>, base_size: FontBaseSize, line_height_base: LineHeightBase, ) -> CSSPixelLength
Computes a length with a given font-relative base size.
Trait Implementations§
Source§impl Clone for NoCalcLength
impl Clone for NoCalcLength
Source§fn clone(&self) -> NoCalcLength
fn clone(&self) -> NoCalcLength
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NoCalcLength
impl Debug for NoCalcLength
Source§impl From<NoCalcLength> for Length
impl From<NoCalcLength> for Length
Source§fn from(len: NoCalcLength) -> Self
fn from(len: NoCalcLength) -> Self
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<NoCalcLength> for NonNegativeLength
impl From<NoCalcLength> for NonNegativeLength
Source§fn from(len: NoCalcLength) -> Self
fn from(len: NoCalcLength) -> Self
Source§impl From<NoCalcLength> for NonNegativeLengthPercentage
impl From<NoCalcLength> for NonNegativeLengthPercentage
Source§fn from(len: NoCalcLength) -> Self
fn from(len: NoCalcLength) -> Self
Source§impl MallocSizeOf for NoCalcLength
impl MallocSizeOf for NoCalcLength
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Source§impl PartialEq for NoCalcLength
impl PartialEq for NoCalcLength
Source§impl PartialOrd for NoCalcLength
impl PartialOrd for NoCalcLength
Source§impl SpecifiedValueInfo for NoCalcLength
impl SpecifiedValueInfo for NoCalcLength
Source§const SUPPORTED_TYPES: u8 = 0
const SUPPORTED_TYPES: u8 = 0
Source§impl ToComputedValue for NoCalcLength
impl ToComputedValue for NoCalcLength
Source§type ComputedValue = CSSPixelLength
type ComputedValue = CSSPixelLength
Source§fn to_computed_value(&self, context: &Context<'_>) -> Self::ComputedValue
fn to_computed_value(&self, context: &Context<'_>) -> Self::ComputedValue
Context.Source§fn from_computed_value(computed: &Self::ComputedValue) -> Self
fn from_computed_value(computed: &Self::ComputedValue) -> Self
Source§impl ToCss for NoCalcLength
impl ToCss for NoCalcLength
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,
self in CSS syntax, writing to dest.Source§fn to_css_string(&self) -> String
fn to_css_string(&self) -> String
self in CSS syntax and return a string. Read moreSource§fn to_css_cssstring(&self) -> String
fn to_css_cssstring(&self) -> String
self in CSS syntax and return a CssString. Read moreSource§impl ToShmem for NoCalcLength
impl ToShmem for NoCalcLength
Source§impl ToTyped for NoCalcLength
impl ToTyped for NoCalcLength
Source§fn to_typed_value(&self) -> Option<TypedValue>
fn to_typed_value(&self) -> Option<TypedValue>
Source§fn to_numeric_value(&self) -> Option<NumericValue>
fn to_numeric_value(&self) -> Option<NumericValue>
Source§fn to_typed_value_list(&self) -> Option<TypedValueList>
fn to_typed_value_list(&self) -> Option<TypedValueList>
Source§impl Zero for NoCalcLength
impl Zero for NoCalcLength
impl Copy for NoCalcLength
impl StructuralPartialEq for NoCalcLength
Auto Trait Implementations§
impl Freeze for NoCalcLength
impl RefUnwindSafe for NoCalcLength
impl Send for NoCalcLength
impl Sync for NoCalcLength
impl Unpin for NoCalcLength
impl UnsafeUnpin for NoCalcLength
impl UnwindSafe for NoCalcLength
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§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