mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +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);
|
/// -moz-image-rect(<uri>, top, right, bottom, left);
|
||||||
pub type ImageRect = GenericImageRect<NumberOrPercentage>;
|
pub type ImageRect = GenericImageRect<NumberOrPercentage>;
|
||||||
|
|
||||||
impl Image {
|
impl Parse for Image {
|
||||||
#[allow(missing_docs)]
|
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Image, ()> {
|
||||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<Image, ()> {
|
|
||||||
if let Ok(url) = input.try(|input| SpecifiedUrl::parse(context, input)) {
|
if let Ok(url) = input.try(|input| SpecifiedUrl::parse(context, input)) {
|
||||||
return Ok(GenericImage::Url(url));
|
return Ok(GenericImage::Url(url));
|
||||||
}
|
}
|
||||||
|
@ -88,7 +87,9 @@ impl Image {
|
||||||
|
|
||||||
Ok(GenericImage::Element(Image::parse_element(input)?))
|
Ok(GenericImage::Element(Image::parse_element(input)?))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Image {
|
||||||
/// Creates an already specified image value from an already resolved URL
|
/// Creates an already specified image value from an already resolved URL
|
||||||
/// for insertion in the cascade.
|
/// for insertion in the cascade.
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
@ -98,16 +99,13 @@ impl Image {
|
||||||
|
|
||||||
/// Parses a `-moz-element(# <element-id>)`.
|
/// Parses a `-moz-element(# <element-id>)`.
|
||||||
fn parse_element(input: &mut Parser) -> Result<Atom, ()> {
|
fn parse_element(input: &mut Parser) -> Result<Atom, ()> {
|
||||||
if input.try(|i| i.expect_function_matching("-moz-element")).is_ok() {
|
input.try(|i| i.expect_function_matching("-moz-element"))?;
|
||||||
input.parse_nested_block(|i| {
|
input.parse_nested_block(|i| {
|
||||||
match i.next()? {
|
match i.next()? {
|
||||||
Token::IDHash(id) => Ok(Atom::from(id)),
|
Token::IDHash(id) => Ok(Atom::from(id)),
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
Err(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use parsing::parse;
|
use parsing::parse;
|
||||||
|
use style::parser::Parse;
|
||||||
use style::values::specified::image::*;
|
use style::values::specified::image::*;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue