mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Clean up methods on specified::Image
This commit is contained in:
parent
abef5da9d8
commit
fa5b46b6ee
2 changed files with 12 additions and 13 deletions
|
@ -73,9 +73,8 @@ pub type ColorStop = GenericColorStop<CSSColor, LengthOrPercentage>;
|
|||
/// -moz-image-rect(<uri>, top, right, bottom, left);
|
||||
pub type ImageRect = GenericImageRect<NumberOrPercentage>;
|
||||
|
||||
impl Image {
|
||||
#[allow(missing_docs)]
|
||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<Image, ()> {
|
||||
impl Parse for Image {
|
||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Image, ()> {
|
||||
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(# <element-id>)`.
|
||||
fn parse_element(input: &mut Parser) -> Result<Atom, ()> {
|
||||
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(()),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue