pub enum Color {
CurrentColor,
Absolute(Box<Absolute>),
ColorMix(Box<ColorMix>),
LightDark(Box<LightDark>),
}
Expand description
Specified color value
Variants§
CurrentColor
The ‘currentColor’ keyword
Absolute(Box<Absolute>)
An absolute color. https://w3c.github.io/csswg-drafts/css-color-4/#typedef-absolute-color-function
ColorMix(Box<ColorMix>)
A color mix.
LightDark(Box<LightDark>)
A light-dark() color.
Implementations§
source§impl Color
impl Color
fn parse_internal<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, preserve_authored: PreserveAuthored, ) -> Result<Self, ParseError<'i>>
sourcepub fn is_valid(context: &ParserContext<'_>, input: &mut Parser<'_, '_>) -> bool
pub fn is_valid(context: &ParserContext<'_>, input: &mut Parser<'_, '_>) -> bool
Returns whether a given color is valid for authors.
sourcepub fn parse_and_compute(
context: &ParserContext<'_>,
input: &mut Parser<'_, '_>,
device: Option<&Device>,
) -> Option<ComputedColor>
pub fn parse_and_compute( context: &ParserContext<'_>, input: &mut Parser<'_, '_>, device: Option<&Device>, ) -> Option<ComputedColor>
Tries to parse a color and compute it with a given device.
source§impl Color
impl Color
sourcepub fn honored_in_forced_colors_mode(&self, allow_transparent: bool) -> bool
pub fn honored_in_forced_colors_mode(&self, allow_transparent: bool) -> bool
Returns whether this color is allowed in forced-colors mode.
sourcepub fn currentcolor() -> Self
pub fn currentcolor() -> Self
Returns currentcolor value.
sourcepub fn transparent() -> Self
pub fn transparent() -> Self
Returns transparent value.
sourcepub fn from_absolute_color(color: AbsoluteColor) -> Self
pub fn from_absolute_color(color: AbsoluteColor) -> Self
Create a color from an AbsoluteColor
.
sourcepub fn resolve_to_absolute(&self) -> Option<AbsoluteColor>
pub fn resolve_to_absolute(&self) -> Option<AbsoluteColor>
Resolve this Color into an AbsoluteColor if it does not use any of the forms that are invalid in an absolute color. https://drafts.csswg.org/css-color-5/#absolute-color Returns None if the specified color is not valid as an absolute color.
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>>
Parse a color, with quirks.
https://quirks.spec.whatwg.org/#the-hashless-hex-color-quirk
fn parse_hash<'i>( bytes: &[u8], loc: &SourceLocation, ) -> Result<Self, ParseError<'i>>
sourcefn parse_quirky_color<'i, 't>(
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>>
fn parse_quirky_color<'i, 't>( input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>>
Parse a
https://quirks.spec.whatwg.org/#the-hashless-hex-color-quirk
source§impl Color
impl Color
sourcepub fn to_computed_color(
&self,
context: Option<&Context<'_>>,
) -> Option<ComputedColor>
pub fn to_computed_color( &self, context: Option<&Context<'_>>, ) -> Option<ComputedColor>
Converts this Color into a ComputedColor.
If context
is None
, and the specified color requires data from
the context to resolve, then None
is returned.
Trait Implementations§
source§impl From<AbsoluteColor> for Color
impl From<AbsoluteColor> for Color
source§fn from(value: AbsoluteColor) -> Self
fn from(value: AbsoluteColor) -> Self
source§impl MallocSizeOf for Color
impl MallocSizeOf for Color
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
source§impl Parse for Color
impl Parse for Color
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 Color
impl PartialEq for Color
source§impl SpecifiedValueInfo for Color
impl SpecifiedValueInfo for Color
source§const SUPPORTED_TYPES: u8 = 1u8
const SUPPORTED_TYPES: u8 = 1u8
source§fn collect_completion_keywords(f: KeywordsCollectFn<'_>)
fn collect_completion_keywords(f: KeywordsCollectFn<'_>)
source§impl ToComputedValue for Color
impl ToComputedValue for Color
§type ComputedValue = GenericColor<Percentage>
type ComputedValue = GenericColor<Percentage>
source§fn to_computed_value(&self, context: &Context<'_>) -> ComputedColor
fn to_computed_value(&self, context: &Context<'_>) -> ComputedColor
Context
.source§fn from_computed_value(computed: &ComputedColor) -> Self
fn from_computed_value(computed: &ComputedColor) -> Self
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
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> 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