diff --git a/components/style/values/specified/image.rs b/components/style/values/specified/image.rs index 12a87c7913a..692a01ffdae 100644 --- a/components/style/values/specified/image.rs +++ b/components/style/values/specified/image.rs @@ -73,9 +73,8 @@ pub type ColorStop = GenericColorStop; /// -moz-image-rect(, top, right, bottom, left); pub type ImageRect = GenericImageRect; -impl Image { - #[allow(missing_docs)] - pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { +impl Parse for Image { + fn parse(context: &ParserContext, input: &mut Parser) -> Result { if let Ok(url) = input.try(|input| SpecifiedUrl::parse(context, input)) { return Ok(GenericImage::Url(url)); } @@ -88,7 +87,9 @@ impl Image { Ok(GenericImage::Element(Image::parse_element(input)?)) } +} +impl Image { /// Creates an already specified image value from an already resolved URL /// for insertion in the cascade. #[cfg(feature = "servo")] @@ -98,16 +99,13 @@ impl Image { /// Parses a `-moz-element(# )`. fn parse_element(input: &mut Parser) -> Result { - if input.try(|i| i.expect_function_matching("-moz-element")).is_ok() { - input.parse_nested_block(|i| { - match i.next()? { - Token::IDHash(id) => Ok(Atom::from(id)), - _ => Err(()), - } - }) - } else { - Err(()) - } + input.try(|i| i.expect_function_matching("-moz-element"))?; + input.parse_nested_block(|i| { + match i.next()? { + Token::IDHash(id) => Ok(Atom::from(id)), + _ => Err(()), + } + }) } } diff --git a/tests/unit/style/parsing/image.rs b/tests/unit/style/parsing/image.rs index b4956e8edb7..481fbbb952d 100644 --- a/tests/unit/style/parsing/image.rs +++ b/tests/unit/style/parsing/image.rs @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use parsing::parse; +use style::parser::Parse; use style::values::specified::image::*; use style_traits::ToCss;