mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Utilize match_ignore_ascii_case! in more places.
This commit is contained in:
parent
6238035612
commit
befe538472
5 changed files with 39 additions and 46 deletions
|
@ -12,7 +12,6 @@ use cssparser::{Delimiter, Parser, Token, ParserInput};
|
|||
use parser::ParserContext;
|
||||
use selectors::parser::SelectorParseError;
|
||||
use serialize_comma_separated_list;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use style_traits::{ToCss, ParseError, StyleParseError};
|
||||
|
||||
|
@ -146,20 +145,15 @@ pub enum MediaQueryType {
|
|||
|
||||
impl MediaQueryType {
|
||||
fn parse(ident: &str) -> Result<Self, ()> {
|
||||
if ident.eq_ignore_ascii_case("all") {
|
||||
return Ok(MediaQueryType::All);
|
||||
}
|
||||
|
||||
// From https://drafts.csswg.org/mediaqueries/#mq-syntax:
|
||||
//
|
||||
// The <media-type> production does not include the keywords only,
|
||||
// not, and, and or.
|
||||
if ident.eq_ignore_ascii_case("not") ||
|
||||
ident.eq_ignore_ascii_case("or") ||
|
||||
ident.eq_ignore_ascii_case("and") ||
|
||||
ident.eq_ignore_ascii_case("only") {
|
||||
return Err(())
|
||||
}
|
||||
match_ignore_ascii_case! { ident,
|
||||
"all" => return Ok(MediaQueryType::All),
|
||||
// From https://drafts.csswg.org/mediaqueries/#mq-syntax:
|
||||
//
|
||||
// The <media-type> production does not include the keywords only,
|
||||
// not, and, and or.
|
||||
"not" | "or" | "and" | "only" => return Err(()),
|
||||
_ => (),
|
||||
};
|
||||
|
||||
Ok(match MediaType::parse(ident) {
|
||||
Some(media_type) => MediaQueryType::Known(media_type),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue