style: move list-style-image out of mako

cleaner way to set boxed param

redefine get_initial_value to none

make parse method clearer

remove some extra lines
This commit is contained in:
Felipe Nakandakari 2017-12-15 14:53:55 +11:00
parent d832e1b8f8
commit eb88a298f6
5 changed files with 45 additions and 42 deletions

View file

@ -8,6 +8,41 @@ use cssparser::{Parser, Token};
use parser::{Parse, ParserContext};
use std::fmt;
use style_traits::{ParseError, StyleParseErrorKind, ToCss};
use values::{Either, None_};
use values::specified::UrlOrNone;
/// Specified and computed `list-style-image` property.
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
pub struct ListStyleImage(pub UrlOrNone);
// FIXME(nox): This is wrong, there are different types for specified
// and computed URLs in Servo.
trivial_to_computed_value!(ListStyleImage);
impl ListStyleImage {
/// Initial specified value for `list-style-image`.
#[inline]
pub fn none() -> ListStyleImage {
ListStyleImage(Either::Second(None_))
}
}
impl Parse for ListStyleImage {
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<ListStyleImage, ParseError<'i>> {
#[allow(unused_mut)]
let mut value = input.try(|input| UrlOrNone::parse(context, input))?;
#[cfg(feature = "gecko")]
{
if let Either::First(ref mut url) = value {
url.build_image_value();
}
}
return Ok(ListStyleImage(value));
}
}
/// Specified and computed `quote` property.
///

View file

@ -49,7 +49,7 @@ pub use self::length::{LengthOrPercentage, LengthOrPercentageOrAuto};
pub use self::length::{LengthOrPercentageOrNone, MaxLength, MozLength};
pub use self::length::{NoCalcLength, ViewportPercentageLength};
pub use self::length::NonNegativeLengthOrPercentage;
pub use self::list::Quotes;
pub use self::list::{ListStyleImage, Quotes};
pub use self::outline::OutlineStyle;
pub use self::rect::LengthOrNumberRect;
pub use self::percentage::Percentage;