MCPcopy Create free account
hub / github.com/csskit/csskit / QueryableNode

Interface QueryableNode

crates/css_ast/src/visit/mod.rs:125–149  ·  view source on GitHub ↗

Marker trait for AST nodes that can be queried with selectors. Implemented by `#[derive(Visitable)]` for queryable nodes, and manually for nodes with `get_property` overrides (named at-rules, declarations). Not part of the `Visit` public API - visitors receive a [`VisitNode`] instead.

Source from the content-addressed store, hash-verified

123/// with `get_property` overrides (named at-rules, declarations).
124/// Not part of the `Visit` public API - visitors receive a [`VisitNode`] instead.
125pub(crate) trait QueryableNode: ToSpan + NodeWithMetadata<CssMetadata> {
126 /// Unique identifier for this node type.
127 const NODE_ID: NodeId;
128
129 /// Returns a cursor for the given property kind, if the node has that property.
130 /// Used by attribute selectors to extract values from nodes.
131 ///
132 /// For `PropertyKind::Name`, returns a cursor to the node's name (e.g., property
133 /// name for declarations, animation name for `@keyframes`).
134 fn get_property(&self, _kind: PropertyKind) -> Option<Cursor> {
135 None
136 }
137
138 /// Builds the [`VisitNode`] passed to every `Visit` callback for this node.
139 ///
140 /// `subtree_metadata` (eager) uses `metadata()` (self + subtree) so the prune gate can
141 /// reject whole subtrees; `self_metadata`/properties are deferred to `&dyn` accessors so
142 /// they only cost anything when a visitor actually reads them.
143 fn visit_node(&self) -> VisitNode<'_>
144 where
145 Self: Sized,
146 {
147 VisitNode::new(self.to_span(), Self::NODE_ID, self.metadata(), self)
148 }
149}
150
151/// Blanket bridge so any [`QueryableNode`] can be held as a `&dyn` in [`VisitNode`].
152impl<T: QueryableNode> QueryNodeData for T {

Callers

nothing calls this directly

Implementers 6

mod.rscrates/css_ast/src/visit/mod.rs
counter_style.rscrates/css_ast/src/rules/counter_style
webkit.rscrates/css_ast/src/rules/webkit.rs
keyframes.rscrates/css_ast/src/rules/keyframes.rs
property.rscrates/css_ast/src/rules/property.rs
mod.rscrates/css_ast/src/rules/container/mod

Calls

no outgoing calls

Tested by

no test coverage detected