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

Add clear #23

Merged
merged 1 commit into from
Aug 5, 2013
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
4 changes: 4 additions & 0 deletions complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ impl<'self> CompleteStyle<'self> {
strip(self.inner.float())
}

pub fn clear(&self) -> CSSClear {
strip(self.inner.clear())
}

// CSS 2.1, Section 10 - Visual formatting model details

pub fn width(&self) -> CSSWidth {
Expand Down
14 changes: 14 additions & 0 deletions computed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ impl<'self> ComputedStyle<'self> {
convert_net_float_value(self.inner.float())
}

pub fn clear(&self) -> CSSValue<CSSClear> {
convert_net_clear_value(self.inner.clear())
}

// CSS 2.1, Section 10 - Visual formatting model details

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

fn convert_net_clear_value(value: n::v::CssClearValue) -> CSSValue<CSSClear> {
match value {
n::v::CssClearInherit => Inherit,
n::v::CssClearNone => Specified(CSSClearNone),
n::v::CssClearLeft => Specified(CSSClearLeft),
n::v::CssClearRight => Specified(CSSClearRight),
n::v::CssClearBoth => Specified(CSSClearBoth)
}
}

fn convert_net_position_value(value: n::v::CssPositionValue) -> CSSValue<CSSPosition> {
match value {
n::v::CssPositionInherit => Inherit,
Expand Down
8 changes: 8 additions & 0 deletions test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@ fn test_float() {
}
}

#[test]
fn test_clear() {
let style = "div { clear: both; }";
do single_div_test(style) |computed| {
assert!(computed.clear() == Specified(CSSClearBoth));
}
}

#[test]
fn test_position() {
let style = "div { position: static; }";
Expand Down
8 changes: 8 additions & 0 deletions values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ pub enum CSSFloat {
CSSFloatNone
}

#[deriving(Eq)]
pub enum CSSClear {
CSSClearLeft,
CSSClearRight,
CSSClearBoth,
CSSClearNone
}

#[deriving(Eq)]
pub enum CSSDirection {
CSSDirectionLtr,
Expand Down