Skip to content

Commit

Permalink
Rename DropShadow to SimpleShadow
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Jun 23, 2017
1 parent 9267948 commit ae1c890
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 36 deletions.
12 changes: 6 additions & 6 deletions components/style/gecko_bindings/sugar/ns_css_shadow_item.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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),
Expand Down
6 changes: 4 additions & 2 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 => {
Expand Down
28 changes: 14 additions & 14 deletions components/style/values/animated/effects.rs
Expand Up @@ -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;
Expand All @@ -24,7 +24,7 @@ pub type Filter = GenericFilter<
// FIXME: Should be `NumberOrPercentage`.
Number,
Length,
DropShadow
SimpleShadow,
>;

/// An animated value for the `drop-shadow()` filter.
Expand All @@ -33,15 +33,15 @@ 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.
///
/// Contrary to the canonical order from the spec, the color is serialised
/// 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.
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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, ()> {
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions components/style/values/computed/effects.rs
Expand Up @@ -20,7 +20,7 @@ pub type Filter = GenericFilter<
// FIXME: Should be `NumberOrPercentage`.
Number,
Length,
DropShadow,
SimpleShadow,
>;

/// A computed value for the `drop-shadow()` filter.
Expand All @@ -29,15 +29,15 @@ 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.
///
/// Contrary to the canonical order from the spec, the color is serialised
/// 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.
Expand Down
22 changes: 11 additions & 11 deletions components/style/values/specified/effects.rs
Expand Up @@ -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};
Expand All @@ -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`.
///
Expand All @@ -44,15 +44,15 @@ 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.
///
/// Contrary to the canonical order from the spec, the color is serialised
/// 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.
Expand Down Expand Up @@ -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)?)),
}
})
}
Expand Down Expand Up @@ -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>(
Expand All @@ -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,
Expand All @@ -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]
Expand All @@ -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),
Expand All @@ -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),
Expand Down

0 comments on commit ae1c890

Please sign in to comment.