pub struct ResolvedStyle { /* private fields */ }Expand description
Resolved style for one node — property -> value, with cascade already applied. Adapter crates (e.g. hjkl-css-floem) convert this to their own builder type.
Internally each property stores the (rule_idx, decl_idx) of the
winning declaration so that iter can replay
properties in CSS source order, which is the correct semantic for
adapters that apply shorthand/longhand overrides.
Implementations§
Source§impl ResolvedStyle
impl ResolvedStyle
pub fn get(&self, property: &str) -> Option<&Value>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &Value)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &Value)>
Iterate declarations in CSS source order: ascending rule_idx
of the winning declaration, with decl_idx (position inside the
rule) breaking ties. The result matches the order in which the
declarations appeared in the stylesheet so that adapters applying
properties sequentially produce CSS-spec behaviour for
shorthand/longhand collisions.
Example: x { border-color: blue; border: 1px solid red; } yields
("border-color", blue) then ("border", red). An adapter that
applies border-color first then border ends up with red, which
is the CSS-correct winner.
If you need alphabetical order for snapshots or serialization,
collect the iterator and sort the resulting Vec by key.
Performance: allocates a Vec and sorts it on every call. For
one-shot adapter conversion this cost is negligible.
Trait Implementations§
Source§impl Clone for ResolvedStyle
impl Clone for ResolvedStyle
Source§fn clone(&self) -> ResolvedStyle
fn clone(&self) -> ResolvedStyle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResolvedStyle
impl Debug for ResolvedStyle
Source§impl Default for ResolvedStyle
impl Default for ResolvedStyle
Source§fn default() -> ResolvedStyle
fn default() -> ResolvedStyle
Source§impl PartialEq for ResolvedStyle
impl PartialEq for ResolvedStyle
Source§fn eq(&self, other: &ResolvedStyle) -> bool
fn eq(&self, other: &ResolvedStyle) -> bool
self and other values to be equal, and is used by ==.