pub struct CalcNumeric {
pub clamping_mode: AllowedNumericType,
pub node: CalcNode,
}Expand description
A struct to hold a simplified calc expression and associated clamping mode.
In some cases, e.g. DOMMatrix, we support calc(), but reject all the relative lengths, and to_computed_pixel_length_without_context() handles this case. Therefore, if you want to add a new field, please make sure this function work properly.
Fields§
§clamping_mode: AllowedNumericType§node: CalcNodeImplementations§
Source§impl CalcNumeric
impl CalcNumeric
Sourcepub fn with_clamping_mode(&self, clamping_mode: AllowedNumericType) -> Self
pub fn with_clamping_mode(&self, clamping_mode: AllowedNumericType) -> Self
Returns a new CalcNumeric with the same expression but the specified clamping mode
Sourcepub fn with_leaf_node(&self, leaf: Leaf) -> Self
pub fn with_leaf_node(&self, leaf: Leaf) -> Self
Returns a new CalcNumeric with the same clamping mode but a different leaf node
Sourcepub fn resolve(
&self,
context: &Context<'_>,
leaf_to_f32: impl FnOnce(Result<Leaf, ()>) -> f32,
) -> f32
pub fn resolve( &self, context: &Context<'_>, leaf_to_f32: impl FnOnce(Result<Leaf, ()>) -> f32, ) -> f32
Resolves this calc expression given a computed context, applying clamping.
Sourcepub fn as_number(&self) -> Option<NoCalcNumber>
pub fn as_number(&self) -> Option<NoCalcNumber>
Gets this calc expression as a number
Sourcepub fn as_percentage(&self) -> Option<NoCalcPercentage>
pub fn as_percentage(&self) -> Option<NoCalcPercentage>
Gets this calc expression as a percentage
Sourcepub fn as_time(&self) -> Option<NoCalcTime>
pub fn as_time(&self) -> Option<NoCalcTime>
Gets this calc expression as a time
Sourcepub fn as_resolution(&self) -> Option<NoCalcResolution>
pub fn as_resolution(&self) -> Option<NoCalcResolution>
Gets this calc expression as a resolution
Sourcepub fn as_angle(&self) -> Option<NoCalcAngle>
pub fn as_angle(&self) -> Option<NoCalcAngle>
Gets this calc expression as an angle
Trait Implementations§
Source§impl Clone for CalcNumeric
impl Clone for CalcNumeric
Source§fn clone(&self) -> CalcNumeric
fn clone(&self) -> CalcNumeric
Returns a duplicate 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 CalcNumeric
impl Debug for CalcNumeric
Source§impl MallocSizeOf for CalcNumeric
impl MallocSizeOf for CalcNumeric
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 PartialEq for CalcNumeric
impl PartialEq for CalcNumeric
Source§impl SpecifiedValueInfo for CalcNumeric
impl SpecifiedValueInfo for CalcNumeric
Source§const SUPPORTED_TYPES: u8 = 0
const SUPPORTED_TYPES: u8 = 0
Supported CssTypes by the given value type. Read more
Source§impl ToCss for CalcNumeric
impl ToCss for CalcNumeric
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 CalcNumeric
impl ToShmem for CalcNumeric
Source§impl ToTyped for CalcNumeric
impl ToTyped for CalcNumeric
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>
impl StructuralPartialEq for CalcNumeric
Auto Trait Implementations§
impl Freeze for CalcNumeric
impl RefUnwindSafe for CalcNumeric
impl Send for CalcNumeric
impl Sync for CalcNumeric
impl Unpin for CalcNumeric
impl UnsafeUnpin for CalcNumeric
impl UnwindSafe for CalcNumeric
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