pub struct Styler { /* private fields */ }Expand description
Holds stylesheets and computes styles for elements against them.
Stylesheets are consulted in the order they were added, and a later stylesheet wins over an earlier one when specificity ties, so add the theme first and overrides after.
Computing a style needs the parent’s computed style for inheritance, so walk the tree top-down and keep each parent’s result around for its children.
Implementations§
Source§impl Styler
impl Styler
pub fn add_stylesheet(&mut self, sheet: Stylesheet)
pub fn stylesheets(&self) -> &[Stylesheet]
pub fn clear_stylesheets(&mut self)
Sourcepub fn set_root_font_size(&mut self, px: f32)
pub fn set_root_font_size(&mut self, px: f32)
The font size rem is relative to, in pixels. Tie it to the user’s
text scale to make every rem in the stylesheets follow it.
pub fn root_font_size(&self) -> f32
Sourcepub fn compute<E: Element>(
&self,
element: &E,
parent: Option<&ComputedStyle>,
) -> ComputedStyle
pub fn compute<E: Element>( &self, element: &E, parent: Option<&ComputedStyle>, ) -> ComputedStyle
The style of element given its parent’s computed style, or None
for the root.
Sourcepub fn compute_with_inline<E: Element>(
&self,
element: &E,
parent: Option<&ComputedStyle>,
inline: Option<&DeclarationBlock>,
) -> ComputedStyle
pub fn compute_with_inline<E: Element>( &self, element: &E, parent: Option<&ComputedStyle>, inline: Option<&DeclarationBlock>, ) -> ComputedStyle
Like compute, with an inline style that beats every
stylesheet declaration of the same importance.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Styler
impl RefUnwindSafe for Styler
impl Send for Styler
impl Sync for Styler
impl Unpin for Styler
impl UnsafeUnpin for Styler
impl UnwindSafe for Styler
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