Remove all color stuff from nsCSSValue.

This commit is contained in:
Xidorn Quan 2018-04-05 18:32:57 +10:00
parent 665ea9037a
commit 8932dc98be

View file

@ -7,7 +7,7 @@
use gecko_bindings::bindings;
use gecko_bindings::structs;
use gecko_bindings::structs::{nsCSSValue, nsCSSUnit};
use gecko_bindings::structs::{nsCSSValue_Array, nsCSSValueList, nscolor};
use gecko_bindings::structs::{nsCSSValue_Array, nsCSSValueList};
use gecko_string_cache::Atom;
use std::marker::PhantomData;
use std::mem;
@ -33,33 +33,20 @@ impl nsCSSValue {
/// builds.
pub fn integer_unchecked(&self) -> i32 {
debug_assert!(self.mUnit == nsCSSUnit::eCSSUnit_Integer ||
self.mUnit == nsCSSUnit::eCSSUnit_Enumerated ||
self.mUnit == nsCSSUnit::eCSSUnit_EnumColor);
self.mUnit == nsCSSUnit::eCSSUnit_Enumerated);
unsafe { *self.mValue.mInt.as_ref() }
}
/// Checks if it is an integer and returns it if so
pub fn integer(&self) -> Option<i32> {
if self.mUnit == nsCSSUnit::eCSSUnit_Integer ||
self.mUnit == nsCSSUnit::eCSSUnit_Enumerated ||
self.mUnit == nsCSSUnit::eCSSUnit_EnumColor {
self.mUnit == nsCSSUnit::eCSSUnit_Enumerated {
Some(unsafe { *self.mValue.mInt.as_ref() })
} else {
None
}
}
/// Checks if it is an RGBA color, returning it if so
/// Only use it with colors set by SetColorValue(),
/// which always sets RGBA colors
pub fn color_value(&self) -> Option<nscolor> {
if self.mUnit == nsCSSUnit::eCSSUnit_RGBAColor {
Some(unsafe { *self.mValue.mColor.as_ref() })
} else {
None
}
}
/// Returns this nsCSSValue value as a floating point value, unchecked in
/// release builds.
pub fn float_unchecked(&self) -> f32 {