Skip to main content

LengthUnit

Enum LengthUnit 

Source
#[repr(u8)]
pub enum LengthUnit {
Show 50 variants Px = 0, In = 1, Cm = 2, Mm = 3, Q = 4, Pt = 5, Pc = 6, Em = 7, Ex = 8, Rex = 9, Ch = 10, Rch = 11, Cap = 12, Rcap = 13, Ic = 14, Ric = 15, Rem = 16, Lh = 17, Rlh = 18, Vw = 19, Svw = 20, Lvw = 21, Dvw = 22, Vh = 23, Svh = 24, Lvh = 25, Dvh = 26, Vmin = 27, Svmin = 28, Lvmin = 29, Dvmin = 30, Vmax = 31, Svmax = 32, Lvmax = 33, Dvmax = 34, Vb = 35, Svb = 36, Lvb = 37, Dvb = 38, Vi = 39, Svi = 40, Lvi = 41, Dvi = 42, Cqw = 43, Cqh = 44, Cqi = 45, Cqb = 46, Cqmin = 47, Cqmax = 48, ServoCharacterWidth = 49,
}
Expand description

The unit of a <length> value. Note that if any new font-relative value is added here, custom_properties::NonCustomReferences::from_unit must also be updated. Consult the comment in that function as to why.

The variants are grouped (absolute, font-relative, viewport, container, servo-internal) so that is_* predicates can be implemented with simple range checks.

Variants§

§

Px = 0

§

In = 1

§

Cm = 2

§

Mm = 3

§

Q = 4

§

Pt = 5

§

Pc = 6

§

Em = 7

§

Ex = 8

§

Rex = 9

§

Ch = 10

§

Rch = 11

§

Cap = 12

§

Rcap = 13

§

Ic = 14

§

Ric = 15

§

Rem = 16

§

Lh = 17

§

Rlh = 18

§

Vw = 19

§

Svw = 20

§

Lvw = 21

§

Dvw = 22

§

Vh = 23

§

Svh = 24

§

Lvh = 25

§

Dvh = 26

§

Vmin = 27

§

Svmin = 28

§

Lvmin = 29

§

Dvmin = 30

§

Vmax = 31

§

Svmax = 32

§

Lvmax = 33

§

Dvmax = 34

§

Vb = 35

§

Svb = 36

§

Lvb = 37

§

Dvb = 38

§

Vi = 39

§

Svi = 40

§

Lvi = 41

§

Dvi = 42

§

Cqw = 43

§

Cqh = 44

§

Cqi = 45

§

Cqb = 46

§

Cqmin = 47

§

Cqmax = 48

§

ServoCharacterWidth = 49

HTML5 “character width”, as defined in HTML5 § 14.5.4. Internal-only.

Implementations§

Source§

impl LengthUnit

Source

pub fn as_str(self) -> &'static str

Returns this unit as a string.

Source

pub fn is_absolute(self) -> bool

Whether this is an absolute length unit (px, in, cm, mm, q, pt, pc).

Source

pub fn is_font_relative(self) -> bool

Whether this is a font-relative unit.

Source

pub fn is_viewport_percentage(self) -> bool

Whether this is a viewport-percentage unit.

Source

pub fn is_container_relative(self) -> bool

Whether this is a container-relative unit.

Source

fn sort_key(self) -> SortKey

Returns the sort key for this unit. Must not be called for the internal ServoCharacterWidth unit.

Trait Implementations§

Source§

impl Clone for LengthUnit

Source§

fn clone(&self) -> LengthUnit

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LengthUnit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl MallocSizeOf for LengthUnit

Source§

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 PartialEq for LengthUnit

Source§

fn eq(&self, other: &LengthUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for LengthUnit

Source§

fn partial_cmp(&self, other: &LengthUnit) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl ToShmem for LengthUnit

Source§

fn to_shmem(&self, builder: &mut SharedMemoryBuilder) -> Result<Self>

Clones this value into a form suitable for writing into a SharedMemoryBuilder. Read more
Source§

impl Copy for LengthUnit

Source§

impl Eq for LengthUnit

Source§

impl StructuralPartialEq for LengthUnit

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T