pub struct StylePatch { /* private fields */ }Expand description
A style as written (style={...}): its declarations in order (the
shorthands of StylePatch::set before their longhands), kept so the
core can apply them again over class styles when those change.
Implementations§
Source§impl StylePatch
impl StylePatch
Sourcepub fn push(
&mut self,
style: &mut Style,
decl: StyleDecl,
) -> Result<(), StyleError>
pub fn push( &mut self, style: &mut Style, decl: StyleDecl, ) -> Result<(), StyleError>
Applies decl to style and records it if it applied. A default
(StyleDecl::Default) applies unless the patch sets the property.
Sourcepub fn set(
&mut self,
style: &mut Style,
key: &str,
value: StyleValue<'_>,
) -> Result<(), StyleError>
pub fn set( &mut self, style: &mut Style, key: &str, value: StyleValue<'_>, ) -> Result<(), StyleError>
Sets property key of the style object this patch records on
style, and records it. As in React Native, a longhand
(borderTopWidth, marginHorizontal, flexGrow, …) wins over
its shorthand (borderWidth, margin, flex) in one object
whatever their order: a shorthand set after its longhands is
recorded before them, and they apply again; a null longhand is
unset, so its shorthand shows.
Sourcepub fn apply_defaults(&self, style: &mut Style, current: Color)
pub fn apply_defaults(&self, style: &mut Style, current: Color)
Applies the values the style gives properties that nothing sets
(StyleDecl::Default, StyleDecl::CurrentColor with current,
the node’s text color): to the style before its classes, which
StylePatch::apply then follows.
Sourcepub fn reads_current_color(&self) -> bool
pub fn reads_current_color(&self) -> bool
Whether a color of the style is the node’s text color
(StyleDecl::CurrentColor): it is styled again when the color
it inherits changes.