style: Add FFI function for parsing IntersectionObserver rootMargin values.

This commit is contained in:
Cameron McCormack 2017-10-16 18:01:42 +08:00
parent eecee32a0b
commit ef28ccb1a3
3 changed files with 120 additions and 5 deletions

View file

@ -75,10 +75,10 @@ impl nsCSSValue {
pub unsafe fn set_lop(&mut self, lop: LengthOrPercentage) {
match lop {
LengthOrPercentage::Length(px) => {
bindings::Gecko_CSSValue_SetPixelLength(self, px.px())
self.set_px(px.px())
}
LengthOrPercentage::Percentage(pc) => {
bindings::Gecko_CSSValue_SetPercentage(self, pc.0)
self.set_percentage(pc.0)
}
LengthOrPercentage::Calc(calc) => {
bindings::Gecko_CSSValue_SetCalc(self, calc.into())
@ -86,6 +86,16 @@ impl nsCSSValue {
}
}
/// Sets a px value to this nsCSSValue.
pub unsafe fn set_px(&mut self, px: f32) {
bindings::Gecko_CSSValue_SetPixelLength(self, px)
}
/// Sets a percentage value to this nsCSSValue.
pub unsafe fn set_percentage(&mut self, unit_value: f32) {
bindings::Gecko_CSSValue_SetPercentage(self, unit_value)
}
/// Returns LengthOrPercentage value.
pub unsafe fn get_lop(&self) -> LengthOrPercentage {
use values::computed::Length;