mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Borrow input to match_ignore_ascii_case!
In cssparser version 0.11, this macro will stop implicitly borrowing its own input.
This commit is contained in:
parent
4fa3e8e82c
commit
0f2d000a23
21 changed files with 62 additions and 61 deletions
|
@ -69,7 +69,7 @@ impl TransitionProperty {
|
|||
|
||||
/// Parse a transition-property value.
|
||||
pub fn parse(input: &mut Parser) -> Result<Self, ()> {
|
||||
match_ignore_ascii_case! { try!(input.expect_ident()),
|
||||
match_ignore_ascii_case! { &try!(input.expect_ident()),
|
||||
"all" => Ok(TransitionProperty::All),
|
||||
% for prop in data.longhands:
|
||||
% if prop.animatable:
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
/// Parse a display value.
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser)
|
||||
-> Result<SpecifiedValue, ()> {
|
||||
match_ignore_ascii_case! { try!(input.expect_ident()),
|
||||
match_ignore_ascii_case! { &try!(input.expect_ident()),
|
||||
% for value in values:
|
||||
"${value}" => {
|
||||
Ok(computed_value::T::${to_rust_ident(value)})
|
||||
|
@ -299,7 +299,7 @@ ${helpers.single_keyword("-moz-top-layer", "none top",
|
|||
input.try(|i| specified::LengthOrPercentage::parse(context, i))
|
||||
.map(SpecifiedValue::LengthOrPercentage)
|
||||
.or_else(|_| {
|
||||
match_ignore_ascii_case! { try!(input.expect_ident()),
|
||||
match_ignore_ascii_case! { &try!(input.expect_ident()),
|
||||
% for keyword in vertical_align_keywords:
|
||||
"${keyword}" => Ok(SpecifiedValue::${to_rust_ident(keyword)}),
|
||||
% endfor
|
||||
|
@ -588,7 +588,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
impl Parse for SpecifiedValue {
|
||||
fn parse(_context: &ParserContext, input: &mut ::cssparser::Parser) -> Result<Self, ()> {
|
||||
if let Ok(function_name) = input.try(|input| input.expect_function()) {
|
||||
return match_ignore_ascii_case! { function_name,
|
||||
return match_ignore_ascii_case! { &function_name,
|
||||
"cubic-bezier" => {
|
||||
let (mut p1x, mut p1y, mut p2x, mut p2y) = (0.0, 0.0, 0.0, 0.0);
|
||||
try!(input.parse_nested_block(|input| {
|
||||
|
@ -618,7 +618,7 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
|
|||
|
||||
if input.try(|input| input.expect_comma()).is_ok() {
|
||||
start_end = try!(match_ignore_ascii_case! {
|
||||
try!(input.expect_ident()),
|
||||
&try!(input.expect_ident()),
|
||||
"start" => Ok(StartEnd::Start),
|
||||
"end" => Ok(StartEnd::End),
|
||||
_ => Err(())
|
||||
|
@ -1319,7 +1319,7 @@ ${helpers.predefined_type("scroll-snap-coordinate",
|
|||
Err(_) => break,
|
||||
};
|
||||
match_ignore_ascii_case! {
|
||||
name,
|
||||
&name,
|
||||
"matrix" => {
|
||||
try!(input.parse_nested_block(|input| {
|
||||
let values = try!(input.parse_comma_separated(|input| {
|
||||
|
|
|
@ -140,7 +140,7 @@
|
|||
content.push(ContentItem::String(value.into_owned()))
|
||||
}
|
||||
Ok(Token::Function(name)) => {
|
||||
content.push(try!(match_ignore_ascii_case! { name,
|
||||
content.push(try!(match_ignore_ascii_case! { &name,
|
||||
"counter" => input.parse_nested_block(|input| {
|
||||
let name = try!(input.expect_ident()).into_owned();
|
||||
let style = input.try(|input| {
|
||||
|
@ -163,7 +163,7 @@
|
|||
}));
|
||||
}
|
||||
Ok(Token::Ident(ident)) => {
|
||||
match_ignore_ascii_case! { ident,
|
||||
match_ignore_ascii_case! { &ident,
|
||||
"open-quote" => content.push(ContentItem::OpenQuote),
|
||||
"close-quote" => content.push(ContentItem::CloseQuote),
|
||||
"no-open-quote" => content.push(ContentItem::NoOpenQuote),
|
||||
|
|
|
@ -339,7 +339,7 @@ ${helpers.predefined_type("clip",
|
|||
% endif
|
||||
if let Ok(function_name) = input.try(|input| input.expect_function()) {
|
||||
filters.push(try!(input.parse_nested_block(|input| {
|
||||
match_ignore_ascii_case! { function_name,
|
||||
match_ignore_ascii_case! { &function_name,
|
||||
"blur" => specified::Length::parse_non_negative(input).map(SpecifiedFilter::Blur),
|
||||
"brightness" => parse_factor(input).map(SpecifiedFilter::Brightness),
|
||||
"contrast" => parse_factor(input).map(SpecifiedFilter::Contrast),
|
||||
|
@ -445,7 +445,7 @@ pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result<Origi
|
|||
if let Err(_) = input.try(|input| {
|
||||
let token = try!(input.expect_ident());
|
||||
match_ignore_ascii_case! {
|
||||
token,
|
||||
&token,
|
||||
"left" => {
|
||||
if horizontal.is_none() {
|
||||
horizontal = Some(LengthOrPercentage::Percentage(Percentage(0.0)))
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
}
|
||||
_ => {}
|
||||
}
|
||||
match_ignore_ascii_case! { input,
|
||||
match_ignore_ascii_case! { &input,
|
||||
"serif" => return FontFamily::Generic(atom!("serif")),
|
||||
"sans-serif" => return FontFamily::Generic(atom!("sans-serif")),
|
||||
"cursive" => return FontFamily::Generic(atom!("cursive")),
|
||||
|
@ -85,7 +85,7 @@
|
|||
// string (as lowercase) in the static atoms table. We don't have an
|
||||
// API to do that yet though, so we do the simple thing for now.
|
||||
let mut css_wide_keyword = false;
|
||||
match_ignore_ascii_case! { first_ident,
|
||||
match_ignore_ascii_case! { &first_ident,
|
||||
"serif" => return Ok(FontFamily::Generic(atom!("serif"))),
|
||||
"sans-serif" => return Ok(FontFamily::Generic(atom!("sans-serif"))),
|
||||
"cursive" => return Ok(FontFamily::Generic(atom!("cursive"))),
|
||||
|
@ -254,7 +254,7 @@ ${helpers.single_keyword("font-variant-caps",
|
|||
/// normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
input.try(|input| {
|
||||
match_ignore_ascii_case! { try!(input.expect_ident()),
|
||||
match_ignore_ascii_case! { &try!(input.expect_ident()),
|
||||
"normal" => Ok(SpecifiedValue::Normal),
|
||||
"bold" => Ok(SpecifiedValue::Bold),
|
||||
"bolder" => Ok(SpecifiedValue::Bolder),
|
||||
|
@ -557,7 +557,7 @@ ${helpers.single_keyword("font-variant-caps",
|
|||
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
let mut result = SpecifiedValue { weight: false, style: false };
|
||||
match_ignore_ascii_case! {try!(input.expect_ident()),
|
||||
match_ignore_ascii_case! { &try!(input.expect_ident()),
|
||||
"none" => Ok(result),
|
||||
"weight" => {
|
||||
result.weight = true;
|
||||
|
|
|
@ -196,7 +196,7 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
|
|||
loop {
|
||||
|
||||
let result = input.try(|i| {
|
||||
match_ignore_ascii_case! { i.expect_ident()?,
|
||||
match_ignore_ascii_case! { &i.expect_ident()?,
|
||||
"fill" => Ok(FILL),
|
||||
"stroke" => Ok(STROKE),
|
||||
"markers" => Ok(MARKERS),
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
impl Parse for Side {
|
||||
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Side, ()> {
|
||||
if let Ok(ident) = input.try(|input| input.expect_ident()) {
|
||||
match_ignore_ascii_case! { ident,
|
||||
match_ignore_ascii_case! { &ident,
|
||||
"clip" => Ok(Side::Clip),
|
||||
"ellipsis" => Ok(Side::Ellipsis),
|
||||
_ => Err(())
|
||||
|
@ -179,7 +179,7 @@ ${helpers.single_keyword("unicode-bidi",
|
|||
|
||||
while input.try(|input| {
|
||||
if let Ok(ident) = input.expect_ident() {
|
||||
match_ignore_ascii_case! { ident,
|
||||
match_ignore_ascii_case! { &ident,
|
||||
"underline" => if result.contains(UNDERLINE) { return Err(()) }
|
||||
else { empty = false; result.insert(UNDERLINE) },
|
||||
"overline" => if result.contains(OVERLINE) { return Err(()) }
|
||||
|
|
|
@ -455,7 +455,7 @@ impl Parse for CSSWideKeyword {
|
|||
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
let ident = input.expect_ident()?;
|
||||
input.expect_exhausted()?;
|
||||
match_ignore_ascii_case! { ident,
|
||||
match_ignore_ascii_case! { &ident,
|
||||
"initial" => Ok(CSSWideKeyword::InitialKeyword),
|
||||
"inherit" => Ok(CSSWideKeyword::InheritKeyword),
|
||||
"unset" => Ok(CSSWideKeyword::UnsetKeyword),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue