diff --git a/complete.rs b/complete.rs index 1788a65..b5b97af 100644 --- a/complete.rs +++ b/complete.rs @@ -129,6 +129,21 @@ impl<'self> CompleteStyle<'self> { strip(self.inner.padding_left()) } + pub fn border_top_style(&self) -> CSSBorderStyle { + strip(self.inner.border_top_style()) + } + + pub fn border_right_style(&self) -> CSSBorderStyle { + strip(self.inner.border_right_style()) + } + pub fn border_bottom_style(&self) -> CSSBorderStyle { + strip(self.inner.border_bottom_style()) + } + + pub fn border_left_style(&self) -> CSSBorderStyle { + strip(self.inner.border_left_style()) + } + pub fn border_top_width(&self) -> CSSBorderWidth { strip(self.inner.border_top_width()) } diff --git a/computed.rs b/computed.rs index e4a1fb6..1196947 100644 --- a/computed.rs +++ b/computed.rs @@ -49,6 +49,22 @@ impl<'self> ComputedStyle<'self> { convert_net_padding(self.inner.padding_left()) } + pub fn border_top_style(&self) -> CSSValue { + convert_net_border_style(self.inner.border_top_style()) + } + + pub fn border_right_style(&self) -> CSSValue { + convert_net_border_style(self.inner.border_right_style()) + } + + pub fn border_bottom_style(&self) -> CSSValue { + convert_net_border_style(self.inner.border_bottom_style()) + } + + pub fn border_left_style(&self) -> CSSValue { + convert_net_border_style(self.inner.border_left_style()) + } + pub fn border_top_width(&self) -> CSSValue { convert_net_border_width(self.inner.border_top_width()) } @@ -174,6 +190,22 @@ fn convert_net_color_value(color: n::v::CssColorValue) -> CSSValue { } } +fn convert_net_border_style(style: n::v::CssBorderStyleValue) -> CSSValue { + match style { + n::v::CssBorderStyleInherit => Inherit, + n::v::CssBorderStyleNone => Specified(CSSBorderStyleNone), + n::v::CssBorderStyleHidden => Specified(CSSBorderStyleHidden), + n::v::CssBorderStyleDotted => Specified(CSSBorderStyleDotted), + n::v::CssBorderStyleDashed => Specified(CSSBorderStyleDashed), + n::v::CssBorderStyleSolid => Specified(CSSBorderStyleSolid), + n::v::CssBorderStyleDouble => Specified(CSSBorderStyleDouble), + n::v::CssBorderStyleGroove => Specified(CSSBorderStyleGroove), + n::v::CssBorderStyleRidge => Specified(CSSBorderStyleRidge), + n::v::CssBorderStyleInset => Specified(CSSBorderStyleInset), + n::v::CssBorderStyleOutset => Specified(CSSBorderStyleOutset), + } +} + fn convert_net_border_width(width: n::v::CssBorderWidthValue) -> CSSValue { match width { n::v::CssBorderWidthInherit => Inherit, diff --git a/test.rs b/test.rs index 0363304..30701c9 100644 --- a/test.rs +++ b/test.rs @@ -145,6 +145,57 @@ fn test_background_color_simple() { } } +#[test] +fn test_border_top_style() { + let style = "div { border-top-style: dotted; }"; + do single_div_test(style) |computed| { + let style = computed.border_top_style(); + assert!(style == Specified(CSSBorderStyleDotted)); + } +} + +#[test] +fn test_border_right_style() { + let style = "div { border-right-style: solid; }"; + do single_div_test(style) |computed| { + let style = computed.border_right_style(); + assert!(style == Specified(CSSBorderStyleSolid)); + } +} + +#[test] +fn test_border_bottom_style() { + let style = "div { border-bottom-style: groove; }"; + do single_div_test(style) |computed| { + let style = computed.border_bottom_style(); + assert!(style == Specified(CSSBorderStyleGroove)); + } +} + +#[test] +fn test_border_left_style() { + let style = "div { border-left-style: inset; }"; + do single_div_test(style) |computed| { + let style = computed.border_left_style(); + assert!(style == Specified(CSSBorderStyleInset)); + } +} + +#[test] +fn test_border_style() { + let style = "div { border-style: inset; }"; + do single_div_test(style) |computed| { + let style = computed.border_top_style(); + assert!(style == Specified(CSSBorderStyleInset)); + let style = computed.border_right_style(); + assert!(style == Specified(CSSBorderStyleInset)); + let style = computed.border_left_style(); + assert!(style == Specified(CSSBorderStyleInset)); + let style = computed.border_bottom_style(); + assert!(style == Specified(CSSBorderStyleInset)); + } +} + #[test] fn test_border_top_width_px() { let style = "div { border-top-width: 10px; }";