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

Commit 55884aa

Browse files
committed
Merge pull request #23 from sanxiyn/clear
Add clear
2 parents b45dd83 + 1433878 commit 55884aa

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

complete.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ impl<'self> CompleteStyle<'self> {
175175
strip(self.inner.float())
176176
}
177177

178+
pub fn clear(&self) -> CSSClear {
179+
strip(self.inner.clear())
180+
}
181+
178182
// CSS 2.1, Section 10 - Visual formatting model details
179183

180184
pub fn width(&self) -> CSSWidth {

computed.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ impl<'self> ComputedStyle<'self> {
9595
convert_net_float_value(self.inner.float())
9696
}
9797

98+
pub fn clear(&self) -> CSSValue<CSSClear> {
99+
convert_net_clear_value(self.inner.clear())
100+
}
101+
98102
// CSS 2.1, Section 10 - Visual formatting model details
99103

100104
pub fn width(&self) -> CSSValue<CSSWidth> {
@@ -266,6 +270,16 @@ fn convert_net_float_value(value: n::v::CssFloatValue) -> CSSValue<CSSFloat> {
266270
}
267271
}
268272

273+
fn convert_net_clear_value(value: n::v::CssClearValue) -> CSSValue<CSSClear> {
274+
match value {
275+
n::v::CssClearInherit => Inherit,
276+
n::v::CssClearNone => Specified(CSSClearNone),
277+
n::v::CssClearLeft => Specified(CSSClearLeft),
278+
n::v::CssClearRight => Specified(CSSClearRight),
279+
n::v::CssClearBoth => Specified(CSSClearBoth)
280+
}
281+
}
282+
269283
fn convert_net_position_value(value: n::v::CssPositionValue) -> CSSValue<CSSPosition> {
270284
match value {
271285
n::v::CssPositionInherit => Inherit,

test.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ fn test_float() {
266266
}
267267
}
268268
269+
#[test]
270+
fn test_clear() {
271+
let style = "div { clear: both; }";
272+
do single_div_test(style) |computed| {
273+
assert!(computed.clear() == Specified(CSSClearBoth));
274+
}
275+
}
276+
269277
#[test]
270278
fn test_position() {
271279
let style = "div { position: static; }";

values.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ pub enum CSSFloat {
136136
CSSFloatNone
137137
}
138138

139+
#[deriving(Eq)]
140+
pub enum CSSClear {
141+
CSSClearLeft,
142+
CSSClearRight,
143+
CSSClearBoth,
144+
CSSClearNone
145+
}
146+
139147
#[deriving(Eq)]
140148
pub enum CSSDirection {
141149
CSSDirectionLtr,

0 commit comments

Comments
 (0)