diff options
author | Xidorn Quan <me@upsuper.org> | 2017-06-08 10:42:32 +1000 |
---|---|---|
committer | Xidorn Quan <me@upsuper.org> | 2017-06-08 12:59:28 +1000 |
commit | 5c643adb9831ef9c59b96da2eb6349554afa2441 (patch) | |
tree | 0217129f39be0b8306e51a3a7ff550b1c7bd598f | |
parent | c62935577a36ea98c9d625747cc3e4387ee9941e (diff) | |
download | servo-5c643adb9831ef9c59b96da2eb6349554afa2441.tar.gz servo-5c643adb9831ef9c59b96da2eb6349554afa2441.zip |
Simplify caret-color conversion.
-rw-r--r-- | components/style/gecko_bindings/sugar/style_complex_color.rs | 33 | ||||
-rw-r--r-- | components/style/properties/gecko.mako.rs | 22 |
2 files changed, 22 insertions, 33 deletions
diff --git a/components/style/gecko_bindings/sugar/style_complex_color.rs b/components/style/gecko_bindings/sugar/style_complex_color.rs index 6b166384aed..cd0e408b26f 100644 --- a/components/style/gecko_bindings/sugar/style_complex_color.rs +++ b/components/style/gecko_bindings/sugar/style_complex_color.rs @@ -6,7 +6,7 @@ use gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor}; use gecko_bindings::structs::{nscolor, StyleComplexColor}; -use values; +use values::{Auto, Either}; use values::computed::Color as ComputedColor; impl From<nscolor> for StyleComplexColor { @@ -49,18 +49,6 @@ impl From<ComputedColor> for StyleComplexColor { } } -impl From<StyleComplexColor> for values::computed::ColorOrAuto { - fn from(color: StyleComplexColor) -> Self { - use values::{Auto, Either}; - - if color.mIsAuto { - return Either::Second(Auto); - } - - Either::First(color.into()) - } -} - impl From<StyleComplexColor> for ComputedColor { fn from(other: StyleComplexColor) -> Self { debug_assert!(!other.mIsAuto); @@ -70,3 +58,22 @@ impl From<StyleComplexColor> for ComputedColor { } } } + +impl From<Either<ComputedColor, Auto>> for StyleComplexColor { + fn from(other: Either<ComputedColor, Auto>) -> Self { + match other { + Either::First(color) => color.into(), + Either::Second(_auto) => StyleComplexColor::auto(), + } + } +} + +impl From<StyleComplexColor> for Either<ComputedColor, Auto> { + fn from(other: StyleComplexColor) -> Self { + if !other.mIsAuto { + Either::First(other.into()) + } else { + Either::Second(Auto) + } + } +} diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 1f64cf99daf..0df0ee4bde6 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -42,7 +42,7 @@ use gecko_bindings::bindings::Gecko_SetNullImageValue; use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull; use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom}; use gecko_bindings::bindings::RawGeckoPresContextBorrowed; -use gecko_bindings::structs::{self, StyleComplexColor}; +use gecko_bindings::structs; use gecko_bindings::structs::nsCSSPropertyID; use gecko_bindings::structs::nsStyleVariables; use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut}; @@ -4259,25 +4259,7 @@ clip-path } } - pub fn set_caret_color(&mut self, v: longhands::caret_color::computed_value::T){ - use values::Either; - - match v { - Either::First(color) => { - self.gecko.mCaretColor = StyleComplexColor::from(color); - } - Either::Second(_auto) => { - self.gecko.mCaretColor = StyleComplexColor::auto(); - } - } - } - - pub fn copy_caret_color_from(&mut self, other: &Self){ - self.gecko.mCaretColor = other.gecko.mCaretColor; - } - - <%call expr="impl_color_clone('caret_color', 'mCaretColor')"></%call> - + <%call expr="impl_color('caret_color', 'mCaretColor', need_clone=True)"></%call> </%self:impl_trait> <%self:impl_trait style_struct_name="Column" |