geckolib: Add FFI function to parse a @counter-style name.

This commit is contained in:
Cameron McCormack 2017-11-24 15:51:43 +08:00
parent 1e0b216ea0
commit 374f0091c1
3 changed files with 37 additions and 11 deletions

View file

@ -5,7 +5,7 @@
//! Parsing of the stylesheet contents.
use {Namespace, Prefix};
use counter_style::{parse_counter_style_body, parse_counter_style_name};
use counter_style::{parse_counter_style_body, parse_counter_style_name_definition};
use cssparser::{AtRuleParser, AtRuleType, Parser, QualifiedRuleParser, RuleListParser};
use cssparser::{CowRcStr, SourceLocation, BasicParseError, BasicParseErrorKind};
use error_reporting::{ContextualParseError, ParseErrorReporter};
@ -383,13 +383,7 @@ impl<'a, 'b, 'i, R: ParseErrorReporter> AtRuleParser<'i> for NestedRuleParser<'a
// Support for this rule is not fully implemented in Servo yet.
return Err(input.new_custom_error(StyleParseErrorKind::UnsupportedAtRule(name.clone())))
}
let name = parse_counter_style_name(input)?;
// ASCII-case-insensitive matches for "decimal" and "disc".
// The name is already lower-cased by `parse_counter_style_name`
// so we can use == here.
if name.0 == atom!("decimal") || name.0 == atom!("disc") {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
}
let name = parse_counter_style_name_definition(input)?;
Ok(AtRuleType::WithBlock(AtRuleBlockPrelude::CounterStyle(name)))
},
"viewport" => {