From 5c643adb9831ef9c59b96da2eb6349554afa2441 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Thu, 8 Jun 2017 10:42:32 +1000 Subject: [PATCH] Simplify caret-color conversion. --- .../sugar/style_complex_color.rs | 33 +++++++++++-------- 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 for StyleComplexColor { @@ -49,18 +49,6 @@ impl From for StyleComplexColor { } } -impl From 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 for ComputedColor { fn from(other: StyleComplexColor) -> Self { debug_assert!(!other.mIsAuto); @@ -70,3 +58,22 @@ impl From for ComputedColor { } } } + +impl From> for StyleComplexColor { + fn from(other: Either) -> Self { + match other { + Either::First(color) => color.into(), + Either::Second(_auto) => StyleComplexColor::auto(), + } + } +} + +impl From for Either { + 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 expr="impl_color('caret_color', 'mCaretColor', need_clone=True)"> <%self:impl_trait style_struct_name="Column"