Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit aeecb55

Browse files
committed
Add border-style
1 parent 9ed02f7 commit aeecb55

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

complete.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,21 @@ impl<'self> CompleteStyle<'self> {
129129
strip(self.inner.padding_left())
130130
}
131131

132+
pub fn border_top_style(&self) -> CSSBorderStyle {
133+
strip(self.inner.border_top_style())
134+
}
135+
136+
pub fn border_right_style(&self) -> CSSBorderStyle {
137+
strip(self.inner.border_right_style())
138+
}
139+
pub fn border_bottom_style(&self) -> CSSBorderStyle {
140+
strip(self.inner.border_bottom_style())
141+
}
142+
143+
pub fn border_left_style(&self) -> CSSBorderStyle {
144+
strip(self.inner.border_left_style())
145+
}
146+
132147
pub fn border_top_width(&self) -> CSSBorderWidth {
133148
strip(self.inner.border_top_width())
134149
}

computed.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ impl<'self> ComputedStyle<'self> {
4949
convert_net_padding(self.inner.padding_left())
5050
}
5151

52+
pub fn border_top_style(&self) -> CSSValue<CSSBorderStyle> {
53+
convert_net_border_style(self.inner.border_top_style())
54+
}
55+
56+
pub fn border_right_style(&self) -> CSSValue<CSSBorderStyle> {
57+
convert_net_border_style(self.inner.border_right_style())
58+
}
59+
60+
pub fn border_bottom_style(&self) -> CSSValue<CSSBorderStyle> {
61+
convert_net_border_style(self.inner.border_bottom_style())
62+
}
63+
64+
pub fn border_left_style(&self) -> CSSValue<CSSBorderStyle> {
65+
convert_net_border_style(self.inner.border_left_style())
66+
}
67+
5268
pub fn border_top_width(&self) -> CSSValue<CSSBorderWidth> {
5369
convert_net_border_width(self.inner.border_top_width())
5470
}
@@ -174,6 +190,22 @@ fn convert_net_color_value(color: n::v::CssColorValue) -> CSSValue<Color> {
174190
}
175191
}
176192

193+
fn convert_net_border_style(style: n::v::CssBorderStyleValue) -> CSSValue<CSSBorderStyle> {
194+
match style {
195+
n::v::CssBorderStyleInherit => Inherit,
196+
n::v::CssBorderStyleNone => Specified(CSSBorderStyleNone),
197+
n::v::CssBorderStyleHidden => Specified(CSSBorderStyleHidden),
198+
n::v::CssBorderStyleDotted => Specified(CSSBorderStyleDotted),
199+
n::v::CssBorderStyleDashed => Specified(CSSBorderStyleDashed),
200+
n::v::CssBorderStyleSolid => Specified(CSSBorderStyleSolid),
201+
n::v::CssBorderStyleDouble => Specified(CSSBorderStyleDouble),
202+
n::v::CssBorderStyleGroove => Specified(CSSBorderStyleGroove),
203+
n::v::CssBorderStyleRidge => Specified(CSSBorderStyleRidge),
204+
n::v::CssBorderStyleInset => Specified(CSSBorderStyleInset),
205+
n::v::CssBorderStyleOutset => Specified(CSSBorderStyleOutset),
206+
}
207+
}
208+
177209
fn convert_net_border_width(width: n::v::CssBorderWidthValue) -> CSSValue<CSSBorderWidth> {
178210
match width {
179211
n::v::CssBorderWidthInherit => Inherit,

test.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,57 @@ fn test_background_color_simple() {
145145
}
146146
}
147147
148+
#[test]
149+
fn test_border_top_style() {
150+
let style = "div { border-top-style: dotted; }";
151+
do single_div_test(style) |computed| {
152+
let style = computed.border_top_style();
153+
assert!(style == Specified(CSSBorderStyleDotted));
154+
}
155+
}
156+
157+
#[test]
158+
fn test_border_right_style() {
159+
let style = "div { border-right-style: solid; }";
160+
do single_div_test(style) |computed| {
161+
let style = computed.border_right_style();
162+
assert!(style == Specified(CSSBorderStyleSolid));
163+
}
164+
}
165+
166+
#[test]
167+
fn test_border_bottom_style() {
168+
let style = "div { border-bottom-style: groove; }";
169+
do single_div_test(style) |computed| {
170+
let style = computed.border_bottom_style();
171+
assert!(style == Specified(CSSBorderStyleGroove));
172+
}
173+
}
174+
175+
#[test]
176+
fn test_border_left_style() {
177+
let style = "div { border-left-style: inset; }";
178+
do single_div_test(style) |computed| {
179+
let style = computed.border_left_style();
180+
assert!(style == Specified(CSSBorderStyleInset));
181+
}
182+
}
183+
184+
#[test]
185+
fn test_border_style() {
186+
let style = "div { border-style: inset; }";
187+
do single_div_test(style) |computed| {
188+
let style = computed.border_top_style();
189+
assert!(style == Specified(CSSBorderStyleInset));
190+
let style = computed.border_right_style();
191+
assert!(style == Specified(CSSBorderStyleInset));
192+
let style = computed.border_left_style();
193+
assert!(style == Specified(CSSBorderStyleInset));
194+
let style = computed.border_bottom_style();
195+
assert!(style == Specified(CSSBorderStyleInset));
196+
}
197+
}
198+
148199
#[test]
149200
fn test_border_top_width_px() {
150201
let style = "div { border-top-width: 10px; }";

0 commit comments

Comments
 (0)