Add support for auto value in nsCSSValue sugar.

This commit is contained in:
Xidorn Quan 2017-05-16 09:47:14 +10:00
parent 11ac1e894e
commit 3ea2f3a16c
2 changed files with 19 additions and 4 deletions

View file

@ -217,9 +217,9 @@ impl ToNsCssValue for counter_style::Symbol {
}
impl ToNsCssValue for counter_style::Ranges {
fn convert(&self, _nscssvalue: &mut nsCSSValue) {
fn convert(&self, nscssvalue: &mut nsCSSValue) {
if self.0.is_empty() {
//nscssvalue.set_auto(); // FIXME: add bindings for nsCSSValue::SetAutoValue
nscssvalue.set_auto();
} else {
for range in &self.0 {
fn set_bound(bound: Option<i32>, nscssvalue: &mut nsCSSValue) {
@ -274,7 +274,7 @@ impl ToNsCssValue for counter_style::SpeakAs {
fn convert(&self, nscssvalue: &mut nsCSSValue) {
use counter_style::SpeakAs::*;
match *self {
Auto => {} //nscssvalue.set_auto(), // FIXME: add bindings for nsCSSValue::SetAutoValue
Auto => nscssvalue.set_auto(),
Bullets => nscssvalue.set_enum(structs::NS_STYLE_COUNTER_SPEAKAS_BULLETS as i32),
Numbers => nscssvalue.set_enum(structs::NS_STYLE_COUNTER_SPEAKAS_NUMBERS as i32),
Words => nscssvalue.set_enum(structs::NS_STYLE_COUNTER_SPEAKAS_WORDS as i32),

View file

@ -101,9 +101,24 @@ impl nsCSSValue {
}
}
fn set_valueless_unit(&mut self, unit: nsCSSUnit) {
debug_assert_eq!(self.mUnit, nsCSSUnit::eCSSUnit_Null);
debug_assert!(unit as u32 <= nsCSSUnit::eCSSUnit_DummyInherit as u32, "Not a valueless unit");
self.mUnit = unit;
}
/// Set to an auto value
///
/// This method requires the current value to be null.
pub fn set_auto(&mut self) {
self.set_valueless_unit(nsCSSUnit::eCSSUnit_Auto);
}
/// Set to a normal value
///
/// This method requires the current value to be null.
pub fn set_normal(&mut self) {
unsafe { bindings::Gecko_CSSValue_SetNormal(self) }
self.set_valueless_unit(nsCSSUnit::eCSSUnit_Normal);
}
fn set_string_internal(&mut self, s: &str, unit: nsCSSUnit) {