Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support interpolation between currentcolor and numeric color #17219

Merged
merged 10 commits into from Jun 8, 2017
Prev

Simplify caret-color conversion.

  • Loading branch information
upsuper committed Jun 8, 2017
commit 5c643adb9831ef9c59b96da2eb6349554afa2441
@@ -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)
}
}
}
@@ -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"
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.