diff --git a/jirs-css/src/prop.rs b/jirs-css/src/prop.rs index 086cc8d2..b21b3bdc 100644 --- a/jirs-css/src/prop.rs +++ b/jirs-css/src/prop.rs @@ -333,7 +333,11 @@ impl CssParser { Property::BackfaceVisibility(p) } // "background" => Property::Background, - // "background-attachment" => Property::BackgroundAttachment, + "background-attachment" => { + let p = self.parse_expected_prop_value()?; + self.consume_expected(";")?; + Property::BackgroundAttachment(p) + } "background-blend-mode" => { let p = self.parse_expected_prop_value()?; self.consume_expected(";")?; @@ -1314,6 +1318,40 @@ impl FromStr for BackgroundBlendModeProperty { } } +#[derive(Debug, PartialEq)] +pub enum BackgroundDirectionProperty { + ToRight, + ToLeft, + ToTop, + ToBottom, + Angle(PropertyValue), +} + +#[derive(Debug, PartialEq)] +pub enum BackgroundAttachmentProperty { + Scroll, + Fixed, + Local, + Initial, + Inherit, +} + +impl FromStr for BackgroundAttachmentProperty { + type Err = String; + + fn from_str(s: &str) -> Result { + let p = match s { + "scroll" => BackgroundAttachmentProperty::Scroll, + "fixed" => BackgroundAttachmentProperty::Fixed, + "local" => BackgroundAttachmentProperty::Local, + "initial" => BackgroundAttachmentProperty::Initial, + "inherit" => BackgroundAttachmentProperty::Inherit, + _ => return Err(format!("invalid background attachment {:?}", s)), + }; + Ok(p) + } +} + #[derive(Debug, PartialEq)] pub enum PropertyValue { Variable(String), @@ -1337,7 +1375,7 @@ pub enum Property { AnimationTimingFunction(PropertyValue), BackfaceVisibility(PropertyValue), Background(String), - BackgroundAttachment(String), + BackgroundAttachment(PropertyValue), BackgroundBlendMode(PropertyValue), BackgroundClip(PropertyValue), BackgroundColor(PropertyValue),