css_parse/traits/
node_metadata.rs

1/// Aggregated metadata for nodes, that can propagate up a node tree.
2pub trait NodeMetadata: Sized + Copy + Default {
3	/// Merges another NodeMetadata into this one, returning the result.
4	fn merge(self, other: Self) -> Self;
5}
6
7/// A Node that has NodeMetadata
8pub trait NodeWithMetadata<M: NodeMetadata> {
9	/// Returns the metadata contributed by this node itself, not including children.
10	/// Most nodes don't contribute metadata, so can simply return `M::default()`.
11	/// Nodes like StyleRule or AtRules should return their own node kind flags here.
12	fn self_metadata(&self) -> M {
13		M::default()
14	}
15
16	/// Returns the complete aggregated metadata for this node (self + children).
17	/// Default implementation merges children's metadata with self_metadata().
18	fn metadata(&self) -> M;
19}
20
21// Stub implementation allowing tests to use () for M
22impl NodeMetadata for () {
23	fn merge(self, _: Self) -> Self {}
24}