From 4351c29f27dd5ae415397fbb252cacc7c3f80582 Mon Sep 17 00:00:00 2001 From: Eric Atkinson Date: Mon, 20 May 2013 20:04:25 -0700 Subject: [PATCH 1/2] Add text decoration to netsurfcss bindings --- ll.rs | 10 ++++++++++ netsurfcss.rc | 25 ++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/ll.rs b/ll.rs index 83a39bc..bcd84e6 100644 --- a/ll.rs +++ b/ll.rs @@ -388,6 +388,15 @@ pub mod properties { pub static CSS_TEXT_ALIGN_LIBCSS_CENTER: css_text_align_e = 0x8; pub static CSS_TEXT_ALIGN_LIBCSS_RIGHT: css_text_align_e = 0x9; + pub type css_text_decoration_e = c_enum; + + pub static CSS_TEXT_DECORATION_INHERIT: css_text_decoration_e = 0x00; + pub static CSS_TEXT_DECORATION_NONE: css_text_decoration_e = 0x10; + pub static CSS_TEXT_DECORATION_BLINK: css_text_decoration_e = (1<<3); + pub static CSS_TEXT_DECORATION_LINE_THROUGH: css_text_decoration_e = (1<<2); + pub static CSS_TEXT_DECORATION_OVERLINE: css_text_decoration_e = (1<<1); + pub static CSS_TEXT_DECORATION_UNDERLINE: css_text_decoration_e = (1<<0); + pub type css_line_height_e = c_enum; pub static CSS_LINE_HEIGHT_INHERIT: css_line_height_e = 0x0; @@ -587,6 +596,7 @@ pub mod computed { fn css_computed_font_style(style: *css_computed_style) -> uint8_t; fn css_computed_font_weight(style: *css_computed_style) -> uint8_t; fn css_computed_text_align(style: *css_computed_style) -> uint8_t; + fn css_computed_text_decoration(style: *css_computed_style) -> uint8_t; fn css_computed_line_height(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; } } diff --git a/netsurfcss.rc b/netsurfcss.rc index 4837ee4..7a43b17 100644 --- a/netsurfcss.rc +++ b/netsurfcss.rc @@ -1032,7 +1032,7 @@ pub mod computed { use select::CssSelectResults; use values::{CssColorValue, CssMarginValue, CssBorderWidthValue, CssDisplayValue}; use values::{CssFloatValue, CssPositionValue, CssWidthValue, CssHeightValue, CssFontFamilyValue}; - use values::{CssFontSizeValue, CssFontStyleValue, CssFontWeightValue, CssTextAlignValue}; + use values::{CssFontSizeValue, CssFontStyleValue, CssFontWeightValue, CssTextAlignValue, CssTextDecorationValue}; use values::{CssLineHeightValue}; use ll::properties::*; use ll::computed::*; @@ -1270,6 +1270,14 @@ pub mod computed { CssTextAlignValue::new(type_) } + fn text_decoration(&self) -> CssTextDecorationValue { + let type_ = unsafe { css_computed_text_decoration(self.computed_style) }; + let type_ = type_ as css_text_decoration_e; + + CssTextDecorationValue::new(type_) + } + + fn line_height(&self) -> CssLineHeightValue { let mut length = 0; let mut unit = 0; @@ -1604,6 +1612,21 @@ mod values { } } + enum CssTextDecorationValue{ + CssTextDecorationInherit = 0x00, + CssTextDecorationNone = 0x10, + CssTextDecorationBlink = (1<<3), + CssTextDecorationLineThrough = (1<<2), + CssTextDecorationOverline = (1<<1), + CssTextDecorationUnderline = (1<<0), + } + + pub impl CssTextDecorationValue { + fn new(type_: css_text_decoration_e) -> CssTextDecorationValue { + c_enum_to_rust_enum(type_) + } + } + pub enum CssLineHeightValue { CssLineHeightInherit, CssLineHeightNumber(css_fixed), From bb4a3186d6be2000834d586ec8ba298a4ad0cb8a Mon Sep 17 00:00:00 2001 From: Eric Atkinson Date: Thu, 23 May 2013 17:03:26 -0700 Subject: [PATCH 2/2] Add visited callback plumbing --- netsurfcss.rc | 15 ++++++++++++--- test.rs | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/netsurfcss.rc b/netsurfcss.rc index 7a43b17..c51560e 100644 --- a/netsurfcss.rc +++ b/netsurfcss.rc @@ -831,9 +831,9 @@ pub mod select { enter("node_is_link"); (ph(pw).node_is_link)(node, match_) } - pub extern fn node_is_visited(_pw: *c_void, _node: *c_void, _match_: *mut bool) -> css_error { - unimpl_warn("node_is_visited"); - CSS_OK + pub extern fn node_is_visited(pw: *c_void, node: *c_void, match_: *mut bool) -> css_error { + enter("node_is_visited"); + (ph(pw).node_is_visited)(node, match_) } pub extern fn node_is_hover(_pw: *c_void, _node: *c_void, _match_: *bool) -> css_error { unimpl_warn("node_is_hover"); @@ -903,6 +903,7 @@ pub mod select { parent: *mut *c_void) -> css_error, node_is_root: &'self fn(node: *c_void, match_: *mut bool) -> css_error, node_is_link: &'self fn(node: *c_void, match_: *mut bool) -> css_error, + node_is_visited: &'self fn(node: *c_void, match_: *mut bool) -> css_error, ua_default_for_property: &'self fn(property: uint32_t, hint: *mut css_hint) -> css_error, } @@ -974,6 +975,12 @@ pub mod select { *match_ = handler.node_is_link(&hlnode); CSS_OK }, + node_is_visited: |node: *c_void, match_: *mut bool| -> css_error { + let hlnode = VoidPtrLike::from_void_ptr(node); + *match_ = handler.node_is_visited(&hlnode); + CSS_OK + }, + ua_default_for_property: |property: uint32_t, hint: *mut css_hint| -> css_error { use properties::property_from_uint; let hlproperty = property_from_uint(property); @@ -995,6 +1002,7 @@ pub mod select { fn named_ancestor_node(&self, node: &N, qname: &CssQName) -> Option; fn node_is_root(&self, node: &N) -> bool; fn node_is_link(&self, node: &N) -> bool; + fn node_is_visited(&self, node: &N) -> bool; fn ua_default_for_property(&self, property: CssProperty) -> CssHint; } @@ -1273,6 +1281,7 @@ pub mod computed { fn text_decoration(&self) -> CssTextDecorationValue { let type_ = unsafe { css_computed_text_decoration(self.computed_style) }; let type_ = type_ as css_text_decoration_e; + debug!("Getting text-decoration raw: %?", type_); CssTextDecorationValue::new(type_) } diff --git a/test.rs b/test.rs index 060df8b..10605f5 100644 --- a/test.rs +++ b/test.rs @@ -146,6 +146,8 @@ mod example1 { fn node_is_link(&self, _node: &MyDomNode) -> bool { false } + fn node_is_visited(&self, _node: &MyDomNode) -> bool { false } + fn ua_default_for_property(&self, property: CssProperty) -> CssHint { match property { _ => CssHintDefault