pub struct StyleSheet {
pub rules: Vec<Rule>,
}Expand description
A parsed stylesheet containing zero or more rules.
Fields§
§rules: Vec<Rule>The rules parsed from the CSS source, in source order.
Implementations§
Source§impl StyleSheet
impl StyleSheet
Sourcepub fn parse(input: &str) -> ParseResult
pub fn parse(input: &str) -> ParseResult
Parse a CSS-subset string.
Malformed rules are skipped with ParseDiagnostics rather than
causing a panic. Valid rules following a malformed one are still
parsed.
Sourcepub fn matching_rules<'a>(
&'a self,
widget_type: &str,
classes: &[&str],
id: Option<&str>,
) -> Vec<(&'a Rule, Specificity)>
pub fn matching_rules<'a>( &'a self, widget_type: &str, classes: &[&str], id: Option<&str>, ) -> Vec<(&'a Rule, Specificity)>
Find all rules that match a widget described by type, classes, and id.
Returns rules sorted ascending by (specificity, source_order) so that
the caller can apply them in order and the last write wins (standard CSS
cascade).
Sourcepub fn compute_style(
&self,
widget_type: &str,
classes: &[&str],
id: Option<&str>,
) -> ComputedStyle
pub fn compute_style( &self, widget_type: &str, classes: &[&str], id: Option<&str>, ) -> ComputedStyle
Compute the final ComputedStyle for a widget by cascading all
matching rules.
Rules are applied in ascending specificity / source-order, so the last (most specific) rule wins for each property.
Trait Implementations§
Source§impl Clone for StyleSheet
impl Clone for StyleSheet
Source§fn clone(&self) -> StyleSheet
fn clone(&self) -> StyleSheet
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 StyleSheet
impl Debug for StyleSheet
Source§impl Default for StyleSheet
impl Default for StyleSheet
Source§fn default() -> StyleSheet
fn default() -> StyleSheet
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StyleSheet
impl RefUnwindSafe for StyleSheet
impl Send for StyleSheet
impl Sync for StyleSheet
impl Unpin for StyleSheet
impl UnsafeUnpin for StyleSheet
impl UnwindSafe for StyleSheet
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