Rename DropShadow to SimpleShadow

This commit is contained in:
Anthony Ramine 2017-06-23 15:00:34 +02:00
parent 92679480b1
commit ae1c890c9e
5 changed files with 38 additions and 36 deletions

View file

@ -8,7 +8,7 @@ use app_units::Au;
use gecko::values::{convert_rgba_to_nscolor, convert_nscolor_to_rgba};
use gecko_bindings::structs::nsCSSShadowItem;
use values::computed::{Color, Shadow};
use values::computed::effects::DropShadow;
use values::computed::effects::SimpleShadow;
impl nsCSSShadowItem {
/// Set this item to the given shadow value.
@ -41,9 +41,9 @@ impl nsCSSShadowItem {
}
}
/// Sets this item from the given drop shadow.
/// Sets this item from the given simple shadow.
#[inline]
pub fn set_from_drop_shadow(&mut self, shadow: DropShadow) {
pub fn set_from_simple_shadow(&mut self, shadow: SimpleShadow) {
self.mXOffset = shadow.horizontal.0;
self.mYOffset = shadow.vertical.0;
self.mRadius = shadow.blur.0;
@ -60,12 +60,12 @@ impl nsCSSShadowItem {
}
}
/// Returns this item as a drop shadow.
/// Returns this item as a simple shadow.
#[inline]
pub fn to_drop_shadow(&self) -> DropShadow {
pub fn to_simple_shadow(&self) -> SimpleShadow {
debug_assert_eq!(self.mSpread, 0);
debug_assert_eq!(self.mInset, false);
DropShadow {
SimpleShadow {
color: Color::rgba(convert_nscolor_to_rgba(self.mColor)),
horizontal: Au(self.mXOffset),
vertical: Au(self.mYOffset),

View file

@ -3508,7 +3508,7 @@ fn static_assert() {
}
let mut gecko_shadow = init_shadow(gecko_filter);
gecko_shadow.mArray[0].set_from_drop_shadow(shadow);
gecko_shadow.mArray[0].set_from_simple_shadow(shadow);
},
Url(ref url) => {
unsafe {
@ -3561,7 +3561,9 @@ fn static_assert() {
},
NS_STYLE_FILTER_DROP_SHADOW => {
filters.push(unsafe {
Filter::DropShadow((**filter.__bindgen_anon_1.mDropShadow.as_ref()).mArray[0].to_drop_shadow())
Filter::DropShadow(
(**filter.__bindgen_anon_1.mDropShadow.as_ref()).mArray[0].to_simple_shadow(),
)
});
},
NS_STYLE_FILTER_URL => {

View file

@ -8,9 +8,9 @@ use properties::animated_properties::Animatable;
#[cfg(feature = "gecko")]
use properties::animated_properties::IntermediateColor;
use values::computed::{Angle, Number};
use values::computed::effects::DropShadow as ComputedDropShadow;
use values::computed::effects::Filter as ComputedFilter;
use values::computed::effects::FilterList as ComputedFilterList;
use values::computed::effects::SimpleShadow as ComputedSimpleShadow;
use values::computed::length::Length;
use values::generics::effects::Filter as GenericFilter;
use values::generics::effects::FilterList as GenericFilterList;
@ -24,7 +24,7 @@ pub type Filter = GenericFilter<
// FIXME: Should be `NumberOrPercentage`.
Number,
Length,
DropShadow
SimpleShadow,
>;
/// An animated value for the `drop-shadow()` filter.
@ -33,7 +33,7 @@ pub type Filter = GenericFilter<
#[cfg(not(feature = "gecko"))]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq)]
pub enum DropShadow {}
pub enum SimpleShadow {}
/// An animated value for the `drop-shadow()` filter.
///
@ -41,7 +41,7 @@ pub enum DropShadow {}
/// first, like in Gecko and Webkit.
#[cfg(feature = "gecko")]
#[derive(Clone, Debug, PartialEq)]
pub struct DropShadow {
pub struct SimpleShadow {
/// Color.
pub color: IntermediateColor,
/// Horizontal radius.
@ -110,17 +110,17 @@ impl From<Filter> for ComputedFilter {
}
}
impl From<ComputedDropShadow> for DropShadow {
impl From<ComputedSimpleShadow> for SimpleShadow {
#[cfg(not(feature = "gecko"))]
#[inline]
fn from(shadow: ComputedDropShadow) -> Self {
fn from(shadow: ComputedSimpleShadow) -> Self {
match shadow {}
}
#[cfg(feature = "gecko")]
#[inline]
fn from(shadow: ComputedDropShadow) -> Self {
DropShadow {
fn from(shadow: ComputedSimpleShadow) -> Self {
SimpleShadow {
color: shadow.color.into(),
horizontal: shadow.horizontal,
vertical: shadow.vertical,
@ -129,17 +129,17 @@ impl From<ComputedDropShadow> for DropShadow {
}
}
impl From<DropShadow> for ComputedDropShadow {
impl From<SimpleShadow> for ComputedSimpleShadow {
#[cfg(not(feature = "gecko"))]
#[inline]
fn from(shadow: DropShadow) -> Self {
fn from(shadow: SimpleShadow) -> Self {
match shadow {}
}
#[cfg(feature = "gecko")]
#[inline]
fn from(shadow: DropShadow) -> Self {
ComputedDropShadow {
fn from(shadow: SimpleShadow) -> Self {
ComputedSimpleShadow {
color: shadow.color.into(),
horizontal: shadow.horizontal,
vertical: shadow.vertical,
@ -148,7 +148,7 @@ impl From<DropShadow> for ComputedDropShadow {
}
}
impl Animatable for DropShadow {
impl Animatable for SimpleShadow {
#[cfg(not(feature = "gecko"))]
#[inline]
fn add_weighted(&self, _other: &Self, _self_portion: f64, _other_portion: f64) -> Result<Self, ()> {
@ -163,7 +163,7 @@ impl Animatable for DropShadow {
let vertical = self.vertical.add_weighted(&other.vertical, self_portion, other_portion)?;
let blur = self.blur.add_weighted(&other.blur, self_portion, other_portion)?;
Ok(DropShadow {
Ok(SimpleShadow {
color: color,
horizontal: horizontal,
vertical: vertical,

View file

@ -20,7 +20,7 @@ pub type Filter = GenericFilter<
// FIXME: Should be `NumberOrPercentage`.
Number,
Length,
DropShadow,
SimpleShadow,
>;
/// A computed value for the `drop-shadow()` filter.
@ -29,7 +29,7 @@ pub type Filter = GenericFilter<
#[cfg(not(feature = "gecko"))]
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub enum DropShadow {}
pub enum SimpleShadow {}
/// A computed value for the `drop-shadow()` filter.
///
@ -37,7 +37,7 @@ pub enum DropShadow {}
/// first, like in Gecko and Webkit.
#[cfg(feature = "gecko")]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub struct DropShadow {
pub struct SimpleShadow {
/// Color.
pub color: Color,
/// Horizontal radius.

View file

@ -10,7 +10,7 @@ use style_traits::ParseError;
#[cfg(not(feature = "gecko"))]
use style_traits::StyleParseError;
use values::computed::{Context, Number as ComputedNumber, ToComputedValue};
use values::computed::effects::DropShadow as ComputedDropShadow;
use values::computed::effects::SimpleShadow as ComputedSimpleShadow;
use values::generics::effects::Filter as GenericFilter;
use values::generics::effects::FilterList as GenericFilterList;
use values::specified::{Angle, Percentage};
@ -24,7 +24,7 @@ use values::specified::url::SpecifiedUrl;
pub type FilterList = GenericFilterList<Filter>;
/// A specified value for a single `filter`.
pub type Filter = GenericFilter<Angle, Factor, Length, DropShadow>;
pub type Filter = GenericFilter<Angle, Factor, Length, SimpleShadow>;
/// A value for the `<factor>` parts in `Filter`.
///
@ -44,7 +44,7 @@ pub enum Factor {
#[cfg(not(feature = "gecko"))]
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
pub enum DropShadow {}
pub enum SimpleShadow {}
/// A specified value for the `drop-shadow()` filter.
///
@ -52,7 +52,7 @@ pub enum DropShadow {}
/// first, like in Gecko's computed values and in all Webkit's values.
#[cfg(feature = "gecko")]
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
pub struct DropShadow {
pub struct SimpleShadow {
/// Color.
pub color: Option<Color>,
/// Horizontal radius.
@ -104,7 +104,7 @@ impl Parse for Filter {
"opacity" => Ok(GenericFilter::Opacity(Factor::parse(context, i)?)),
"saturate" => Ok(GenericFilter::Saturate(Factor::parse(context, i)?)),
"sepia" => Ok(GenericFilter::Sepia(Factor::parse(context, i)?)),
"drop-shadow" => Ok(GenericFilter::DropShadow(DropShadow::parse(context, i)?)),
"drop-shadow" => Ok(GenericFilter::DropShadow(SimpleShadow::parse(context, i)?)),
}
})
}
@ -147,7 +147,7 @@ impl ToComputedValue for Factor {
}
}
impl Parse for DropShadow {
impl Parse for SimpleShadow {
#[cfg(not(feature = "gecko"))]
#[inline]
fn parse<'i, 't>(
@ -168,7 +168,7 @@ impl Parse for DropShadow {
let vertical = Length::parse(context, input)?;
let blur = input.try(|i| Length::parse_non_negative(context, i)).ok();
let color = color.or_else(|| input.try(|i| Color::parse(context, i)).ok());
Ok(DropShadow {
Ok(SimpleShadow {
color: color,
horizontal: horizontal,
vertical: vertical,
@ -177,8 +177,8 @@ impl Parse for DropShadow {
}
}
impl ToComputedValue for DropShadow {
type ComputedValue = ComputedDropShadow;
impl ToComputedValue for SimpleShadow {
type ComputedValue = ComputedSimpleShadow;
#[cfg(not(feature = "gecko"))]
#[inline]
@ -189,7 +189,7 @@ impl ToComputedValue for DropShadow {
#[cfg(feature = "gecko")]
#[inline]
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
ComputedDropShadow {
ComputedSimpleShadow {
color:
self.color.as_ref().unwrap_or(&Color::CurrentColor).to_computed_value(context),
horizontal: self.horizontal.to_computed_value(context),
@ -208,7 +208,7 @@ impl ToComputedValue for DropShadow {
#[cfg(feature = "gecko")]
#[inline]
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
DropShadow {
SimpleShadow {
color: Some(ToComputedValue::from_computed_value(&computed.color)),
horizontal: ToComputedValue::from_computed_value(&computed.horizontal),
vertical: ToComputedValue::from_computed_value(&computed.vertical),