Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
32 changes: 32 additions & 0 deletions computed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ impl<'self> ComputedStyle<'self> {
convert_net_padding(self.inner.padding_left())
}

pub fn border_top_style(&self) -> CSSValue<CSSBorderStyle> {
convert_net_border_style(self.inner.border_top_style())
}

pub fn border_right_style(&self) -> CSSValue<CSSBorderStyle> {
convert_net_border_style(self.inner.border_right_style())
}

pub fn border_bottom_style(&self) -> CSSValue<CSSBorderStyle> {
convert_net_border_style(self.inner.border_bottom_style())
}

pub fn border_left_style(&self) -> CSSValue<CSSBorderStyle> {
convert_net_border_style(self.inner.border_left_style())
}

pub fn border_top_width(&self) -> CSSValue<CSSBorderWidth> {
convert_net_border_width(self.inner.border_top_width())
}
Expand Down Expand Up @@ -174,6 +190,22 @@ fn convert_net_color_value(color: n::v::CssColorValue) -> CSSValue<Color> {
}
}

fn convert_net_border_style(style: n::v::CssBorderStyleValue) -> CSSValue<CSSBorderStyle> {
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<CSSBorderWidth> {
match width {
n::v::CssBorderWidthInherit => Inherit,
Expand Down
51 changes: 51 additions & 0 deletions test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }";
Expand Down