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

Method parse

crates/css_parse/src/syntax/component_values.rs:22–51  ·  view source on GitHub ↗

https://drafts.csswg.org/css-syntax-3/#consume-list-of-components

(p: &mut Parser<'a, Iter>)

Source from the content-addressed store, hash-verified

20impl<'a> Parse<'a> for ComponentValues<'a> {
21 // https://drafts.csswg.org/css-syntax-3/#consume-list-of-components
22 fn parse<Iter>(p: &mut Parser<'a, Iter>) -> Result<Self>
23 where
24 Iter: Iterator<Item = Cursor> + Clone,
25 {
26 let mut values = Vec::new_in(p.bump());
27 let mut last_was_whitespace = false;
28
29 loop {
30 if p.at_end() {
31 break;
32 }
33 if p.next_is_stop() {
34 break;
35 }
36 if let Some(mut value) = p.parse_if_peek::<ComponentValue>()? {
37 if let ComponentValue::Delim(d) = value
38 && last_was_whitespace
39 && d.associated_whitespace().contains(AssociatedWhitespaceRules::EnforceAfter)
40 {
41 let rules = d.associated_whitespace() | AssociatedWhitespaceRules::EnforceBefore;
42 value = ComponentValue::Delim(d.with_associated_whitespace(rules))
43 }
44 last_was_whitespace = matches!(value, ComponentValue::Whitespace(_));
45 values.push(value);
46 } else {
47 break;
48 }
49 }
50 Ok(Self { values })
51 }
52}
53
54impl<'a, M: NodeMetadata> NodeWithMetadata<M> for ComponentValues<'a> {

Callers

nothing calls this directly

Calls 6

next_is_stopMethod · 0.80
associated_whitespaceMethod · 0.80
bumpMethod · 0.45
at_endMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected