diff --git a/ll.rs b/ll.rs index bcc7981..149a048 100644 --- a/ll.rs +++ b/ll.rs @@ -418,6 +418,18 @@ pub mod properties { pub static CSS_LINE_HEIGHT_DIMENSION: css_line_height_e = 0x2; pub static CSS_LINE_HEIGHT_NORMAL: css_line_height_e = 0x3; + pub type css_vertical_align_e = c_enum; + + pub static CSS_VERTICAL_ALIGN_INHERIT: css_vertical_align_e = 0x0; + pub static CSS_VERTICAL_ALIGN_BASELINE: css_vertical_align_e = 0x1; + pub static CSS_VERTICAL_ALIGN_SUB: css_vertical_align_e = 0x2; + pub static CSS_VERTICAL_ALIGN_SUPER: css_vertical_align_e = 0x3; + pub static CSS_VERTICAL_ALIGN_TOP: css_vertical_align_e = 0x4; + pub static CSS_VERTICAL_ALIGN_TEXTTOP: css_vertical_align_e = 0x5; + pub static CSS_VERTICAL_ALIGN_MIDDLE: css_vertical_align_e = 0x6; + pub static CSS_VERTICAL_ALIGN_BOTTOM: css_vertical_align_e = 0x7; + pub static CSS_VERTICAL_ALIGN_TEXTBOTTOM: css_vertical_align_e = 0x8; + pub static CSS_VERTICAL_ALIGN_DIMENSION: css_vertical_align_e = 0x9; } pub mod stylesheet { @@ -617,5 +629,6 @@ pub mod computed { pub fn css_computed_text_align(style: *css_computed_style) -> uint8_t; pub fn css_computed_text_decoration(style: *css_computed_style) -> uint8_t; pub fn css_computed_line_height(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; + pub fn css_computed_vertical_align(style: *css_computed_style, length: *mut css_fixed, unit: *mut css_unit) -> uint8_t; } } diff --git a/netsurfcss.rc b/netsurfcss.rc index 32315a0..adb837c 100644 --- a/netsurfcss.rc +++ b/netsurfcss.rc @@ -1110,7 +1110,7 @@ pub mod computed { use values::{CssColorValue, CssMarginValue, CssPaddingValue, CssBorderWidthValue, CssDisplayValue}; use values::{CssFloatValue, CssClearValue, CssPositionValue, CssWidthValue, CssHeightValue, CssFontFamilyValue}; use values::{CssFontSizeValue, CssFontStyleValue, CssFontWeightValue, CssTextAlignValue, CssTextDecorationValue}; - use values::{CssLineHeightValue}; + use values::{CssLineHeightValue, CssVerticalAlignValue}; use ll::properties::*; use ll::computed::*; use std::ptr::{to_mut_unsafe_ptr, null}; @@ -1418,6 +1418,16 @@ pub mod computed { CssLineHeightValue::new(type_, length, unit) } + pub fn vertical_align(&self) -> CssVerticalAlignValue { + let mut length = 0; + let mut unit = 0; + let type_ = unsafe { css_computed_vertical_align(self.computed_style, + to_mut_unsafe_ptr(&mut length), + to_mut_unsafe_ptr(&mut unit)) }; + let type_ = type_ as css_vertical_align_e; + + CssVerticalAlignValue::new(type_, length, unit) + } } pub type ComputeFontSizeCb = @fn(parent: &Option, child: &CssHint) -> CssHint; @@ -1811,6 +1821,37 @@ mod values { } } + pub enum CssVerticalAlignValue { + CssVerticalAlignInherit, + CssVerticalAlignBaseline, + CssVerticalAlignSub, + CssVerticalAlignSuper, + CssVerticalAlignTop, + CssVerticalAlignTextTop, + CssVerticalAlignMiddle, + CssVerticalAlignBottom, + CssVerticalAlignTextBottom, + CssVerticalAlignDimension(CssUnit), + } + + impl CssVerticalAlignValue { + pub fn new(type_: css_vertical_align_e, length: css_fixed, unit: css_unit) -> CssVerticalAlignValue { + match type_ { + CSS_VERTICAL_ALIGN_INHERIT => CssVerticalAlignInherit, + CSS_VERTICAL_ALIGN_BASELINE => CssVerticalAlignBaseline, + CSS_VERTICAL_ALIGN_SUB => CssVerticalAlignSub, + CSS_VERTICAL_ALIGN_SUPER => CssVerticalAlignSuper, + CSS_VERTICAL_ALIGN_TOP => CssVerticalAlignTop, + CSS_VERTICAL_ALIGN_TEXTTOP => CssVerticalAlignTextTop, + CSS_VERTICAL_ALIGN_MIDDLE => CssVerticalAlignMiddle, + CSS_VERTICAL_ALIGN_BOTTOM => CssVerticalAlignBottom, + CSS_VERTICAL_ALIGN_TEXTBOTTOM => CssVerticalAlignTextBottom, + CSS_VERTICAL_ALIGN_DIMENSION => CssVerticalAlignDimension(ll_unit_to_hl_unit(unit, length)), + _ => { unimpl("vertical-align") } + } + } + } + fn unimpl(what: &str) -> ! { fail!(fmt!("unimplemented css value: %?", what)); }