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

Commit e3057f0

Browse files
committed
Merge pull request #9 from eric93/master
text-decoration
2 parents 83ab489 + baa87a0 commit e3057f0

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

complete.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ impl<'self> CompleteStyle<'self> {
194194
strip(self.inner.font_size())
195195
}
196196

197+
pub fn text_decoration(&self) -> CSSTextDecoration{
198+
strip(self.inner.text_decoration())
199+
}
200+
197201
// CSS 2.1, Section 16 - Text
198202

199203
pub fn text_align(&self) -> CSSTextAlign {

computed.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ pub impl<'self> ComputedStyle<'self> {
137137
convert_net_text_align_value(self.inner.text_align())
138138
}
139139

140+
pub fn text_decoration(&self) -> CSSValue<CSSTextDecoration> {
141+
convert_net_text_decoration_value(self.inner.text_decoration())
142+
}
143+
140144
// CSS 2.1, Section 17 - Tables
141145

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

316+
fn convert_net_text_decoration_value(value: n::v::CssTextDecorationValue) -> CSSValue<CSSTextDecoration> {
317+
match value {
318+
n::v::CssTextDecorationInherit => Inherit,
319+
n::v::CssTextDecorationNone => Specified(CSSTextDecorationNone),
320+
n::v::CssTextDecorationBlink => Specified(CSSTextDecorationBlink),
321+
n::v::CssTextDecorationLineThrough => Specified(CSSTextDecorationLineThrough),
322+
n::v::CssTextDecorationOverline => Specified(CSSTextDecorationOverline),
323+
n::v::CssTextDecorationUnderline => Specified(CSSTextDecorationUnderline),
324+
}
325+
}
326+
312327
fn convert_net_line_height_value(value: n::v::CssLineHeightValue) -> CSSValue<CSSLineHeight> {
313328
match value {
314329
n::v::CssLineHeightInherit => Inherit,

select.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ impl<N, H: SelectHandler<N>> n::s::CssSelectHandler<N> for SelectHandlerWrapper<
144144
false
145145
}
146146

147+
fn node_is_visited(&self, _node: &N) -> bool {
148+
// FIXME
149+
warn_unimpl("node_is_visited");
150+
false
151+
}
152+
147153
fn ua_default_for_property(&self, property: n::p::CssProperty) -> n::h::CssHint {
148154
warn!("not specifiying ua default for property %?", property);
149155
n::h::CssHintDefault

test.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,22 @@ fn single_div_test(style: &str, f: &fn(&ComputedStyle)) {
112112
f(&computed);
113113
}
114114
115+
fn single_html_test(style: &str, f: &fn(&ComputedStyle)) {
116+
let sheet = Stylesheet::new(test_url(), style_stream(style));
117+
let mut select_ctx = SelectCtx::new();
118+
let handler = &TestHandler::new();
119+
select_ctx.append_sheet(sheet, OriginAuthor);
120+
let dom = &TestNode(@NodeData {
121+
name: ~"html",
122+
id: ~"id1",
123+
children: ~[],
124+
parent: @mut None
125+
});
126+
let style = select_ctx.select_style(dom, handler);
127+
let computed = style.computed_style();
128+
f(&computed);
129+
}
130+
115131
#[test]
116132
fn test_background_color_simple() {
117133
let style = "div { background-color: #123456; }";
@@ -345,6 +361,22 @@ fn test_text_align() {
345361
}
346362
}
347363
364+
#[test]
365+
fn test_text_decoration(){
366+
let style = "div { text-decoration: none; }";
367+
do single_html_test(style) |computed| {
368+
assert!(computed.text_decoration() == Specified(CSSTextDecorationNone));
369+
}
370+
let style = "html { text-decoration: underline; }";
371+
do single_html_test(style) |computed| {
372+
assert!(computed.text_decoration() == Specified(CSSTextDecorationUnderline));
373+
}
374+
let style = "";
375+
do single_html_test(style) |computed| {
376+
assert!(computed.text_decoration() == Specified(CSSTextDecorationNone));
377+
}
378+
}
379+
348380
#[test]
349381
fn test_id_selector() {
350382
let style = "#id1 { text-align: center; }";

values.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ pub enum CSSTextAlign {
280280
CSSTextAlignJustify
281281
}
282282

283+
#[deriving(Eq)]
283284
pub enum CSSTextDecoration {
284285
CSSTextDecorationNone,
285286
CSSTextDecorationUnderline,

0 commit comments

Comments
 (0)