Files
tubestation/servo/components/style/values/specified/flex.rs
Simon Sapin a917619a4a servo: Merge #18808 - Use the current parser location for CSS error (from servo:error-location_); r=emilio
… rather than the start location of the current construct. This likely places the error just *after* of the unexpected token whereas before would be best, but that’s likely a much bigger change.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1378861

Source-Repo: https://github.com/servo/servo
Source-Revision: c79a54dbd9d3a590f5fd8191b8e57a0b9d1d0fdb
2017-10-10 12:31:24 -05:00

30 lines
1.0 KiB
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Specified types for CSS values related to flexbox.
use cssparser::Parser;
use parser::{Parse, ParserContext};
use style_traits::ParseError;
use values::generics::flex::FlexBasis as GenericFlexBasis;
use values::specified::length::LengthOrPercentage;
/// A specified value for the `flex-basis` property.
pub type FlexBasis = GenericFlexBasis<LengthOrPercentage>;
impl Parse for FlexBasis {
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>)
-> Result<Self, ParseError<'i>> {
if let Ok(length) = input.try(|i| LengthOrPercentage::parse_non_negative(context, i)) {
return Ok(GenericFlexBasis::Length(length));
}
try_match_ident_ignore_ascii_case! { input,
"auto" => Ok(GenericFlexBasis::Auto),
"content" => Ok(GenericFlexBasis::Content),
}
}
}