Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text-decoration #9

Merged
merged 3 commits into from May 24, 2013
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -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 {
@@ -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
@@ -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,
@@ -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
32 test.rs
@@ -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; }";
@@ -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; }";
@@ -280,6 +280,7 @@ pub enum CSSTextAlign {
CSSTextAlignJustify
}

#[deriving(Eq)]
pub enum CSSTextDecoration {
CSSTextDecorationNone,
CSSTextDecorationUnderline,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.