Struct style::custom_properties::VariableValue
source · pub struct VariableValue {
pub css: String,
pub url_data: UrlExtraData,
first_token_type: TokenSerializationType,
last_token_type: TokenSerializationType,
references: References,
}
Expand description
A value for a custom property is just a set of tokens.
We preserve the original CSS for serialization, and also the variable references to other custom property names.
Fields§
§css: String
The raw CSS string.
url_data: UrlExtraData
The url data of the stylesheet where this value came from.
first_token_type: TokenSerializationType
§last_token_type: TokenSerializationType
§references: References
var(), env(), or non-custom property (e.g. through em
) references.
Implementations§
source§impl VariableValue
impl VariableValue
fn empty(url_data: &UrlExtraData) -> Self
sourcepub fn new(
css: String,
url_data: &UrlExtraData,
first_token_type: TokenSerializationType,
last_token_type: TokenSerializationType,
) -> Self
pub fn new( css: String, url_data: &UrlExtraData, first_token_type: TokenSerializationType, last_token_type: TokenSerializationType, ) -> Self
Create a new custom property without parsing if the CSS is known to be valid and contain no references.
fn push<'i>( &mut self, css: &str, css_first_token_type: TokenSerializationType, css_last_token_type: TokenSerializationType, ) -> Result<(), ()>
sourcepub fn parse<'i, 't>(
input: &mut Parser<'i, 't>,
url_data: &UrlExtraData,
) -> Result<Self, ParseError<'i>>
pub fn parse<'i, 't>( input: &mut Parser<'i, 't>, url_data: &UrlExtraData, ) -> Result<Self, ParseError<'i>>
Parse a custom property value.
sourcefn integer(number: i32, url_data: &UrlExtraData) -> Self
fn integer(number: i32, url_data: &UrlExtraData) -> Self
Create VariableValue from an int.
sourcefn ident(ident: &'static str, url_data: &UrlExtraData) -> Self
fn ident(ident: &'static str, url_data: &UrlExtraData) -> Self
Create VariableValue from an int.
sourcefn pixels(number: f32, url_data: &UrlExtraData) -> Self
fn pixels(number: f32, url_data: &UrlExtraData) -> Self
Create VariableValue from a float amount of CSS pixels.
sourcefn int_ms(number: i32, url_data: &UrlExtraData) -> Self
fn int_ms(number: i32, url_data: &UrlExtraData) -> Self
Create VariableValue from an integer amount of milliseconds.
sourcefn int_pixels(number: i32, url_data: &UrlExtraData) -> Self
fn int_pixels(number: i32, url_data: &UrlExtraData) -> Self
Create VariableValue from an integer amount of CSS pixels.
fn from_token(token: Token<'_>, url_data: &UrlExtraData) -> Self
sourcepub fn has_references(&self) -> bool
pub fn has_references(&self) -> bool
Returns whether this variable value has any reference to the environment or other variables.
Trait Implementations§
source§impl Clone for VariableValue
impl Clone for VariableValue
source§fn clone(&self) -> VariableValue
fn clone(&self) -> VariableValue
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for VariableValue
impl Debug for VariableValue
source§impl MallocSizeOf for VariableValue
impl MallocSizeOf for VariableValue
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
source§impl PartialEq for VariableValue
impl PartialEq for VariableValue
source§impl ToComputedValue for VariableValue
impl ToComputedValue for VariableValue
§type ComputedValue = VariableValue
type ComputedValue = VariableValue
source§fn to_computed_value(&self, _: &Context<'_>) -> Self
fn to_computed_value(&self, _: &Context<'_>) -> Self
Context
.source§fn from_computed_value(other: &Self) -> Self
fn from_computed_value(other: &Self) -> Self
source§impl ToResolvedValue for VariableValue
impl ToResolvedValue for VariableValue
§type ResolvedValue = VariableValue
type ResolvedValue = VariableValue
source§fn to_resolved_value(self, _: &Context<'_>) -> Self
fn to_resolved_value(self, _: &Context<'_>) -> Self
source§fn from_resolved_value(resolved: Self::ResolvedValue) -> Self
fn from_resolved_value(resolved: Self::ResolvedValue) -> Self
source§impl ToShmem for VariableValue
impl ToShmem for VariableValue
impl Eq for VariableValue
Auto Trait Implementations§
impl Freeze for VariableValue
impl RefUnwindSafe for VariableValue
impl Send for VariableValue
impl Sync for VariableValue
impl Unpin for VariableValue
impl UnwindSafe for VariableValue
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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