/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
impl Parse for TrackBreadth<LengthPercentage> { fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { // FIXME: This and other callers in this file should use // NonNegativeLengthPercentage instead. // // Though it seems these cannot be animated so it's ~ok. iflet Ok(lp) = input.try_parse(|i| LengthPercentage::parse_non_negative(context, i)) { return Ok(TrackBreadth::Breadth(lp));
}
input.expect_function_matching("fit-content")?; let lp = input.parse_nested_block(|i| LengthPercentage::parse_non_negative(context, i))?;
Ok(TrackSize::FitContent(TrackBreadth::Breadth(lp)))
}
}
impl Parse for ImplicitGridTracks<TrackSize<LengthPercentage>> { fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { use style_traits::{Separator, Space}; let track_sizes = Space::parse(input, |i| TrackSize::parse(context, i))?; if track_sizes.len() == 1 && track_sizes[0].is_initial() { // A single track with the initial value is always represented by an empty slice. return Ok(Default::default());
} return Ok(ImplicitGridTracks(track_sizes.into()));
}
}
/// Parse the grid line names into a vector of owned strings. /// /// <https://drafts.csswg.org/css-grid/#typedef-line-names> pubfn parse_line_names<'i, 't>(
input: &mut Parser<'i, 't>,
) -> Result<crate::OwnedSlice<CustomIdent>, ParseError<'i>> {
input.expect_square_bracket_block()?;
input.parse_nested_block(|input| { letmut values = vec![]; whilelet Ok(ident) = input.try_parse(|i| CustomIdent::parse(i, &["span", "auto"])) {
values.push(ident);
}
let is_auto = count == RepeatCount::AutoFit || count == RepeatCount::AutoFill; letmut repeat_type = if is_auto {
RepeatType::Auto
} else { // <fixed-size> is a subset of <track-size>, so it should work for both
RepeatType::Fixed
};
loop {
current_names = input.try_parse(parse_line_names).unwrap_or_default(); iflet Ok(track_size) = input.try_parse(|i| TrackSize::parse(context, i)) { if !track_size.is_fixed() { if is_auto { // should be <fixed-size> for <auto-repeat> return Err(input
.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
if repeat_type == RepeatType::Fixed {
repeat_type = RepeatType::Normal // <track-size> for sure
}
}
values.push(track_size);
names.push(current_names);
} else { if values.is_empty() { // expecting at least one <track-size> return Err(
input.new_custom_error(StyleParseErrorKind::UnspecifiedError)
);
}
names.push(current_names); // final `<line-names>` break; // no more <track-size>, breaking
}
}
i.expect_comma()?; letmut names_list = vec![];
names_list.push(parse_line_names(i)?); // there should be at least one whilelet Ok(names) = i.try_parse(parse_line_names) {
names_list.push(names);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.