diff --git a/ll.rs b/ll.rs index bcd84e6..af58177 100644 --- a/ll.rs +++ b/ll.rs @@ -314,6 +314,11 @@ pub mod properties { pub static CSS_MARGIN_SET: css_margin_e = 0x1; pub static CSS_MARGIN_AUTO: css_margin_e = 0x2; + pub type css_padding_e = c_enum; + + pub static CSS_PADDING_INHERIT: css_padding_e = 0x0; + pub static CSS_PADDING_SET: css_padding_e = 0x1; + pub type css_display_e = c_enum; pub static CSS_DISPLAY_INHERIT: css_display_e = 0x00; @@ -586,6 +591,10 @@ pub mod computed { fn css_computed_margin_right(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; fn css_computed_margin_bottom(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; fn css_computed_margin_left(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + fn css_computed_padding_top(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + fn css_computed_padding_right(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + fn css_computed_padding_bottom(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + fn css_computed_padding_left(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; fn css_computed_display(style: *css_computed_style, root: bool) -> uint8_t; fn css_computed_float(style: *css_computed_style) -> uint8_t; fn css_computed_position(style: *css_computed_style) -> uint8_t; diff --git a/netsurfcss.rc b/netsurfcss.rc index c51560e..e8510c2 100644 --- a/netsurfcss.rc +++ b/netsurfcss.rc @@ -1038,7 +1038,7 @@ pub mod computed { use properties::CssPropFontSize; use hint::CssHint; use select::CssSelectResults; - use values::{CssColorValue, CssMarginValue, CssBorderWidthValue, CssDisplayValue}; + use values::{CssColorValue, CssMarginValue, CssPaddingValue, CssBorderWidthValue, CssDisplayValue}; use values::{CssFloatValue, CssPositionValue, CssWidthValue, CssHeightValue, CssFontFamilyValue}; use values::{CssFontSizeValue, CssFontStyleValue, CssFontWeightValue, CssTextAlignValue, CssTextDecorationValue}; use values::{CssLineHeightValue}; @@ -1194,6 +1194,50 @@ pub mod computed { CssMarginValue::new(type_, length, unit) } + fn padding_top(&self) -> CssPaddingValue { + let mut length = 0; + let mut unit = 0; + let type_ = unsafe { css_computed_padding_top(self.computed_style, + to_mut_unsafe_ptr(&mut length), + to_mut_unsafe_ptr(&mut unit)) }; + let type_ = type_ as css_padding_e; + + CssPaddingValue::new(type_, length, unit) + } + + fn padding_right(&self) -> CssPaddingValue { + let mut length = 0; + let mut unit = 0; + let type_ = unsafe {css_computed_padding_right(self.computed_style, + to_mut_unsafe_ptr(&mut length), + to_mut_unsafe_ptr(&mut unit)) }; + let type_ = type_ as css_padding_e; + + CssPaddingValue::new(type_, length, unit) + } + + fn padding_bottom(&self) -> CssPaddingValue { + let mut length = 0; + let mut unit = 0; + let type_ = unsafe { css_computed_padding_bottom(self.computed_style, + to_mut_unsafe_ptr(&mut length), + to_mut_unsafe_ptr(&mut unit)) }; + let type_ = type_ as css_padding_e; + + CssPaddingValue::new(type_, length, unit) + } + + fn padding_left(&self) -> CssPaddingValue { + let mut length = 0; + let mut unit = 0; + let type_ = unsafe { css_computed_padding_left(self.computed_style, + to_mut_unsafe_ptr(&mut length), + to_mut_unsafe_ptr(&mut unit)) }; + let type_ = type_ as css_padding_e; + + CssPaddingValue::new(type_, length, unit) + } + fn display(&self, root: bool) -> CssDisplayValue { let type_ = unsafe { css_computed_display(self.computed_style, root) }; let type_ = type_ as css_display_e; @@ -1382,6 +1426,24 @@ mod values { } } + + pub enum CssPaddingValue { + CssPaddingInherit, + CssPaddingSet(CssUnit) + } + + pub impl CssPaddingValue { + fn new(type_: css_padding_e, length: css_fixed, unit: css_unit) -> CssPaddingValue { + if type_ == CSS_PADDING_INHERIT { + CssPaddingInherit + } else if type_ == CSS_PADDING_SET { + CssPaddingSet(ll_unit_to_hl_unit(unit, length)) + } else { + unimpl("padding") + } + } + } + pub enum CssBorderWidthValue { CssBorderWidthInherit, CssBorderWidthThin,