Auto merge of #15735 - servo:cssparserup, r=emilio

Update cssparser to 0.11

<!-- Please describe your changes on the following line: -->

<s>Depends on https://github.com/servo/rust-cssparser/pull/122.</s>

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15735)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-02-26 02:19:32 -08:00 committed by GitHub
commit 94e563e4d9
42 changed files with 143 additions and 175 deletions

View file

@ -28,7 +28,7 @@ macro_rules! define_numbered_css_keyword_enum {
impl Parse for $name {
#[allow(missing_docs)]
fn parse(_context: &ParserContext, input: &mut ::cssparser::Parser) -> Result<$name, ()> {
match_ignore_ascii_case! { try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
$( $css => Ok($name::$variant), )+
_ => Err(())
}

View file

@ -323,7 +323,7 @@ impl Parse for JustifyItems {
// auto | normal | stretch | <baseline-position>
fn parse_auto_normal_stretch_baseline(input: &mut Parser) -> Result<AlignFlags, ()> {
let ident = input.expect_ident()?;
match_ignore_ascii_case! { ident,
match_ignore_ascii_case! { &ident,
"auto" => Ok(ALIGN_AUTO),
"normal" => Ok(ALIGN_NORMAL),
"stretch" => Ok(ALIGN_STRETCH),
@ -335,7 +335,7 @@ fn parse_auto_normal_stretch_baseline(input: &mut Parser) -> Result<AlignFlags,
// normal | stretch | <baseline-position>
fn parse_normal_stretch_baseline(input: &mut Parser) -> Result<AlignFlags, ()> {
let ident = input.expect_ident()?;
match_ignore_ascii_case! { ident,
match_ignore_ascii_case! { &ident,
"normal" => Ok(ALIGN_NORMAL),
"stretch" => Ok(ALIGN_STRETCH),
"baseline" => Ok(ALIGN_BASELINE),
@ -346,7 +346,7 @@ fn parse_normal_stretch_baseline(input: &mut Parser) -> Result<AlignFlags, ()> {
// normal | <baseline-position>
fn parse_normal_or_baseline(input: &mut Parser) -> Result<AlignFlags, ()> {
let ident = input.expect_ident()?;
match_ignore_ascii_case! { ident,
match_ignore_ascii_case! { &ident,
"normal" => Ok(ALIGN_NORMAL),
"baseline" => Ok(ALIGN_BASELINE),
_ => Err(())
@ -356,7 +356,7 @@ fn parse_normal_or_baseline(input: &mut Parser) -> Result<AlignFlags, ()> {
// <content-distribution>
fn parse_content_distribution(input: &mut Parser) -> Result<AlignFlags, ()> {
let ident = input.expect_ident()?;
match_ignore_ascii_case! { ident,
match_ignore_ascii_case! { &ident,
"stretch" => Ok(ALIGN_STRETCH),
"space_between" => Ok(ALIGN_SPACE_BETWEEN),
"space_around" => Ok(ALIGN_SPACE_AROUND),
@ -386,7 +386,7 @@ fn parse_overflow_content_position(input: &mut Parser) -> Result<AlignFlags, ()>
// <content-position>
fn parse_content_position(input: &mut Parser) -> Result<AlignFlags, ()> {
let ident = input.expect_ident()?;
match_ignore_ascii_case! { ident,
match_ignore_ascii_case! { &ident,
"start" => Ok(ALIGN_START),
"end" => Ok(ALIGN_END),
"flex-start" => Ok(ALIGN_FLEX_START),
@ -401,7 +401,7 @@ fn parse_content_position(input: &mut Parser) -> Result<AlignFlags, ()> {
// <overflow-position>
fn parse_overflow_position(input: &mut Parser) -> Result<AlignFlags, ()> {
let ident = input.expect_ident()?;
match_ignore_ascii_case! { ident,
match_ignore_ascii_case! { &ident,
"safe" => Ok(ALIGN_SAFE),
"unsafe" => Ok(ALIGN_UNSAFE),
_ => Err(())
@ -429,7 +429,7 @@ fn parse_overflow_self_position(input: &mut Parser) -> Result<AlignFlags, ()> {
// <self-position>
fn parse_self_position(input: &mut Parser) -> Result<AlignFlags, ()> {
let ident = input.expect_ident()?;
match_ignore_ascii_case! { ident,
match_ignore_ascii_case! { &ident,
"start" => Ok(ALIGN_START),
"end" => Ok(ALIGN_END),
"flex-start" => Ok(ALIGN_FLEX_START),
@ -448,14 +448,14 @@ fn parse_legacy(input: &mut Parser) -> Result<AlignFlags, ()> {
let a = input.expect_ident()?;
let b = input.expect_ident()?;
if a.eq_ignore_ascii_case("legacy") {
match_ignore_ascii_case! { b,
match_ignore_ascii_case! { &b,
"left" => Ok(ALIGN_LEGACY | ALIGN_LEFT),
"right" => Ok(ALIGN_LEGACY | ALIGN_RIGHT),
"center" => Ok(ALIGN_LEGACY | ALIGN_CENTER),
_ => Err(())
}
} else if b.eq_ignore_ascii_case("legacy") {
match_ignore_ascii_case! { a,
match_ignore_ascii_case! { &a,
"left" => Ok(ALIGN_LEGACY | ALIGN_LEFT),
"right" => Ok(ALIGN_LEGACY | ALIGN_RIGHT),
"center" => Ok(ALIGN_LEGACY | ALIGN_CENTER),

View file

@ -141,7 +141,7 @@ pub enum BasicShape {
impl Parse for BasicShape {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<BasicShape, ()> {
match_ignore_ascii_case! { try!(input.expect_function()),
match_ignore_ascii_case! { &try!(input.expect_function()),
"inset" => {
Ok(BasicShape::Inset(
try!(input.parse_nested_block(|i| InsetRect::parse_function_arguments(context, i)))))
@ -237,7 +237,7 @@ impl InsetRect {
impl Parse for InsetRect {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
match_ignore_ascii_case! { try!(input.expect_function()),
match_ignore_ascii_case! { &try!(input.expect_function()),
"inset" => {
input.parse_nested_block(|i| InsetRect::parse_function_arguments(context, i))
},
@ -413,7 +413,7 @@ impl Circle {
impl Parse for Circle {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
match_ignore_ascii_case! { try!(input.expect_function()),
match_ignore_ascii_case! { &try!(input.expect_function()),
"circle" => {
input.parse_nested_block(|i| Circle::parse_function_arguments(context, i))
},
@ -497,7 +497,7 @@ impl Ellipse {
impl Parse for Ellipse {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
match_ignore_ascii_case! { try!(input.expect_function()),
match_ignore_ascii_case! { &try!(input.expect_function()),
"ellipse" => {
input.parse_nested_block(|i| Ellipse::parse_function_arguments(context, i))
},
@ -575,7 +575,7 @@ impl Polygon {
impl Parse for Polygon {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
match_ignore_ascii_case! { try!(input.expect_function()),
match_ignore_ascii_case! { &try!(input.expect_function()),
"polygon" => {
input.parse_nested_block(|i| Polygon::parse_function_arguments(context, i))
},
@ -664,7 +664,7 @@ impl Default for ShapeRadius {
impl Parse for ShapeRadius {
fn parse(_: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
input.try(|i| LengthOrPercentage::parse_non_negative(i)).map(ShapeRadius::Length).or_else(|_| {
match_ignore_ascii_case! { try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
"closest-side" => Ok(ShapeRadius::ClosestSide),
"farthest-side" => Ok(ShapeRadius::FarthestSide),
_ => Err(())
@ -832,7 +832,7 @@ impl ComputedValueAsSpecified for FillRule {}
impl Parse for FillRule {
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<FillRule, ()> {
match_ignore_ascii_case! { try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
"nonzero" => Ok(FillRule::NonZero),
"evenodd" => Ok(FillRule::EvenOdd),
_ => Err(())
@ -871,7 +871,7 @@ impl Parse for GeometryBox {
if let Ok(shape_box) = input.try(|i| ShapeBox::parse(context, i)) {
Ok(GeometryBox::ShapeBox(shape_box))
} else {
match_ignore_ascii_case! { try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
"fill-box" => Ok(GeometryBox::Fill),
"stroke-box" => Ok(GeometryBox::Stroke),
"view-box" => Ok(GeometryBox::View),
@ -908,7 +908,7 @@ pub enum ShapeBox {
impl Parse for ShapeBox {
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
match_ignore_ascii_case! { try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
"margin-box" => Ok(ShapeBox::Margin),
"border-box" => Ok(ShapeBox::Border),
"padding-box" => Ok(ShapeBox::Padding),

View file

@ -103,7 +103,7 @@ impl Gradient {
/// Parses a gradient from the given arguments.
pub fn parse_function(context: &ParserContext, input: &mut Parser) -> Result<Gradient, ()> {
let mut repeating = false;
let (gradient_kind, stops) = match_ignore_ascii_case! { try!(input.expect_function()),
let (gradient_kind, stops) = match_ignore_ascii_case! { &try!(input.expect_function()),
"linear-gradient" => {
try!(input.parse_nested_block(|input| {
let kind = try!(GradientKind::parse_linear(context, input));

View file

@ -1344,13 +1344,7 @@ impl Parse for MinLength {
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
input.try(ExtremumLength::parse).map(MinLength::ExtremumLength)
.or_else(|()| input.try(LengthOrPercentage::parse_non_negative).map(MinLength::LengthOrPercentage))
.or_else(|()| {
match_ignore_ascii_case! { try!(input.expect_ident()),
"auto" =>
Ok(MinLength::Auto),
_ => Err(())
}
})
.or_else(|()| input.expect_ident_matching("auto").map(|()| MinLength::Auto))
}
}
@ -1391,7 +1385,7 @@ impl Parse for MaxLength {
input.try(ExtremumLength::parse).map(MaxLength::ExtremumLength)
.or_else(|()| input.try(LengthOrPercentage::parse_non_negative).map(MaxLength::LengthOrPercentage))
.or_else(|()| {
match_ignore_ascii_case! { try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
"none" =>
Ok(MaxLength::None),
_ => Err(())

View file

@ -297,7 +297,7 @@ impl Angle {
#[allow(missing_docs)]
pub fn parse_border_radius(context: &ParserContext, input: &mut Parser) -> Result<BorderRadiusSize, ()> {
input.try(|i| BorderRadiusSize::parse(context, i)).or_else(|_| {
match_ignore_ascii_case! { try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
"thin" => Ok(BorderRadiusSize::circle(
LengthOrPercentage::Length(NoCalcLength::from_px(1.)))),
"medium" => Ok(BorderRadiusSize::circle(
@ -312,7 +312,7 @@ pub fn parse_border_radius(context: &ParserContext, input: &mut Parser) -> Resul
#[allow(missing_docs)]
pub fn parse_border_width(input: &mut Parser) -> Result<Length, ()> {
input.try(Length::parse_non_negative).or_else(|()| {
match_ignore_ascii_case! { try!(input.expect_ident()),
match_ignore_ascii_case! { &try!(input.expect_ident()),
"thin" => Ok(Length::from_px(1.)),
"medium" => Ok(Length::from_px(3.)),
"thick" => Ok(Length::from_px(5.)),
@ -335,7 +335,7 @@ impl Parse for BorderWidth {
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<BorderWidth, ()> {
match input.try(Length::parse_non_negative) {
Ok(length) => Ok(BorderWidth::Width(length)),
Err(_) => match_ignore_ascii_case! { try!(input.expect_ident()),
Err(_) => match_ignore_ascii_case! { &try!(input.expect_ident()),
"thin" => Ok(BorderWidth::Thin),
"medium" => Ok(BorderWidth::Medium),
"thick" => Ok(BorderWidth::Thick),
@ -714,7 +714,7 @@ pub enum SVGPaintKind {
impl SVGPaintKind {
fn parse_ident(input: &mut Parser) -> Result<Self, ()> {
Ok(match_ignore_ascii_case! { input.expect_ident()?,
Ok(match_ignore_ascii_case! { &input.expect_ident()?,
"none" => SVGPaintKind::None,
"context-fill" => SVGPaintKind::ContextFill,
"context-stroke" => SVGPaintKind::ContextStroke,

View file

@ -595,17 +595,17 @@ impl Parse for PositionComponent {
.or_else(|()| {
match try!(input.next()) {
Token::Ident(value) => {
match_ignore_ascii_case! { value,
"center" => Ok(PositionComponent::Keyword(Keyword::Center)),
"left" => Ok(PositionComponent::Keyword(Keyword::Left)),
"right" => Ok(PositionComponent::Keyword(Keyword::Right)),
"top" => Ok(PositionComponent::Keyword(Keyword::Top)),
"bottom" => Ok(PositionComponent::Keyword(Keyword::Bottom)),
"x-start" => Ok(PositionComponent::Keyword(Keyword::XStart)),
"x-end" => Ok(PositionComponent::Keyword(Keyword::XEnd)),
"y-start" => Ok(PositionComponent::Keyword(Keyword::YStart)),
"y-end" => Ok(PositionComponent::Keyword(Keyword::YEnd)),
_ => Err(())
match_ignore_ascii_case! { &value,
"center" => Ok(PositionComponent::Keyword(Keyword::Center)),
"left" => Ok(PositionComponent::Keyword(Keyword::Left)),
"right" => Ok(PositionComponent::Keyword(Keyword::Right)),
"top" => Ok(PositionComponent::Keyword(Keyword::Top)),
"bottom" => Ok(PositionComponent::Keyword(Keyword::Bottom)),
"x-start" => Ok(PositionComponent::Keyword(Keyword::XStart)),
"x-end" => Ok(PositionComponent::Keyword(Keyword::XEnd)),
"y-start" => Ok(PositionComponent::Keyword(Keyword::YStart)),
"y-end" => Ok(PositionComponent::Keyword(Keyword::YEnd)),
_ => Err(())
}
},
_ => Err(())