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

text-decoration #9

Merged
merged 3 commits into from
May 24, 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 @@ -194,6 +194,10 @@ impl<'self> CompleteStyle<'self> {
strip(self.inner.font_size())
}

pub fn text_decoration(&self) -> CSSTextDecoration{
strip(self.inner.text_decoration())
}

// CSS 2.1, Section 16 - Text

pub fn text_align(&self) -> CSSTextAlign {
Expand Down
15 changes: 15 additions & 0 deletions computed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ pub impl<'self> ComputedStyle<'self> {
convert_net_text_align_value(self.inner.text_align())
}

pub fn text_decoration(&self) -> CSSValue<CSSTextDecoration> {
convert_net_text_decoration_value(self.inner.text_decoration())
}

// CSS 2.1, Section 17 - Tables

// CSS 2.1, Section 18 - User interface
Expand Down Expand Up @@ -309,6 +313,17 @@ fn convert_net_text_align_value(value: n::v::CssTextAlignValue) -> CSSValue<CSST
}
}

fn convert_net_text_decoration_value(value: n::v::CssTextDecorationValue) -> CSSValue<CSSTextDecoration> {
match value {
n::v::CssTextDecorationInherit => Inherit,
n::v::CssTextDecorationNone => Specified(CSSTextDecorationNone),
n::v::CssTextDecorationBlink => Specified(CSSTextDecorationBlink),
n::v::CssTextDecorationLineThrough => Specified(CSSTextDecorationLineThrough),
n::v::CssTextDecorationOverline => Specified(CSSTextDecorationOverline),
n::v::CssTextDecorationUnderline => Specified(CSSTextDecorationUnderline),
}
}

fn convert_net_line_height_value(value: n::v::CssLineHeightValue) -> CSSValue<CSSLineHeight> {
match value {
n::v::CssLineHeightInherit => Inherit,
Expand Down
6 changes: 6 additions & 0 deletions select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ impl<N, H: SelectHandler<N>> n::s::CssSelectHandler<N> for SelectHandlerWrapper<
false
}

fn node_is_visited(&self, _node: &N) -> bool {
// FIXME
warn_unimpl("node_is_visited");
false
}

fn ua_default_for_property(&self, property: n::p::CssProperty) -> n::h::CssHint {
warn!("not specifiying ua default for property %?", property);
n::h::CssHintDefault
Expand Down
32 changes: 32 additions & 0 deletions test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ fn single_div_test(style: &str, f: &fn(&ComputedStyle)) {
f(&computed);
}

fn single_html_test(style: &str, f: &fn(&ComputedStyle)) {
let sheet = Stylesheet::new(test_url(), style_stream(style));
let mut select_ctx = SelectCtx::new();
let handler = &TestHandler::new();
select_ctx.append_sheet(sheet, OriginAuthor);
let dom = &TestNode(@NodeData {
name: ~"html",
id: ~"id1",
children: ~[],
parent: @mut None
});
let style = select_ctx.select_style(dom, handler);
let computed = style.computed_style();
f(&computed);
}

#[test]
fn test_background_color_simple() {
let style = "div { background-color: #123456; }";
Expand Down Expand Up @@ -345,6 +361,22 @@ fn test_text_align() {
}
}

#[test]
fn test_text_decoration(){
let style = "div { text-decoration: none; }";
do single_html_test(style) |computed| {
assert!(computed.text_decoration() == Specified(CSSTextDecorationNone));
}
let style = "html { text-decoration: underline; }";
do single_html_test(style) |computed| {
assert!(computed.text_decoration() == Specified(CSSTextDecorationUnderline));
}
let style = "";
do single_html_test(style) |computed| {
assert!(computed.text_decoration() == Specified(CSSTextDecorationNone));
}
}

#[test]
fn test_id_selector() {
let style = "#id1 { text-align: center; }";
Expand Down
1 change: 1 addition & 0 deletions values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ pub enum CSSTextAlign {
CSSTextAlignJustify
}

#[deriving(Eq)]
pub enum CSSTextDecoration {
CSSTextDecorationNone,
CSSTextDecorationUnderline,
Expand Down