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

Commit 075fb10

Browse files
committed
Merge pull request #10 from jrfeenst/master
Add support for padding properties.
2 parents e3057f0 + 24b4033 commit 075fb10

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

complete.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ impl<'self> CompleteStyle<'self> {
9696
strip(self.inner.margin_left())
9797
}
9898

99+
pub fn padding_top(&self) -> CSSPadding {
100+
strip(self.inner.padding_top())
101+
}
102+
103+
pub fn padding_right(&self) -> CSSPadding {
104+
strip(self.inner.padding_right())
105+
}
106+
107+
pub fn padding_bottom(&self) -> CSSPadding {
108+
strip(self.inner.padding_bottom())
109+
}
110+
111+
pub fn padding_left(&self) -> CSSPadding {
112+
strip(self.inner.padding_left())
113+
}
114+
99115
pub fn border_top_width(&self) -> CSSBorderWidth {
100116
strip(self.inner.border_top_width())
101117
}

computed.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ pub impl<'self> ComputedStyle<'self> {
3333
convert_net_margin(self.inner.margin_left())
3434
}
3535

36+
pub fn padding_top(&self) -> CSSValue<CSSPadding> {
37+
convert_net_padding(self.inner.padding_top())
38+
}
39+
40+
pub fn padding_right(&self) -> CSSValue<CSSPadding> {
41+
convert_net_padding(self.inner.padding_right())
42+
}
43+
44+
pub fn padding_bottom(&self) -> CSSValue<CSSPadding> {
45+
convert_net_padding(self.inner.padding_bottom())
46+
}
47+
48+
pub fn padding_left(&self) -> CSSValue<CSSPadding> {
49+
convert_net_padding(self.inner.padding_left())
50+
}
51+
3652
pub fn border_top_width(&self) -> CSSValue<CSSBorderWidth> {
3753
convert_net_border_width(self.inner.border_top_width())
3854
}
@@ -176,6 +192,13 @@ fn convert_net_margin(margin: n::v::CssMarginValue) -> CSSValue<CSSMargin> {
176192
}
177193
}
178194

195+
fn convert_net_padding(padding: n::v::CssPaddingValue) -> CSSValue<CSSPadding> {
196+
match padding {
197+
n::v::CssPaddingInherit => Inherit,
198+
n::v::CssPaddingSet(length) => Specified(CSSPaddingLength(convert_net_unit_to_length(length)))
199+
}
200+
}
201+
179202
fn convert_net_width_value(value: n::v::CssWidthValue) -> CSSValue<CSSWidth> {
180203
match value {
181204
n::v::CssWidthInherit => Inherit,

0 commit comments

Comments
 (0)